gui: Propagate context to GcalSearchButton
The people who introduced this code were not careful enough to make sure the code they removed from GcalWindow was added back in GcalToolbarEnd. They also simply commented out some code instead of properly reimplementing that. I regret having trusted their code :( Closes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/880
This commit is contained in:
@@ -18,24 +18,111 @@
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "gcal-toolbar-end.h"
|
||||
|
||||
#include "gcal-context.h"
|
||||
#include "gcal-search-button.h"
|
||||
#include "gcal-toolbar-end.h"
|
||||
|
||||
struct _GcalToolbarEnd
|
||||
{
|
||||
AdwBin parent_instance;
|
||||
AdwBin parent_instance;
|
||||
|
||||
GcalSearchButton *search_button;
|
||||
|
||||
GcalContext *context;
|
||||
};
|
||||
|
||||
G_DEFINE_FINAL_TYPE (GcalToolbarEnd, gcal_toolbar_end, ADW_TYPE_BIN)
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CONTEXT,
|
||||
N_PROPS
|
||||
};
|
||||
|
||||
static GParamSpec *properties [N_PROPS];
|
||||
|
||||
|
||||
/*
|
||||
* GObject overrides
|
||||
*/
|
||||
|
||||
static void
|
||||
gcal_toolbar_end_finalize (GObject *object)
|
||||
{
|
||||
GcalToolbarEnd *self = (GcalToolbarEnd *)object;
|
||||
|
||||
g_clear_object (&self->context);
|
||||
|
||||
G_OBJECT_CLASS (gcal_toolbar_end_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_toolbar_end_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GcalToolbarEnd *self = GCAL_TOOLBAR_END (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTEXT:
|
||||
g_value_set_object (value, self->context);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_toolbar_end_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GcalToolbarEnd *self = GCAL_TOOLBAR_END (object);
|
||||
|
||||
switch (prop_id)
|
||||
{
|
||||
case PROP_CONTEXT:
|
||||
g_assert (self->context == NULL);
|
||||
self->context = g_value_dup_object (value);
|
||||
g_object_bind_property (self, "context", self->search_button, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gcal_toolbar_end_class_init (GcalToolbarEndClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class,
|
||||
"/org/gnome/calendar/ui/gui/gcal-toolbar-end.ui");
|
||||
object_class->finalize = gcal_toolbar_end_finalize;
|
||||
object_class->get_property = gcal_toolbar_end_get_property;
|
||||
object_class->set_property = gcal_toolbar_end_set_property;
|
||||
|
||||
/**
|
||||
* GcalToolbarEnd::context:
|
||||
*
|
||||
* The #GcalContext of the application.
|
||||
*/
|
||||
properties[PROP_CONTEXT] = g_param_spec_object ("context",
|
||||
"Context of the application",
|
||||
"The context of the application",
|
||||
GCAL_TYPE_CONTEXT,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/calendar/ui/gui/gcal-toolbar-end.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalToolbarEnd, search_button);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<object class="GtkBox">
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<object class="GcalSearchButton">
|
||||
<object class="GcalSearchButton" id="search_button">
|
||||
<property name="tooltip_text" translatable="yes" context="tooltip">Search for events</property>
|
||||
<binding name="context">
|
||||
<lookup type="GcalWindow" name="context">
|
||||
|
||||
@@ -106,6 +106,7 @@ struct _GcalWindow
|
||||
GtkWidget *agenda_view;
|
||||
GtkWidget *date_chooser;
|
||||
GtkWidget *action_bar;
|
||||
GcalToolbarEnd *toolbar_end;
|
||||
|
||||
/* header_bar widets */
|
||||
GtkWidget *calendars_button;
|
||||
@@ -855,6 +856,7 @@ gcal_window_constructed (GObject *object)
|
||||
g_object_bind_property (self, "context", self->date_chooser, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (self, "context", self->event_editor, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (self, "context", self->quick_add_popover, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
g_object_bind_property (self, "context", self->toolbar_end, "context", G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
|
||||
|
||||
/* CSS */
|
||||
load_css_providers (self);
|
||||
@@ -1044,6 +1046,7 @@ gcal_window_class_init (GcalWindowClass *klass)
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, quick_add_popover);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, calendar_management_dialog);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, overlay);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, toolbar_end);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, views_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, views_switcher);
|
||||
gtk_widget_class_bind_template_child (widget_class, GcalWindow, weather_settings);
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child type="end">
|
||||
<object class="GcalToolbarEnd"/>
|
||||
<object class="GcalToolbarEnd" id="toolbar_end" />
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
Reference in New Issue
Block a user