aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2010-04-01 22:18:40 +0800
committerMilan Crha <mcrha@redhat.com>2010-04-01 22:18:40 +0800
commitb276c75c7c0f537cf4f5d122b1bff41420ca3232 (patch)
tree829da2bb5e4c2795c884d0e53ffd0da1b344dfb1
parentba1c4eade6a41d285fae59969f2db4b253139041 (diff)
downloadgsoc2013-evolution-b276c75c7c0f537cf4f5d122b1bff41420ca3232.tar.gz
gsoc2013-evolution-b276c75c7c0f537cf4f5d122b1bff41420ca3232.tar.zst
gsoc2013-evolution-b276c75c7c0f537cf4f5d122b1bff41420ca3232.zip
Bug #613352 - Changed time range not propagated to calendar
-rw-r--r--calendar/gui/e-cal-list-view.c9
-rw-r--r--calendar/gui/gnome-cal.c186
-rw-r--r--calendar/gui/gnome-cal.h4
-rw-r--r--modules/calendar/e-cal-shell-view-private.c6
-rw-r--r--shell/e-shell-view.c59
-rw-r--r--shell/e-shell-view.h4
6 files changed, 238 insertions, 30 deletions
diff --git a/calendar/gui/e-cal-list-view.c b/calendar/gui/e-cal-list-view.c
index 1d3e0e114a..0a3c3de0be 100644
--- a/calendar/gui/e-cal-list-view.c
+++ b/calendar/gui/e-cal-list-view.c
@@ -528,6 +528,15 @@ e_cal_list_view_get_visible_time_range (ECalendarView *cal_view, time_t *start_t
return TRUE;
}
+ if (!n_rows) {
+ ECalModel *model = e_calendar_view_get_model (cal_view);
+
+ /* Use time range set in the model when nothing shown in the list view */
+ e_cal_model_get_time_range (model, start_time, end_time);
+
+ return TRUE;
+ }
+
return FALSE;
}
diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c
index 8ad4ca460e..670512bb43 100644
--- a/calendar/gui/gnome-cal.c
+++ b/calendar/gui/gnome-cal.c
@@ -66,6 +66,8 @@
#include "misc.h"
#include "ea-calendar.h"
#include "common/authentication.h"
+#include "e-memo-table.h"
+#include "e-task-table.h"
#define d(x)
@@ -90,6 +92,8 @@ struct _GnomeCalendarPrivate {
GtkWidget *hpane;
ECalendar *date_navigator;
+ GtkWidget *memo_table; /* EMemoTable, but can be NULL */
+ GtkWidget *task_table; /* ETaskTable, but can be NULL */
/* Calendar query for the date navigator */
GMutex *dn_query_lock;
@@ -137,7 +141,9 @@ enum {
PROP_0,
PROP_DATE_NAVIGATOR,
PROP_SHELL_SETTINGS,
- PROP_VIEW
+ PROP_VIEW,
+ PROP_MEMO_TABLE,
+ PROP_TASK_TABLE
};
enum {
@@ -170,6 +176,7 @@ typedef void (*MessageFunc) (Message *msg);
struct _Message {
MessageFunc func;
+ GSourceFunc done;
};
static void
@@ -178,6 +185,8 @@ message_proxy (Message *msg)
g_return_if_fail (msg->func != NULL);
msg->func (msg);
+ if (msg->done)
+ g_idle_add (msg->done, msg);
}
static gpointer
@@ -353,6 +362,18 @@ gnome_calendar_set_property (GObject *object,
GNOME_CALENDAR (object),
g_value_get_int (value));
return;
+
+ case PROP_MEMO_TABLE:
+ gnome_calendar_set_memo_table (
+ GNOME_CALENDAR (object),
+ g_value_get_object (value));
+ return;
+
+ case PROP_TASK_TABLE:
+ gnome_calendar_set_task_table (
+ GNOME_CALENDAR (object),
+ g_value_get_object (value));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -382,6 +403,18 @@ gnome_calendar_get_property (GObject *object,
value, gnome_calendar_get_view (
GNOME_CALENDAR (object)));
return;
+
+ case PROP_MEMO_TABLE:
+ g_value_set_object (
+ value, gnome_calendar_get_memo_table (
+ GNOME_CALENDAR (object)));
+ return;
+
+ case PROP_TASK_TABLE:
+ g_value_set_object (
+ value, gnome_calendar_get_task_table (
+ GNOME_CALENDAR (object)));
+ return;
}
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -533,6 +566,26 @@ gnome_calendar_class_init (GnomeCalendarClass *class)
GNOME_CAL_DAY_VIEW,
G_PARAM_READWRITE));
+ g_object_class_install_property (
+ object_class,
+ PROP_MEMO_TABLE,
+ g_param_spec_object (
+ "memo-table",
+ "Memo table",
+ NULL,
+ E_TYPE_MEMO_TABLE,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (
+ object_class,
+ PROP_TASK_TABLE,
+ g_param_spec_object (
+ "task-table",
+ "Task table",
+ NULL,
+ E_TYPE_TASK_TABLE,
+ G_PARAM_READWRITE));
+
signals[DATES_SHOWN_CHANGED] =
g_signal_new ("dates_shown_changed",
G_TYPE_FROM_CLASS (object_class),
@@ -1020,7 +1073,7 @@ update_query_async (struct _date_query_msg *msg)
{
GnomeCalendar *gcal = msg->gcal;
GnomeCalendarPrivate *priv;
- ECalView *old_query;
+ ECalView *new_query;
gchar *real_sexp;
GList *list, *iter;
@@ -1052,8 +1105,8 @@ update_query_async (struct _date_query_msg *msg)
continue;
try_again:
- old_query = NULL;
- if (!e_cal_get_query (client, real_sexp, &old_query, &error)) {
+ new_query = NULL;
+ if (!e_cal_get_query (client, real_sexp, &new_query, &error)) {
/* If calendar is busy try again for 3 times. */
if (error->code == E_CALENDAR_STATUS_BUSY && tries != 10) {
tries++;
@@ -1070,18 +1123,19 @@ try_again:
continue;
}
- g_signal_connect (old_query, "objects_added",
+ g_signal_connect (new_query, "objects_added",
G_CALLBACK (dn_e_cal_view_objects_added_cb), gcal);
- g_signal_connect (old_query, "objects_modified",
+ g_signal_connect (new_query, "objects_modified",
G_CALLBACK (dn_e_cal_view_objects_modified_cb), gcal);
- g_signal_connect (old_query, "objects_removed",
+ g_signal_connect (new_query, "objects_removed",
G_CALLBACK (dn_e_cal_view_objects_removed_cb), gcal);
- g_signal_connect (old_query, "view_done",
+ g_signal_connect (new_query, "view_done",
G_CALLBACK (dn_e_cal_view_done_cb), gcal);
- priv->dn_queries = g_list_append (priv->dn_queries, old_query);
-
- e_cal_view_start (old_query);
+ g_mutex_lock (priv->dn_query_lock);
+ priv->dn_queries = g_list_append (priv->dn_queries, new_query);
+ e_cal_view_start (new_query);
+ g_mutex_unlock (priv->dn_query_lock);
}
g_list_foreach (list, (GFunc) g_object_unref, NULL);
@@ -1107,6 +1161,7 @@ gnome_calendar_update_query (GnomeCalendar *gcal)
msg = g_slice_new0 (struct _date_query_msg);
msg->header.func = (MessageFunc) update_query_async;
+ msg->header.done = NULL;
msg->gcal = g_object_ref (gcal);
message_push ((Message *) msg);
@@ -1158,9 +1213,6 @@ gnome_calendar_set_search_query (GnomeCalendar *gcal,
gnome_calendar_update_date_navigator (gcal);
} else
e_cal_model_set_search_query (model, sexp);
-
- /* Set the query on the task pad */
- update_todo_view (gcal);
}
static void
@@ -1190,7 +1242,6 @@ struct _mupdate_todo_msg {
GnomeCalendar *gcal;
};
-#if 0 /* KILL-BONOBO */
static void
update_todo_view_async (struct _mupdate_todo_msg *msg)
{
@@ -1204,6 +1255,8 @@ update_todo_view_async (struct _mupdate_todo_msg *msg)
gcal = msg->gcal;
priv = gcal->priv;
+ g_return_if_fail (priv->task_table != NULL);
+
g_mutex_lock (priv->todo_update_lock);
/* Set the query on the task pad */
@@ -1212,7 +1265,7 @@ update_todo_view_async (struct _mupdate_todo_msg *msg)
priv->todo_sexp = NULL;
}
- model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo));
+ model = e_task_table_get_model (E_TASK_TABLE (priv->task_table));
if ((sexp = calendar_config_get_hide_completed_tasks_sexp (FALSE)) != NULL) {
priv->todo_sexp = g_strdup_printf ("(and %s %s)", sexp,
@@ -1224,40 +1277,68 @@ update_todo_view_async (struct _mupdate_todo_msg *msg)
e_cal_model_set_search_query (model, priv->todo_sexp);
}
+ update_memo_view (msg->gcal);
+
g_mutex_unlock (priv->todo_update_lock);
+}
+
+static gboolean
+update_todo_view_done (struct _mupdate_todo_msg *msg)
+{
+ GnomeCalendar *gcal;
+ GnomeCalendarPrivate *priv;
+
+ g_return_val_if_fail (msg != NULL, FALSE);
+
+ gcal = msg->gcal;
+ priv = gcal->priv;
+
+ g_return_val_if_fail (priv->task_table != NULL, FALSE);
+ g_return_val_if_fail (priv->memo_table != NULL, FALSE);
+
+ e_shell_view_unblock_update_actions (e_task_table_get_shell_view (E_TASK_TABLE (priv->task_table)));
+ e_shell_view_unblock_update_actions (e_memo_table_get_shell_view (E_MEMO_TABLE (priv->memo_table)));
g_object_unref (msg->gcal);
g_slice_free (struct _mupdate_todo_msg, msg);
+
+ return FALSE;
}
-#endif
static void
update_todo_view (GnomeCalendar *gcal)
{
-#if 0 /* KILL-BONOBO */
struct _mupdate_todo_msg *msg;
+ /* they are both or none anyway */
+ if (!gcal->priv->task_table || !gcal->priv->memo_table)
+ return;
+
msg = g_slice_new0 (struct _mupdate_todo_msg);
msg->header.func = (MessageFunc) update_todo_view_async;
+ msg->header.done = (GSourceFunc) update_todo_view_done;
msg->gcal = g_object_ref (gcal);
+ e_shell_view_block_update_actions (e_task_table_get_shell_view (E_TASK_TABLE (gcal->priv->task_table)));
+ e_shell_view_block_update_actions (e_memo_table_get_shell_view (E_MEMO_TABLE (gcal->priv->memo_table)));
+
message_push ((Message *) msg);
-#endif
}
static void
update_memo_view (GnomeCalendar *gcal)
{
-#if 0 /* KILL-BONOBO */
GnomeCalendarPrivate *priv;
ECalModel *model, *view_model;
- time_t start, end;
+ time_t start = -1, end = -1;
gchar *iso_start, *iso_end;
priv = gcal->priv;
+ if (!priv->memo_table)
+ return;
/* Set the query on the memo pad*/
- model = e_memo_table_get_model (E_MEMO_TABLE (priv->memo));
+ model = e_memo_table_get_model (E_MEMO_TABLE (priv->memo_table));
view_model = gnome_calendar_get_model (gcal);
e_cal_model_get_time_range (view_model, &start, &end);
@@ -1269,9 +1350,9 @@ update_memo_view (GnomeCalendar *gcal)
g_free (priv->memo_sexp);
}
- priv->memo_sexp = g_strdup_printf ("(or (not (has-start?)) (and (occur-in-time-range? (make-time \"%s\")"
+ priv->memo_sexp = g_strdup_printf ("(and (or (not (has-start?)) (occur-in-time-range? (make-time \"%s\")"
" (make-time \"%s\"))"
- " %s))",
+ " ) %s)",
iso_start, iso_end,
priv->sexp ? priv->sexp : "");
@@ -1280,7 +1361,6 @@ update_memo_view (GnomeCalendar *gcal)
g_free (iso_start);
g_free (iso_end);
}
-#endif
}
static void
@@ -1361,7 +1441,7 @@ setup_widgets (GnomeCalendar *gcal)
/* The Marcus Bains line */
priv->update_marcus_bains_line_timeout = g_timeout_add_full (G_PRIORITY_LOW, 60000, (GSourceFunc) update_marcus_bains_line_cb, gcal, NULL);
- update_memo_view (gcal);
+ /* update_memo_view (gcal); */
}
/* Object initialization function for the gnome calendar */
@@ -1873,6 +1953,58 @@ gnome_calendar_set_date_navigator (GnomeCalendar *gcal,
g_object_notify (G_OBJECT (gcal), "date-navigator");
}
+GtkWidget *
+gnome_calendar_get_memo_table (GnomeCalendar *gcal)
+{
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
+
+ return gcal->priv->memo_table;
+}
+
+void
+gnome_calendar_set_memo_table (GnomeCalendar *gcal, GtkWidget *memo_table)
+{
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
+ if (memo_table != NULL) {
+ g_return_if_fail (E_IS_MEMO_TABLE (memo_table));
+ g_object_ref (memo_table);
+ }
+
+ if (gcal->priv->memo_table != NULL)
+ g_object_unref (gcal->priv->memo_table);
+
+ gcal->priv->memo_table = memo_table;
+
+ g_object_notify (G_OBJECT (gcal), "memo-table");
+}
+
+GtkWidget *
+gnome_calendar_get_task_table (GnomeCalendar *gcal)
+{
+ g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), NULL);
+
+ return gcal->priv->task_table;
+}
+
+void
+gnome_calendar_set_task_table (GnomeCalendar *gcal, GtkWidget *task_table)
+{
+ g_return_if_fail (GNOME_IS_CALENDAR (gcal));
+
+ if (task_table != NULL) {
+ g_return_if_fail (E_IS_TASK_TABLE (task_table));
+ g_object_ref (task_table);
+ }
+
+ if (gcal->priv->task_table != NULL)
+ g_object_unref (gcal->priv->task_table);
+
+ gcal->priv->task_table = task_table;
+
+ g_object_notify (G_OBJECT (gcal), "task-table");
+}
+
/**
* gnome_calendar_get_model:
* @gcal: A calendar view.
@@ -2107,7 +2239,7 @@ gnome_calendar_notify_dates_shown_changed (GnomeCalendar *gcal)
gtk_widget_queue_draw (GTK_WIDGET (calendar_view));
g_signal_emit (gcal, signals[DATES_SHOWN_CHANGED], 0);
}
- update_memo_view (gcal);
+ update_todo_view (gcal);
}
/* Returns the number of selected events (0 or 1 at present). */
diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h
index b24648e2bc..4fa36b1446 100644
--- a/calendar/gui/gnome-cal.h
+++ b/calendar/gui/gnome-cal.h
@@ -122,6 +122,10 @@ ECalendar * gnome_calendar_get_date_navigator
void gnome_calendar_set_date_navigator
(GnomeCalendar *gcal,
ECalendar *date_navigator);
+GtkWidget * gnome_calendar_get_memo_table (GnomeCalendar *gcal);
+void gnome_calendar_set_memo_table (GnomeCalendar *gcal, GtkWidget *memo_table);
+GtkWidget * gnome_calendar_get_task_table (GnomeCalendar *gcal);
+void gnome_calendar_set_task_table (GnomeCalendar *gcal, GtkWidget *task_table);
ECalModel * gnome_calendar_get_model (GnomeCalendar *gcal);
void gnome_calendar_update_query (GnomeCalendar *gcal);
void gnome_calendar_set_search_query (GnomeCalendar *gcal,
diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c
index 8806ad691b..dc30897aab 100644
--- a/modules/calendar/e-cal-shell-view-private.c
+++ b/modules/calendar/e-cal-shell-view-private.c
@@ -219,7 +219,7 @@ cal_shell_view_date_navigator_scroll_event_cb (ECalShellView *cal_shell_view,
* we could move this handler into ECalShellSidebar. */
e_calendar_item_set_selection (calitem, &start_date, &end_date);
- cal_shell_view_date_navigator_date_range_changed_cb (
+ cal_shell_view_date_navigator_selection_changed_cb (
cal_shell_view, calitem);
}
@@ -459,8 +459,10 @@ e_cal_shell_view_private_constructed (ECalShellView *cal_shell_view)
selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
date_navigator = e_cal_shell_sidebar_get_date_navigator (cal_shell_sidebar);
- /* Give GnomeCalendar a handle to the date navigator. */
+ /* Give GnomeCalendar a handle to the date navigator, memo and task table. */
gnome_calendar_set_date_navigator (calendar, date_navigator);
+ gnome_calendar_set_memo_table (calendar, memo_table ? GTK_WIDGET (memo_table) : NULL);
+ gnome_calendar_set_task_table (calendar, task_table ? GTK_WIDGET (task_table) : NULL);
e_calendar_item_set_get_time_callback (
date_navigator->calitem, (ECalendarItemGetTimeCallback)
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index 537024a548..3a5c6e219d 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -60,6 +60,9 @@ struct _EShellViewPrivate {
EFilterRule *search_rule;
guint execute_search_blocked;
+
+ guint update_actions_blocked;
+ gboolean update_actions_called;
};
enum {
@@ -629,6 +632,9 @@ shell_view_update_actions (EShellView *shell_view)
EShellWindow *shell_window;
EFocusTracker *focus_tracker;
+ g_return_if_fail (!shell_view->priv->update_actions_blocked);
+ g_return_if_fail (e_shell_view_is_active (shell_view));
+
shell_window = e_shell_view_get_shell_window (shell_view);
focus_tracker = e_shell_window_get_focus_tracker (shell_window);
@@ -1514,13 +1520,64 @@ e_shell_view_unblock_execute_search (EShellView *shell_view)
* #EShellView::update-actions signal is typically emitted just before
* showing a popup menu or just after the user selects an item in the
* shell view.
+ *
+ * Emission can be blocked by e_shell_view_block_update_actions().
**/
void
e_shell_view_update_actions (EShellView *shell_view)
{
g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
- g_signal_emit (shell_view, signals[UPDATE_ACTIONS], 0);
+ if (!e_shell_view_is_active (shell_view))
+ return;
+
+ if (shell_view->priv->update_actions_blocked > 0) {
+ shell_view->priv->update_actions_called = TRUE;
+ } else {
+ shell_view->priv->update_actions_called = FALSE;
+ g_signal_emit (shell_view, signals[UPDATE_ACTIONS], 0);
+ }
+}
+
+/**
+ * e_shell_view_block_update_actions:
+ * @shell_view: an #EShellView
+ *
+ * Block emission of #EShellView::update-actions signal through
+ * e_shell_view_update_actions(). The emission si blocked until
+ * e_shell_view_unblock_update_actions() is called same times as
+ * this function.
+ **/
+void
+e_shell_view_block_update_actions (EShellView *shell_view)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ g_return_if_fail (shell_view->priv->update_actions_blocked + 1 != 0);
+
+ shell_view->priv->update_actions_blocked++;
+ if (shell_view->priv->update_actions_blocked == 1)
+ shell_view->priv->update_actions_called = FALSE;
+}
+
+/**
+ * e_shell_view_unblock_update_actions:
+ * @shell_view: an #EShellView
+ *
+ * Unblock emission of #EShellView::update-actions signal through
+ * e_shell_view_update_actions(), previously blocked by function
+ * e_shell_view_block_update_actions().
+ **/
+void
+e_shell_view_unblock_update_actions (EShellView *shell_view)
+{
+ g_return_if_fail (E_IS_SHELL_VIEW (shell_view));
+ g_return_if_fail (shell_view->priv->update_actions_blocked > 0);
+
+ shell_view->priv->update_actions_blocked--;
+ if (!shell_view->priv->update_actions_blocked && shell_view->priv->update_actions_called) {
+ shell_view->priv->update_actions_called = FALSE;
+ e_shell_view_update_actions (shell_view);
+ }
}
/**
diff --git a/shell/e-shell-view.h b/shell/e-shell-view.h
index d014d694ce..1e189217e1 100644
--- a/shell/e-shell-view.h
+++ b/shell/e-shell-view.h
@@ -215,6 +215,10 @@ void e_shell_view_block_execute_search
void e_shell_view_unblock_execute_search
(EShellView *shell_view);
void e_shell_view_update_actions (EShellView *shell_view);
+void e_shell_view_block_update_actions
+ (EShellView *shell_view);
+void e_shell_view_unblock_update_actions
+ (EShellView *shell_view);
GtkWidget * e_shell_view_show_popup_menu (EShellView *shell_view,
const gchar *widget_path,
GdkEventButton *event);