event-editor/notes-section: Inherit AdwPreferencesGroup
The end goal is to make GcalEventEditorSection require inheriting AdwPreferencesGroup. Given that most widgets utilizing GcalEventEditorSection inherit another widget, we first want to change and adapt the inheritance, and then bump the requirement of the interface. These changes will be made incrementally, starting with GcalNotesSection. Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/781>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user