From 0b1658ed7a215dad8295b02a30d5220011e199f1 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Mon, 30 Nov 2009 12:31:31 +0530 Subject: Bug 494394 - No way for the user to refresh a calendar --- modules/calendar/e-cal-shell-sidebar.c | 7 +++++ modules/calendar/e-cal-shell-sidebar.h | 3 ++- modules/calendar/e-cal-shell-view-actions.c | 40 ++++++++++++++++++++++++++++ modules/calendar/e-cal-shell-view-actions.h | 2 ++ modules/calendar/e-cal-shell-view.c | 7 +++++ modules/calendar/e-memo-shell-sidebar.c | 7 +++++ modules/calendar/e-memo-shell-sidebar.h | 3 ++- modules/calendar/e-memo-shell-view-actions.c | 40 ++++++++++++++++++++++++++++ modules/calendar/e-memo-shell-view-actions.h | 2 ++ modules/calendar/e-memo-shell-view.c | 7 +++++ modules/calendar/e-task-shell-sidebar.c | 7 +++++ modules/calendar/e-task-shell-sidebar.h | 3 ++- modules/calendar/e-task-shell-view-actions.c | 40 ++++++++++++++++++++++++++++ modules/calendar/e-task-shell-view-actions.h | 2 ++ modules/calendar/e-task-shell-view.c | 7 +++++ 15 files changed, 174 insertions(+), 3 deletions(-) (limited to 'modules') diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c index 244136ea0f..573299084a 100644 --- a/modules/calendar/e-cal-shell-sidebar.c +++ b/modules/calendar/e-cal-shell-sidebar.c @@ -510,6 +510,7 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar) ESource *source; gboolean can_delete = FALSE; gboolean is_system = FALSE; + gboolean refresh_supported = FALSE; guint32 state = 0; cal_shell_sidebar = E_CAL_SHELL_SIDEBAR (shell_sidebar); @@ -517,6 +518,7 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar) source = e_source_selector_peek_primary_selection (selector); if (source != NULL) { + ECal *client; const gchar *uri; const gchar *delete; @@ -526,6 +528,9 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar) can_delete = !is_system; delete = e_source_get_property (source, "delete"); can_delete &= (delete == NULL || strcmp (delete, "no") != 0); + + client = g_hash_table_lookup (cal_shell_sidebar->priv->client_table, e_source_peek_uid (source)); + refresh_supported = client && e_cal_get_refresh_supported (client); } if (source != NULL) @@ -534,6 +539,8 @@ cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar) state |= E_CAL_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE; if (is_system) state |= E_CAL_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM; + if (refresh_supported) + state |= E_CAL_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH; return state; } diff --git a/modules/calendar/e-cal-shell-sidebar.h b/modules/calendar/e-cal-shell-sidebar.h index 47dc9fa191..6169d303d6 100644 --- a/modules/calendar/e-cal-shell-sidebar.h +++ b/modules/calendar/e-cal-shell-sidebar.h @@ -57,7 +57,8 @@ typedef struct _ECalShellSidebarPrivate ECalShellSidebarPrivate; enum { E_CAL_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0, E_CAL_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE = 1 << 1, - E_CAL_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2 + E_CAL_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2, + E_CAL_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH = 1 << 3 }; struct _ECalShellSidebar { diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c index 68da6b2643..a8c8fc1ea4 100644 --- a/modules/calendar/e-cal-shell-view-actions.c +++ b/modules/calendar/e-cal-shell-view-actions.c @@ -349,6 +349,35 @@ exit: gtk_widget_destroy (dialog); } +static void +action_calendar_refresh_cb (GtkAction *action, + ECalShellView *cal_shell_view) +{ + ECal *client; + ECalModel *model; + ESource *source; + gchar *uri; + GError *error = NULL; + + model = e_cal_shell_content_get_model (cal_shell_view->priv->cal_shell_content); + source = e_source_selector_peek_primary_selection (e_cal_shell_sidebar_get_selector (cal_shell_view->priv->cal_shell_sidebar)); + g_return_if_fail (E_IS_SOURCE (source)); + + uri = e_source_get_uri (source); + client = e_cal_model_get_client_for_uri (model, uri); + g_free (uri); + + if (client == NULL) + return; + + g_return_if_fail (e_cal_get_refresh_supported (client)); + + if (!e_cal_refresh (client, &error) && error) { + g_warning ("%s: Failed to refresh '%s', %s\n", G_STRFUNC, e_source_peek_name (source), error->message); + g_error_free (error); + } +} + static void action_calendar_rename_cb (GtkAction *action, ECalShellView *cal_shell_view) @@ -1264,6 +1293,13 @@ static GtkActionEntry calendar_entries[] = { N_("Purge old appointments and meetings"), G_CALLBACK (action_calendar_purge_cb) }, + { "calendar-refresh", + GTK_STOCK_REFRESH, + N_("Re_fresh"), + NULL, + N_("Refresh the selected calendar"), + G_CALLBACK (action_calendar_refresh_cb) }, + { "calendar-rename", NULL, N_("_Rename..."), @@ -1454,6 +1490,10 @@ static EPopupActionEntry calendar_popup_entries[] = { NULL, "calendar-properties" }, + { "calendar-popup-refresh", + NULL, + "calendar-refresh" }, + { "calendar-popup-rename", NULL, "calendar-rename" }, diff --git a/modules/calendar/e-cal-shell-view-actions.h b/modules/calendar/e-cal-shell-view-actions.h index 94ad66cbc1..a6b1c3d01c 100644 --- a/modules/calendar/e-cal-shell-view-actions.h +++ b/modules/calendar/e-cal-shell-view-actions.h @@ -47,6 +47,8 @@ E_SHELL_WINDOW_ACTION ((window), "calendar-properties") #define E_SHELL_WINDOW_ACTION_CALENDAR_PURGE(window) \ E_SHELL_WINDOW_ACTION ((window), "calendar-purge") +#define E_SHELL_WINDOW_ACTION_CALENDAR_REFRESH(window) \ + E_SHELL_WINDOW_ACTION ((window), "calendar-refresh") #define E_SHELL_WINDOW_ACTION_CALENDAR_RENAME(window) \ E_SHELL_WINDOW_ACTION ((window), "calendar-rename") #define E_SHELL_WINDOW_ACTION_CALENDAR_SELECT_ONE(window) \ diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c index 396cdec62e..47d734921c 100644 --- a/modules/calendar/e-cal-shell-view.c +++ b/modules/calendar/e-cal-shell-view.c @@ -291,6 +291,7 @@ cal_shell_view_update_actions (EShellView *shell_view) gboolean is_meeting = FALSE; gboolean is_delegatable = FALSE; gboolean clipboard_has_calendar; + gboolean refresh_supported = FALSE; priv = E_CAL_SHELL_VIEW_GET_PRIVATE (shell_view); @@ -367,6 +368,8 @@ cal_shell_view_update_actions (EShellView *shell_view) (state & E_CAL_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE); primary_source_is_system = (state & E_CAL_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM); + refresh_supported = + (state & E_CAL_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH); action = ACTION (CALENDAR_COPY); sensitive = has_primary_source; @@ -380,6 +383,10 @@ cal_shell_view_update_actions (EShellView *shell_view) sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); + action = ACTION (CALENDAR_REFRESH); + sensitive = refresh_supported; + gtk_action_set_sensitive (action, sensitive); + action = ACTION (CALENDAR_RENAME); sensitive = can_delete_primary_source; gtk_action_set_sensitive (action, sensitive); diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c index 6da89988c8..dee57e0d26 100644 --- a/modules/calendar/e-memo-shell-sidebar.c +++ b/modules/calendar/e-memo-shell-sidebar.c @@ -455,6 +455,7 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar) ESource *source; gboolean can_delete = FALSE; gboolean is_system = FALSE; + gboolean refresh_supported = FALSE; guint32 state = 0; memo_shell_sidebar = E_MEMO_SHELL_SIDEBAR (shell_sidebar); @@ -462,6 +463,7 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar) source = e_source_selector_peek_primary_selection (selector); if (source != NULL) { + ECal *client; const gchar *uri; const gchar *delete; @@ -471,6 +473,9 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar) can_delete = !is_system; delete = e_source_get_property (source, "delete"); can_delete &= (delete == NULL || strcmp (delete, "no") != 0); + + client = g_hash_table_lookup (memo_shell_sidebar->priv->client_table, e_source_peek_uid (source)); + refresh_supported = client && e_cal_get_refresh_supported (client); } if (source != NULL) @@ -479,6 +484,8 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar) state |= E_MEMO_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE; if (is_system) state |= E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM; + if (refresh_supported) + state |= E_MEMO_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH; return state; } diff --git a/modules/calendar/e-memo-shell-sidebar.h b/modules/calendar/e-memo-shell-sidebar.h index 5df8089668..8eabee103d 100644 --- a/modules/calendar/e-memo-shell-sidebar.h +++ b/modules/calendar/e-memo-shell-sidebar.h @@ -56,7 +56,8 @@ typedef struct _EMemoShellSidebarPrivate EMemoShellSidebarPrivate; enum { E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0, E_MEMO_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE = 1 << 1, - E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2 + E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2, + E_MEMO_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH = 1 << 3 }; struct _EMemoShellSidebar { diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c index 734a7c522d..c36b4569c4 100644 --- a/modules/calendar/e-memo-shell-view-actions.c +++ b/modules/calendar/e-memo-shell-view-actions.c @@ -291,6 +291,35 @@ action_memo_list_properties_cb (GtkAction *action, calendar_setup_edit_memo_list (GTK_WINDOW (shell_window), source); } +static void +action_memo_list_refresh_cb (GtkAction *action, + EMemoShellView *memo_shell_view) +{ + ECal *client; + ECalModel *model; + ESource *source; + gchar *uri; + GError *error = NULL; + + model = e_memo_shell_content_get_memo_model (memo_shell_view->priv->memo_shell_content); + source = e_source_selector_peek_primary_selection (e_memo_shell_sidebar_get_selector (memo_shell_view->priv->memo_shell_sidebar)); + g_return_if_fail (E_IS_SOURCE (source)); + + uri = e_source_get_uri (source); + client = e_cal_model_get_client_for_uri (model, uri); + g_free (uri); + + if (client == NULL) + return; + + g_return_if_fail (e_cal_get_refresh_supported (client)); + + if (!e_cal_refresh (client, &error) && error) { + g_warning ("%s: Failed to refresh '%s', %s\n", G_STRFUNC, e_source_peek_name (source), error->message); + g_error_free (error); + } +} + static void action_memo_list_rename_cb (GtkAction *action, EMemoShellView *memo_shell_view) @@ -624,6 +653,13 @@ static GtkActionEntry memo_entries[] = { NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_memo_list_properties_cb) }, + { "memo-list-refresh", + GTK_STOCK_REFRESH, + N_("Re_fresh"), + NULL, + N_("Refresh the selected memo list"), + G_CALLBACK (action_memo_list_refresh_cb) }, + { "memo-list-rename", NULL, N_("_Rename..."), @@ -683,6 +719,10 @@ static EPopupActionEntry memo_popup_entries[] = { NULL, "memo-list-properties" }, + { "memo-list-popup-refresh", + NULL, + "memo-list-refresh" }, + { "memo-list-popup-rename", NULL, "memo-list-rename" }, diff --git a/modules/calendar/e-memo-shell-view-actions.h b/modules/calendar/e-memo-shell-view-actions.h index 9fe4d6964d..cb4309c18a 100644 --- a/modules/calendar/e-memo-shell-view-actions.h +++ b/modules/calendar/e-memo-shell-view-actions.h @@ -65,6 +65,8 @@ E_SHELL_WINDOW_ACTION ((window), "memo-list-print-preview") #define E_SHELL_WINDOW_ACTION_MEMO_LIST_PROPERTIES(window) \ E_SHELL_WINDOW_ACTION ((window), "memo-list-properties") +#define E_SHELL_WINDOW_ACTION_MEMO_LIST_REFRESH(window) \ + E_SHELL_WINDOW_ACTION ((window), "memo-list-refresh") #define E_SHELL_WINDOW_ACTION_MEMO_LIST_RENAME(window) \ E_SHELL_WINDOW_ACTION ((window), "memo-list-rename") #define E_SHELL_WINDOW_ACTION_MEMO_LIST_SELECT_ONE(window) \ diff --git a/modules/calendar/e-memo-shell-view.c b/modules/calendar/e-memo-shell-view.c index 242bdfce92..206e50c961 100644 --- a/modules/calendar/e-memo-shell-view.c +++ b/modules/calendar/e-memo-shell-view.c @@ -176,6 +176,7 @@ memo_shell_view_update_actions (EShellView *shell_view) gboolean selection_has_url; gboolean single_memo_selected; gboolean sources_are_editable; + gboolean refresh_supported; priv = E_MEMO_SHELL_VIEW_GET_PRIVATE (shell_view); @@ -204,6 +205,8 @@ memo_shell_view_update_actions (EShellView *shell_view) (state & E_MEMO_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE); primary_source_is_system = (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM); + refresh_supported = + (state & E_MEMO_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH); any_memos_selected = (single_memo_selected || multiple_memos_selected); @@ -245,6 +248,10 @@ memo_shell_view_update_actions (EShellView *shell_view) sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); + action = ACTION (MEMO_LIST_REFRESH); + sensitive = refresh_supported; + gtk_action_set_sensitive (action, sensitive); + action = ACTION (MEMO_LIST_RENAME); sensitive = can_delete_primary_source; gtk_action_set_sensitive (action, sensitive); diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c index 9107d65464..df3761f444 100644 --- a/modules/calendar/e-task-shell-sidebar.c +++ b/modules/calendar/e-task-shell-sidebar.c @@ -453,6 +453,7 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar) ESource *source; gboolean can_delete = FALSE; gboolean is_system = FALSE; + gboolean refresh_supported = FALSE; guint32 state = 0; task_shell_sidebar = E_TASK_SHELL_SIDEBAR (shell_sidebar); @@ -460,6 +461,7 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar) source = e_source_selector_peek_primary_selection (selector); if (source != NULL) { + ECal *client; const gchar *uri; const gchar *delete; @@ -469,6 +471,9 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar) can_delete = !is_system; delete = e_source_get_property (source, "delete"); can_delete &= (delete == NULL || strcmp (delete, "no") != 0); + + client = g_hash_table_lookup (task_shell_sidebar->priv->client_table, e_source_peek_uid (source)); + refresh_supported = client && e_cal_get_refresh_supported (client); } if (source != NULL) @@ -477,6 +482,8 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar) state |= E_TASK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE; if (is_system) state |= E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM; + if (refresh_supported) + state |= E_TASK_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH; return state; } diff --git a/modules/calendar/e-task-shell-sidebar.h b/modules/calendar/e-task-shell-sidebar.h index 81021b8cda..6a18279753 100644 --- a/modules/calendar/e-task-shell-sidebar.h +++ b/modules/calendar/e-task-shell-sidebar.h @@ -56,7 +56,8 @@ typedef struct _ETaskShellSidebarPrivate ETaskShellSidebarPrivate; enum { E_TASK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0, E_TASK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE = 1 << 1, - E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2 + E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2, + E_TASK_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH = 1 << 3 }; struct _ETaskShellSidebar { diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c index 06177784ce..872cd785fe 100644 --- a/modules/calendar/e-task-shell-view-actions.c +++ b/modules/calendar/e-task-shell-view-actions.c @@ -322,6 +322,35 @@ action_task_list_properties_cb (GtkAction *action, calendar_setup_edit_task_list (GTK_WINDOW (shell_window), source); } +static void +action_task_list_refresh_cb (GtkAction *action, + ETaskShellView *task_shell_view) +{ + ECal *client; + ECalModel *model; + ESource *source; + gchar *uri; + GError *error = NULL; + + model = e_task_shell_content_get_task_model (task_shell_view->priv->task_shell_content); + source = e_source_selector_peek_primary_selection (e_task_shell_sidebar_get_selector (task_shell_view->priv->task_shell_sidebar)); + g_return_if_fail (E_IS_SOURCE (source)); + + uri = e_source_get_uri (source); + client = e_cal_model_get_client_for_uri (model, uri); + g_free (uri); + + if (client == NULL) + return; + + g_return_if_fail (e_cal_get_refresh_supported (client)); + + if (!e_cal_refresh (client, &error) && error) { + g_warning ("%s: Failed to refresh '%s', %s\n", G_STRFUNC, e_source_peek_name (source), error->message); + g_error_free (error); + } +} + static void action_task_list_rename_cb (GtkAction *action, ETaskShellView *task_shell_view) @@ -748,6 +777,13 @@ static GtkActionEntry task_entries[] = { NULL, /* XXX Add a tooltip! */ G_CALLBACK (action_task_list_properties_cb) }, + { "task-list-refresh", + GTK_STOCK_REFRESH, + N_("Re_fresh"), + NULL, + N_("Refresh the selected task list"), + G_CALLBACK (action_task_list_refresh_cb) }, + { "task-list-rename", NULL, N_("_Rename..."), @@ -835,6 +871,10 @@ static EPopupActionEntry task_popup_entries[] = { NULL, "task-list-properties" }, + { "task-list-popup-refresh", + NULL, + "task-list-refresh" }, + { "task-list-popup-rename", NULL, "task-list-rename" }, diff --git a/modules/calendar/e-task-shell-view-actions.h b/modules/calendar/e-task-shell-view-actions.h index 6c2d5d51b6..3d49ff636e 100644 --- a/modules/calendar/e-task-shell-view-actions.h +++ b/modules/calendar/e-task-shell-view-actions.h @@ -73,6 +73,8 @@ E_SHELL_WINDOW_ACTION ((window), "task-list-print-preview") #define E_SHELL_WINDOW_ACTION_TASK_LIST_PROPERTIES(window) \ E_SHELL_WINDOW_ACTION ((window), "task-list-properties") +#define E_SHELL_WINDOW_ACTION_TASK_LIST_REFRESH(window) \ + E_SHELL_WINDOW_ACTION ((window), "task-list-refresh") #define E_SHELL_WINDOW_ACTION_TASK_LIST_RENAME(window) \ E_SHELL_WINDOW_ACTION ((window), "task-list-rename") #define E_SHELL_WINDOW_ACTION_TASK_LIST_SELECT_ONE(window) \ diff --git a/modules/calendar/e-task-shell-view.c b/modules/calendar/e-task-shell-view.c index 8518a6dcb1..9558eb77c0 100644 --- a/modules/calendar/e-task-shell-view.c +++ b/modules/calendar/e-task-shell-view.c @@ -291,6 +291,7 @@ task_shell_view_update_actions (EShellView *shell_view) gboolean some_tasks_incomplete; gboolean sources_are_editable; gboolean clipboard_has_calendar; + gboolean refresh_supported; priv = E_TASK_SHELL_VIEW_GET_PRIVATE (shell_view); @@ -325,6 +326,8 @@ task_shell_view_update_actions (EShellView *shell_view) (state & E_TASK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE); primary_source_is_system = (state & E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM); + refresh_supported = + (state & E_TASK_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH); any_tasks_selected = (single_task_selected || multiple_tasks_selected); @@ -372,6 +375,10 @@ task_shell_view_update_actions (EShellView *shell_view) sensitive = has_primary_source; gtk_action_set_sensitive (action, sensitive); + action = ACTION (TASK_LIST_REFRESH); + sensitive = refresh_supported; + gtk_action_set_sensitive (action, sensitive); + action = ACTION (TASK_LIST_RENAME); sensitive = can_delete_primary_source; gtk_action_set_sensitive (action, sensitive); -- cgit v1.2.3