aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/modules
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/modules')
-rw-r--r--calendar/modules/e-cal-shell-content.h14
-rw-r--r--calendar/modules/e-cal-shell-sidebar.h7
-rw-r--r--calendar/modules/e-memo-shell-content.c49
-rw-r--r--calendar/modules/e-memo-shell-content.h7
-rw-r--r--calendar/modules/e-memo-shell-sidebar.c32
-rw-r--r--calendar/modules/e-memo-shell-sidebar.h5
-rw-r--r--calendar/modules/e-memo-shell-view.c95
-rw-r--r--calendar/modules/e-task-shell-content.c74
-rw-r--r--calendar/modules/e-task-shell-content.h10
-rw-r--r--calendar/modules/e-task-shell-sidebar.c32
-rw-r--r--calendar/modules/e-task-shell-sidebar.h5
-rw-r--r--calendar/modules/e-task-shell-view.c147
12 files changed, 352 insertions, 125 deletions
diff --git a/calendar/modules/e-cal-shell-content.h b/calendar/modules/e-cal-shell-content.h
index 5d8a56a185..f199be3b78 100644
--- a/calendar/modules/e-cal-shell-content.h
+++ b/calendar/modules/e-cal-shell-content.h
@@ -54,6 +54,20 @@ typedef struct _ECalShellContent ECalShellContent;
typedef struct _ECalShellContentClass ECalShellContentClass;
typedef struct _ECalShellContentPrivate ECalShellContentPrivate;
+enum {
+ E_CAL_SHELL_CONTENT_SELECTION_SINGLE = 1 << 0,
+ E_CAL_SHELL_CONTENT_SELECTION_MULTIPLE = 1 << 1,
+ E_CAL_SHELL_CONTENT_SELECTION_IS_ASSIGNABLE = 1 << 2,
+ E_CAL_SHELL_CONTENT_SELECTION_IS_COMPLETE = 1 << 3,
+ E_CAL_SHELL_CONTENT_SELECTION_IS_EDITABLE = 1 << 4,
+ E_CAL_SHELL_CONTENT_SELECTION_IS_MEETING = 1 << 5,
+ E_CAL_SHELL_CONTENT_SELECTION_IS_ORGANIZER = 1 << 6,
+ E_CAL_SHELL_CONTENT_SELECTION_IS_RECURRING = 1 << 7,
+ E_CAL_SHELL_CONTENT_SELECTION_CAN_ACCEPT = 1 << 8,
+ E_CAL_SHELL_CONTENT_SELECTION_CAN_DELEGATE = 1 << 9,
+ E_CAL_SHELL_CONTENT_SELECTION_CAN_SAVE = 1 << 10
+};
+
struct _ECalShellContent {
EShellContent parent;
ECalShellContentPrivate *priv;
diff --git a/calendar/modules/e-cal-shell-sidebar.h b/calendar/modules/e-cal-shell-sidebar.h
index eecb6a0365..ff30541448 100644
--- a/calendar/modules/e-cal-shell-sidebar.h
+++ b/calendar/modules/e-cal-shell-sidebar.h
@@ -54,6 +54,13 @@ typedef struct _ECalShellSidebar ECalShellSidebar;
typedef struct _ECalShellSidebarClass ECalShellSidebarClass;
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
+};
+
struct _ECalShellSidebar {
EShellSidebar parent;
ECalShellSidebarPrivate *priv;
diff --git a/calendar/modules/e-memo-shell-content.c b/calendar/modules/e-memo-shell-content.c
index 72ecbbf2f8..fc245b8f44 100644
--- a/calendar/modules/e-memo-shell-content.c
+++ b/calendar/modules/e-memo-shell-content.c
@@ -416,10 +416,56 @@ memo_shell_content_constructed (GObject *object)
gconf_bridge_bind_property_delayed (bridge, key, object, "position");
}
+static guint32
+memo_shell_content_check_state (EShellContent *shell_content)
+{
+ EMemoShellContent *memo_shell_content;
+ EMemoTable *memo_table;
+ ETable *table;
+ GSList *list, *iter;
+ gboolean editable = TRUE;
+ gboolean has_url = FALSE;
+ gint n_selected;
+ guint32 state = 0;
+
+ memo_shell_content = E_MEMO_SHELL_CONTENT (shell_content);
+ memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
+
+ table = e_memo_table_get_table (memo_table);
+ n_selected = e_table_selected_count (table);
+
+ list = e_memo_table_get_selected (memo_table);
+ for (iter = list; iter != NULL; iter = iter->next) {
+ ECalModelComponent *comp_data = iter->data;
+ icalproperty *prop;
+ gboolean read_only;
+
+ e_cal_is_read_only (comp_data->client, &read_only, NULL);
+ editable &= !read_only;
+
+ prop = icalcomponent_get_first_property (
+ comp_data->icalcomp, ICAL_URL_PROPERTY);
+ has_url |= (prop != NULL);
+ }
+ g_slist_free (list);
+
+ if (n_selected == 1)
+ state |= E_MEMO_SHELL_CONTENT_SELECTION_SINGLE;
+ if (n_selected > 1)
+ state |= E_MEMO_SHELL_CONTENT_SELECTION_MULTIPLE;
+ if (editable)
+ state |= E_MEMO_SHELL_CONTENT_SELECTION_CAN_EDIT;
+ if (has_url)
+ state |= E_MEMO_SHELL_CONTENT_SELECTION_HAS_URL;
+
+ return state;
+}
+
static void
memo_shell_content_class_init (EMemoShellContentClass *class)
{
GObjectClass *object_class;
+ EShellContentClass *shell_content_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EMemoShellContentPrivate));
@@ -431,6 +477,9 @@ memo_shell_content_class_init (EMemoShellContentClass *class)
object_class->finalize = memo_shell_content_finalize;
object_class->constructed = memo_shell_content_constructed;
+ shell_content_class = E_SHELL_CONTENT_CLASS (class);
+ shell_content_class->check_state = memo_shell_content_check_state;
+
g_object_class_install_property (
object_class,
PROP_PREVIEW_VISIBLE,
diff --git a/calendar/modules/e-memo-shell-content.h b/calendar/modules/e-memo-shell-content.h
index 3965c24e8d..036a04be56 100644
--- a/calendar/modules/e-memo-shell-content.h
+++ b/calendar/modules/e-memo-shell-content.h
@@ -55,6 +55,13 @@ typedef struct _EMemoShellContent EMemoShellContent;
typedef struct _EMemoShellContentClass EMemoShellContentClass;
typedef struct _EMemoShellContentPrivate EMemoShellContentPrivate;
+enum {
+ E_MEMO_SHELL_CONTENT_SELECTION_SINGLE = 1 << 0,
+ E_MEMO_SHELL_CONTENT_SELECTION_MULTIPLE = 1 << 1,
+ E_MEMO_SHELL_CONTENT_SELECTION_CAN_EDIT = 1 << 2,
+ E_MEMO_SHELL_CONTENT_SELECTION_HAS_URL = 1 << 3
+};
+
struct _EMemoShellContent {
EShellContent parent;
EMemoShellContentPrivate *priv;
diff --git a/calendar/modules/e-memo-shell-sidebar.c b/calendar/modules/e-memo-shell-sidebar.c
index e46b84e8ea..6e5475e290 100644
--- a/calendar/modules/e-memo-shell-sidebar.c
+++ b/calendar/modules/e-memo-shell-sidebar.c
@@ -441,6 +441,34 @@ memo_shell_sidebar_constructed (GObject *object)
object);
}
+static guint32
+memo_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
+{
+ EMemoShellSidebar *memo_shell_sidebar;
+ ESourceSelector *selector;
+ ESource *source;
+ gboolean is_system = FALSE;
+ guint32 state = 0;
+
+ memo_shell_sidebar = E_MEMO_SHELL_SIDEBAR (shell_sidebar);
+ selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
+ source = e_source_selector_peek_primary_selection (selector);
+
+ if (source != NULL) {
+ const gchar *uri;
+
+ uri = e_source_peek_relative_uri (source);
+ is_system = (uri == NULL || strcmp (uri, "system") == 0);
+ }
+
+ if (source != NULL)
+ state = E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE;
+ if (is_system)
+ state = E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM;
+
+ return state;
+}
+
static void
memo_shell_sidebar_client_added (EMemoShellSidebar *memo_shell_sidebar,
ECal *client)
@@ -477,6 +505,7 @@ static void
memo_shell_sidebar_class_init (EMemoShellSidebarClass *class)
{
GObjectClass *object_class;
+ EShellSidebarClass *shell_sidebar_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (EMemoShellSidebarPrivate));
@@ -487,6 +516,9 @@ memo_shell_sidebar_class_init (EMemoShellSidebarClass *class)
object_class->finalize = memo_shell_sidebar_finalize;
object_class->constructed = memo_shell_sidebar_constructed;
+ shell_sidebar_class = E_SHELL_SIDEBAR_CLASS (class);
+ shell_sidebar_class->check_state = memo_shell_sidebar_check_state;
+
class->client_added = memo_shell_sidebar_client_added;
class->client_removed = memo_shell_sidebar_client_removed;
diff --git a/calendar/modules/e-memo-shell-sidebar.h b/calendar/modules/e-memo-shell-sidebar.h
index 4b516889b5..8e59c5b38e 100644
--- a/calendar/modules/e-memo-shell-sidebar.h
+++ b/calendar/modules/e-memo-shell-sidebar.h
@@ -53,6 +53,11 @@ typedef struct _EMemoShellSidebar EMemoShellSidebar;
typedef struct _EMemoShellSidebarClass EMemoShellSidebarClass;
typedef struct _EMemoShellSidebarPrivate EMemoShellSidebarPrivate;
+enum {
+ E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0,
+ E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 1
+};
+
struct _EMemoShellSidebar {
EShellSidebar parent;
EMemoShellSidebarPrivate *priv;
diff --git a/calendar/modules/e-memo-shell-view.c b/calendar/modules/e-memo-shell-view.c
index a618c307e9..161caf92d0 100644
--- a/calendar/modules/e-memo-shell-view.c
+++ b/calendar/modules/e-memo-shell-view.c
@@ -77,104 +77,101 @@ static void
memo_shell_view_update_actions (EShellView *shell_view)
{
EMemoShellViewPrivate *priv;
- EMemoShellContent *memo_shell_content;
- EMemoShellSidebar *memo_shell_sidebar;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
EShellWindow *shell_window;
- ESourceSelector *selector;
- EMemoTable *memo_table;
- ETable *table;
- ESource *source;
GtkAction *action;
- GSList *list, *iter;
const gchar *label;
- const gchar *uri = NULL;
- gboolean user_created_source;
- gboolean editable = TRUE;
- gboolean has_url = FALSE;
gboolean sensitive;
- gint n_selected;
+ guint32 state;
+
+ /* Be descriptive. */
+ gboolean any_memos_selected;
+ 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;
priv = E_MEMO_SHELL_VIEW_GET_PRIVATE (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- memo_shell_content = priv->memo_shell_content;
- memo_table = e_memo_shell_content_get_memo_table (memo_shell_content);
-
- memo_shell_sidebar = priv->memo_shell_sidebar;
- selector = e_memo_shell_sidebar_get_selector (memo_shell_sidebar);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ state = e_shell_content_check_state (shell_content);
- table = e_memo_table_get_table (memo_table);
- n_selected = e_table_selected_count (table);
+ single_memo_selected =
+ (state & E_MEMO_SHELL_CONTENT_SELECTION_SINGLE);
+ multiple_memos_selected =
+ (state & E_MEMO_SHELL_CONTENT_SELECTION_MULTIPLE);
+ sources_are_editable =
+ (state & E_MEMO_SHELL_CONTENT_SELECTION_CAN_EDIT);
+ selection_has_url =
+ (state & E_MEMO_SHELL_CONTENT_SELECTION_HAS_URL);
- list = e_memo_table_get_selected (memo_table);
- for (iter = list; iter != NULL; iter = iter->next) {
- ECalModelComponent *comp_data = iter->data;
- icalproperty *prop;
- gboolean read_only;
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ state = e_shell_sidebar_check_state (shell_sidebar);
- e_cal_is_read_only (comp_data->client, &read_only, NULL);
- editable &= !read_only;
-
- prop = icalcomponent_get_first_property (
- comp_data->icalcomp, ICAL_URL_PROPERTY);
- has_url |= (prop != NULL);
- }
- g_slist_free (list);
+ has_primary_source =
+ (state & E_MEMO_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE);
+ primary_source_is_system =
+ (state & E_MEMO_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM);
- 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);
+ any_memos_selected =
+ (single_memo_selected || multiple_memos_selected);
action = ACTION (MEMO_CLIPBOARD_COPY);
- sensitive = (n_selected > 0);
+ sensitive = any_memos_selected;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_CLIPBOARD_CUT);
- sensitive = (n_selected > 0) && editable;
+ sensitive = any_memos_selected && sources_are_editable;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_CLIPBOARD_PASTE);
- sensitive = editable;
+ sensitive = sources_are_editable;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_DELETE);
- sensitive = (n_selected > 0) && editable;
+ sensitive = any_memos_selected && sources_are_editable;
gtk_action_set_sensitive (action, sensitive);
- label = ngettext ("Delete Memo", "Delete Memos", n_selected);
+ if (multiple_memos_selected)
+ label = _("Delete Memos");
+ else
+ label = _("Delete Memo");
g_object_set (action, "label", label, NULL);
action = ACTION (MEMO_FORWARD);
- sensitive = (n_selected == 1);
+ sensitive = single_memo_selected;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_LIST_COPY);
- sensitive = (source != NULL);
+ sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_LIST_DELETE);
- sensitive = user_created_source;
+ sensitive = has_primary_source && !primary_source_is_system;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_LIST_PROPERTIES);
- sensitive = (source != NULL);
+ sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_OPEN);
- sensitive = (n_selected == 1);
+ sensitive = single_memo_selected;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_OPEN_URL);
- sensitive = (n_selected == 1) && has_url;
+ sensitive = single_memo_selected && selection_has_url;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_PRINT);
- sensitive = (n_selected == 1);
+ sensitive = single_memo_selected;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (MEMO_SAVE_AS);
- sensitive = (n_selected == 1);
+ sensitive = single_memo_selected;
gtk_action_set_sensitive (action, sensitive);
}
diff --git a/calendar/modules/e-task-shell-content.c b/calendar/modules/e-task-shell-content.c
index 9599e35d3b..40b8372c46 100644
--- a/calendar/modules/e-task-shell-content.c
+++ b/calendar/modules/e-task-shell-content.c
@@ -417,10 +417,81 @@ task_shell_content_constructed (GObject *object)
gconf_bridge_bind_property_delayed (bridge, key, object, "position");
}
+static guint32
+task_shell_content_check_state (EShellContent *shell_content)
+{
+ ETaskShellContent *task_shell_content;
+ ECalendarTable *task_table;
+ ETable *table;
+ GSList *list, *iter;
+ gboolean assignable = TRUE;
+ gboolean editable = TRUE;
+ gboolean has_url = FALSE;
+ gint n_selected;
+ gint n_complete = 0;
+ gint n_incomplete = 0;
+ guint32 state = 0;
+
+ task_shell_content = E_TASK_SHELL_CONTENT (shell_content);
+ task_table = e_task_shell_content_get_task_table (task_shell_content);
+
+ table = e_calendar_table_get_table (task_table);
+ n_selected = e_table_selected_count (table);
+
+ list = e_calendar_table_get_selected (task_table);
+ for (iter = list; iter != NULL; iter = iter->next) {
+ ECalModelComponent *comp_data = iter->data;
+ icalproperty *prop;
+ const gchar *cap;
+ gboolean read_only;
+
+ e_cal_is_read_only (comp_data->client, &read_only, NULL);
+ editable &= !read_only;
+
+ cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT;
+ if (e_cal_get_static_capability (comp_data->client, cap))
+ assignable = FALSE;
+
+ cap = CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK;
+ if (e_cal_get_static_capability (comp_data->client, cap))
+ assignable = FALSE;
+
+ prop = icalcomponent_get_first_property (
+ comp_data->icalcomp, ICAL_URL_PROPERTY);
+ has_url |= (prop != NULL);
+
+ prop = icalcomponent_get_first_property (
+ comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
+ if (prop != NULL)
+ n_complete++;
+ else
+ n_incomplete++;
+ }
+ g_slist_free (list);
+
+ if (n_selected == 1)
+ state |= E_TASK_SHELL_CONTENT_SELECTION_SINGLE;
+ if (n_selected > 1)
+ state |= E_TASK_SHELL_CONTENT_SELECTION_MULTIPLE;
+ if (assignable)
+ state |= E_TASK_SHELL_CONTENT_SELECTION_CAN_ASSIGN;
+ if (editable)
+ state |= E_TASK_SHELL_CONTENT_SELECTION_CAN_EDIT;
+ if (n_complete > 0)
+ state |= E_TASK_SHELL_CONTENT_SELECTION_HAS_COMPLETE;
+ if (n_incomplete > 0)
+ state |= E_TASK_SHELL_CONTENT_SELECTION_HAS_INCOMPLETE;
+ if (has_url)
+ state |= E_TASK_SHELL_CONTENT_SELECTION_HAS_URL;
+
+ return state;
+}
+
static void
task_shell_content_class_init (ETaskShellContentClass *class)
{
GObjectClass *object_class;
+ EShellContentClass *shell_content_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (ETaskShellContentPrivate));
@@ -432,6 +503,9 @@ task_shell_content_class_init (ETaskShellContentClass *class)
object_class->finalize = task_shell_content_finalize;
object_class->constructed = task_shell_content_constructed;
+ shell_content_class = E_SHELL_CONTENT_CLASS (class);
+ shell_content_class->check_state = task_shell_content_check_state;
+
g_object_class_install_property (
object_class,
PROP_PREVIEW_VISIBLE,
diff --git a/calendar/modules/e-task-shell-content.h b/calendar/modules/e-task-shell-content.h
index dad6702a0c..361b289f77 100644
--- a/calendar/modules/e-task-shell-content.h
+++ b/calendar/modules/e-task-shell-content.h
@@ -55,6 +55,16 @@ typedef struct _ETaskShellContent ETaskShellContent;
typedef struct _ETaskShellContentClass ETaskShellContentClass;
typedef struct _ETaskShellContentPrivate ETaskShellContentPrivate;
+enum {
+ E_TASK_SHELL_CONTENT_SELECTION_SINGLE = 1 << 0,
+ E_TASK_SHELL_CONTENT_SELECTION_MULTIPLE = 1 << 1,
+ E_TASK_SHELL_CONTENT_SELECTION_CAN_ASSIGN = 1 << 2,
+ E_TASK_SHELL_CONTENT_SELECTION_CAN_EDIT = 1 << 3,
+ E_TASK_SHELL_CONTENT_SELECTION_HAS_COMPLETE = 1 << 4,
+ E_TASK_SHELL_CONTENT_SELECTION_HAS_INCOMPLETE = 1 << 5,
+ E_TASK_SHELL_CONTENT_SELECTION_HAS_URL = 1 << 6
+};
+
struct _ETaskShellContent {
EShellContent parent;
ETaskShellContentPrivate *priv;
diff --git a/calendar/modules/e-task-shell-sidebar.c b/calendar/modules/e-task-shell-sidebar.c
index 6a84ef3179..913d18e37f 100644
--- a/calendar/modules/e-task-shell-sidebar.c
+++ b/calendar/modules/e-task-shell-sidebar.c
@@ -441,6 +441,34 @@ task_shell_sidebar_constructed (GObject *object)
object);
}
+static guint32
+task_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
+{
+ ETaskShellSidebar *task_shell_sidebar;
+ ESourceSelector *selector;
+ ESource *source;
+ gboolean is_system = FALSE;
+ guint32 state = 0;
+
+ task_shell_sidebar = E_TASK_SHELL_SIDEBAR (shell_sidebar);
+ selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
+ source = e_source_selector_peek_primary_selection (selector);
+
+ if (source != NULL) {
+ const gchar *uri;
+
+ uri = e_source_peek_relative_uri (source);
+ is_system = (uri == NULL || strcmp (uri, "system") == 0);
+ }
+
+ if (source != NULL)
+ state |= E_TASK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE;
+ if (is_system)
+ state |= E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM;
+
+ return state;
+}
+
static void
task_shell_sidebar_client_added (ETaskShellSidebar *task_shell_sidebar,
ECal *client)
@@ -477,6 +505,7 @@ static void
task_shell_sidebar_class_init (ETaskShellSidebarClass *class)
{
GObjectClass *object_class;
+ EShellSidebarClass *shell_sidebar_class;
parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (ETaskShellSidebarPrivate));
@@ -487,6 +516,9 @@ task_shell_sidebar_class_init (ETaskShellSidebarClass *class)
object_class->finalize = task_shell_sidebar_finalize;
object_class->constructed = task_shell_sidebar_constructed;
+ shell_sidebar_class = E_SHELL_SIDEBAR_CLASS (class);
+ shell_sidebar_class->check_state = task_shell_sidebar_check_state;
+
class->client_added = task_shell_sidebar_client_added;
class->client_removed = task_shell_sidebar_client_removed;
diff --git a/calendar/modules/e-task-shell-sidebar.h b/calendar/modules/e-task-shell-sidebar.h
index 6b926685d8..8fcafcaa98 100644
--- a/calendar/modules/e-task-shell-sidebar.h
+++ b/calendar/modules/e-task-shell-sidebar.h
@@ -53,6 +53,11 @@ typedef struct _ETaskShellSidebar ETaskShellSidebar;
typedef struct _ETaskShellSidebarClass ETaskShellSidebarClass;
typedef struct _ETaskShellSidebarPrivate ETaskShellSidebarPrivate;
+enum {
+ E_TASK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE = 1 << 0,
+ E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM = 1 << 1
+};
+
struct _ETaskShellSidebar {
EShellSidebar parent;
ETaskShellSidebarPrivate *priv;
diff --git a/calendar/modules/e-task-shell-view.c b/calendar/modules/e-task-shell-view.c
index 3183323901..99e6164eb4 100644
--- a/calendar/modules/e-task-shell-view.c
+++ b/calendar/modules/e-task-shell-view.c
@@ -77,139 +77,134 @@ static void
task_shell_view_update_actions (EShellView *shell_view)
{
ETaskShellViewPrivate *priv;
- ETaskShellContent *task_shell_content;
- ETaskShellSidebar *task_shell_sidebar;
+ EShellContent *shell_content;
+ EShellSidebar *shell_sidebar;
EShellWindow *shell_window;
- ESourceSelector *selector;
- ETable *table;
- ECalendarTable *task_table;
- ESource *source;
GtkAction *action;
- GSList *list, *iter;
const gchar *label;
- const gchar *uri = NULL;
- gboolean user_created_source;
- gboolean assignable = TRUE;
- gboolean editable = TRUE;
- gboolean has_url = FALSE;
gboolean sensitive;
- gint n_selected;
- gint n_complete = 0;
- gint n_incomplete = 0;
+ guint32 state;
+
+ /* Be descriptive. */
+ gboolean any_tasks_selected;
+ gboolean has_primary_source;
+ gboolean multiple_tasks_selected;
+ gboolean primary_source_is_system;
+ gboolean selection_has_url;
+ gboolean selection_is_assignable;
+ gboolean single_task_selected;
+ gboolean some_tasks_complete;
+ gboolean some_tasks_incomplete;
+ gboolean sources_are_editable;
priv = E_TASK_SHELL_VIEW_GET_PRIVATE (shell_view);
shell_window = e_shell_view_get_shell_window (shell_view);
- task_shell_content = priv->task_shell_content;
- task_table = e_task_shell_content_get_task_table (task_shell_content);
-
- task_shell_sidebar = priv->task_shell_sidebar;
- selector = e_task_shell_sidebar_get_selector (task_shell_sidebar);
-
- table = e_calendar_table_get_table (task_table);
- n_selected = e_table_selected_count (table);
-
- list = e_calendar_table_get_selected (task_table);
- for (iter = list; iter != NULL; iter = iter->next) {
- ECalModelComponent *comp_data = iter->data;
- icalproperty *prop;
- const gchar *cap;
- gboolean read_only;
-
- e_cal_is_read_only (comp_data->client, &read_only, NULL);
- editable &= !read_only;
-
- cap = CAL_STATIC_CAPABILITY_NO_TASK_ASSIGNMENT;
- if (e_cal_get_static_capability (comp_data->client, cap))
- assignable = FALSE;
-
- cap = CAL_STATIC_CAPABILITY_NO_CONV_TO_ASSIGN_TASK;
- if (e_cal_get_static_capability (comp_data->client, cap))
- assignable = FALSE;
-
- prop = icalcomponent_get_first_property (
- comp_data->icalcomp, ICAL_URL_PROPERTY);
- has_url |= (prop != NULL);
-
- prop = icalcomponent_get_first_property (
- comp_data->icalcomp, ICAL_COMPLETED_PROPERTY);
- if (prop != NULL)
- n_complete++;
- else
- n_incomplete++;
- }
- g_slist_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);
+ shell_content = e_shell_view_get_shell_content (shell_view);
+ state = e_shell_content_check_state (shell_content);
+
+ single_task_selected =
+ (state & E_TASK_SHELL_CONTENT_SELECTION_SINGLE);
+ multiple_tasks_selected =
+ (state & E_TASK_SHELL_CONTENT_SELECTION_MULTIPLE);
+ selection_is_assignable =
+ (state & E_TASK_SHELL_CONTENT_SELECTION_CAN_ASSIGN);
+ sources_are_editable =
+ (state & E_TASK_SHELL_CONTENT_SELECTION_CAN_EDIT);
+ some_tasks_complete =
+ (state & E_TASK_SHELL_CONTENT_SELECTION_HAS_COMPLETE);
+ some_tasks_incomplete =
+ (state & E_TASK_SHELL_CONTENT_SELECTION_HAS_INCOMPLETE);
+ selection_has_url =
+ (state & E_TASK_SHELL_CONTENT_SELECTION_HAS_URL);
+
+ shell_sidebar = e_shell_view_get_shell_sidebar (shell_view);
+ state = e_shell_sidebar_check_state (shell_sidebar);
+
+ has_primary_source =
+ (state & E_TASK_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE);
+ primary_source_is_system =
+ (state & E_TASK_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_SYSTEM);
+
+ any_tasks_selected =
+ (single_task_selected || multiple_tasks_selected);
action = ACTION (TASK_ASSIGN);
- sensitive = (n_selected == 1) && editable && assignable;
+ sensitive =
+ single_task_selected && sources_are_editable &&
+ selection_is_assignable;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_CLIPBOARD_COPY);
- sensitive = (n_selected > 0);
+ sensitive = any_tasks_selected;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_CLIPBOARD_CUT);
- sensitive = (n_selected > 0) && editable;
+ sensitive = any_tasks_selected && sources_are_editable;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_CLIPBOARD_PASTE);
- sensitive = editable;
+ sensitive = sources_are_editable;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_DELETE);
- sensitive = (n_selected > 0) && editable;
+ sensitive = any_tasks_selected && sources_are_editable;
gtk_action_set_sensitive (action, sensitive);
- label = ngettext ("Delete Task", "Delete Tasks", n_selected);
+ if (multiple_tasks_selected)
+ label = _("Delete Tasks");
+ else
+ label = _("Delete Task");
g_object_set (action, "label", label, NULL);
action = ACTION (TASK_FORWARD);
- sensitive = (n_selected == 1);
+ sensitive = single_task_selected;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_LIST_COPY);
- sensitive = (source != NULL);
+ sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_LIST_DELETE);
- sensitive = user_created_source;
+ sensitive = has_primary_source && !primary_source_is_system;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_LIST_PROPERTIES);
- sensitive = (source != NULL);
+ sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_MARK_COMPLETE);
- sensitive = (n_selected > 0) && editable && (n_incomplete > 0);
+ sensitive =
+ any_tasks_selected &&
+ sources_are_editable &&
+ some_tasks_incomplete;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_MARK_INCOMPLETE);
- sensitive = (n_selected > 0) && editable && (n_complete > 0);
+ sensitive =
+ any_tasks_selected &&
+ sources_are_editable &&
+ some_tasks_complete;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_OPEN);
- sensitive = (n_selected == 1);
+ sensitive = single_task_selected;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_OPEN_URL);
- sensitive = (n_selected == 1) && has_url;
+ sensitive = single_task_selected && selection_has_url;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_PRINT);
- sensitive = (n_selected == 1);
+ sensitive = single_task_selected;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_PURGE);
- sensitive = editable;
+ sensitive = sources_are_editable;
gtk_action_set_sensitive (action, sensitive);
action = ACTION (TASK_SAVE_AS);
- sensitive = (n_selected == 1);
+ sensitive = single_task_selected;
gtk_action_set_sensitive (action, sensitive);
}