From f436da0a3f8cf7a01ccb0ae062d53e5be6cd5ff8 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Wed, 23 Mar 2011 10:24:35 +0000 Subject: changes for bug #649800 - requires dbusmenu to be released --- src/datetime-service.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index bd9a9c9..129ec14 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -318,6 +318,27 @@ day_selected_double_click_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant return TRUE; } +static gboolean +close_menu_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant) +{ + if (calendar == NULL) return FALSE; + start_time_appointments = 0; + // TODO create a variant which will be an array of 3 ints {y,m,d} + GVariant *date_variant; + time_t curtime; + struct tm *t1; + time(&curtime); + t1 = localtime(&curtime); + GVariant *date[3]; + date[0] = g_variant_new_uint32(t1->tm_year + 1900); + date[1] = g_variant_new_uint32(t1->tm_mon); + date[2] = g_variant_new_uint32(t1->tm_mday); + date_variant = g_variant_new_array(NULL, date, 3); + + dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_SET_DATE, date_variant); + return TRUE; +} + static guint ecaltimer = 0; static void @@ -1216,6 +1237,9 @@ main (int argc, char ** argv) build_menus(root); + // Connect to the close signal to reset the calendar date + g_signal_connect(root, "event::closed", G_CALLBACK(close_menu_cb), NULL); + /* Cache the timezone */ update_current_timezone(); -- cgit v1.2.3 From acfa619b0301301a733e820cdda8d9335a15b45f Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Thu, 24 Mar 2011 13:54:25 -0500 Subject: show location separator even if no locations (since we always have the current location --- src/datetime-service.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 65df77e..b166f3c 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -437,11 +437,11 @@ update_timezone_menu_items(gpointer user_data) { gboolean show = g_settings_get_boolean (conf, SETTINGS_SHOW_LOCATIONS_S); - if (len > 0) { - dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); - dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); - } else { + dbusmenu_menuitem_property_set_bool (locations_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, show); + dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_VISIBLE, show); + dbusmenu_menuitem_property_set_bool (current_location, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + + if (len == 0) { g_debug("No locations configured (Empty List)"); return FALSE; } -- cgit v1.2.3 From 6f4d5f0e8a120e35a10a8f4e2bc0b33438720e84 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 28 Mar 2011 11:22:03 +0100 Subject: Show calendar widget always --- src/datetime-service.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 65df77e..7e01f88 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -364,12 +364,13 @@ static gboolean check_for_calendar (gpointer user_data) { g_return_val_if_fail (calendar != NULL, FALSE); - + // Always enable the calendar even if it does nothing + dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); + dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + gchar *evo = g_find_program_in_path("evolution"); if (evo != NULL) { g_debug("Found the calendar application: %s", evo); - dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); - dbusmenu_menuitem_property_set_bool(calendar, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); dbusmenu_menuitem_property_set_bool(date, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); g_signal_connect (G_OBJECT(date), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, -- cgit v1.2.3 From 26fddf955899a2751b140a8c5a75f6861509b66e Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Tue, 29 Mar 2011 14:23:29 +0100 Subject: Adding tedg's suggested change to the property sending, no change in signals being received by the other side. --- src/datetime-service.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 17745fe..b0298ae 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -607,7 +607,7 @@ update_appointment_menu_items (gpointer user_data) int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; if ((this_year % 400 == 0) || (this_year % 100 > 0 && this_year % 4 == 0)) days[1] = 29; - int highlightdays = days[mon] - mday + 1; + int highlightdays = days[mon] - mday; t1 = curtime; // By default the current time is the appointment start time. if (start_time_appointments > 0) { @@ -627,10 +627,7 @@ update_appointment_menu_items (gpointer user_data) g_debug("Will highlight %d days from %s", highlightdays, ctime(&t1)); - t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60); - - // Remove all highlights from the calendar widget - dbusmenu_menuitem_property_set (calendar, CALENDAR_MENUITEM_PROP_CLEAR_MARKS, NULL); + t2 = t1 + (time_t) (highlightdays * 24 * 60 * 60); if (!e_cal_get_sources(&sources, E_CAL_SOURCE_TYPE_EVENT, &gerror)) { g_debug("Failed to get ecal sources\n"); @@ -702,6 +699,11 @@ update_appointment_menu_items (gpointer user_data) } else { apt_output = SETTINGS_TIME_LOCALE; } + // Remove all highlights from the calendar widget + dbusmenu_menuitem_property_set (calendar, CALENDAR_MENUITEM_PROP_CLEAR_MARKS, NULL); + + GVariantBuilder markeddays; + g_variant_builder_init (&markeddays, G_VARIANT_TYPE_ARRAY); i = 0; for (l = sorted_comp_instances; l; l = l->next) { @@ -724,9 +726,8 @@ update_appointment_menu_items (gpointer user_data) const int dyear = due->tm_year; // Mark day - g_debug("Marking date %s", ctime(&ci->start)); - dbusmenu_menuitem_property_set_int (calendar, CALENDAR_MENUITEM_PROP_MARK, due->tm_mday); - + g_debug("Adding marked date %s, %d", ctime(&ci->start), dmday); + g_variant_builder_add (&markeddays, "i", dmday); // If the appointment time is less than the selected date, // don't create an appointment item for it. @@ -854,6 +855,9 @@ update_appointment_menu_items (gpointer user_data) } g_list_free(sorted_comp_instances); + GVariant * marks = g_variant_builder_end (&markeddays); + dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_MARK, marks); + updating_appointments = FALSE; g_debug("End of objects"); return TRUE; -- cgit v1.2.3 From 851b7395730c2679403bc69013a9aea94584721d Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Wed, 30 Mar 2011 12:49:01 +0100 Subject: Made marking work when you change month, still needs more work to get it to do it on startup properly. --- src/datetime-service.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index b0298ae..36a9a73 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -607,7 +607,7 @@ update_appointment_menu_items (gpointer user_data) int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; if ((this_year % 400 == 0) || (this_year % 100 > 0 && this_year % 4 == 0)) days[1] = 29; - int highlightdays = days[mon] - mday; + int highlightdays = days[mon] - mday + 1; t1 = curtime; // By default the current time is the appointment start time. if (start_time_appointments > 0) { @@ -621,7 +621,7 @@ update_appointment_menu_items (gpointer user_data) month_start.tm_mon = start_tm->tm_mon; month_start.tm_mday = 1; t1 = mktime(&month_start); - highlightdays = days[mon]; + highlightdays = days[start_month]; } } @@ -699,8 +699,6 @@ update_appointment_menu_items (gpointer user_data) } else { apt_output = SETTINGS_TIME_LOCALE; } - // Remove all highlights from the calendar widget - dbusmenu_menuitem_property_set (calendar, CALENDAR_MENUITEM_PROP_CLEAR_MARKS, NULL); GVariantBuilder markeddays; g_variant_builder_init (&markeddays, G_VARIANT_TYPE_ARRAY); -- cgit v1.2.3 From 019db0b50bfc677633e06cac7dfddf2c3a61cbf2 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Wed, 30 Mar 2011 15:02:28 +0100 Subject: Move start timer into an idle so we have a chance to actually create the menu items --- src/datetime-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 36a9a73..863bc9e 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -410,7 +410,7 @@ check_for_calendar (gpointer user_data) if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) { dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - start_ecal_timer(); + g_idle_add(start_ecal_timer, NULL); } else { dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); -- cgit v1.2.3 From afdaa937487ff3db6077d851132ea7ae2353bf0f Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Wed, 30 Mar 2011 15:57:26 +0100 Subject: Potential fix for suspend issue suggested by njpatel --- src/datetime-service.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 863bc9e..e284418 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -353,6 +353,12 @@ stop_ecal_timer(void) { if (ecaltimer != 0) g_source_remove(ecaltimer); } +static gboolean +idle_start_ecal_timer (gpointer data) +{ + start_ecal_timer(); + return FALSE; +} static void show_events_changed (void) @@ -410,7 +416,7 @@ check_for_calendar (gpointer user_data) if (g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) { dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); - g_idle_add(start_ecal_timer, NULL); + g_idle_add((GSourceFunc)idle_start_ecal_timer, NULL); } else { dbusmenu_menuitem_property_set_bool(add_appointment, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); -- cgit v1.2.3 From fb7e5a07951216e5771614b92f4a49f57807b337 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Mar 2011 10:29:58 -0500 Subject: Switching to one variable with all the marks in it --- src/datetime-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index e284418..ef67d85 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -860,7 +860,7 @@ update_appointment_menu_items (gpointer user_data) g_list_free(sorted_comp_instances); GVariant * marks = g_variant_builder_end (&markeddays); - dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_MARK, marks); + dbusmenu_menuitem_property_set_variant (calendar, CALENDAR_MENUITEM_PROP_MARKS, marks); updating_appointments = FALSE; g_debug("End of objects"); -- cgit v1.2.3 From 88d10f2b5102676f9498a700ef290b42953664f1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Mar 2011 11:03:51 -0500 Subject: Clear marks on month changes --- src/datetime-service.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index ef67d85..6042e94 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -281,6 +281,11 @@ month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, g start_time_appointments = (time_t)g_variant_get_uint32(variant); g_debug("Received month changed with timestamp: %d -> %s",(int)start_time_appointments, ctime(&start_time_appointments)); + /* By default one of the first things we do is + clear the marks as we don't know the correct + ones yet and we don't want to confuse the + user. */ + dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS); update_appointment_menu_items(NULL); return TRUE; } -- cgit v1.2.3 From 0e435a010c1350df7de029725ba9e721d543ccf5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Mar 2011 11:25:45 -0500 Subject: Update the appointments in the idle loop so we can get those signals returned promptly! --- src/datetime-service.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 6042e94..6820bb9 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -275,6 +275,13 @@ activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) } } +static gboolean +update_appointment_menu_items_idle (gpointer user_data) +{ + update_appointment_menu_items(user_data); + return FALSE; +} + static gboolean month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) { @@ -286,7 +293,7 @@ month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, g ones yet and we don't want to confuse the user. */ dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS); - update_appointment_menu_items(NULL); + g_idle_add(update_appointment_menu_items_idle, NULL); return TRUE; } @@ -296,7 +303,7 @@ day_selected_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, gu start_time_appointments = (time_t)g_variant_get_uint32(variant); g_debug("Received day-selected with timestamp: %d -> %s",(int)start_time_appointments, ctime(&start_time_appointments)); - update_appointment_menu_items(NULL); + g_idle_add(update_appointment_menu_items_idle, NULL); return TRUE; } -- cgit v1.2.3 From 49ffaa6c41cee3855f5101cdbe0220e225f59ac0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Mar 2011 14:44:28 -0500 Subject: Ensure that the marks get cleared on day changes that go across monthly boundries as well --- src/datetime-service.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 6820bb9..85139ed 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -300,10 +300,33 @@ month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, g static gboolean day_selected_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) { - start_time_appointments = (time_t)g_variant_get_uint32(variant); - + time_t new_time = (time_t)g_variant_get_uint32(variant); + g_warn_if_fail(new_time != 0); + + if (start_time_appointments == 0 || new_time == 0) { + /* If we've got nothing, assume everyhting is going to + get repopulated, let's start with a clean slate */ + dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS); + } else { + /* No check to see if we changed months. If we did we'll + want to clear the marks. Otherwise we're cool keeping + them around. */ + struct tm start_tm; + struct tm new_tm; + + localtime_r(&start_time_appointments, &start_tm); + localtime_r(&new_time, &new_tm); + + if (start_tm.tm_mon != new_tm.tm_mon) { + dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS); + } + } + + start_time_appointments = new_time; + g_debug("Received day-selected with timestamp: %d -> %s",(int)start_time_appointments, ctime(&start_time_appointments)); g_idle_add(update_appointment_menu_items_idle, NULL); + return TRUE; } -- cgit v1.2.3 From cdf13963033711cd14d01e1a47958f861f6ff21d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Mar 2011 14:49:07 -0500 Subject: Disable the appointments on date or month change to make it show that they're being updated and aren't currently valid --- src/datetime-service.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 85139ed..91e9d81 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -293,6 +293,13 @@ month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, g ones yet and we don't want to confuse the user. */ dbusmenu_menuitem_property_remove(menuitem, CALENDAR_MENUITEM_PROP_MARKS); + + GList * appointment; + for (appointment = appointments; appointment != NULL; appointment = g_list_next(appointment)) { + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(appointment->data); + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); + } + g_idle_add(update_appointment_menu_items_idle, NULL); return TRUE; } @@ -322,6 +329,12 @@ day_selected_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, gu } } + GList * appointment; + for (appointment = appointments; appointment != NULL; appointment = g_list_next(appointment)) { + DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(appointment->data); + dbusmenu_menuitem_property_set_bool(mi, DBUSMENU_MENUITEM_PROP_ENABLED, FALSE); + } + start_time_appointments = new_time; g_debug("Received day-selected with timestamp: %d -> %s",(int)start_time_appointments, ctime(&start_time_appointments)); -- cgit v1.2.3 From d331e3005e9c3d00709f146ccd2e32f6f2a2c82d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Mar 2011 15:10:41 -0500 Subject: Changing code to recycle the appointment menu items for a cleaner switching of days --- src/datetime-service.c | 55 +++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 21 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 91e9d81..fb3b89f 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -420,14 +420,13 @@ show_events_changed (void) dbusmenu_menuitem_property_set_bool(events_separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); /* Remove all of the previous appointments */ if (appointments != NULL) { - g_debug("Freeing old appointments"); - while (appointments != NULL) { - DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(appointments->data); - g_debug("Freeing old appointment: %p", litem); + g_debug("Hiding old appointments"); + GList * appointment; + for (appointment = appointments; appointment != NULL; appointment = g_list_next(appointment)) { + DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(appointment->data); + g_debug("Hiding old appointment: %p", litem); // Remove all the existing menu items which are in appointments. - appointments = g_list_remove(appointments, litem); - dbusmenu_menuitem_child_delete(root, DBUSMENU_MENUITEM(litem)); - g_object_unref(G_OBJECT(litem)); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(litem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } } stop_ecal_timer(); @@ -725,16 +724,15 @@ update_appointment_menu_items (gpointer user_data) comp_instances = NULL; g_debug("Components sorted"); - /* Remove all of the previous appointments */ + /* Hiding all of the previous appointments */ if (appointments != NULL) { - g_debug("Freeing old appointments"); - while (appointments != NULL) { - DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(appointments->data); - g_debug("Freeing old appointment: %p", litem); + g_debug("Hiding old appointments"); + GList * appointment; + for (appointment = appointments; appointment != NULL; appointment = g_list_next(appointment)) { + DbusmenuMenuitem * litem = DBUSMENU_MENUITEM(appointment->data); + g_debug("Hiding old appointment: %p", litem); // Remove all the existing menu items which are in appointments. - appointments = g_list_remove(appointments, litem); - dbusmenu_menuitem_child_delete(root, DBUSMENU_MENUITEM(litem)); - g_object_unref(G_OBJECT(litem)); + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(litem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } } @@ -758,6 +756,7 @@ update_appointment_menu_items (gpointer user_data) g_variant_builder_init (&markeddays, G_VARIANT_TYPE_ARRAY); i = 0; + GList * cached_appointment = appointments; for (l = sorted_comp_instances; l; l = l->next) { struct comp_instance *ci = l->data; ECalComponent *ecalcomp = ci->comp; @@ -792,12 +791,28 @@ update_appointment_menu_items (gpointer user_data) if (i >= 5) continue; i++; - g_debug("Create menu item"); - - item = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, APPOINTMENT_MENUITEM_TYPE); + if (cached_appointment == NULL) { + g_debug("Create menu item"); + + item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set (item, DBUSMENU_MENUITEM_PROP_TYPE, APPOINTMENT_MENUITEM_TYPE); + + dbusmenu_menuitem_child_add_position (root, item, 2+i); + appointments = g_list_append (appointments, item); // Keep track of the items here to make them easy to remove + } else { + item = DBUSMENU_MENUITEM(cached_appointment->data); + cached_appointment = g_list_next(cached_appointment); + + /* Remove the icon as we might not replace it on error */ + dbusmenu_menuitem_property_remove(item, APPOINTMENT_MENUITEM_PROP_ICON); + + /* Remove the activate handler */ + g_signal_handlers_disconnect_matched(G_OBJECT(item), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, G_CALLBACK(activate_cb), NULL); + } + dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_ENABLED, TRUE); dbusmenu_menuitem_property_set_bool (item, DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + // Label text e_cal_component_get_summary (ecalcomp, &valuetext); @@ -895,8 +910,6 @@ update_appointment_menu_items (gpointer user_data) cairo_surface_destroy (surface); cairo_destroy(cr); } - dbusmenu_menuitem_child_add_position (root, item, 2+i); - appointments = g_list_append (appointments, item); // Keep track of the items here to make them easy to remove g_debug("Adding appointment: %p", item); } -- cgit v1.2.3 From b690f64445e81b5ce09f5b1eb7b56defb64bbba4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Mar 2011 16:06:05 -0500 Subject: Setting the default _WITH_DAY to be 12_WITH_DAY --- src/datetime-service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index fb3b89f..5172eea 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -654,7 +654,7 @@ update_appointment_menu_items (gpointer user_data) const int mday = today->tm_mday; const int mon = today->tm_mon; const int year = today->tm_year; - + struct tm *start_tm = NULL; int this_year = today->tm_year + 1900; int days[12]={31,28,31,30,31,30,31,31,30,31,30,31}; -- cgit v1.2.3 From e8d074ffc39904e5095623c8c865e32a1fffecc8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 30 Mar 2011 16:50:04 -0500 Subject: Be a bit smarter about handling the the locale --- src/datetime-service.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 5172eea..9eb26e8 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -749,7 +749,11 @@ update_appointment_menu_items (gpointer user_data) } else if (g_strcmp0(time_format_str, "24-hour") == 0) { apt_output = SETTINGS_TIME_24_HOUR; } else { - apt_output = SETTINGS_TIME_LOCALE; + if (is_locale_12h()) { + apt_output = SETTINGS_TIME_12_HOUR; + } else { + apt_output = SETTINGS_TIME_24_HOUR; + } } GVariantBuilder markeddays; @@ -833,11 +837,6 @@ update_appointment_menu_items (gpointer user_data) strftime(right, 20, _(DEFAULT_TIME_24_FORMAT), due); else strftime(right, 20, _(DEFAULT_TIME_24_FORMAT_WITH_DAY), due); - } else { - if ((mday == dmday) && (mon == dmon) && (year == dyear)) - strftime(right, 20, _(DEFAULT_TIME_FORMAT), due); - else - strftime(right, 20, _(DEFAULT_TIME_FORMAT_WITH_DAY), due); } g_debug("Appointment time: %s, for date %s", right, asctime(due)); dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_RIGHT, right); -- cgit v1.2.3