aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-11-17 22:55:48 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-11-17 22:55:48 +0800
commit900d019a0332b24d2bee7ea1407b149fca2c0598 (patch)
tree627edf5d63874be616d41c9a043571a80fc542f5 /calendar/gui
parentcdb09641dc6be772931e5381cdf1e6a824a15684 (diff)
parentbadc11edcf5e73bc6148c7b5cdccee739eb9d7ae (diff)
downloadgsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.gz
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.bz2
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.lz
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.xz
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.tar.zst
gsoc2013-evolution-900d019a0332b24d2bee7ea1407b149fca2c0598.zip
Merge branch 'master' into wip/gsettings
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.c93
-rw-r--r--calendar/gui/alarm-notify/alarm-notify.h3
-rw-r--r--calendar/gui/e-meeting-time-sel-item.c37
-rw-r--r--calendar/gui/e-meeting-time-sel.c49
-rw-r--r--calendar/gui/e-meeting-time-sel.h10
5 files changed, 133 insertions, 59 deletions
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c
index 3b5402b4a6..bc3af20e3c 100644
--- a/calendar/gui/alarm-notify/alarm-notify.c
+++ b/calendar/gui/alarm-notify/alarm-notify.c
@@ -49,6 +49,9 @@ struct _AlarmNotifyPrivate {
ESourceList *source_lists[E_CAL_CLIENT_SOURCE_TYPE_LAST];
ESourceList *selected_calendars;
GMutex *mutex;
+
+ GSList *offline_sources;
+ guint offline_timeout_id;
};
typedef struct {
@@ -100,6 +103,21 @@ process_removal_in_hash (const gchar *uri,
prd->removals = g_list_prepend (prd->removals, (gpointer) uri);
}
+static gint
+find_slist_source_uri_cb (gconstpointer a, gconstpointer b)
+{
+ ESource *asource = (ESource *) a;
+ const gchar *buri = b;
+ gchar *auri;
+ gint res;
+
+ auri = e_source_get_uri (asource);
+ res = g_strcmp0 (auri, buri);
+ g_free (auri);
+
+ return res;
+}
+
static void
alarm_notify_list_changed_cb (ESourceList *source_list,
AlarmNotify *an)
@@ -139,9 +157,10 @@ alarm_notify_list_changed_cb (ESourceList *source_list,
continue;
uri = e_source_get_uri (source);
- if (!g_hash_table_lookup (an->priv->uri_client_hash[source_type], uri)) {
+ if (!g_hash_table_lookup (an->priv->uri_client_hash[source_type], uri) &&
+ !g_slist_find_custom (an->priv->offline_sources, uri, find_slist_source_uri_cb)) {
debug (("Adding Calendar %s", uri));
- alarm_notify_add_calendar (an, source_type, source, FALSE);
+ alarm_notify_add_calendar (an, source_type, source);
}
g_free (uri);
}
@@ -194,7 +213,7 @@ alarm_notify_load_calendars (AlarmNotify *an,
uri = e_source_get_uri (source);
debug (("Loading Calendar %s", uri));
- alarm_notify_add_calendar (an, source_type, source, FALSE);
+ alarm_notify_add_calendar (an, source_type, source);
g_free (uri);
}
@@ -222,6 +241,12 @@ alarm_notify_finalize (GObject *object)
priv = ALARM_NOTIFY (object)->priv;
+ if (priv->offline_timeout_id)
+ g_source_remove (priv->offline_timeout_id);
+ priv->offline_timeout_id = 0;
+ g_slist_free_full (priv->offline_sources, g_object_unref);
+ priv->offline_sources = NULL;
+
for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) {
g_hash_table_foreach (
priv->uri_client_hash[ii],
@@ -349,6 +374,32 @@ alarm_notify_new (GCancellable *cancellable,
"application-id", APPLICATION_ID, NULL);
}
+static gboolean
+try_open_offline_timeout_cb (gpointer user_data)
+{
+ AlarmNotify *an = ALARM_NOTIFY (user_data);
+ GSList *sources, *iter;
+
+ g_return_val_if_fail (an != NULL, FALSE);
+ g_return_val_if_fail (an->priv != NULL, FALSE);
+
+ sources = an->priv->offline_sources;
+ an->priv->offline_sources = NULL;
+ an->priv->offline_timeout_id = 0;
+
+ for (iter = sources; iter; iter = iter->next) {
+ ESource *source = iter->data;
+
+ alarm_notify_add_calendar (an,
+ GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (source), "source-type")),
+ source);
+ }
+
+ g_slist_free_full (sources, g_object_unref);
+
+ return FALSE;
+}
+
static void
client_opened_cb (GObject *source_object,
GAsyncResult *result,
@@ -360,11 +411,22 @@ client_opened_cb (GObject *source_object,
ECalClient *cal_client;
ECalClientSourceType source_type;
const gchar *uri;
+ GError *error = NULL;
+
+ e_client_utils_open_new_finish (source, result, &client, &error);
+
+ if (client == NULL) {
+ if (g_error_matches (error, E_CLIENT_ERROR, E_CLIENT_ERROR_REPOSITORY_OFFLINE)) {
+ if (an->priv->offline_timeout_id)
+ g_source_remove (an->priv->offline_timeout_id);
+ an->priv->offline_sources = g_slist_append (an->priv->offline_sources, g_object_ref (source));
+ an->priv->offline_timeout_id = g_timeout_add_seconds (5 * 60, try_open_offline_timeout_cb, an);
+ }
- e_client_utils_open_new_finish (source, result, &client, NULL);
+ g_clear_error (&error);
- if (client == NULL)
return;
+ }
cal_client = E_CAL_CLIENT (client);
source_type = e_cal_client_get_source_type (cal_client);
@@ -385,8 +447,6 @@ client_opened_cb (GObject *source_object,
* alarm_notify_add_calendar:
* @an: An alarm notification service.
* @uri: URI of the calendar to load.
- * @load_afterwards: Whether this calendar should be loaded in the future
- * when the alarm daemon starts up.
*
* Tells the alarm notification service to load a calendar and start monitoring
* its alarms. It can optionally be made to save the URI of this calendar so
@@ -395,8 +455,7 @@ client_opened_cb (GObject *source_object,
void
alarm_notify_add_calendar (AlarmNotify *an,
ECalClientSourceType source_type,
- ESource *source,
- gboolean load_afterwards)
+ ESource *source)
{
AlarmNotifyPrivate *priv;
EClientSourceType client_source_type;
@@ -459,6 +518,8 @@ alarm_notify_add_calendar (AlarmNotify *an,
client_source_type = E_CLIENT_SOURCE_TYPE_LAST;
}
+ g_object_set_data (G_OBJECT (source), "source-type", GUINT_TO_POINTER (source_type));
+
e_client_utils_open_new (
source, client_source_type, TRUE, NULL,
e_client_utils_authenticate_handler, NULL,
@@ -476,6 +537,7 @@ alarm_notify_remove_calendar (AlarmNotify *an,
{
AlarmNotifyPrivate *priv;
ECalClient *cal_client;
+ GSList *in_offline;
priv = an->priv;
@@ -486,4 +548,17 @@ alarm_notify_remove_calendar (AlarmNotify *an,
alarm_queue_remove_client (cal_client, FALSE);
g_hash_table_remove (priv->uri_client_hash[source_type], str_uri);
}
+
+ in_offline = g_slist_find_custom (priv->offline_sources, str_uri, find_slist_source_uri_cb);
+ if (in_offline) {
+ ESource *source = in_offline->data;
+
+ priv->offline_sources = g_slist_remove (priv->offline_sources, source);
+ if (!priv->offline_sources && priv->offline_timeout_id) {
+ g_source_remove (priv->offline_timeout_id);
+ priv->offline_timeout_id = 0;
+ }
+
+ g_object_unref (source);
+ }
}
diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h
index f95a4d6b33..b48cd5a602 100644
--- a/calendar/gui/alarm-notify/alarm-notify.h
+++ b/calendar/gui/alarm-notify/alarm-notify.h
@@ -69,8 +69,7 @@ AlarmNotify * alarm_notify_new (GCancellable *cancellable,
GError **error);
void alarm_notify_add_calendar (AlarmNotify *an,
ECalClientSourceType source_type,
- ESource *source,
- gboolean load_afterwards);
+ ESource *source);
void alarm_notify_remove_calendar (AlarmNotify *an,
ECalClientSourceType source_type,
const gchar *str_uri);
diff --git a/calendar/gui/e-meeting-time-sel-item.c b/calendar/gui/e-meeting-time-sel-item.c
index 35f3a7d743..ced8414ef9 100644
--- a/calendar/gui/e-meeting-time-sel-item.c
+++ b/calendar/gui/e-meeting-time-sel-item.c
@@ -29,6 +29,9 @@
#include <time.h>
#include <glib/gi18n.h>
+
+#include "e-util/e-datetime-format.h"
+
#include "calendar-config.h"
#include "e-meeting-time-sel-item.h"
#include "e-meeting-time-sel.h"
@@ -389,9 +392,10 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
{
EMeetingTimeSelector *mts;
gint y, grid_x;
- gchar buffer[128], *format;
+ gchar *str;
gint hour, hour_x, hour_y;
PangoLayout *layout;
+ struct tm tm_time;
cairo_save (cr);
@@ -437,29 +441,31 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
cairo_rel_line_to (cr, 0, height);
cairo_stroke (cr);
+ g_date_to_struct_tm (date, &tm_time);
+ str = e_datetime_format_format_tm ("calendar", "table", DTFormatKindDate, &tm_time);
+
+ g_return_if_fail (str != NULL);
+
/* Draw the date. Set a clipping rectangle so we don't draw over the
* next day. */
- if (mts->date_format == E_MEETING_TIME_SELECTOR_DATE_FULL)
- /* This is a strftime() format string %A = full weekday name,
- * %B = full month name, %d = month day, %Y = full year. */
- format = _("%A, %B %d, %Y");
- else if (mts->date_format == E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY)
- /* This is a strftime() format string %a = abbreviated weekday
- * name, %m = month number, %d = month day, %Y = full year. */
- format = _("%a %m/%d/%Y");
- else
- /* This is a strftime() format string %m = month number,
- * %d = month day, %Y = full year. */
- format = _("%m/%d/%Y");
+ if (mts->date_format == E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY
+ && !e_datetime_format_includes_day_name ("calendar", "table", DTFormatKindDate)) {
+ gchar buffer[128];
+ gchar *tmp;
+
+ g_date_strftime (buffer, sizeof (buffer), "%a", date);
- g_date_strftime (buffer, sizeof (buffer), format, date);
+ tmp = str;
+ str = g_strconcat (buffer, " ", str, NULL);
+ g_free (tmp);
+ }
cairo_save (cr);
cairo_rectangle (cr, x, -scroll_y, mts->day_width - 2, mts->row_height - 2);
cairo_clip (cr);
- pango_layout_set_text (layout, buffer, -1);
+ pango_layout_set_text (layout, str, -1);
cairo_move_to (cr, x + 2, 4 - scroll_y);
pango_cairo_show_layout (cr, layout);
@@ -484,6 +490,7 @@ e_meeting_time_selector_item_paint_day_top (EMeetingTimeSelectorItem *mts_item,
g_object_unref (layout);
cairo_restore (cr);
+ g_free (str);
}
/* This paints the colored bars representing busy periods for the combined
diff --git a/calendar/gui/e-meeting-time-sel.c b/calendar/gui/e-meeting-time-sel.c
index 36e7ad7d42..9957be998d 100644
--- a/calendar/gui/e-meeting-time-sel.c
+++ b/calendar/gui/e-meeting-time-sel.c
@@ -41,6 +41,7 @@
#include "misc/e-dateedit.h"
#include "e-util/e-util.h"
+#include "e-util/e-datetime-format.h"
#include "e-meeting-utils.h"
#include "e-meeting-list-view.h"
@@ -2327,10 +2328,11 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
GDate date;
gint max_date_width, longest_weekday_width, longest_month_width, width;
gint day, longest_weekday, month, longest_month;
- gchar buffer[128];
+ gchar buffer[128], *str;
const gchar *name;
PangoContext *pango_context;
PangoLayout *layout;
+ struct tm tm_time;
/* Set up Pango prerequisites */
pango_context = gtk_widget_get_pango_context (GTK_WIDGET (mts));
@@ -2368,28 +2370,6 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
}
}
- /* See if we can use the full date. We want to use a date with a
- * month day > 20 and also the longest weekday. We use a
- * pre-calculated array of days for each month and add on the
- * weekday (which is 1 (Mon) to 7 (Sun). */
- g_date_set_dmy (&date, days[longest_month - 1] + longest_weekday,
- longest_month, 2000);
- /* This is a strftime() format string %A = full weekday name,
- * %B = full month name, %d = month day, %Y = full year. */
- g_date_strftime (buffer, sizeof (buffer), _("%A, %B %d, %Y"), &date);
-
-#if 0
- g_print ("longest_month: %i longest_weekday: %i date: %s\n",
- longest_month, longest_weekday, buffer);
-#endif
-
- pango_layout_set_text (layout, buffer, -1);
- pango_layout_get_pixel_size (layout, &width, NULL);
- if (width < max_date_width) {
- mts->date_format = E_MEETING_TIME_SELECTOR_DATE_FULL;
- return;
- }
-
/* Now try it with abbreviated weekday names. */
longest_weekday_width = 0;
longest_weekday = G_DATE_MONDAY;
@@ -2405,16 +2385,28 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
g_date_set_dmy (&date, days[longest_month - 1] + longest_weekday,
longest_month, 2000);
- /* This is a strftime() format string %a = abbreviated weekday name,
- * %m = month number, %d = month day, %Y = full year. */
- g_date_strftime (buffer, sizeof (buffer), _("%a %m/%d/%Y"), &date);
+
+ g_date_to_struct_tm (&date, &tm_time);
+ str = e_datetime_format_format_tm ("calendar", "table", DTFormatKindDate, &tm_time);
+
+ g_return_if_fail (str != NULL);
+
+ if (!e_datetime_format_includes_day_name ("calendar", "table", DTFormatKindDate)) {
+ gchar *tmp;
+
+ g_date_strftime (buffer, sizeof (buffer), "%a", &date);
+
+ tmp = str;
+ str = g_strconcat (buffer, " ", str, NULL);
+ g_free (tmp);
+ }
#if 0
g_print ("longest_month: %i longest_weekday: %i date: %s\n",
- longest_month, longest_weekday, buffer);
+ longest_month, longest_weekday, str);
#endif
- pango_layout_set_text (layout, buffer, -1);
+ pango_layout_set_text (layout, str, -1);
pango_layout_get_pixel_size (layout, &width, NULL);
if (width < max_date_width)
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY;
@@ -2422,6 +2414,7 @@ e_meeting_time_selector_recalc_date_format (EMeetingTimeSelector *mts)
mts->date_format = E_MEETING_TIME_SELECTOR_DATE_SHORT;
g_object_unref (layout);
+ g_free (str);
}
/* Turn off the background of the canvas windows. This reduces flicker
diff --git a/calendar/gui/e-meeting-time-sel.h b/calendar/gui/e-meeting-time-sel.h
index 7f45242006..7c3f7c3021 100644
--- a/calendar/gui/e-meeting-time-sel.h
+++ b/calendar/gui/e-meeting-time-sel.h
@@ -68,13 +68,13 @@
G_BEGIN_DECLS
/* This is used to specify the format used when displaying the dates.
- * The full format is like 'Sunday, September 12, 1999'. The abbreviated format
- * is like 'Sun 12/9/99'. The short format is like '12/9/99'. The actual
- * format used is determined in e_meeting_time_selector_style_set (), once we
- * know the font being used. */
+ * The abbreviated format is like 'Sun 12/9/99'.
+ * The short format is like '12/9/99'.
+ * The actual format used is determined in e_meeting_time_selector_style_set (),
+ * once we know the font being used.
+ */
typedef enum
{
- E_MEETING_TIME_SELECTOR_DATE_FULL,
E_MEETING_TIME_SELECTOR_DATE_ABBREVIATED_DAY,
E_MEETING_TIME_SELECTOR_DATE_SHORT
} EMeetingTimeSelectorDateFormat;