aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-05-02 04:44:57 +0000
committerTarmac <Unknown>2013-05-02 04:44:57 +0000
commit78effeb670b399999c42fcb94c05fb4bb9b54894 (patch)
tree4315ef92049525603e6bed2330890884077b3ff3
parent139717ed246434a8e32b75453266c8d321d119b7 (diff)
parente03ef8e4ac74e87cefaff1ef792d8a5bff54c926 (diff)
downloadayatana-indicator-datetime-78effeb670b399999c42fcb94c05fb4bb9b54894.tar.gz
ayatana-indicator-datetime-78effeb670b399999c42fcb94c05fb4bb9b54894.tar.bz2
ayatana-indicator-datetime-78effeb670b399999c42fcb94c05fb4bb9b54894.zip
Since the calendar widget may not be created yet when visible_notify_cb() is triggered, call wrap its use in "if (IDO_IS_CALENDAR(foo))". Fixes: https://bugs.launchpad.net/bugs/1175392.
Approved by PS Jenkins bot, Lars Uebernickel.
-rw-r--r--src/indicator-datetime.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 9546664..f7d1a78 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -266,28 +266,35 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass)
}
static void
-menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
+menu_visible_notify_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
{
- GtkWidget * w;
- GtkCalendar * calendar;
- IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
- GDateTime *datetime;
- gint cur_y, cur_m, cur_d;
- guint cal_y, cal_m, cal_d;
-
- g_debug("notify visible signal received");
-
- /* set the calendar to today's date */
- datetime = g_date_time_new_now_local ();
- g_date_time_get_ymd (datetime, &cur_y, &cur_m, &cur_d);
- g_date_time_unref (datetime);
- w = ido_calendar_menu_item_get_calendar (self->priv->ido_calendar);
- calendar = GTK_CALENDAR(w);
- gtk_calendar_get_date (calendar, &cal_y, &cal_m, &cal_d);
- if ((cur_y != cal_y) || (cur_m-1 != cal_m))
- gtk_calendar_select_month (calendar, cur_m-1, cur_y); /* (cur_m is 1-based) */
- if (cur_d != cal_d)
- gtk_calendar_select_day (calendar, cur_d);
+ IndicatorDatetime * self;
+ g_debug ("notify visible signal received");
+
+ self = INDICATOR_DATETIME (user_data);
+ g_assert (self != NULL);
+
+ /* if the calendar widget's been created, set it to today's datë */
+ if (self->priv->ido_calendar != NULL) {
+ GtkWidget * w;
+ GtkCalendar * calendar;
+ gint cur_y, cur_m, cur_d;
+ guint cal_y, cal_m, cal_d;
+ GDateTime * datetime = g_date_time_new_now_local ();
+
+ g_date_time_get_ymd (datetime, &cur_y, &cur_m, &cur_d);
+ w = ido_calendar_menu_item_get_calendar (self->priv->ido_calendar);
+ calendar = GTK_CALENDAR(w);
+ g_return_if_fail (calendar != NULL);
+
+ gtk_calendar_get_date (calendar, &cal_y, &cal_m, &cal_d);
+ if ((cur_y != cal_y) || (cur_m-1 != cal_m))
+ gtk_calendar_select_month (calendar, cur_m-1, cur_y); /* (cur_m is 1-based) */
+ if (cur_d != cal_d)
+ gtk_calendar_select_day (calendar, cur_d);
+
+ g_date_time_unref (datetime);
+ }
/* Update in case date was changed outside of indicator-datetime */
update_label(self, NULL);
@@ -380,7 +387,7 @@ indicator_datetime_init (IndicatorDatetime *self)
self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ);
- g_signal_connect(self->priv->menu, "notify::visible", G_CALLBACK(menu_visible_notfy_cb), self);
+ g_signal_connect(self->priv->menu, "notify::visible", G_CALLBACK(menu_visible_notify_cb), self);
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);