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 {
|
||||||
$GcalNotesSection notes_section {
|
sensitive: bind template.writable;
|
||||||
sensitive: bind template.writable;
|
|
||||||
vexpand: true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Adw.PreferencesGroup delete_group {
|
Adw.PreferencesGroup delete_group {
|
||||||
|
|||||||
@@ -1,67 +1,74 @@
|
|||||||
using Gtk 4.0;
|
using Gtk 4.0;
|
||||||
using Adw 1;
|
using Adw 1;
|
||||||
|
|
||||||
template $GcalNotesSection: Adw.PreferencesRow {
|
template $GcalNotesSection: Adw.PreferencesGroup {
|
||||||
focusable: false;
|
|
||||||
selectable: false;
|
|
||||||
|
|
||||||
styles [
|
styles [
|
||||||
"entry",
|
"notes-section",
|
||||||
]
|
]
|
||||||
|
|
||||||
GestureClick {
|
Adw.PreferencesRow {
|
||||||
pressed => $on_row_pressed(notes_text) not-swapped;
|
vexpand: true;
|
||||||
}
|
activatable: false;
|
||||||
|
focusable: false;
|
||||||
child: Overlay {
|
state-flags-changed => $on_row_state_flags_changed_cb();
|
||||||
css-name: "box";
|
|
||||||
|
|
||||||
styles [
|
styles [
|
||||||
"header",
|
"entry",
|
||||||
]
|
]
|
||||||
|
|
||||||
[overlay]
|
GestureClick {
|
||||||
Adw.Bin {
|
pressed => $on_row_pressed(notes_text) not-swapped;
|
||||||
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",
|
|
||||||
]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
child: Adw.Bin {
|
child: Overlay {
|
||||||
|
css-name: "box";
|
||||||
|
|
||||||
styles [
|
styles [
|
||||||
"editable-area",
|
"header",
|
||||||
]
|
]
|
||||||
|
|
||||||
child: TextView notes_text {
|
[overlay]
|
||||||
hexpand: true;
|
Adw.Bin {
|
||||||
sensitive: true;
|
can-focus: false;
|
||||||
wrap-mode: word_char;
|
can-target: false;
|
||||||
accepts-tab: false;
|
|
||||||
top-margin: 12;
|
|
||||||
bottom-margin: 12;
|
|
||||||
state-flags-changed => $on_notes_text_state_flags_changed_cb(template) not-swapped;
|
|
||||||
|
|
||||||
accessibility {
|
styles [
|
||||||
placeholder: _("Notes");
|
"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
|
struct _GcalNotesSection
|
||||||
{
|
{
|
||||||
AdwPreferencesRow parent;
|
AdwPreferencesGroup parent;
|
||||||
|
|
||||||
GtkTextView *notes_text;
|
GtkTextView *notes_text;
|
||||||
GtkLabel *placeholder;
|
GtkLabel *placeholder;
|
||||||
@@ -36,7 +36,7 @@ struct _GcalNotesSection
|
|||||||
|
|
||||||
static void gcal_event_editor_section_iface_init (GcalEventEditorSectionInterface *iface);
|
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))
|
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
|
static void
|
||||||
on_notes_text_state_flags_changed_cb (GtkTextView *text_view,
|
on_row_state_flags_changed_cb (AdwPreferencesRow *row,
|
||||||
GtkStateFlags previous_flags,
|
GtkStateFlags previous_flags)
|
||||||
GcalNotesSection *self)
|
|
||||||
{
|
{
|
||||||
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)
|
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
|
else
|
||||||
gtk_widget_remove_css_class (GTK_WIDGET (self), "focused");
|
gtk_widget_remove_css_class (GTK_WIDGET (row), "focused");
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
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, empty_string);
|
||||||
gtk_widget_class_bind_template_callback (widget_class, on_row_pressed);
|
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
|
static void
|
||||||
|
|||||||
@@ -25,6 +25,6 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GCAL_TYPE_NOTES_SECTION (gcal_notes_section_get_type())
|
#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
|
G_END_DECLS
|
||||||
|
|||||||
Reference in New Issue
Block a user