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
1=== modified file 'src/datetime-service.c'
2--- src/datetime-service.c 2011-04-07 15:48:50 +0000
3+++ src/datetime-service.c 2011-04-11 14:34:12 +0000
4@@ -440,28 +440,6 @@
5 return TRUE;
6 }
7
8-static gboolean
9-close_menu_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant)
10-{
11- if (calendar == NULL) return FALSE;
12- g_debug("Resetting date on menu close");
13- start_time_appointments = 0;
14- // TODO create a variant which will be an array of 3 ints {y,m,d}
15- GVariant *date_variant;
16- time_t curtime;
17- struct tm *t1;
18- time(&curtime);
19- t1 = localtime(&curtime);
20- GVariant *date[3];
21- date[0] = g_variant_new_uint32(t1->tm_year + 1900);
22- date[1] = g_variant_new_uint32(t1->tm_mon);
23- date[2] = g_variant_new_uint32(t1->tm_mday);
24- date_variant = g_variant_new_array(NULL, date, 3);
25-
26- dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_SET_DATE, date_variant);
27- return TRUE;
28-}
29-
30 static guint ecaltimer = 0;
31
32 static void
33@@ -1439,9 +1417,6 @@
34
35 build_menus(root);
36
37- // Connect to the close signal to reset the calendar date
38- g_signal_connect(root, "event::closed", G_CALLBACK(close_menu_cb), NULL);
39-
40 /* Cache the timezone */
41 update_current_timezone();
42
43
44=== modified file 'src/dbus-shared.h'
45--- src/dbus-shared.h 2011-03-30 15:29:58 +0000
46+++ src/dbus-shared.h 2011-04-11 14:34:12 +0000
47@@ -29,11 +29,7 @@
48
49 #define DBUSMENU_CALENDAR_MENUITEM_TYPE "x-canonical-calendar-item"
50
51-// The following properties are not *really* properties, but are just
52-// a way of accessing the calendar from the service
53 #define CALENDAR_MENUITEM_PROP_MARKS "calendar-marks"
54-#define CALENDAR_MENUITEM_PROP_SET_DATE "calendar-set-date"
55-
56
57 #define APPOINTMENT_MENUITEM_TYPE "appointment-item"
58 #define APPOINTMENT_MENUITEM_PROP_LABEL "appointment-label"
59
60=== modified file 'src/indicator-datetime.c'
61--- src/indicator-datetime.c 2011-03-31 10:35:35 +0000
62+++ src/indicator-datetime.c 2011-04-11 14:34:12 +0000
63@@ -269,6 +269,35 @@
64 }
65
66 static void
67+menu_visible_notfy_cb(GtkWidget * menu, G_GNUC_UNUSED GParamSpec *pspec, gpointer user_data)
68+{
69+ IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
70+ g_debug("notify visible signal recieved");
71+
72+ // we should only react if we're currently visible
73+ gboolean visible;
74+ g_object_get(G_OBJECT(menu), "visible", &visible, NULL);
75+ if (visible) return;
76+ g_debug("notify visible menu hidden, resetting date");
77+
78+ time_t curtime;
79+
80+ time(&curtime);
81+ struct tm *today = localtime(&curtime);
82+ int y = today->tm_year;
83+ int m = today->tm_mon;
84+ int d = today->tm_mday;
85+
86+ // Set the calendar to todays date
87+ ido_calendar_menu_item_set_date (self->priv->ido_calendar, y+1900, m, d);
88+
89+ // Make sure the day-selected signal is sent so the menu updates - may duplicate
90+ /*GVariant *variant = g_variant_new_uint32((guint)curtime);
91+ guint timestamp = (guint)time(NULL);
92+ dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(self->priv->ido_calendar), "day-selected", variant, timestamp);*/
93+}
94+
95+static void
96 indicator_datetime_init (IndicatorDatetime *self)
97 {
98 self->priv = INDICATOR_DATETIME_GET_PRIVATE(self);
99@@ -348,6 +377,8 @@
100
101 self->priv->menu = dbusmenu_gtkmenu_new(SERVICE_NAME, MENU_OBJ);
102
103+ g_signal_connect(self->priv->menu, "notify::visible", G_CALLBACK(menu_visible_notfy_cb), self);
104+
105 DbusmenuGtkClient *client = dbusmenu_gtkmenu_get_client(self->priv->menu);
106 dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), DBUSMENU_CALENDAR_MENUITEM_TYPE, new_calendar_item, self, NULL);
107 dbusmenu_client_add_type_handler_full(DBUSMENU_CLIENT(client), APPOINTMENT_MENUITEM_TYPE, new_appointment_item, self, NULL);
108@@ -1233,13 +1264,6 @@
109 } else {
110 g_debug("\tMarks: <cleared>");
111 }
112- } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) {
113- if (value != NULL) {
114- gsize size = 3;
115- const gint * array = g_variant_get_fixed_array(value, &size, sizeof(gint));
116- g_debug("Setting date y-m-d: %d-%d-%d", array[0], array[1], array[2]);
117- ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]);
118- }
119 }
120 return;
121 }
122@@ -1418,11 +1442,6 @@
123 calendar_prop_change_cb(newitem, CALENDAR_MENUITEM_PROP_MARKS, propval, ido);
124 }
125
126- propval = dbusmenu_menuitem_property_get_variant(newitem, CALENDAR_MENUITEM_PROP_SET_DATE);
127- if (propval != NULL) {
128- calendar_prop_change_cb(newitem, CALENDAR_MENUITEM_PROP_SET_DATE, propval, ido);
129- }
130-
131 return TRUE;
132 }
133

Subscribers

People subscribed via source and target branches