aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-datetime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/indicator-datetime.c')
-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);