diff --git a/src/gui/event-editor/gcal-event-editor-dialog.blp b/src/gui/event-editor/gcal-event-editor-dialog.blp index 43773a8e..b43ae4cf 100644 --- a/src/gui/event-editor/gcal-event-editor-dialog.blp +++ b/src/gui/event-editor/gcal-event-editor-dialog.blp @@ -69,11 +69,8 @@ template $GcalEventEditorDialog: Adw.Dialog { } } - Adw.PreferencesGroup { - $GcalNotesSection notes_section { - sensitive: bind template.writable; - vexpand: true; - } + $GcalNotesSection notes_section { + sensitive: bind template.writable; } Adw.PreferencesGroup delete_group { diff --git a/src/gui/event-editor/gcal-notes-section.blp b/src/gui/event-editor/gcal-notes-section.blp index b9b9bd9a..3fb37f12 100644 --- a/src/gui/event-editor/gcal-notes-section.blp +++ b/src/gui/event-editor/gcal-notes-section.blp @@ -1,67 +1,74 @@ using Gtk 4.0; using Adw 1; -template $GcalNotesSection: Adw.PreferencesRow { - focusable: false; - selectable: false; - +template $GcalNotesSection: Adw.PreferencesGroup { styles [ - "entry", + "notes-section", ] - GestureClick { - pressed => $on_row_pressed(notes_text) not-swapped; - } - - child: Overlay { - css-name: "box"; + Adw.PreferencesRow { + vexpand: true; + activatable: false; + focusable: false; + state-flags-changed => $on_row_state_flags_changed_cb(); styles [ - "header", + "entry", ] - [overlay] - Adw.Bin { - can-focus: false; - can-target: false; - - styles [ - "editable-area", - ] - - child: Label placeholder { - label: _("Notes"); - xalign: 0.0; - yalign: 0.0; - visible: bind $empty_string(notes_text.buffer.text); - margin-top: 12; - margin-bottom: 12; - - styles [ - "dimmed", - "placeholder", - ] - }; + GestureClick { + pressed => $on_row_pressed(notes_text) not-swapped; } - child: Adw.Bin { + child: Overlay { + css-name: "box"; + styles [ - "editable-area", + "header", ] - child: TextView notes_text { - hexpand: true; - sensitive: true; - wrap-mode: word_char; - accepts-tab: false; - top-margin: 12; - bottom-margin: 12; - state-flags-changed => $on_notes_text_state_flags_changed_cb(template) not-swapped; + [overlay] + Adw.Bin { + can-focus: false; + can-target: false; - accessibility { - placeholder: _("Notes"); - } + styles [ + "editable-area", + ] + + child: Label placeholder { + label: _("Notes"); + xalign: 0.0; + yalign: 0.0; + visible: bind $empty_string(notes_text.buffer.text); + margin-top: 12; + margin-bottom: 12; + + styles [ + "dimmed", + "placeholder", + ] + }; + } + + child: Adw.Bin { + styles [ + "editable-area", + ] + + child: TextView notes_text { + hexpand: true; + sensitive: true; + wrap-mode: word_char; + accepts-tab: false; + top-margin: 12; + bottom-margin: 12; + + accessibility { + placeholder: _("Notes"); + } + }; }; }; - }; + } } diff --git a/src/gui/event-editor/gcal-notes-section.c b/src/gui/event-editor/gcal-notes-section.c index a4856cb3..418adb1e 100644 --- a/src/gui/event-editor/gcal-notes-section.c +++ b/src/gui/event-editor/gcal-notes-section.c @@ -26,7 +26,7 @@ struct _GcalNotesSection { - AdwPreferencesRow parent; + AdwPreferencesGroup parent; GtkTextView *notes_text; GtkLabel *placeholder; @@ -36,7 +36,7 @@ struct _GcalNotesSection static void gcal_event_editor_section_iface_init (GcalEventEditorSectionInterface *iface); -G_DEFINE_TYPE_WITH_CODE (GcalNotesSection, gcal_notes_section, ADW_TYPE_PREFERENCES_ROW, +G_DEFINE_TYPE_WITH_CODE (GcalNotesSection, gcal_notes_section, ADW_TYPE_PREFERENCES_GROUP, G_IMPLEMENT_INTERFACE (GCAL_TYPE_EVENT_EDITOR_SECTION, gcal_event_editor_section_iface_init)) /* @@ -44,16 +44,15 @@ G_DEFINE_TYPE_WITH_CODE (GcalNotesSection, gcal_notes_section, ADW_TYPE_PREFEREN */ static void -on_notes_text_state_flags_changed_cb (GtkTextView *text_view, - GtkStateFlags previous_flags, - GcalNotesSection *self) +on_row_state_flags_changed_cb (AdwPreferencesRow *row, + GtkStateFlags previous_flags) { - GtkStateFlags flags = gtk_widget_get_state_flags (GTK_WIDGET (text_view)); + GtkStateFlags flags = gtk_widget_get_state_flags (GTK_WIDGET (row)); if (flags & GTK_STATE_FLAG_FOCUS_WITHIN) - gtk_widget_add_css_class (GTK_WIDGET (self), "focused"); + gtk_widget_add_css_class (GTK_WIDGET (row), "focused"); else - gtk_widget_remove_css_class (GTK_WIDGET (self), "focused"); + gtk_widget_remove_css_class (GTK_WIDGET (row), "focused"); } static gboolean @@ -185,7 +184,7 @@ gcal_notes_section_class_init (GcalNotesSectionClass *klass) gtk_widget_class_bind_template_callback (widget_class, empty_string); gtk_widget_class_bind_template_callback (widget_class, on_row_pressed); - gtk_widget_class_bind_template_callback (widget_class, on_notes_text_state_flags_changed_cb); + gtk_widget_class_bind_template_callback (widget_class, on_row_state_flags_changed_cb); } static void diff --git a/src/gui/event-editor/gcal-notes-section.h b/src/gui/event-editor/gcal-notes-section.h index 39de1d6f..d2ae8ba5 100644 --- a/src/gui/event-editor/gcal-notes-section.h +++ b/src/gui/event-editor/gcal-notes-section.h @@ -25,6 +25,6 @@ G_BEGIN_DECLS #define GCAL_TYPE_NOTES_SECTION (gcal_notes_section_get_type()) -G_DECLARE_FINAL_TYPE (GcalNotesSection, gcal_notes_section, GCAL, NOTES_SECTION, AdwPreferencesRow) +G_DECLARE_FINAL_TYPE (GcalNotesSection, gcal_notes_section, GCAL, NOTES_SECTION, AdwPreferencesGroup) G_END_DECLS