aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-14 21:47:38 -0500
committerTed Gould <ted@gould.cx>2011-03-14 21:47:38 -0500
commitd1f61817819716212f18a15e672a8d7d06d6fb78 (patch)
tree491796274c61413dfe95724803381599a465a364
parent66c8394d67e6a80346f2c5f4a0288088b3e83af1 (diff)
parentf9f137dfe27cbe19a5907a986f986368c637aa75 (diff)
downloadayatana-indicator-datetime-d1f61817819716212f18a15e672a8d7d06d6fb78.tar.gz
ayatana-indicator-datetime-d1f61817819716212f18a15e672a8d7d06d6fb78.tar.bz2
ayatana-indicator-datetime-d1f61817819716212f18a15e672a8d7d06d6fb78.zip
* Upstream Merge
* Fix appointment time format * Change appointments with selected date in calendar
-rw-r--r--debian/changelog8
-rw-r--r--src/datetime-service.c97
-rw-r--r--src/dbus-shared.h1
-rw-r--r--src/indicator-datetime.c64
-rw-r--r--src/settings-shared.h4
5 files changed, 138 insertions, 36 deletions
diff --git a/debian/changelog b/debian/changelog
index 79bef8a..214a4e8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+indicator-datetime (0.1.97-0ubuntu1~ppa2) UNRELEASED; urgency=low
+
+ * Upstream Merge
+ * Fix appointment time format
+ * Change appointments with selected date in calendar
+
+ -- Ted Gould <ted@ubuntu.com> Mon, 14 Mar 2011 21:47:01 -0500
+
indicator-datetime (0.1.97-0ubuntu1~ppa1) natty; urgency=low
* New upstream release.
diff --git a/src/datetime-service.c b/src/datetime-service.c
index 3a0a3f0..e51fc4a 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 = (time_t) 0;
GSettings *conf;
@@ -277,14 +278,15 @@ 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: 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 @@ 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;
@@ -543,29 +546,22 @@ 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;
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,10 +605,37 @@ 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 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;
+
+ 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) {
@@ -664,12 +687,24 @@ 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);
-
- g_debug("Appointment time: %s", right);
+ 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);
// Now we pull out the URI for the calendar event and try to create a URI that'll work when we execute evolution
diff --git a/src/dbus-shared.h b/src/dbus-shared.h
index fa6de7b..8b1a20b 100644
--- a/src/dbus-shared.h
+++ b/src/dbus-shared.h
@@ -34,6 +34,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#define CALENDAR_MENUITEM_PROP_MARK "calendar-mark"
#define CALENDAR_MENUITEM_PROP_UNMARK "calendar-unmark"
#define CALENDAR_MENUITEM_PROP_CLEAR_MARKS "calendar-clear-marks"
+#define CALENDAR_MENUITEM_PROP_SET_DATE "calendar-set-date"
#define APPOINTMENT_MENUITEM_TYPE "appointment-item"
diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c
index 46ed0d9..83ae161 100644
--- a/src/indicator-datetime.c
+++ b/src/indicator-datetime.c
@@ -1153,6 +1153,10 @@ indicator_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GVariant *value,
ido_calendar_menu_item_unmark_day (IDO_CALENDAR_MENU_ITEM (mi_data), g_variant_get_int16(value));
} else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_CLEAR_MARKS)) {
ido_calendar_menu_item_clear_marks (IDO_CALENDAR_MENU_ITEM (mi_data));
+ } else if (!g_strcmp0(prop, CALENDAR_MENUITEM_PROP_SET_DATE)) {
+ // const gint * array = g_variant_get_fixed_array(value, NULL, sizeof(gint));
+ // TODO: Needs ido branch merged - lp:~karl-qdh/ido/select-activate-set-date
+ // ido_calendar_menu_item_set_date (IDO_CALENDAR_MENU_ITEM (mi_data), array[0], array[1], array[2]);
} else {
g_warning("Indicator Item property '%s' unknown", prop);
}
@@ -1240,17 +1244,62 @@ static void
month_changed_cb (IdoCalendarMenuItem *ido,
gpointer user_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);
+ struct tm date = {0};
+ date.tm_mday = d;
+ date.tm_mon = m;
+ date.tm_year = y - 1900;
+ guint selecteddate = (guint)mktime(&date);
+ g_debug("Got month changed signal: %s", asctime(&date));
+ GVariant *variant = g_variant_new_uint32(selecteddate);
guint timestamp = (guint)time(NULL);
- dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "event::month-changed", variant, timestamp);
- g_debug("Got month changed signal: %s", datestring);
+ dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "month-changed", variant, timestamp);
}
+// TODO: Needs ido branch merged - lp:~karl-qdh/ido/select-activate-set-date
+/*
+static void
+day_selected_cb (IdoCalendarMenuItem *ido,
+ guint day,
+ gpointer user_data)
+{
+ guint d,m,y;
+ DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data);
+ ido_calendar_menu_item_get_date(ido, &y, &m, &d);
+ struct tm date = {0};
+ date.tm_mday = d;
+ date.tm_mon = m;
+ date.tm_year = y - 1900;
+ guint selecteddate = (guint)mktime(&date);
+ g_debug("Got day selected signal: %s", asctime(&date));
+ GVariant *variant = g_variant_new_uint32(selecteddate);
+ guint timestamp = (guint)time(NULL);
+ dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "day-selected", variant, timestamp);
+}
+
+static void
+day_selected_double_click_cb (IdoCalendarMenuItem *ido,
+ guint day,
+ gpointer user_data)
+{
+ guint d,m,y;
+ DbusmenuMenuitem * item = DBUSMENU_MENUITEM (user_data);
+ ido_calendar_menu_item_get_date(ido, &y, &m, &d);
+ struct tm date = {0};
+ date.tm_mday = d;
+ date.tm_mon = m;
+ date.tm_year = y - 1900;
+ guint selecteddate = (guint)mktime(&date);
+ g_debug("Got day selected double click signal: %s", asctime(&date));
+ GVariant *variant = g_variant_new_uint32(selecteddate);
+ guint timestamp = (guint)time(NULL);
+ dbusmenu_menuitem_handle_event(DBUSMENU_MENUITEM(item), "day-selected-double-click", variant, timestamp);
+}
+*/
+
+
static gboolean
new_calendar_item (DbusmenuMenuitem * newitem,
DbusmenuMenuitem * parent,
@@ -1284,6 +1333,11 @@ new_calendar_item (DbusmenuMenuitem * newitem,
dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent);
g_signal_connect_after(ido, "month-changed", G_CALLBACK(month_changed_cb), (gpointer)newitem);
+
+ // TODO: Needs ido branch merged - lp:~karl-qdh/ido/select-activate-set-date
+ /*g_signal_connect_after(ido, "day-selected", G_CALLBACK(day_selected_cb), (gpointer)newitem);
+ g_signal_connect_after(ido, "day-selected-double-click", G_CALLBACK(day_selected_double_click_cb), (gpointer)newitem);*/
+
return TRUE;
}
diff --git a/src/settings-shared.h b/src/settings-shared.h
index df2260e..ef1183c 100644
--- a/src/settings-shared.h
+++ b/src/settings-shared.h
@@ -51,5 +51,9 @@ enum {
#define DEFAULT_TIME_24_FORMAT N_("%H:%M")
#define DEFAULT_TIME_FORMAT DEFAULT_TIME_12_FORMAT
+#define DEFAULT_TIME_FORMAT_WITH_DAY DEFAULT_TIME_12_FORMAT
+
+#define DEFAULT_TIME_12_FORMAT_WITH_DAY N_("%a %l:%M %p")
+#define DEFAULT_TIME_24_FORMAT_WITH_DAY N_("%a %H:%M")
#endif