diff --git a/src/gui/event-editor/gcal-notes-section.blp b/src/gui/event-editor/gcal-notes-section.blp index 2b332b99..b9b9bd9a 100644 --- a/src/gui/event-editor/gcal-notes-section.blp +++ b/src/gui/event-editor/gcal-notes-section.blp @@ -2,42 +2,60 @@ using Gtk 4.0; using Adw 1; template $GcalNotesSection: Adw.PreferencesRow { - activatable: false; focusable: false; + selectable: false; styles [ "entry", - "notes-section", ] + GestureClick { + pressed => $on_row_pressed(notes_text) not-swapped; + } + child: Overlay { + css-name: "box"; + + styles [ + "header", + ] + [overlay] - Label placeholder { - label: _("Notes"); + Adw.Bin { can-focus: false; can-target: false; - xalign: 0.0; - yalign: 0.0; - visible: bind $empty_string(notes_text.buffer.text); styles [ - "dimmed", - "placeholder", + "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 { - css-name: "box"; + styles [ + "editable-area", + ] child: TextView notes_text { hexpand: true; - top-margin: 6; - bottom-margin: 6; - left-margin: 6; - right-margin: 6; 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; accessibility { diff --git a/src/gui/event-editor/gcal-notes-section.c b/src/gui/event-editor/gcal-notes-section.c index 05dae890..a4856cb3 100644 --- a/src/gui/event-editor/gcal-notes-section.c +++ b/src/gui/event-editor/gcal-notes-section.c @@ -63,6 +63,25 @@ empty_string (gpointer user_data, return g_utf8_strlen (text, -1) == 0; } +static void +on_row_pressed (GtkGestureClick *gesture, + gint n_press, + gdouble x, + gdouble y, + GtkWidget *text_view) +{ + GtkWidget *row; + + g_assert (GTK_IS_TEXT_VIEW (text_view)); + + row = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (gesture)); + + if (gtk_widget_contains (row, x, y)) + gtk_widget_grab_focus (text_view); + + gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_NONE); +} + /* * GcalEventEditorSection interface */ @@ -165,6 +184,7 @@ gcal_notes_section_class_init (GcalNotesSectionClass *klass) gtk_widget_class_bind_template_child (widget_class, GcalNotesSection, placeholder); 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); } diff --git a/src/theme/style.css b/src/theme/style.css index d98f5269..59a8a87a 100644 --- a/src/theme/style.css +++ b/src/theme/style.css @@ -414,10 +414,6 @@ monthpopover > box { padding: 8px; } -.notes-section label.placeholder { - margin: 14px; -} - .notes-section box > textview > text { background: none; }