aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-11-14 23:39:55 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-11-14 23:42:02 +0800
commitbb1653f64c0998f3c90d9cf0e7a2183dccd4611f (patch)
treeb1419804cd5af877df35c2a2293fb23a58ce5cfd /modules
parente1815361e0a7dc69f5d06a4d623e709eff611464 (diff)
downloadgsoc2013-evolution-bb1653f64c0998f3c90d9cf0e7a2183dccd4611f.tar
gsoc2013-evolution-bb1653f64c0998f3c90d9cf0e7a2183dccd4611f.tar.gz
gsoc2013-evolution-bb1653f64c0998f3c90d9cf0e7a2183dccd4611f.tar.bz2
gsoc2013-evolution-bb1653f64c0998f3c90d9cf0e7a2183dccd4611f.tar.lz
gsoc2013-evolution-bb1653f64c0998f3c90d9cf0e7a2183dccd4611f.tar.xz
gsoc2013-evolution-bb1653f64c0998f3c90d9cf0e7a2183dccd4611f.tar.zst
gsoc2013-evolution-bb1653f64c0998f3c90d9cf0e7a2183dccd4611f.zip
BugĀ 600397 - Delete option enabled for undeletable ESource
Diffstat (limited to 'modules')
-rw-r--r--modules/addressbook/e-book-shell-sidebar.c8
-rw-r--r--modules/addressbook/e-book-shell-sidebar.h3
-rw-r--r--modules/addressbook/e-book-shell-view.c5
-rw-r--r--modules/calendar/e-cal-shell-sidebar.c40
-rw-r--r--modules/calendar/e-cal-shell-sidebar.h5
-rw-r--r--modules/calendar/e-cal-shell-view.c42
-rw-r--r--modules/calendar/e-memo-shell-sidebar.c8
-rw-r--r--modules/calendar/e-memo-shell-sidebar.h3
-rw-r--r--modules/calendar/e-memo-shell-view.c7
-rw-r--r--modules/calendar/e-task-shell-sidebar.c8
-rw-r--r--modules/calendar/e-task-shell-sidebar.h3
-rw-r--r--modules/calendar/e-task-shell-view.c5
12 files changed, 108 insertions, 29 deletions
diff --git a/modules/addressbook/e-book-shell-sidebar.c b/modules/addressbook/e-book-shell-sidebar.c
index fc283e28d7..24a0997173 100644
--- a/modules/addressbook/e-book-shell-sidebar.c
+++ b/modules/addressbook/e-book-shell-sidebar.c
@@ -126,6 +126,7 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
EBookShellSidebar *book_shell_sidebar;
ESourceSelector *selector;
ESource *source;
+ gboolean can_delete = FALSE;
gboolean is_system = FALSE;
guint32 state = 0;
@@ -135,13 +136,20 @@ book_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
if (source != NULL) {
const gchar *uri;
+ const gchar *delete;
uri = e_source_peek_relative_uri (source);
is_system = (uri == NULL || strcmp (uri, "system") == 0);
+
+ can_delete = !is_system;
+ delete = e_source_get_property (source, "delete");
+ can_delete &= (delete == NULL || strcmp (delete, "no") != 0);
}
if (source != NULL)
state |= E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE;
+ if (can_delete)
+ state |= E_BOOK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE;
if (is_system)
state |= E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM;
diff --git a/modules/addressbook/e-book-shell-sidebar.h b/modules/addressbook/e-book-shell-sidebar.h
index 716523f971..a3eb76c77f 100644
--- a/modules/addressbook/e-book-shell-sidebar.h
+++ b/modules/addressbook/e-book-shell-sidebar.h
@@ -54,7 +54,8 @@ typedef struct _EBookShellSidebarPrivate EBookShellSidebarPrivate;
enum {
E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0,
- E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 1
+ E_BOOK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE = 1 << 1,
+ E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2
};
struct _EBookShellSidebar {
diff --git a/modules/addressbook/e-book-shell-view.c b/modules/addressbook/e-book-shell-view.c
index d5f160d407..568bc4567a 100644
--- a/modules/addressbook/e-book-shell-view.c
+++ b/modules/addressbook/e-book-shell-view.c
@@ -237,6 +237,7 @@ book_shell_view_update_actions (EShellView *shell_view)
/* Be descriptive. */
gboolean any_contacts_selected;
+ gboolean can_delete_primary_source;
gboolean has_primary_source;
gboolean multiple_contacts_selected;
gboolean primary_source_is_system;
@@ -277,6 +278,8 @@ book_shell_view_update_actions (EShellView *shell_view)
has_primary_source =
(state & E_BOOK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE);
+ can_delete_primary_source =
+ (state & E_BOOK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE);
primary_source_is_system =
(state & E_BOOK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM);
@@ -284,7 +287,7 @@ book_shell_view_update_actions (EShellView *shell_view)
(single_contact_selected || multiple_contacts_selected);
action = ACTION (ADDRESS_BOOK_DELETE);
- sensitive = has_primary_source && !primary_source_is_system;
+ sensitive = can_delete_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (ADDRESS_BOOK_PRINT);
diff --git a/modules/calendar/e-cal-shell-sidebar.c b/modules/calendar/e-cal-shell-sidebar.c
index cb09c93ef1..244136ea0f 100644
--- a/modules/calendar/e-cal-shell-sidebar.c
+++ b/modules/calendar/e-cal-shell-sidebar.c
@@ -502,6 +502,42 @@ cal_shell_sidebar_constructed (GObject *object)
gconf_bridge_bind_property_delayed (bridge, key, object, "vposition");
}
+static guint32
+cal_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
+{
+ ECalShellSidebar *cal_shell_sidebar;
+ ESourceSelector *selector;
+ ESource *source;
+ gboolean can_delete = FALSE;
+ gboolean is_system = FALSE;
+ guint32 state = 0;
+
+ cal_shell_sidebar = E_CAL_SHELL_SIDEBAR (shell_sidebar);
+ selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
+ source = e_source_selector_peek_primary_selection (selector);
+
+ if (source != NULL) {
+ const gchar *uri;
+ const gchar *delete;
+
+ uri = e_source_peek_relative_uri (source);
+ is_system = (uri == NULL || strcmp (uri, "system") == 0);
+
+ can_delete = !is_system;
+ delete = e_source_get_property (source, "delete");
+ can_delete &= (delete == NULL || strcmp (delete, "no") != 0);
+ }
+
+ if (source != NULL)
+ state |= E_CAL_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE;
+ if (can_delete)
+ state |= E_CAL_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE;
+ if (is_system)
+ state |= E_CAL_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM;
+
+ return state;
+}
+
static void
cal_shell_sidebar_client_removed (ECalShellSidebar *cal_shell_sidebar,
ECal *client)
@@ -531,6 +567,7 @@ static void
cal_shell_sidebar_class_init (ECalShellSidebarClass *class)
{
GObjectClass *object_class;
+ EShellSidebarClass *shell_sidebar_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (ECalShellSidebarPrivate));
@@ -541,6 +578,9 @@ cal_shell_sidebar_class_init (ECalShellSidebarClass *class)
object_class->finalize = cal_shell_sidebar_finalize;
object_class->constructed = cal_shell_sidebar_constructed;
+ shell_sidebar_class = E_SHELL_SIDEBAR_CLASS (class);
+ shell_sidebar_class->check_state = cal_shell_sidebar_check_state;
+
class->client_removed = cal_shell_sidebar_client_removed;
g_object_class_install_property (
diff --git a/modules/calendar/e-cal-shell-sidebar.h b/modules/calendar/e-cal-shell-sidebar.h
index 3b7c0fd3b3..47dc9fa191 100644
--- a/modules/calendar/e-cal-shell-sidebar.h
+++ b/modules/calendar/e-cal-shell-sidebar.h
@@ -56,9 +56,8 @@ typedef struct _ECalShellSidebarPrivate ECalShellSidebarPrivate;
enum {
E_CAL_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0,
- E_CAL_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_EMPTY = 1 << 1,
- E_CAL_SHELL_SIDEBAR_SOURCE_CAN_GO_OFFLINE = 1 << 2,
- E_CAL_SHELL_SIDEBAR_SOURCE_CAN_DELETE = 1 << 3
+ E_CAL_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE = 1 << 1,
+ E_CAL_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2
};
struct _ECalShellSidebar {
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index 60a2781c71..635f0545e7 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -266,26 +266,28 @@ cal_shell_view_update_actions (EShellView *shell_view)
{
ECalShellViewPrivate *priv;
ECalShellContent *cal_shell_content;
- ECalShellSidebar *cal_shell_sidebar;
+ EShellSidebar *shell_sidebar;
EShellWindow *shell_window;
GnomeCalendarViewType view_type;
GnomeCalendar *calendar;
ECalendarView *view;
ECalModel *model;
- ESourceSelector *selector;
- ESource *source;
GtkAction *action;
GList *list, *iter;
- const gchar *uri = NULL;
- gboolean user_created_source;
+ gboolean sensitive;
+ guint32 state;
+ gint n_selected;
+
+ /* Be descriptive. */
+ gboolean can_delete_primary_source;
gboolean editable = TRUE;
+ gboolean has_primary_source;
+ gboolean primary_source_is_system;
gboolean recurring = FALSE;
gboolean is_instance = FALSE;
- gboolean sensitive;
gboolean is_meeting = FALSE;
gboolean is_delegatable = FALSE;
gboolean clipboard_has_calendar;
- gint n_selected;
priv = E_CAL_SHELL_VIEW_GET_PRIVATE (shell_view);
@@ -297,9 +299,6 @@ cal_shell_view_update_actions (EShellView *shell_view)
view = gnome_calendar_get_calendar_view (calendar, view_type);
model = e_calendar_view_get_model (view);
- cal_shell_sidebar = priv->cal_shell_sidebar;
- selector = e_cal_shell_sidebar_get_selector (cal_shell_sidebar);
-
list = e_calendar_view_get_selected_events (view);
n_selected = g_list_length (list);
@@ -352,29 +351,34 @@ cal_shell_view_update_actions (EShellView *shell_view)
g_list_free (list);
- source = e_source_selector_peek_primary_selection (selector);
- if (source != NULL)
- uri = e_source_peek_relative_uri (source);
- user_created_source = (uri != NULL && strcmp (uri, "system") != 0);
-
clipboard_has_calendar =
e_clipboard_wait_is_calendar_available (
gtk_clipboard_get (GDK_SELECTION_CLIPBOARD));
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ state = e_shell_sidebar_check_state (shell_sidebar);
+
+ has_primary_source =
+ (state & E_CAL_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE);
+ can_delete_primary_source =
+ (state & E_CAL_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE);
+ primary_source_is_system =
+ (state & E_CAL_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM);
+
action = ACTION (CALENDAR_COPY);
- sensitive = (source != NULL);
+ sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (CALENDAR_DELETE);
- sensitive = user_created_source;
+ sensitive = can_delete_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (CALENDAR_PROPERTIES);
- sensitive = (source != NULL);
+ sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (CALENDAR_RENAME);
- sensitive = (source != NULL);
+ sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (EVENT_CLIPBOARD_COPY);
diff --git a/modules/calendar/e-memo-shell-sidebar.c b/modules/calendar/e-memo-shell-sidebar.c
index 33a2226c00..6da89988c8 100644
--- a/modules/calendar/e-memo-shell-sidebar.c
+++ b/modules/calendar/e-memo-shell-sidebar.c
@@ -453,6 +453,7 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
EMemoShellSidebar *memo_shell_sidebar;
ESourceSelector *selector;
ESource *source;
+ gboolean can_delete = FALSE;
gboolean is_system = FALSE;
guint32 state = 0;
@@ -462,13 +463,20 @@ memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
if (source != NULL) {
const gchar *uri;
+ const gchar *delete;
uri = e_source_peek_relative_uri (source);
is_system = (uri == NULL || strcmp (uri, "system") == 0);
+
+ can_delete = !is_system;
+ delete = e_source_get_property (source, "delete");
+ can_delete &= (delete == NULL || strcmp (delete, "no") != 0);
}
if (source != NULL)
state |= E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE;
+ if (can_delete)
+ state |= E_MEMO_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE;
if (is_system)
state |= E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM;
diff --git a/modules/calendar/e-memo-shell-sidebar.h b/modules/calendar/e-memo-shell-sidebar.h
index 068d7436bc..5df8089668 100644
--- a/modules/calendar/e-memo-shell-sidebar.h
+++ b/modules/calendar/e-memo-shell-sidebar.h
@@ -55,7 +55,8 @@ typedef struct _EMemoShellSidebarPrivate EMemoShellSidebarPrivate;
enum {
E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0,
- E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 1
+ E_MEMO_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE = 1 << 1,
+ E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2
};
struct _EMemoShellSidebar {
diff --git a/modules/calendar/e-memo-shell-view.c b/modules/calendar/e-memo-shell-view.c
index 7a5b68159d..43dd7e34ea 100644
--- a/modules/calendar/e-memo-shell-view.c
+++ b/modules/calendar/e-memo-shell-view.c
@@ -165,13 +165,14 @@ memo_shell_view_update_actions (EShellView *shell_view)
/* Be descriptive. */
gboolean any_memos_selected;
+ gboolean can_delete_primary_source;
+ gboolean clipboard_has_calendar;
gboolean has_primary_source;
gboolean multiple_memos_selected;
gboolean primary_source_is_system;
gboolean selection_has_url;
gboolean single_memo_selected;
gboolean sources_are_editable;
- gboolean clipboard_has_calendar;
priv = E_MEMO_SHELL_VIEW_GET_PRIVATE (shell_view);
@@ -196,6 +197,8 @@ memo_shell_view_update_actions (EShellView *shell_view)
has_primary_source =
(state & E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE);
+ can_delete_primary_source =
+ (state & E_MEMO_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE);
primary_source_is_system =
(state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM);
@@ -232,7 +235,7 @@ memo_shell_view_update_actions (EShellView *shell_view)
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_LIST_DELETE);
- sensitive = has_primary_source && !primary_source_is_system;
+ sensitive = can_delete_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_LIST_PROPERTIES);
diff --git a/modules/calendar/e-task-shell-sidebar.c b/modules/calendar/e-task-shell-sidebar.c
index 6bd7700fcf..9107d65464 100644
--- a/modules/calendar/e-task-shell-sidebar.c
+++ b/modules/calendar/e-task-shell-sidebar.c
@@ -451,6 +451,7 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
ETaskShellSidebar *task_shell_sidebar;
ESourceSelector *selector;
ESource *source;
+ gboolean can_delete = FALSE;
gboolean is_system = FALSE;
guint32 state = 0;
@@ -460,13 +461,20 @@ task_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
if (source != NULL) {
const gchar *uri;
+ const gchar *delete;
uri = e_source_peek_relative_uri (source);
is_system = (uri == NULL || strcmp (uri, "system") == 0);
+
+ can_delete = !is_system;
+ delete = e_source_get_property (source, "delete");
+ can_delete &= (delete == NULL || strcmp (delete, "no") != 0);
}
if (source != NULL)
state |= E_TASK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE;
+ if (can_delete)
+ state |= E_TASK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE;
if (is_system)
state |= E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM;
diff --git a/modules/calendar/e-task-shell-sidebar.h b/modules/calendar/e-task-shell-sidebar.h
index 5d4c74fe11..81021b8cda 100644
--- a/modules/calendar/e-task-shell-sidebar.h
+++ b/modules/calendar/e-task-shell-sidebar.h
@@ -55,7 +55,8 @@ typedef struct _ETaskShellSidebarPrivate ETaskShellSidebarPrivate;
enum {
E_TASK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0,
- E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 1
+ E_TASK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE = 1 << 1,
+ E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 2
};
struct _ETaskShellSidebar {
diff --git a/modules/calendar/e-task-shell-view.c b/modules/calendar/e-task-shell-view.c
index a55d120cb8..bab7fa1539 100644
--- a/modules/calendar/e-task-shell-view.c
+++ b/modules/calendar/e-task-shell-view.c
@@ -277,6 +277,7 @@ task_shell_view_update_actions (EShellView *shell_view)
/* Be descriptive. */
gboolean any_tasks_selected;
+ gboolean can_delete_primary_source;
gboolean has_primary_source;
gboolean multiple_tasks_selected;
gboolean primary_source_is_system;
@@ -317,6 +318,8 @@ task_shell_view_update_actions (EShellView *shell_view)
has_primary_source =
(state & E_TASK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE);
+ can_delete_primary_source =
+ (state & E_TASK_SHELL_SIDEBAR_CAN_DELETE_PRIMARY_SOURCE);
primary_source_is_system =
(state & E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM);
@@ -359,7 +362,7 @@ task_shell_view_update_actions (EShellView *shell_view)
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_LIST_DELETE);
- sensitive = has_primary_source && !primary_source_is_system;
+ sensitive = can_delete_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_LIST_PROPERTIES);