[evolution] Bug 758752 - "Show all calendars" as a way of undoing "Show only this calendar"
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution] Bug 758752 - "Show all calendars" as a way of undoing "Show only this calendar"
- Date: Mon, 30 Nov 2015 16:12:39 +0000 (UTC)
commit 2f90fcb9f36070f227257f7cf509658e96e80d82
Author: Milan Crha <mcrha redhat com>
Date: Mon Nov 30 17:10:59 2015 +0100
Bug 758752 - "Show all calendars" as a way of undoing "Show only this calendar"
.../evolution-util/evolution-util-sections.txt | 3 +
e-util/e-source-selector.c | 123 ++++++++++++++++++++
e-util/e-source-selector.h | 3 +
modules/calendar/e-cal-base-shell-sidebar.c | 2 +
modules/calendar/e-cal-base-shell-sidebar.h | 3 +-
modules/calendar/e-cal-shell-view-actions.c | 24 ++++
modules/calendar/e-cal-shell-view-actions.h | 2 +
modules/calendar/e-cal-shell-view.c | 7 +
modules/calendar/e-memo-shell-view-actions.c | 24 ++++
modules/calendar/e-memo-shell-view-actions.h | 2 +
modules/calendar/e-memo-shell-view.c | 7 +
modules/calendar/e-task-shell-view-actions.c | 24 ++++
modules/calendar/e-task-shell-view-actions.h | 2 +
modules/calendar/e-task-shell-view.c | 7 +
ui/evolution-calendars.ui | 1 +
ui/evolution-memos.ui | 1 +
ui/evolution-tasks.ui | 1 +
17 files changed, 235 insertions(+), 1 deletions(-)
---
diff --git a/doc/reference/evolution-util/evolution-util-sections.txt
b/doc/reference/evolution-util/evolution-util-sections.txt
index d73f89d..11116d2 100644
--- a/doc/reference/evolution-util/evolution-util-sections.txt
+++ b/doc/reference/evolution-util/evolution-util-sections.txt
@@ -4273,8 +4273,11 @@ e_source_selector_set_show_toggles
e_source_selector_select_source
e_source_selector_unselect_source
e_source_selector_select_exclusive
+e_source_selector_select_all
e_source_selector_source_is_selected
e_source_selector_get_selection
+e_source_selector_count_total
+e_source_selector_count_selected
e_source_selector_edit_primary_selection
e_source_selector_ref_primary_selection
e_source_selector_set_primary_selection
diff --git a/e-util/e-source-selector.c b/e-util/e-source-selector.c
index b8dab71..a32dc16 100644
--- a/e-util/e-source-selector.c
+++ b/e-util/e-source-selector.c
@@ -2237,6 +2237,93 @@ e_source_selector_get_selection (ESourceSelector *selector)
return g_queue_peek_head_link (&closure.queue);
}
+struct CountData {
+ ESourceSelector *selector;
+ guint count;
+ gboolean selected;
+};
+
+static gboolean
+source_selector_count_sources (GtkTreeModel *model,
+ GtkTreePath *path,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ struct CountData *cd = user_data;
+ ESource *source;
+
+ gtk_tree_model_get (model, iter, COLUMN_SOURCE, &source, -1);
+
+ if (e_source_has_extension (source, e_source_selector_get_extension_name (cd->selector))) {
+ if (cd->selected) {
+ if (e_source_selector_source_is_selected (cd->selector, source))
+ cd->count++;
+ } else {
+ cd->count++;
+ }
+ }
+
+ g_object_unref (source);
+
+ return FALSE;
+}
+
+/**
+ * e_source_selector_count_total:
+ * @selector: an #ESourceSelector
+ *
+ * Counts how many ESource-s are shown in the @selector.
+ *
+ * Returns: How many ESource-s are shown in the @selector.
+ *
+ * Since: 3.20
+ **/
+guint
+e_source_selector_count_total (ESourceSelector *selector)
+{
+ struct CountData cd;
+
+ g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), 0);
+
+ cd.selector = selector;
+ cd.count = 0;
+ cd.selected = FALSE;
+
+ gtk_tree_model_foreach (
+ gtk_tree_view_get_model (GTK_TREE_VIEW (selector)),
+ source_selector_count_sources, &cd);
+
+ return cd.count;
+}
+
+/**
+ * e_source_selector_count_selected:
+ * @selector: an #ESourceSelector
+ *
+ * Counts how many ESource-s are selected in the @selector.
+ *
+ * Returns: How many ESource-s are selected in the @selector.
+ *
+ * Since: 3.20
+ **/
+guint
+e_source_selector_count_selected (ESourceSelector *selector)
+{
+ struct CountData cd;
+
+ g_return_val_if_fail (E_IS_SOURCE_SELECTOR (selector), 0);
+
+ cd.selector = selector;
+ cd.count = 0;
+ cd.selected = TRUE;
+
+ gtk_tree_model_foreach (
+ gtk_tree_view_get_model (GTK_TREE_VIEW (selector)),
+ source_selector_count_sources, &cd);
+
+ return cd.count;
+}
+
/**
* e_source_selector_select_source:
* @selector: An #ESourceSelector widget
@@ -2350,6 +2437,42 @@ e_source_selector_select_exclusive (ESourceSelector *selector,
}
/**
+ * e_source_selector_select_all:
+ * @selector: An #ESourceSelector widget
+ *
+ * Selects all ESource-s in the @selector.
+ *
+ * Since: 3.20
+ **/
+void
+e_source_selector_select_all (ESourceSelector *selector)
+{
+ ESourceSelectorClass *class;
+ GHashTable *source_index;
+ GHashTableIter iter;
+ gpointer key;
+ gboolean any_changed = FALSE;
+
+ g_return_if_fail (E_IS_SOURCE_SELECTOR (selector));
+
+ class = E_SOURCE_SELECTOR_GET_CLASS (selector);
+ g_return_if_fail (class->set_source_selected != NULL);
+
+ source_index = selector->priv->source_index;
+ g_hash_table_iter_init (&iter, source_index);
+
+ while (g_hash_table_iter_next (&iter, &key, NULL)) {
+ if (class->set_source_selected (selector, key, TRUE)) {
+ any_changed = TRUE;
+ g_signal_emit (selector, signals[SOURCE_SELECTED], 0, key);
+ }
+ }
+
+ if (any_changed)
+ g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
+}
+
+/**
* e_source_selector_source_is_selected:
* @selector: An #ESourceSelector widget
* @source: An #ESource.
diff --git a/e-util/e-source-selector.h b/e-util/e-source-selector.h
index afccfa6..776ccce 100644
--- a/e-util/e-source-selector.h
+++ b/e-util/e-source-selector.h
@@ -122,10 +122,13 @@ void e_source_selector_unselect_source
void e_source_selector_select_exclusive
(ESourceSelector *selector,
ESource *source);
+void e_source_selector_select_all (ESourceSelector *selector);
gboolean e_source_selector_source_is_selected
(ESourceSelector *selector,
ESource *source);
GList * e_source_selector_get_selection (ESourceSelector *selector);
+guint e_source_selector_count_total (ESourceSelector *selector);
+guint e_source_selector_count_selected(ESourceSelector *selector);
void e_source_selector_edit_primary_selection
(ESourceSelector *selector);
ESource * e_source_selector_ref_primary_selection
diff --git a/modules/calendar/e-cal-base-shell-sidebar.c b/modules/calendar/e-cal-base-shell-sidebar.c
index d3ce3e1..dc81a7e 100644
--- a/modules/calendar/e-cal-base-shell-sidebar.c
+++ b/modules/calendar/e-cal-base-shell-sidebar.c
@@ -215,6 +215,8 @@ cal_base_shell_sidebar_check_state (EShellSidebar *shell_sidebar)
g_object_unref (source);
}
+ if (e_source_selector_count_total (selector) == e_source_selector_count_selected (selector))
+ state |= E_CAL_BASE_SHELL_SIDEBAR_ALL_SOURCES_SELECTED;
if (has_primary_source)
state |= E_CAL_BASE_SHELL_SIDEBAR_HAS_PRIMARY_SOURCE;
if (is_writable)
diff --git a/modules/calendar/e-cal-base-shell-sidebar.h b/modules/calendar/e-cal-base-shell-sidebar.h
index 6ef73fc..e33746f 100644
--- a/modules/calendar/e-cal-base-shell-sidebar.h
+++ b/modules/calendar/e-cal-base-shell-sidebar.h
@@ -56,7 +56,8 @@ enum {
E_CAL_BASE_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_CREATABLE = 1 << 3,
E_CAL_BASE_SHELL_SIDEBAR_PRIMARY_SOURCE_IS_REMOTE_DELETABLE = 1 << 4,
E_CAL_BASE_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION = 1 << 5,
- E_CAL_BASE_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH = 1 << 6
+ E_CAL_BASE_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH = 1 << 6,
+ E_CAL_BASE_SHELL_SIDEBAR_ALL_SOURCES_SELECTED = 1 << 7
};
struct _ECalBaseShellSidebar {
diff --git a/modules/calendar/e-cal-shell-view-actions.c b/modules/calendar/e-cal-shell-view-actions.c
index adac448..bc40565 100644
--- a/modules/calendar/e-cal-shell-view-actions.c
+++ b/modules/calendar/e-cal-shell-view-actions.c
@@ -424,6 +424,19 @@ action_calendar_search_stop_cb (GtkAction *action,
}
static void
+action_calendar_select_all_cb (GtkAction *action,
+ ECalShellView *cal_shell_view)
+{
+ ECalBaseShellSidebar *cal_shell_sidebar;
+ ESourceSelector *selector;
+
+ cal_shell_sidebar = cal_shell_view->priv->cal_shell_sidebar;
+ selector = e_cal_base_shell_sidebar_get_selector (cal_shell_sidebar);
+
+ e_source_selector_select_all (selector);
+}
+
+static void
action_calendar_select_one_cb (GtkAction *action,
ECalShellView *cal_shell_view)
{
@@ -1309,6 +1322,13 @@ static GtkActionEntry calendar_entries[] = {
N_("Stop currently running search"),
G_CALLBACK (action_calendar_search_stop_cb) },
+ { "calendar-select-all",
+ "stock_check-filled",
+ N_("Sho_w All Calendars"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ G_CALLBACK (action_calendar_select_all_cb) },
+
{ "calendar-select-one",
"stock_check-filled",
N_("Show _Only This Calendar"),
@@ -1483,6 +1503,10 @@ static EPopupActionEntry calendar_popup_entries[] = {
NULL,
"calendar-rename" },
+ { "calendar-popup-select-all",
+ NULL,
+ "calendar-select-all" },
+
{ "calendar-popup-select-one",
NULL,
"calendar-select-one" },
diff --git a/modules/calendar/e-cal-shell-view-actions.h b/modules/calendar/e-cal-shell-view-actions.h
index 4549845..cef460b 100644
--- a/modules/calendar/e-cal-shell-view-actions.h
+++ b/modules/calendar/e-cal-shell-view-actions.h
@@ -56,6 +56,8 @@
E_SHELL_WINDOW_ACTION ((window), "calendar-search-next")
#define E_SHELL_WINDOW_ACTION_CALENDAR_SEARCH_STOP(window) \
E_SHELL_WINDOW_ACTION ((window), "calendar-search-stop")
+#define E_SHELL_WINDOW_ACTION_CALENDAR_SELECT_ALL(window) \
+ E_SHELL_WINDOW_ACTION ((window), "calendar-select-all")
#define E_SHELL_WINDOW_ACTION_CALENDAR_SELECT_ONE(window) \
E_SHELL_WINDOW_ACTION ((window), "calendar-select-one")
#define E_SHELL_WINDOW_ACTION_CALENDAR_VIEW_DAY(window) \
diff --git a/modules/calendar/e-cal-shell-view.c b/modules/calendar/e-cal-shell-view.c
index bf29efc..139dc23 100644
--- a/modules/calendar/e-cal-shell-view.c
+++ b/modules/calendar/e-cal-shell-view.c
@@ -285,6 +285,7 @@ cal_shell_view_update_actions (EShellView *shell_view)
gboolean selection_can_delegate;
gboolean single_event_selected;
gboolean refresh_supported;
+ gboolean all_sources_selected;
/* Chain up to parent's update_actions() method. */
E_SHELL_VIEW_CLASS (e_cal_shell_view_parent_class)->
@@ -347,9 +348,15 @@ cal_shell_view_update_actions (EShellView *shell_view)
(state & E_CAL_BASE_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION);
refresh_supported =
(state & E_CAL_BASE_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH);
+ all_sources_selected =
+ (state & E_CAL_BASE_SHELL_SIDEBAR_ALL_SOURCES_SELECTED) != 0;
any_events_selected = (single_event_selected || multiple_events_selected);
+ action = ACTION (CALENDAR_SELECT_ALL);
+ sensitive = !all_sources_selected;
+ gtk_action_set_sensitive (action, sensitive);
+
action = ACTION (CALENDAR_COPY);
sensitive = has_primary_source;
gtk_action_set_sensitive (action, sensitive);
diff --git a/modules/calendar/e-memo-shell-view-actions.c b/modules/calendar/e-memo-shell-view-actions.c
index 7f40de1..c883b4d 100644
--- a/modules/calendar/e-memo-shell-view-actions.c
+++ b/modules/calendar/e-memo-shell-view-actions.c
@@ -298,6 +298,19 @@ action_memo_list_rename_cb (GtkAction *action,
}
static void
+action_memo_list_select_all_cb (GtkAction *action,
+ EMemoShellView *memo_shell_view)
+{
+ ECalBaseShellSidebar *memo_shell_sidebar;
+ ESourceSelector *selector;
+
+ memo_shell_sidebar = memo_shell_view->priv->memo_shell_sidebar;
+ selector = e_cal_base_shell_sidebar_get_selector (memo_shell_sidebar);
+
+ e_source_selector_select_all (selector);
+}
+
+static void
action_memo_list_select_one_cb (GtkAction *action,
EMemoShellView *memo_shell_view)
{
@@ -617,6 +630,13 @@ static GtkActionEntry memo_entries[] = {
NULL, /* XXX Add a tooltip! */
G_CALLBACK (action_memo_list_select_one_cb) },
+ { "memo-list-select-all",
+ "stock_check-filled",
+ N_("Sho_w All Memo Lists"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ G_CALLBACK (action_memo_list_select_all_cb) },
+
{ "memo-new",
"stock_insert-note",
N_("New _Memo"),
@@ -674,6 +694,10 @@ static EPopupActionEntry memo_popup_entries[] = {
NULL,
"memo-list-rename" },
+ { "memo-list-popup-select-all",
+ NULL,
+ "memo-list-select-all" },
+
{ "memo-list-popup-select-one",
NULL,
"memo-list-select-one" },
diff --git a/modules/calendar/e-memo-shell-view-actions.h b/modules/calendar/e-memo-shell-view-actions.h
index 572cfa9..e71a81c 100644
--- a/modules/calendar/e-memo-shell-view-actions.h
+++ b/modules/calendar/e-memo-shell-view-actions.h
@@ -64,6 +64,8 @@
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_ALL(window) \
+ E_SHELL_WINDOW_ACTION ((window), "memo-list-select-all")
#define E_SHELL_WINDOW_ACTION_MEMO_LIST_SELECT_ONE(window) \
E_SHELL_WINDOW_ACTION ((window), "memo-list-select-one")
diff --git a/modules/calendar/e-memo-shell-view.c b/modules/calendar/e-memo-shell-view.c
index 479d20d..1804e6b 100644
--- a/modules/calendar/e-memo-shell-view.c
+++ b/modules/calendar/e-memo-shell-view.c
@@ -168,6 +168,7 @@ memo_shell_view_update_actions (EShellView *shell_view)
gboolean single_memo_selected;
gboolean sources_are_editable;
gboolean refresh_supported;
+ gboolean all_sources_selected;
/* Chain up to parent's update_actions() method. */
E_SHELL_VIEW_CLASS (e_memo_shell_view_parent_class)->
@@ -202,9 +203,15 @@ memo_shell_view_update_actions (EShellView *shell_view)
(state & E_CAL_BASE_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION);
refresh_supported =
(state & E_CAL_BASE_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH);
+ all_sources_selected =
+ (state & E_CAL_BASE_SHELL_SIDEBAR_ALL_SOURCES_SELECTED) != 0;
any_memos_selected = (single_memo_selected || multiple_memos_selected);
+ action = ACTION (MEMO_LIST_SELECT_ALL);
+ sensitive = !all_sources_selected;
+ gtk_action_set_sensitive (action, sensitive);
+
action = ACTION (MEMO_DELETE);
sensitive = any_memos_selected && sources_are_editable;
gtk_action_set_sensitive (action, sensitive);
diff --git a/modules/calendar/e-task-shell-view-actions.c b/modules/calendar/e-task-shell-view-actions.c
index 29f8718..d7bc023 100644
--- a/modules/calendar/e-task-shell-view-actions.c
+++ b/modules/calendar/e-task-shell-view-actions.c
@@ -322,6 +322,19 @@ action_task_list_rename_cb (GtkAction *action,
}
static void
+action_task_list_select_all_cb (GtkAction *action,
+ ETaskShellView *task_shell_view)
+{
+ ECalBaseShellSidebar *task_shell_sidebar;
+ ESourceSelector *selector;
+
+ task_shell_sidebar = task_shell_view->priv->task_shell_sidebar;
+ selector = e_cal_base_shell_sidebar_get_selector (task_shell_sidebar);
+
+ e_source_selector_select_all (selector);
+}
+
+static void
action_task_list_select_one_cb (GtkAction *action,
ETaskShellView *task_shell_view)
{
@@ -736,6 +749,13 @@ static GtkActionEntry task_entries[] = {
N_("Rename the selected task list"),
G_CALLBACK (action_task_list_rename_cb) },
+ { "task-list-select-all",
+ "stock_check-filled",
+ N_("Sho_w All Task Lists"),
+ NULL,
+ NULL, /* XXX Add a tooltip! */
+ G_CALLBACK (action_task_list_select_all_cb) },
+
{ "task-list-select-one",
"stock_check-filled",
N_("Show _Only This Task List"),
@@ -828,6 +848,10 @@ static EPopupActionEntry task_popup_entries[] = {
NULL,
"task-list-rename" },
+ { "task-list-popup-select-all",
+ NULL,
+ "task-list-select-all" },
+
{ "task-list-popup-select-one",
NULL,
"task-list-select-one" },
diff --git a/modules/calendar/e-task-shell-view-actions.h b/modules/calendar/e-task-shell-view-actions.h
index 81a0f7c..f8097e8 100644
--- a/modules/calendar/e-task-shell-view-actions.h
+++ b/modules/calendar/e-task-shell-view-actions.h
@@ -72,6 +72,8 @@
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_ALL(window) \
+ E_SHELL_WINDOW_ACTION ((window), "task-list-select-all")
#define E_SHELL_WINDOW_ACTION_TASK_LIST_SELECT_ONE(window) \
E_SHELL_WINDOW_ACTION ((window), "task-list-select-one")
diff --git a/modules/calendar/e-task-shell-view.c b/modules/calendar/e-task-shell-view.c
index e267b5c..c731b1f 100644
--- a/modules/calendar/e-task-shell-view.c
+++ b/modules/calendar/e-task-shell-view.c
@@ -261,6 +261,7 @@ task_shell_view_update_actions (EShellView *shell_view)
gboolean some_tasks_incomplete;
gboolean sources_are_editable;
gboolean refresh_supported;
+ gboolean all_sources_selected;
/* Chain up to parent's update_actions() method. */
E_SHELL_VIEW_CLASS (e_task_shell_view_parent_class)->update_actions (shell_view);
@@ -300,9 +301,15 @@ task_shell_view_update_actions (EShellView *shell_view)
(state & E_CAL_BASE_SHELL_SIDEBAR_PRIMARY_SOURCE_IN_COLLECTION);
refresh_supported =
(state & E_CAL_BASE_SHELL_SIDEBAR_SOURCE_SUPPORTS_REFRESH);
+ all_sources_selected =
+ (state & E_CAL_BASE_SHELL_SIDEBAR_ALL_SOURCES_SELECTED) != 0;
any_tasks_selected = (single_task_selected || multiple_tasks_selected);
+ action = ACTION (TASK_LIST_SELECT_ALL);
+ sensitive = !all_sources_selected;
+ gtk_action_set_sensitive (action, sensitive);
+
action = ACTION (TASK_ASSIGN);
sensitive =
single_task_selected && sources_are_editable &&
diff --git a/ui/evolution-calendars.ui b/ui/evolution-calendars.ui
index f9978d1..bef4b85 100644
--- a/ui/evolution-calendars.ui
+++ b/ui/evolution-calendars.ui
@@ -68,6 +68,7 @@
<separator/>
<menuitem action='calendar-popup-delete'/>
<menuitem action='calendar-popup-select-one'/>
+ <menuitem action='calendar-popup-select-all'/>
<placeholder name='calendar-popup-actions'/>
<separator/>
<menuitem action='calendar-popup-manage-groups'/>
diff --git a/ui/evolution-memos.ui b/ui/evolution-memos.ui
index 2f34206..0a2c3d8 100644
--- a/ui/evolution-memos.ui
+++ b/ui/evolution-memos.ui
@@ -65,6 +65,7 @@
<separator/>
<menuitem action='memo-list-popup-delete'/>
<menuitem action='memo-list-popup-select-one'/>
+ <menuitem action='memo-list-popup-select-all'/>
<placeholder name='memo-list-popup-actions'/>
<separator/>
<menuitem action='memo-list-popup-manage-groups'/>
diff --git a/ui/evolution-tasks.ui b/ui/evolution-tasks.ui
index 2fc2d01..acef77f 100644
--- a/ui/evolution-tasks.ui
+++ b/ui/evolution-tasks.ui
@@ -78,6 +78,7 @@
<separator/>
<menuitem action='task-list-popup-delete'/>
<menuitem action='task-list-popup-select-one'/>
+ <menuitem action='task-list-popup-select-all'/>
<placeholder name='task-list-popup-actions'/>
<separator/>
<menuitem action='task-list-popup-manage-groups'/>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]