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

Proposed by Karl Lattimer
Status: Merged
Merged at revision: 94
Proposed branch: lp:~karl-qdh/indicator-datetime/resetdate
Merge into: lp:indicator-datetime/0.3
Diff against target: 251 lines (+116/-17)
2 files modified
src/datetime-service.c (+42/-9)
src/indicator-datetime.c (+74/-8)
To merge this branch: bzr merge lp:~karl-qdh/indicator-datetime/resetdate
Reviewer Review Type Date Requested Status
Ted Gould Pending
Review via email: mp+55482@code.launchpad.net

Description of the change

Used the suggested arrays for marking/unmarking days but there's no change, the signal is still not received by the indicator, restarted everything in various ways and nothing seems to get it working.

To post a comment you must log in.
81. By Karl Lattimer

Made marking work when you change month, still needs more work to get it to do it on startup properly.

82. By Karl Lattimer

Move start timer into an idle so we have a chance to actually create the menu items

83. By Karl Lattimer

Potential fix for suspend issue suggested by njpatel

84. By Karl Lattimer

Might not like that signal notation

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-03-29 16:58:28 +0000
+++ src/datetime-service.c 2011-03-30 15:04:58 +0000
@@ -316,6 +316,28 @@
316 return TRUE;316 return TRUE;
317}317}
318318
319static gboolean
320close_menu_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant)
321{
322 if (calendar == NULL) return FALSE;
323 g_debug("Resetting date on menu close");
324 start_time_appointments = 0;
325 // TODO create a variant which will be an array of 3 ints {y,m,d}
326 GVariant *date_variant;
327 time_t curtime;
328 struct tm *t1;
329 time(&curtime);
330 t1 = localtime(&curtime);
331 GVariant *date[3];
332 date[0] = g_variant_new_uint32(t1->tm_year + 1900);
333 date[1] = g_variant_new_uint32(t1->tm_mon);
334 date[2] = g_variant_new_uint32(t1->tm_mday);
335 date_variant = g_variant_new_array(NULL, date, 3);
336
337 dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_SET_DATE, date_variant);
338 return TRUE;
339}
340
319static guint ecaltimer = 0;341static guint ecaltimer = 0;
320342
321static void343static void
@@ -331,6 +353,12 @@
331{353{
332 if (ecaltimer != 0) g_source_remove(ecaltimer);354 if (ecaltimer != 0) g_source_remove(ecaltimer);
333}355}
356static gboolean
357idle_start_ecal_timer (gpointer data)
358{
359 start_ecal_timer();
360 return FALSE;
361}
334362
335static void363static void
336show_events_changed (void)364show_events_changed (void)
@@ -389,7 +417,7 @@
389 if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {417 if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) {
390 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);418 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
391 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);419 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE);
392 start_ecal_timer();420 g_idle_add((GSourceFunc)idle_start_ecal_timer, NULL);
393 } else {421 } else {
394 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);422 dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
395 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);423 dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE);
@@ -600,16 +628,13 @@
600 month_start.tm_mon = start_tm->tm_mon;628 month_start.tm_mon = start_tm->tm_mon;
601 month_start.tm_mday = 1;629 month_start.tm_mday = 1;
602 t1 = mktime(&month_start);630 t1 = mktime(&month_start);
603 highlightdays = days[mon];631 highlightdays = days[start_month];
604 }632 }
605 }633 }
606 634
607 g_debug("Will highlight %d days from %s", highlightdays, ctime(&t1));635 g_debug("Will highlight %d days from %s", highlightdays, ctime(&t1));
608636
609 t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60); 637 t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60);
610
611 // Remove all highlights from the calendar widget
612 dbusmenu_menuitem_property_set (calendar, CALENDAR_MENUITEM_PROP_CLEAR_MARKS, NULL);
613 638
614 if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_EVENT, &gerror)) {639 if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_EVENT, &gerror)) {
615 g_debug("Failed to get ecal sources\n");640 g_debug("Failed to get ecal sources\n");
@@ -682,6 +707,9 @@
682 apt_output = SETTINGS_TIME_LOCALE;707 apt_output = SETTINGS_TIME_LOCALE;
683 }708 }
684 709
710 GVariantBuilder markeddays;
711 g_variant_builder_init (&markeddays, G_VARIANT_TYPE_ARRAY);
712
685 i = 0;713 i = 0;
686 for (l = sorted_comp_instances; l; l = l->next) {714 for (l = sorted_comp_instances; l; l = l->next) {
687 struct comp_instance *ci = l->data;715 struct comp_instance *ci = l->data;
@@ -703,9 +731,8 @@
703 const int dyear = due->tm_year;731 const int dyear = due->tm_year;
704 732
705 // Mark day733 // Mark day
706 g_debug("Marking date %s", ctime(&ci->start));734 g_debug("Adding marked date %s, %d", ctime(&ci->start), dmday);
707 dbusmenu_menuitem_property_set_int (calendar, CALENDAR_MENUITEM_PROP_MARK, due->tm_mday);735 g_variant_builder_add (&markeddays, "i", dmday);
708
709736
710 // If the appointment time is less than the selected date, 737 // If the appointment time is less than the selected date,
711 // don't create an appointment item for it.738 // don't create an appointment item for it.
@@ -833,6 +860,9 @@
833 }860 }
834 g_list_free(sorted_comp_instances);861 g_list_free(sorted_comp_instances);
835 862
863 GVariant * marks = g_variant_builder_end (&markeddays);
864 dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_MARK, marks);
865
836 updating_appointments = FALSE;866 updating_appointments = FALSE;
837 g_debug("End of objects");867 g_debug("End of objects");
838 return TRUE;868 return TRUE;
@@ -1219,6 +1249,9 @@
1219 1249
1220 build_menus(root);1250 build_menus(root);
1221 1251
1252 // Connect to the close signal to reset the calendar date
1253 g_signal_connect(root, "event::closed", G_CALLBACK(close_menu_cb), NULL);
1254
1222 /* Cache the timezone */1255 /* Cache the timezone */
1223 update_current_timezone();1256 update_current_timezone();
12241257
12251258
=== modified file 'src/indicator-datetime.c'
--- src/indicator-datetime.c 2011-03-29 15:43:58 +0000
+++ src/indicator-datetime.c 2011-03-30 15:04:58 +0000
@@ -169,7 +169,9 @@
169static void guess_label_size (IndicatorDatetime * self);169static void guess_label_size (IndicatorDatetime * self);
170static void setup_timer (IndicatorDatetime * self, GDateTime * datetime);170static void setup_timer (IndicatorDatetime * self, GDateTime * datetime);
171static void update_time (IndicatorDatetime * self);171static void update_time (IndicatorDatetime * self);
172static void session_active_change_cb (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
172static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);173static void receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name, GVariant * parameters, gpointer user_data);
174static void system_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
173static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);175static void service_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data);
174static gint generate_strftime_bitmask (const char *time_str);176static gint generate_strftime_bitmask (const char *time_str);
175static void timezone_update_labels (indicator_item_t * mi_data);177static void timezone_update_labels (indicator_item_t * mi_data);
@@ -352,8 +354,34 @@
352 service_proxy_cb,354 service_proxy_cb,
353 self);355 self);
354356
357 g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
358 G_DBUS_PROXY_FLAGS_NONE,
359 NULL,
360 "org.freedesktop.ConsoleKit",
361 "/org/freedesktop/ConsoleKit/Manager",
362 "org.freedesktop.ConsoleKit.Manager",
363 NULL, system_proxy_cb, self);
355 return;364 return;
356}365}
366/* for hooking into console kit signal on wake from suspend */
367static void
368system_proxy_cb (GObject * object, GAsyncResult * res, gpointer user_data)
369{
370 GError * error = NULL;
371
372 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
373 g_return_if_fail(self != NULL);
374
375 GDBusProxy * proxy = g_dbus_proxy_new_for_bus_finish(res, &error);
376
377 if (error != NULL) {
378 g_warning("Could not grab DBus proxy for %s: %s", SERVICE_NAME, error->message);
379 g_error_free(error);
380 return;
381 }
382 g_signal_connect(proxy, "g-signal", G_CALLBACK(session_active_change_cb), self);
383
384}
357385
358/* Callback from trying to create the proxy for the serivce, this386/* Callback from trying to create the proxy for the serivce, this
359 could include starting the service. Sometime it'll fail and387 could include starting the service. Sometime it'll fail and
@@ -776,6 +804,18 @@
776 return;804 return;
777}805}
778806
807static void
808session_active_change_cb (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,
809 GVariant * parameters, gpointer user_data)
810{
811 // Just returned from suspend
812 IndicatorDatetime * self = INDICATOR_DATETIME(user_data);
813 if (g_strcmp0(signal_name, "ActiveChanged") == 0) {
814 update_time(self);
815 }
816 return;
817}
818
779/* Receives all signals from the service, routed to the appropriate functions */819/* Receives all signals from the service, routed to the appropriate functions */
780static void820static void
781receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,821receive_signal (GDBusProxy * proxy, gchar * sender_name, gchar * signal_name,
@@ -1148,18 +1188,45 @@
1148 timezone_update_labels(mi_data);1188 timezone_update_labels(mi_data);
1149 } else if (!g_strcmp0(prop, TIMEZONE_MENUITEM_PROP_RADIO)) {1189 } else if (!g_strcmp0(prop, TIMEZONE_MENUITEM_PROP_RADIO)) {
1150 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi_data->gmi), g_variant_get_boolean(value));1190 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(mi_data->gmi), g_variant_get_boolean(value));
1151 1191 } else {
1152 // Properties for marking and unmarking the calendar1192 g_warning("Indicator Item property '%s' unknown", prop);
1153 1193 }
1154 } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_MARK)) {1194 return;
1155 ido_calendar_menu_item_mark_day (IDO_CALENDAR_MENU_ITEM (mi_data), g_variant_get_int16(value));1195}
1196// Properties for marking and unmarking the calendar
1197static void
1198calendar_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value, IdoCalendarMenuItem * mi_data)
1199{
1200 g_debug("Changing calendar property");
1201 if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_MARK)) {
1202 ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data));
1203 g_debug("Marks: Cleared");
1204 GVariantIter *iter;
1205 gint day;
1206
1207 g_variant_get (value, "ai", &iter);
1208 while (g_variant_iter_loop (iter, "i", &day)) {
1209 ido_calendar_menu_item_mark_day (IDO_CALENDAR_MENU_ITEM (mi_data), day);
1210 g_debug("Marks: Marked day: %d", day);
1211 }
1212 g_variant_iter_free (iter);
1156 } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_UNMARK)) {1213 } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_UNMARK)) {
1157 ido_calendar_menu_item_unmark_day (IDO_CALENDAR_MENU_ITEM (mi_data), g_variant_get_int16(value));1214 GVariantIter *iter;
1215 gint day;
1216
1217 g_variant_get (value, "ai", &iter);
1218 while (g_variant_iter_loop (iter, "i", &day)) {
1219 g_debug("Unmarked day: %d", day);
1220 ido_calendar_menu_item_unmark_day (IDO_CALENDAR_MENU_ITEM (mi_data), day);
1221 }
1222 g_variant_iter_free (iter);
1158 } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_CLEAR_MARKS)) {1223 } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_CLEAR_MARKS)) {
1159 ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data));1224 ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data));
1225 g_debug("Cleared Marks");
1160 } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) {1226 } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) {
1161 gsize size = 3;1227 gsize size = 3;
1162 const gint * array = g_variant_get_fixed_array(value, &size, sizeof(gint));1228 const gint * array = g_variant_get_fixed_array(value, &size, sizeof(gint));
1229 g_debug("Setting date y-m-d: %d-%d-%d", array[0], array[1], array[2]);
1163 ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]);1230 ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]);
1164 } else {1231 } else {
1165 g_warning("Indicator Item property '%s' unknown", prop);1232 g_warning("Indicator Item property '%s' unknown", prop);
@@ -1239,8 +1306,6 @@
1239 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(mi_data->gmi), parent);1306 dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(mi_data->gmi), parent);
12401307
1241 g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(indicator_prop_change_cb), mi_data);1308 g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(indicator_prop_change_cb), mi_data);
1242 g_signal_connect_swapped(G_OBJECT(newitem), "destroyed", G_CALLBACK(g_free), mi_data);
1243
1244 return TRUE;1309 return TRUE;
1245}1310}
12461311
@@ -1334,6 +1399,7 @@
1334 g_signal_connect_after(ido, "day-selected", G_CALLBACK(day_selected_cb), (gpointer)newitem);1399 g_signal_connect_after(ido, "day-selected", G_CALLBACK(day_selected_cb), (gpointer)newitem);
1335 g_signal_connect_after(ido, "day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), (gpointer)newitem);1400 g_signal_connect_after(ido, "day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), (gpointer)newitem);
13361401
1402 g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(calendar_prop_change_cb), ido);
1337 return TRUE;1403 return TRUE;
1338}1404}
13391405

Subscribers

People subscribed via source and target branches