From 8ef94b74f304b3d039a37b3c0a68c8e51d88cf5f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 1 May 2013 16:26:37 -0700 Subject: minor tyop fix: s/notfy/notify/ --- src/indicator-datetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 9546664..7d29914 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -266,7 +266,7 @@ 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; @@ -380,7 +380,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); -- cgit v1.2.3 From c5e72bbaf1744a6693e6a69cfe67c2aa914d3843 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 1 May 2013 16:39:52 -0700 Subject: fix for the datetime g_critical reported by desrt --- src/indicator-datetime.c | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) (limited to 'src/indicator-datetime.c') 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); -- cgit v1.2.3 From 13b5da4c6715e536851dc974fc44ecd235885175 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 1 May 2013 17:42:59 -0700 Subject: since we're just testing to see if the calendar's been created yet, test for NULL instead of using IDO_IS_CALENDAR_MENU_ITEM() --- src/indicator-datetime.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 0945cb2..8c3ae75 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -274,8 +274,8 @@ menu_visible_notify_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpoint 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)) { + /* 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; -- cgit v1.2.3 From e03ef8e4ac74e87cefaff1ef792d8a5bff54c926 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Wed, 1 May 2013 17:44:45 -0700 Subject: this is an assertion, so use g_assert() --- src/indicator-datetime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/indicator-datetime.c') diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 8c3ae75..f7d1a78 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -272,7 +272,7 @@ menu_visible_notify_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpoint g_debug ("notify visible signal received"); self = INDICATOR_DATETIME (user_data); - g_return_if_fail (self != NULL); + g_assert (self != NULL); /* if the calendar widget's been created, set it to today's datë */ if (self->priv->ido_calendar != NULL) { -- cgit v1.2.3