[Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime
The proposal to merge lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime has been updated. Status: Approved = Merged For more details, see: https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53467 -- https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53467 Your team ayatana-commits is subscribed to branch lp:indicator-datetime. ___ Mailing list: https://launchpad.net/~ayatana-commits Post to : ayatana-commits@lists.launchpad.net Unsubscribe : https://launchpad.net/~ayatana-commits More help : https://help.launchpad.net/ListHelp
[Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime
Karl Lattimer has proposed merging lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime. Requested reviews: Ted Gould (ted) Related bugs: Bug #726531 in Indicator Date and Time: Browsing calendar widget should update appointments https://bugs.launchpad.net/indicator-datetime/+bug/726531 For more details, see: https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53467 Updated code in this branch to fulfil ted's comments Partially fixes bug #726531 -- https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53467 Your team ayatana-commits is subscribed to branch lp:indicator-datetime. === modified file 'src/datetime-service.c' --- src/datetime-service.c 2011-03-15 02:43:27 + +++ src/datetime-service.c 2011-03-15 15:51:12 + @@ -280,9 +280,6 @@ static gboolean 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 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)); @@ -290,6 +287,37 @@ return TRUE; } +static gboolean +day_selected_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) +{ + 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); + return TRUE; +} + +static gboolean +day_selected_double_click_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) +{ + time_t evotime = (time_t)g_variant_get_uint32(variant); + + g_debug(Received day-selected-double-click with timestamp: %d - %s,(int)evotime, ctime(evotime)); + + gchar *ad = isodate_from_time_t(evotime); + gchar *cmd = g_strconcat(evolution calendar:///?startdate=, ad, NULL); + + GError * error = NULL; + + g_debug(Issuing command '%s', cmd); + if (!g_spawn_command_line_async(cmd, error)) { + g_warning(Unable to start %s: %s, (char *)cmd, error-message); + g_error_free(error); + } + + return TRUE; +} + static guint ecaltimer = 0; static void @@ -365,8 +393,10 @@ stop_ecal_timer(); } - // Connect to event::month-changed + // Connect to calendar events g_signal_connect(calendar, event::month-changed, G_CALLBACK(month_changed_cb), NULL); + g_signal_connect(calendar, event::day-selected, G_CALLBACK(day_selected_cb), NULL); + g_signal_connect(calendar, event::day-selected-double-click, G_CALLBACK(day_selected_double_click_cb), NULL); g_free(evo); } else { g_debug(Unable to find calendar app.); @@ -543,27 +573,51 @@ if (updating_appointments) return TRUE; updating_appointments = TRUE; - time_t t1, t2; + time_t curtime = 0, t1 = 0, t2 = 0; gchar *ad; GList *l; GSList *g; GError *gerror = NULL; gint i; - gint width, height; + gint width = 0, height = 0; ESourceList * sources = NULL; - - if (start_time_appointments 0) - t1 = start_time_appointments; - else - time(t1); - - /* 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 + + // Get today work out query times + time(curtime); + struct tm *today = localtime(curtime); + 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}; + if ((this_year % 400 == 0) || (this_year % 100 0 this_year % 4 == 0)) days[1] = 29; + + int highlightdays = days[mon] - mday + 1; + t1 = curtime; // By default the current time is the appointment start time. + + if (start_time_appointments 0) { + start_tm = localtime(start_time_appointments); + int start_month = start_tm-tm_mon; + int start_year = start_tm-tm_year + 1900; + if ((start_month != mon) || (start_year != this_year)) { + // Set t1 to the start of that month. + struct tm month_start = {0}; + month_start.tm_year = start_tm-tm_year; + month_start.tm_mon = start_tm-tm_mon; + month_start.tm_mday = 1; + t1 = mktime(month_start); + highlightdays = days[mon]; + } + } + + 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,
Re: [Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime
Review: Approve review approve merge approve -- https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53467 Your team ayatana-commits is subscribed to branch lp:indicator-datetime. ___ Mailing list: https://launchpad.net/~ayatana-commits Post to : ayatana-commits@lists.launchpad.net Unsubscribe : https://launchpad.net/~ayatana-commits More help : https://help.launchpad.net/ListHelp
Re: [Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime
+ // TODO This needs to be an array of 3 ints Confused here... use an array of 3 ints then? :) This isn't actually used as there was an ido branch I was working on that hadn't been merged. +static void +day_selected_double_click_cb (IdoCalendarMenuItem *ido, + guint day, + gpointeruser_data) +{ + gchar datestring[20]; + guint d,m,y; + DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data); + ido_calendar_menu_item_get_date(ido, y, m, d); + g_sprintf(datestring, %d-%d-%d, y, m, d); + GVariant *variant = g_variant_new_string(datestring); + guint timestamp = (guint)time(NULL); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), day-selected- double-click, variant, timestamp); + g_debug(Got day-selected-double-click signal: %s, datestring); +} +*/ Why are you encoding the data into a string instead of just passing an array of ints? Seems it would be better to let GVariant do the encoding for us. I _was_ encoding to a string, but I changed it, the month-changed signal being the only one libido actually supported at the time. + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent); + /*g_signal_connect_after(ido, day-selected, G_CALLBACK(day_selected_cb), (gpointer)newitem); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent); + g_signal_connect_after(ido, day-selected-double-click, G_CALLBACK(day_selected_double_click_cb), (gpointer)newitem);*/ _newitem_base() should only need to be called once here. True review needsfixing -- https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/52570 Your team ayatana-commits is subscribed to branch lp:indicator-datetime. ___ Mailing list: https://launchpad.net/~ayatana-commits Post to : ayatana-commits@lists.launchpad.net Unsubscribe : https://launchpad.net/~ayatana-commits More help : https://help.launchpad.net/ListHelp
[Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime
Karl Lattimer has proposed merging lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime. Requested reviews: Ted Gould (ted) Related bugs: Bug #726531 in Indicator Date and Time: Browsing calendar widget should update appointments https://bugs.launchpad.net/indicator-datetime/+bug/726531 For more details, see: https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53212 Updated code in this branch to fulfil ted's comments Partially fixes bug #726531 -- https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53212 Your team ayatana-commits is subscribed to branch lp:indicator-datetime. === modified file 'src/datetime-service.c' --- src/datetime-service.c 2011-03-10 15:05:51 + +++ src/datetime-service.c 2011-03-14 10:02:49 + @@ -82,6 +82,7 @@ static GList * dconflocations = NULL; static GList * comp_instances = NULL; static gboolean updating_appointments = FALSE; +static time_t start_time_appointments = (time_t) 0; GSettings *conf; @@ -277,14 +278,15 @@ } static gboolean -month_changed_cb (DbusmenuMenuitem * menuitem, GVariant *variant, guint timestamp) +month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) { - // BLOCKED: We're not getting the signal from calendar the ido calendar menuitem - // 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 : %s, g_variant_get_string(variant, NULL)); + 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; } @@ -535,6 +537,7 @@ { // 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; @@ -543,29 +546,22 @@ time_t t1, t2; gchar *ad; GList *l; - //GList *allobjects = NULL; GSList *g; GError *gerror = NULL; gint i; 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)); - } - } + /* 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 @@ -609,11 +605,27 @@ 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 timestamps + // is there a buffer overwrite causing it? 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 =
[Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime
The proposal to merge lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime has been updated. Status: Needs review = Merged For more details, see: https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53212 -- https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/53212 Your team ayatana-commits is subscribed to branch lp:indicator-datetime. ___ Mailing list: https://launchpad.net/~ayatana-commits Post to : ayatana-commits@lists.launchpad.net Unsubscribe : https://launchpad.net/~ayatana-commits More help : https://help.launchpad.net/ListHelp
[Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime
Karl Lattimer has proposed merging lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime. Requested reviews: Ted Gould (ted) Related bugs: #726531 Browsing calendar widget should update appointments https://bugs.launchpad.net/bugs/726531 For more details, see: https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/52570 Partially fixes bug #726531 -- https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/52570 Your team ayatana-commits is subscribed to branch lp:indicator-datetime. === modified file 'src/datetime-service.c' --- src/datetime-service.c 2011-03-04 10:35:22 + +++ src/datetime-service.c 2011-03-08 15:46:34 + @@ -82,6 +82,7 @@ static GList * dconflocations = NULL; static GList * comp_instances = NULL; static gboolean updating_appointments = FALSE; +static time_t start_time_appointments = (time_t) 0; GSettings *conf; @@ -277,14 +278,15 @@ } static gboolean -month_changed_cb (DbusmenuMenuitem * menuitem, GVariant *variant, guint timestamp) +month_changed_cb (DbusmenuMenuitem * menuitem, gchar *name, GVariant *variant, guint timestamp) { - // BLOCKED: We're not getting the signal from calendar the ido calendar menuitem - // 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 : %s, g_variant_get_string(variant, NULL)); + 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; } @@ -537,6 +539,7 @@ { // 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; @@ -552,22 +555,12 @@ 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 @@ -611,11 +604,26 @@ 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; @@ -671,7 +679,7 @@ else strftime(right, 20, %a %l:%M %p, due); - g_debug(Appointment time: %s, right); + 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
Re: [Ayatana-commits] [Merge] lp:~karl-qdh/indicator-datetime/calendarmenuitemsignals into lp:indicator-datetime
Review: Needs Fixing On Tue, 2011-03-08 at 15:46 +, Karl Lattimer wrote: + t2 = t1 + (time_t) (7 * 24 * 60 * 60); /* 7 days ahead of now, we actually need number_of_days_in_this_month */ Could you please make this comment a TODO. + } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) { + // TODO This needs to be an array of 3 ints + //ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), ); Confused here... use an array of 3 ints then? :) +static void +day_selected_double_click_cb (IdoCalendarMenuItem *ido, + guint day, + gpointeruser_data) +{ + gchar datestring[20]; + guint d,m,y; + DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data); + ido_calendar_menu_item_get_date(ido, y, m, d); + g_sprintf(datestring, %d-%d-%d, y, m, d); + GVariant *variant = g_variant_new_string(datestring); + guint timestamp = (guint)time(NULL); + dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), day-selected-double-click, variant, timestamp); + g_debug(Got day-selected-double-click signal: %s, datestring); +} +*/ Why are you encoding the data into a string instead of just passing an array of ints? Seems it would be better to let GVariant do the encoding for us. + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent); + /*g_signal_connect_after(ido, day-selected, G_CALLBACK(day_selected_cb), (gpointer)newitem); + dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent); + g_signal_connect_after(ido, day-selected-double-click, G_CALLBACK(day_selected_double_click_cb), (gpointer)newitem);*/ _newitem_base() should only need to be called once here. review needsfixing -- https://code.launchpad.net/~karl-qdh/indicator-datetime/calendarmenuitemsignals/+merge/52570 Your team ayatana-commits is subscribed to branch lp:indicator-datetime. ___ Mailing list: https://launchpad.net/~ayatana-commits Post to : ayatana-commits@lists.launchpad.net Unsubscribe : https://launchpad.net/~ayatana-commits More help : https://help.launchpad.net/ListHelp