Merge lp:~karl-qdh/indicator-datetime/datereset into lp:indicator-datetime/0.3

Proposed by Karl Lattimer
Status: Merged
Merged at revision: 105
Proposed branch: lp:~karl-qdh/indicator-datetime/datereset
Merge into: lp:indicator-datetime/0.3
Diff against target: 132 lines (+31/-41)
3 files modified
src/datetime-service.c (+0/-25)
src/dbus-shared.h (+0/-4)
src/indicator-datetime.c (+31/-12)
To merge this branch: bzr merge lp:~karl-qdh/indicator-datetime/datereset
Reviewer Review Type Date Requested Status
Ted Gould Pending
Review via email: mp+57173@code.launchpad.net

Description of the change

Different method of resetting the date works.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/datetime-service.c'
--- src/datetime-service.c 2011-04-07 15:48:50 +0000
+++ src/datetime-service.c 2011-04-11 14:34:12 +0000
@@ -440,28 +440,6 @@
440 return TRUE;440 return TRUE;
441}441}
442442
443static gboolean
444close_menu_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant)
445{
446 if (calendar == NULL) return FALSE;
447 g_debug("Resetting date on menu close");
448 start_time_appointments = 0;
449 // TODO create a variant which will be an array of 3 ints {y,m,d}
450 GVariant *date_variant;
451 time_t curtime;
452 struct tm *t1;
453 time(&curtime);
454 t1 = localtime(&curtime);
455 GVariant *date[3];
456 date[0] = g_variant_new_uint32(t1->tm_year + 1900);
457 date[1] = g_variant_new_uint32(t1->tm_mon);
458 date[2] = g_variant_new_uint32(t1->tm_mday);
459 date_variant = g_variant_new_array(NULL, date, 3);
460
461 dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_SET_DATE, date_variant);
462 return TRUE;
463}
464
465static guint ecaltimer = 0;443static guint ecaltimer = 0;
466444
467static void445static void
@@ -1439,9 +1417,6 @@
1439 1417
1440 build_menus(root);1418 build_menus(root);
1441 1419
1442 // Connect to the close signal to reset the calendar date
1443 g_signal_connect(root, "event::closed", G_CALLBACK(close_menu_cb), NULL);
1444
1445 /* Cache the timezone */1420 /* Cache the timezone */
1446 update_current_timezone();1421 update_current_timezone();
14471422
14481423
=== modified file 'src/dbus-shared.h'
--- src/dbus-shared.h 2011-03-30 15:29:58 +0000
+++ src/dbus-shared.h 2011-04-11 14:34:12 +0000
@@ -29,11 +29,7 @@
2929
30#define DBUSMENU_CALENDAR_MENUITEM_TYPE "x-canonical-calendar-item"30#define DBUSMENU_CALENDAR_MENUITEM_TYPE "x-canonical-calendar-item"
3131
32// The following properties are not *really* properties, but are just
33// a way of accessing the calendar from the service
34#define CALENDAR_MENUITEM_PROP_MARKS "calendar-marks"32#define CALENDAR_MENUITEM_PROP_MARKS "calendar-marks"
35#define CALENDAR_MENUITEM_PROP_SET_DATE "calendar-set-date"
36
3733
38#define APPOINTMENT_MENUITEM_TYPE "appointment-item" 34#define APPOINTMENT_MENUITEM_TYPE "appointment-item"
39#define APPOINTMENT_MENUITEM_PROP_LABEL "appointment-label"35#define APPOINTMENT_MENUITEM_PROP_LABEL "appointment-label"
4036
=== modified file 'src/indicator-datetime.c'
--- src/indicator-datetime.c 2011-03-31 10:35:35 +0000
+++ src/indicator-datetime.c 2011-04-11 14:34:12 +0000
@@ -269,6 +269,35 @@
269}269}
270270
271static void271static void
272menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
273{
274 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
275 g_debug("notify visible signal recieved");
276
277 // we should only react if we're currently visible
278 gboolean visible;
279 g_object_get(G_OBJECT(menu), "visible", &visible, NULL);
280 if (visible) return;
281 g_debug("notify visible menu hidden, resetting date");
282
283 time_t curtime;
284
285 time(&curtime);
286 struct tm *today = localtime(&curtime);
287 int y = today->tm_year;
288 int m = today->tm_mon;
289 int d = today->tm_mday;
290
291 // Set the calendar to todays date
292 ido_calendar_menu_item_set_date (self->priv->ido_calendar, y+1900, m, d);
293
294 // Make sure the day-selected signal is sent so the menu updates - may duplicate
295 /*GVariant *variant = g_variant_new_uint32((guint)curtime);
296 guint timestamp = (guint)time(NULL);
297 dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(self->priv->ido_calendar), "day-selected", variant, timestamp);*/
298}
299
300static void
272indicator_datetime_init (IndicatorDatetime *self)301indicator_datetime_init (IndicatorDatetime *self)
273{302{
274 self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);303 self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
@@ -348,6 +377,8 @@
348377
349 self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ);378 self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ);
350379
380 g_signal_connect(self->priv->menu, "notify::visible", G_CALLBACK(menu_visible_notfy_cb), self);
381
351 DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(self->priv->menu);382 DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(self->priv->menu);
352 dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), DBUSMENU_CALENDAR_MENUITEM_TYPE, new_calendar_item, self, NULL);383 dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), DBUSMENU_CALENDAR_MENUITEM_TYPE, new_calendar_item, self, NULL);
353 dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), APPOINTMENT_MENUITEM_TYPE, new_appointment_item, self, NULL);384 dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), APPOINTMENT_MENUITEM_TYPE, new_appointment_item, self, NULL);
@@ -1233,13 +1264,6 @@
1233 } else {1264 } else {
1234 g_debug("\tMarks: <cleared>");1265 g_debug("\tMarks: <cleared>");
1235 }1266 }
1236 } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) {
1237 if (value != NULL) {
1238 gsize size = 3;
1239 const gint * array = g_variant_get_fixed_array(value, &size, sizeof(gint));
1240 g_debug("Setting date y-m-d: %d-%d-%d", array[0], array[1], array[2]);
1241 ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]);
1242 }
1243 }1267 }
1244 return;1268 return;
1245}1269}
@@ -1418,11 +1442,6 @@
1418 calendar_prop_change_cb(newitem, CALENDAR_MENUITEM_PROP_MARKS, propval, ido);1442 calendar_prop_change_cb(newitem, CALENDAR_MENUITEM_PROP_MARKS, propval, ido);
1419 }1443 }
14201444
1421 propval = dbusmenu_menuitem_property_get_variant(newitem, CALENDAR_MENUITEM_PROP_SET_DATE);
1422 if (propval != NULL) {
1423 calendar_prop_change_cb(newitem, CALENDAR_MENUITEM_PROP_SET_DATE, propval, ido);
1424 }
1425
1426 return TRUE;1445 return TRUE;
1427}1446}
14281447

Subscribers

People subscribed via source and target branches