aboutsummaryrefslogtreecommitdiff
path: root/src/indicator-datetime.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-10-03 22:27:33 -0500
committerCharles Kerr <charles.kerr@canonical.com>2012-10-03 22:27:33 -0500
commit6db1219ef000df92d5389922123fe85170fa9350 (patch)
treef61938bbbc2854af208d34e977ebdc6ca67cc91c /src/indicator-datetime.c
parentbf4edf2bc976a6ac8459d7f8583269c6a3ca6f2a (diff)
downloadayatana-indicator-datetime-6db1219ef000df92d5389922123fe85170fa9350.tar.gz
ayatana-indicator-datetime-6db1219ef000df92d5389922123fe85170fa9350.tar.bz2
ayatana-indicator-datetime-6db1219ef000df92d5389922123fe85170fa9350.zip
When showing/hiding the menu, don't change the calendar date if it's already what we want. This way we avoid unnecessary appointment rebuilds in the service.
Diffstat (limited to 'src/indicator-datetime.c')
-rw-r--r--src/indicator-datetime.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 2356c6d..92e7fed 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -268,18 +268,26 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass)
static void
menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
{
+ GtkWidget * w;
+ GtkCalendar * calendar;
IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
GDateTime *datetime;
- gint y, m, d;
+ 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, &y, &m, &d);
+ g_date_time_get_ymd (datetime, &cur_y, &cur_m, &cur_d);
g_date_time_unref (datetime);
-
- // Set the calendar to todays date
- ido_calendar_menu_item_set_date (self->priv->ido_calendar, y, m-1, d);
+ 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 ((cal_y != cur_y) || (cal_m-1 != cur_m))
+ gtk_calendar_select_month (calendar, cur_m-1, cur_y); /* (cur_m is 1-based) */
+ if (cal_d != cur_d)
+ gtk_calendar_select_day (calendar, cur_d);
/* Update in case date was changed outside of indicator-datetime */
update_label(self, NULL);