core/shell-search-provider: Replace "context" property with context getter method
Part-of: <https://gitlab.gnome.org/GNOME/gnome-calendar/-/merge_requests/702>
This commit is contained in:
@@ -40,7 +40,6 @@ struct _GcalShellSearchProvider
|
|||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
GcalShellSearchProvider2 *skel;
|
GcalShellSearchProvider2 *skel;
|
||||||
GcalContext *context;
|
|
||||||
|
|
||||||
PendingSearch *pending_search;
|
PendingSearch *pending_search;
|
||||||
GHashTable *events;
|
GHashTable *events;
|
||||||
@@ -56,15 +55,6 @@ G_DEFINE_TYPE_WITH_CODE (GcalShellSearchProvider, gcal_shell_search_provider, G_
|
|||||||
G_IMPLEMENT_INTERFACE (GCAL_TYPE_TIMELINE_SUBSCRIBER,
|
G_IMPLEMENT_INTERFACE (GCAL_TYPE_TIMELINE_SUBSCRIBER,
|
||||||
gcal_timeline_subscriber_interface_init));
|
gcal_timeline_subscriber_interface_init));
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
PROP_0,
|
|
||||||
PROP_CONTEXT,
|
|
||||||
N_PROPS
|
|
||||||
};
|
|
||||||
|
|
||||||
static GParamSpec* properties[N_PROPS] = { NULL, };
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Auxiliary methods
|
* Auxiliary methods
|
||||||
@@ -118,10 +108,12 @@ maybe_update_range (GcalShellSearchProvider *self)
|
|||||||
g_autoptr (GDateTime) end = NULL;
|
g_autoptr (GDateTime) end = NULL;
|
||||||
g_autoptr (GDateTime) now = NULL;
|
g_autoptr (GDateTime) now = NULL;
|
||||||
gboolean range_changed = FALSE;
|
gboolean range_changed = FALSE;
|
||||||
|
GcalContext *context;
|
||||||
|
|
||||||
GCAL_ENTRY;
|
GCAL_ENTRY;
|
||||||
|
|
||||||
now = g_date_time_new_now (gcal_context_get_timezone (self->context));
|
context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||||
|
now = g_date_time_new_now (gcal_context_get_timezone (context));
|
||||||
start = g_date_time_add_weeks (now, -1);
|
start = g_date_time_add_weeks (now, -1);
|
||||||
end = g_date_time_add_weeks (now, 3);
|
end = g_date_time_add_weeks (now, 3);
|
||||||
|
|
||||||
@@ -481,62 +473,24 @@ gcal_shell_search_provider_finalize (GObject *object)
|
|||||||
GcalShellSearchProvider *self = (GcalShellSearchProvider *) object;
|
GcalShellSearchProvider *self = (GcalShellSearchProvider *) object;
|
||||||
|
|
||||||
g_clear_pointer (&self->events, g_hash_table_destroy);
|
g_clear_pointer (&self->events, g_hash_table_destroy);
|
||||||
g_clear_object (&self->context);
|
|
||||||
g_clear_object (&self->skel);
|
g_clear_object (&self->skel);
|
||||||
|
|
||||||
G_OBJECT_CLASS (gcal_shell_search_provider_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gcal_shell_search_provider_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gcal_shell_search_provider_get_property (GObject *object,
|
gcal_shell_search_provider_constructed (GObject *object)
|
||||||
guint property_id,
|
|
||||||
GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
{
|
||||||
GcalShellSearchProvider *self = GCAL_SHELL_SEARCH_PROVIDER (object);
|
GcalShellSearchProvider *self = (GcalShellSearchProvider *) object;
|
||||||
|
|
||||||
switch (property_id)
|
GcalContext *context = gcal_application_get_context (GCAL_DEFAULT_APPLICATION);
|
||||||
{
|
GcalManager *manager = gcal_context_get_manager (context);
|
||||||
case PROP_CONTEXT:
|
|
||||||
g_value_set_object (value, self->context);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
self->timeline = gcal_timeline_new ();
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
g_signal_connect (self->timeline, "notify::complete", G_CALLBACK (on_timeline_completed_cb), self);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
g_signal_connect (manager, "calendar-added", G_CALLBACK (on_manager_calendar_added_cb), self);
|
||||||
gcal_shell_search_provider_set_property (GObject *object,
|
g_signal_connect (manager, "calendar-removed", G_CALLBACK (on_manager_calendar_removed_cb), self);
|
||||||
guint property_id,
|
|
||||||
const GValue *value,
|
|
||||||
GParamSpec *pspec)
|
|
||||||
{
|
|
||||||
GcalShellSearchProvider *self = GCAL_SHELL_SEARCH_PROVIDER (object);
|
|
||||||
|
|
||||||
switch (property_id)
|
|
||||||
{
|
|
||||||
case PROP_CONTEXT:
|
|
||||||
{
|
|
||||||
GcalManager *manager;
|
|
||||||
|
|
||||||
g_assert (self->context == NULL);
|
|
||||||
self->context = g_value_get_object (value);
|
|
||||||
|
|
||||||
self->timeline = gcal_timeline_new ();
|
|
||||||
g_signal_connect (self->timeline, "notify::complete", G_CALLBACK (on_timeline_completed_cb), self);
|
|
||||||
|
|
||||||
manager = gcal_context_get_manager (self->context);
|
|
||||||
g_signal_connect (manager, "calendar-added", G_CALLBACK (on_manager_calendar_added_cb), self);
|
|
||||||
g_signal_connect (manager, "calendar-removed", G_CALLBACK (on_manager_calendar_removed_cb), self);
|
|
||||||
|
|
||||||
g_object_notify_by_pspec (object, properties[PROP_CONTEXT]);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -545,16 +499,7 @@ gcal_shell_search_provider_class_init (GcalShellSearchProviderClass *klass)
|
|||||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||||
|
|
||||||
object_class->finalize = gcal_shell_search_provider_finalize;
|
object_class->finalize = gcal_shell_search_provider_finalize;
|
||||||
object_class->get_property = gcal_shell_search_provider_get_property;
|
object_class->constructed = gcal_shell_search_provider_constructed;
|
||||||
object_class->set_property = gcal_shell_search_provider_set_property;
|
|
||||||
|
|
||||||
properties[PROP_CONTEXT] = g_param_spec_object ("context",
|
|
||||||
"The context object",
|
|
||||||
"The context object",
|
|
||||||
GCAL_TYPE_CONTEXT,
|
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
||||||
|
|
||||||
g_object_class_install_properties (object_class, N_PROPS, properties);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -571,10 +516,9 @@ gcal_shell_search_provider_init (GcalShellSearchProvider *self)
|
|||||||
}
|
}
|
||||||
|
|
||||||
GcalShellSearchProvider*
|
GcalShellSearchProvider*
|
||||||
gcal_shell_search_provider_new (GcalContext *context)
|
gcal_shell_search_provider_new (void)
|
||||||
{
|
{
|
||||||
return g_object_new (GCAL_TYPE_SHELL_SEARCH_PROVIDER,
|
return g_object_new (GCAL_TYPE_SHELL_SEARCH_PROVIDER,
|
||||||
"context", context,
|
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
G_DECLARE_FINAL_TYPE (GcalShellSearchProvider, gcal_shell_search_provider, GCAL, SHELL_SEARCH_PROVIDER, GObject)
|
G_DECLARE_FINAL_TYPE (GcalShellSearchProvider, gcal_shell_search_provider, GCAL, SHELL_SEARCH_PROVIDER, GObject)
|
||||||
|
|
||||||
GcalShellSearchProvider* gcal_shell_search_provider_new (GcalContext *context);
|
GcalShellSearchProvider* gcal_shell_search_provider_new (void);
|
||||||
|
|
||||||
gboolean gcal_shell_search_provider_dbus_export (GcalShellSearchProvider *search_provider,
|
gboolean gcal_shell_search_provider_dbus_export (GcalShellSearchProvider *search_provider,
|
||||||
GDBusConnection *connection,
|
GDBusConnection *connection,
|
||||||
|
|||||||
@@ -513,6 +513,8 @@ gcal_application_dbus_register (GApplication *application,
|
|||||||
|
|
||||||
self = GCAL_APPLICATION (application);
|
self = GCAL_APPLICATION (application);
|
||||||
|
|
||||||
|
self->search_provider = gcal_shell_search_provider_new ();
|
||||||
|
|
||||||
if (!G_APPLICATION_CLASS (gcal_application_parent_class)->dbus_register (application, connection, object_path, error))
|
if (!G_APPLICATION_CLASS (gcal_application_parent_class)->dbus_register (application, connection, object_path, error))
|
||||||
GCAL_RETURN (FALSE);
|
GCAL_RETURN (FALSE);
|
||||||
|
|
||||||
@@ -602,7 +604,6 @@ gcal_application_init (GcalApplication *self)
|
|||||||
g_application_add_main_option_entries (G_APPLICATION (self), gcal_application_goptions);
|
g_application_add_main_option_entries (G_APPLICATION (self), gcal_application_goptions);
|
||||||
|
|
||||||
self->context = gcal_context_new ();
|
self->context = gcal_context_new ();
|
||||||
self->search_provider = gcal_shell_search_provider_new (self->context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Public API */
|
/* Public API */
|
||||||
|
|||||||
Reference in New Issue
Block a user