event-editor/notes-section: Follow AdwEntryRow's style
The current notes text view has had a 2px offset for an unknown amount of time, due to us magic-numbering margins and/or padding. This approach works a little bit differently, in that it uses the `.editable-area` style class and sets the overlay's CSS name to "box" to use a predictable size of margins from AdwEntryRow. Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/738>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -414,10 +414,6 @@ monthpopover > box {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.notes-section label.placeholder {
|
||||
margin: 14px;
|
||||
}
|
||||
|
||||
.notes-section box > textview > text {
|
||||
background: none;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user