event-editor/multi-choice: Inherit GtkWidget

This is a prerequisite for removing the strong dependence on the
child GtkToggleButton widget, removing the platform state override,
and adding binding actions in later commits.

Inheriting AdwBin was attempted but it didn't work, as AdwBin
presumably messes with focusability and activation, making
it insufficient for this use case.

`hexpand=true` needs to be explicitly set.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/841>
This commit is contained in:
Hari Rana
2026-09-25 19:09:10 +00:00
committed by Marge Bot
parent f20c9235ce
commit 34be5e4663
3 changed files with 11 additions and 4 deletions
+4 -1
View File
@@ -1,7 +1,10 @@
using Gtk 4.0;
template $GcalMultiChoice: Box {
template $GcalMultiChoice: Widget {
accessible-role: spin_button;
receives-default: true;
focusable: true;
hexpand: true;
PopoverBin popover_bin {
child: Box {
+6 -2
View File
@@ -26,7 +26,7 @@
struct _GcalMultiChoice
{
GtkBox parent;
GtkWidget parent;
GtkWidget *down_button;
GtkWidget *button;
@@ -82,7 +82,7 @@ static void gcal_multi_choice_accessible_init (GtkAccessibleInterface *iface);
static void gcal_multi_choice_accessible_range_init (GtkAccessibleRangeInterface *iface);
G_DEFINE_FINAL_TYPE_WITH_CODE (GcalMultiChoice, gcal_multi_choice, GTK_TYPE_BOX,
G_DEFINE_FINAL_TYPE_WITH_CODE (GcalMultiChoice, gcal_multi_choice, GTK_TYPE_WIDGET,
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE, gcal_multi_choice_accessible_init)
G_IMPLEMENT_INTERFACE (GTK_TYPE_ACCESSIBLE_RANGE, gcal_multi_choice_accessible_range_init))
@@ -335,6 +335,8 @@ gcal_multi_choice_dispose (GObject *object)
{
GcalMultiChoice *self = GCAL_MULTI_CHOICE (object);
g_clear_pointer ((GtkWidget **) &self->popover_bin, gtk_widget_unparent);
g_clear_pointer (&self->choices, g_free);
g_clear_pointer (&self->category, g_free);
g_clear_pointer (&self->prev_button_tooltip_text, g_free);
@@ -608,6 +610,8 @@ gcal_multi_choice_class_init (GcalMultiChoiceClass *class)
gtk_widget_class_bind_template_callback (widget_class, key_pressed_cb);
gtk_widget_class_set_css_name (widget_class, "navigator");
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
}
static void
+1 -1
View File
@@ -25,7 +25,7 @@ G_BEGIN_DECLS
#define GCAL_TYPE_MULTI_CHOICE (gcal_multi_choice_get_type())
G_DECLARE_FINAL_TYPE (GcalMultiChoice, gcal_multi_choice, GCAL, MULTI_CHOICE, GtkBox)
G_DECLARE_FINAL_TYPE (GcalMultiChoice, gcal_multi_choice, GCAL, MULTI_CHOICE, GtkWidget)
GtkWidget* gcal_multi_choice_new (void);