aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-05-01 16:39:52 -0700
committerCharles Kerr <charles.kerr@canonical.com>2013-05-01 16:39:52 -0700
commitc5e72bbaf1744a6693e6a69cfe67c2aa914d3843 (patch)
tree476446550a82a98b8fcef7e021e460b539ce2c1b
parent8ef94b74f304b3d039a37b3c0a68c8e51d88cf5f (diff)
downloadayatana-indicator-datetime-c5e72bbaf1744a6693e6a69cfe67c2aa914d3843.tar.gz
ayatana-indicator-datetime-c5e72bbaf1744a6693e6a69cfe67c2aa914d3843.tar.bz2
ayatana-indicator-datetime-c5e72bbaf1744a6693e6a69cfe67c2aa914d3843.zip
fix for the datetime g_critical reported by desrt
-rw-r--r--src/indicator-datetime.c47
1 files changed, 27 insertions, 20 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 7d29914..0945cb2 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -268,26 +268,33 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass)
static void
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_return_if_fail (self != NULL);
+
+ /* if the calendar widget's been created, set it to today's date */
+ if (IDO_IS_CALENDAR_MENU_ITEM(self->priv->ido_calendar)) {
+ 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);