From 9485b01a79c5a7ebe563986295acf24f6ce7df1a Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Sun, 6 Mar 2011 14:28:05 +0000 Subject: Hooking up the signals from the calendar and getting it working on service side --- 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 6f38004..ffaafb0 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -279,7 +279,7 @@ activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) static gboolean month_changed_cb (DbusmenuMenuitem * menuitem, GVariant *variant, guint timestamp) { - // BLOCKED: We're not getting the signal from calendar the ido calendar menuitem + // BLOCKED: Get string from the variant causes segfault in glib // TODO: * Decode the month/year from the string we received // * Check what our current month/year are // * Set some globals so when we-re-run update appointment menu items it gets the right start date -- cgit v1.2.3 From 7823baf6ae4d84d7796bd003f2c3f0bb0122d126 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Sun, 6 Mar 2011 17:08:13 +0000 Subject: Tried using uint but still segfaulting in variant code --- 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 ffaafb0..b097217 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -284,7 +284,7 @@ month_changed_cb (DbusmenuMenuitem * menuitem, GVariant *variant, guint timestam // * Check what our current month/year are // * Set some globals so when we-re-run update appointment menu items it gets the right start date // * update appointment menu items - g_debug("Received month changed : %s", g_variant_get_string(variant, NULL)); + g_debug("Received month changed : %d", g_variant_get_uint32(variant)); return TRUE; } -- cgit v1.2.3 From 3bd841330e0299c54031218e3fc20f911ba7e952 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Tue, 8 Mar 2011 13:18:50 +0000 Subject: Fixed incorrect year in tm struct for indicator-datetime.c:month_changed_cb, still receiving a segfault in datetime-service.c when we try to use the variant. Checked the variant value over dbus and its fine. --- src/datetime-service.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index b097217..78e695d 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -82,6 +82,7 @@ static GList * appointments = NULL; static GList * dconflocations = NULL; static GList * comp_instances = NULL; static gboolean updating_appointments = FALSE; +//static time_t start_time_appointments = NULL; GSettings *conf; @@ -279,12 +280,16 @@ activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) static gboolean month_changed_cb (DbusmenuMenuitem * menuitem, GVariant *variant, guint timestamp) { - // BLOCKED: Get string from the variant causes segfault in glib - // TODO: * Decode the month/year from the string we received - // * Check what our current month/year are - // * Set some globals so when we-re-run update appointment menu items it gets the right start date + // BLOCKED: get type, then get type as string from the variant causes segfault in glib + // TODO: * Set some globals so when we-re-run update appointment menu items it gets the right start date // * update appointment menu items - g_debug("Received month changed : %d", g_variant_get_uint32(variant)); + if (g_variant_get_type(variant) != G_VARIANT_TYPE_UINT32) + g_debug("Variant type is not uint32"); + else + g_debug("Received month changed with timestamp: %d", g_variant_get_uint32(variant)); + + //start_time_appointments = (time_t)g_variant_get_uint32(variant); + //update_appointment_menu_items(NULL); return TRUE; } -- cgit v1.2.3 From fb0dd849ffde2e04fb86f9e99d442283193b9ba9 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Tue, 8 Mar 2011 15:22:18 +0000 Subject: Changed update appointment items so there's less of a delay when refreshing between no-appointments and appointments loaded. Fixed the handle_event signalling from the client to the service. Started hooking up calendar browsing. --- src/datetime-service.c | 60 ++++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 29 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 78e695d..2db414f 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -82,7 +82,7 @@ static GList * appointments = NULL; static GList * dconflocations = NULL; static GList * comp_instances = NULL; static gboolean updating_appointments = FALSE; -//static time_t start_time_appointments = NULL; +static time_t start_time_appointments = (time_t) 0; GSettings *conf; @@ -278,18 +278,14 @@ activate_cb (DbusmenuMenuitem * menuitem, guint timestamp, const gchar *command) } static gboolean -month_changed_cb (DbusmenuMenuitem * menuitem, GVariant *variant, guint timestamp) +month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) { // BLOCKED: get type, then get type as string from the variant causes segfault in glib // TODO: * Set some globals so when we-re-run update appointment menu items it gets the right start date // * update appointment menu items - if (g_variant_get_type(variant) != G_VARIANT_TYPE_UINT32) - g_debug("Variant type is not uint32"); - else - g_debug("Received month changed with timestamp: %d", g_variant_get_uint32(variant)); - - //start_time_appointments = (time_t)g_variant_get_uint32(variant); - //update_appointment_menu_items(NULL); + g_debug("Received month changed with timestamp: %d", g_variant_get_uint32(variant)); + start_time_appointments = (time_t)g_variant_get_uint32(variant); + update_appointment_menu_items(NULL); return TRUE; } @@ -542,6 +538,7 @@ update_appointment_menu_items (gpointer user_data) { // FFR: we should take into account short term timers, for instance // tea timers, pomodoro timers etc... that people may add, this is hinted to in the spec. + g_debug("Update appointments called"); if (calendar == NULL) return FALSE; if (!g_settings_get_boolean(conf, SETTINGS_SHOW_EVENTS_S)) return FALSE; if (updating_appointments) return TRUE; @@ -557,22 +554,12 @@ update_appointment_menu_items (gpointer user_data) gint width, height; ESourceList * sources = NULL; - time(&t1); - time(&t2); - t2 += (time_t) (7 * 24 * 60 * 60); /* 7 days ahead of now, we actually need number_of_days_in_this_month */ + if (start_time_appointments > 0) + t1 = start_time_appointments; + else + time(&t1); - /* 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); - // 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)); - } - } + t2 = t1 + (time_t) (7 * 24 * 60 * 60); /* 7 days ahead of now, we actually need number_of_days_in_this_month */ // TODO Remove all highlights from the calendar widget @@ -616,11 +603,26 @@ update_appointment_menu_items (gpointer user_data) g_debug("Number of ECalComponents returned: %d", g_list_length(comp_instances)); GList *sorted_comp_instances = g_list_sort(comp_instances, compare_comp_instances); comp_instances = NULL; - - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + + /* 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); + // 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)); + } + } + + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); + // Sometimes these give negative numbers, sometimes large numbers which look like timestampss if (width <= 0) width = 12; - if (height <= 0) height = 13; - + if (height <= 0) height = 12; + if (width > 30) width = 12; + if (height > 30) height = 12; i = 0; for (l = sorted_comp_instances; l; l = l->next) { struct comp_instance *ci = l->data; @@ -676,7 +678,7 @@ update_appointment_menu_items (gpointer user_data) else strftime(right, 20, "%a %l:%M %p", due); - g_debug("Appointment time: %s", right); + g_debug("Appointment time: %s, for date", right, asctime(&due)); dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_RIGHT, right); // Now we pull out the URI for the calendar event and try to create a URI that'll work when we execute evolution -- cgit v1.2.3 From 7d8535da7bd004bf6aa16ea0a52d2a4052614860 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Tue, 8 Mar 2011 15:44:28 +0000 Subject: Fixed calendar browsing with month-changed and removed bogus off by one error --- src/datetime-service.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 2db414f..46b31ef 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -283,8 +283,9 @@ month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, g // BLOCKED: get type, then get type as string from the variant causes segfault in glib // TODO: * Set some globals so when we-re-run update appointment menu items it gets the right start date // * update appointment menu items - g_debug("Received month changed with timestamp: %d", g_variant_get_uint32(variant)); 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)); update_appointment_menu_items(NULL); return TRUE; } @@ -678,7 +679,7 @@ update_appointment_menu_items (gpointer user_data) else strftime(right, 20, "%a %l:%M %p", due); - g_debug("Appointment time: %s, for date", right, asctime(&due)); + g_debug("Appointment time: %s, for date %s", right, asctime(due)); dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_RIGHT, right); // Now we pull out the URI for the calendar event and try to create a URI that'll work when we execute evolution -- cgit v1.2.3 From 6ff10245dca9d00474b8fd25052cde4b0ed619bd Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Tue, 8 Mar 2011 16:05:31 +0000 Subject: Fixed time format of appointments not respecting the configuration --- src/datetime-service.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 46b31ef..458457a 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -624,6 +624,17 @@ update_appointment_menu_items (gpointer user_data) if (height <= 0) height = 12; if (width > 30) width = 12; if (height > 30) height = 12; + + gchar *time_format_str = g_settings_get_string(conf, SETTINGS_TIME_FORMAT_S); + gint apt_output; + if (g_strcmp0(time_format_str, "12-hour") == 0) { + apt_output = SETTINGS_TIME_12_HOUR; + } else if (g_strcmp0(time_format_str, "24-hour") == 0) { + apt_output = SETTINGS_TIME_24_HOUR; + } else { + apt_output = SETTINGS_TIME_LOCALE; + } + i = 0; for (l = sorted_comp_instances; l; l = l->next) { struct comp_instance *ci = l->data; @@ -674,11 +685,23 @@ update_appointment_menu_items (gpointer user_data) int dmon = due->tm_mon; int dyear = due->tm_year; - if ((mday == dmday) && (mon == dmon) && (year == dyear)) - strftime(right, 20, "%l:%M %p", due); - else - strftime(right, 20, "%a %l:%M %p", due); - + if (apt_output == SETTINGS_TIME_12_HOUR) { + if ((mday == dmday) && (mon == dmon) && (year == dyear)) + strftime(right, 20, DEFAULT_TIME_12_FORMAT, due); + else + strftime(right, 20, DEFAULT_TIME_12_FORMAT_WITH_DAY, due); + } else if (apt_output == SETTINGS_TIME_24_HOUR) { + if ((mday == dmday) && (mon == dmon) && (year == dyear)) + 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 From 3cf4b8aea38d62a047b609d13909d79d5c246d65 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Mon, 14 Mar 2011 09:59:55 +0000 Subject: Fixing ted's comments --- src/datetime-service.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/datetime-service.c') diff --git a/src/datetime-service.c b/src/datetime-service.c index 46b31ef..5616d1c 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -548,7 +548,6 @@ update_appointment_menu_items (gpointer user_data) time_t t1, t2; gchar *ad; GList *l; - //GList *allobjects = NULL; GSList *g; GError *gerror = NULL; gint i; @@ -560,7 +559,11 @@ update_appointment_menu_items (gpointer user_data) else time(&t1); - t2 = t1 + (time_t) (7 * 24 * 60 * 60); /* 7 days ahead of now, we actually need number_of_days_in_this_month */ + /* TODO: 7 days ahead of now, we actually need number_of_days_in_this_month + * so we call "mark-day" for all remaining days in this month + * N.B. Ideally we want any/all dates which are later than today to be marked. + */ + t2 = t1 + (time_t) (7 * 24 * 60 * 60); // TODO Remove all highlights from the calendar widget @@ -619,7 +622,8 @@ update_appointment_menu_items (gpointer user_data) } gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - // Sometimes these give negative numbers, sometimes large numbers which look like timestampss + // Sometimes these give negative numbers, sometimes large numbers which look like timestamps + // is there a buffer overwrite causing it? if (width <= 0) width = 12; if (height <= 0) height = 12; if (width > 30) width = 12; -- cgit v1.2.3 From 05e4b574ec953bd6b509f0b623de0cf520ce1598 Mon Sep 17 00:00:00 2001 From: karl-qdh Date: Tue, 15 Mar 2011 09:55:23 +0000 Subject: Fixed missed build error, caused by sync problems between netbook and laptop. --- 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 13dc057..62fa435 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -551,7 +551,7 @@ update_appointment_menu_items (gpointer user_data) GSList *g; GError *gerror = NULL; gint i; - gint width, height; + gint width = 0, height = 0; ESourceList * sources = NULL; if (start_time_appointments > 0) @@ -621,9 +621,7 @@ update_appointment_menu_items (gpointer user_data) } } - gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - // Sometimes these give negative numbers, sometimes large numbers which look like timestamps - // is there a buffer overwrite causing it? + gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); if (width <= 0) width = 12; if (height <= 0) height = 12; if (width > 30) width = 12; -- cgit v1.2.3