diff options
author | Ted Gould <ted@gould.cx> | 2011-03-30 13:21:10 -0500 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2011-03-30 13:21:10 -0500 |
commit | 6be8ddada1ca8b9901d7b9dccef39af47230bf32 (patch) | |
tree | be226ca5cbcbbe593f797eb3ea5950f89d299d81 /src/indicator-datetime.c | |
parent | 0e435a010c1350df7de029725ba9e721d543ccf5 (diff) | |
download | ayatana-indicator-datetime-6be8ddada1ca8b9901d7b9dccef39af47230bf32.tar.gz ayatana-indicator-datetime-6be8ddada1ca8b9901d7b9dccef39af47230bf32.tar.bz2 ayatana-indicator-datetime-6be8ddada1ca8b9901d7b9dccef39af47230bf32.zip |
Moving the registration of the type handlers into the init so that they'll not execute more than once.
Diffstat (limited to 'src/indicator-datetime.c')
-rw-r--r-- | src/indicator-datetime.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index c96ec48..1e8b452 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -177,6 +177,9 @@ static void system_proxy_cb (GObject * object, GAsyncResult * res, gpointer use static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data); static gint generate_strftime_bitmask (const char *time_str); static void timezone_update_labels (indicator_item_t * mi_data); +static gboolean new_calendar_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); +static gboolean new_appointment_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); +static gboolean new_timezone_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client, gpointer user_data); /* Indicator Module Config */ INDICATOR_SET_VERSION @@ -343,6 +346,13 @@ indicator_datetime_init (IndicatorDatetime *self) self->priv->sm = indicator_service_manager_new_version(SERVICE_NAME, SERVICE_VERSION); self->priv->indicator_right_group = GTK_SIZE_GROUP(gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL)); + self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ); + + DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(self->priv->menu); + dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), DBUSMENU_CALENDAR_MENUITEM_TYPE, new_calendar_item, self, NULL); + dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), APPOINTMENT_MENUITEM_TYPE, new_appointment_item, self, NULL); + dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), TIMEZONE_MENUITEM_TYPE, new_timezone_item, self, NULL); + self->priv->service_proxy_cancel = g_cancellable_new(); g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION, @@ -1368,15 +1378,10 @@ new_calendar_item (DbusmenuMenuitem * newitem, g_debug("New calendar item"); g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); + g_return_val_if_fail(IS_INDICATOR_DATETIME(user_data), FALSE); /* Note: not checking parent, it's reasonable for it to be NULL */ - IndicatorObject *io = g_object_get_data (G_OBJECT (client), "indicator"); - if (io == NULL) { - g_warning ("found no indicator to attach the caledar to"); - return FALSE; - } - - IndicatorDatetime *self = INDICATOR_DATETIME(io); + IndicatorDatetime *self = INDICATOR_DATETIME(user_data); self->priv = INDICATOR_DATETIME_GET_PRIVATE(self); IdoCalendarMenuItem *ido = IDO_CALENDAR_MENU_ITEM (ido_calendar_menu_item_new ()); @@ -1521,17 +1526,6 @@ get_menu (IndicatorObject * io) { IndicatorDatetime * self = INDICATOR_DATETIME(io); - if (self->priv->menu == NULL) { - self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ); - } - - DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(self->priv->menu); - g_object_set_data (G_OBJECT (client), "indicator", io); - - dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), DBUSMENU_CALENDAR_MENUITEM_TYPE, new_calendar_item, io, NULL); - dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), APPOINTMENT_MENUITEM_TYPE, new_appointment_item, io, NULL); - dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), TIMEZONE_MENUITEM_TYPE, new_timezone_item, io, NULL); - return GTK_MENU(self->priv->menu); } |