Bug 758752 - "Show all calendars" as a way of undoing "Show only this calendar"

This commit is contained in:
Milan Crha
2015-11-30 17:10:59 +01:00
parent 1d59ac9e28
commit 2f90fcb9f3
17 changed files with 235 additions and 1 deletions

View File

@ -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

View File

@ -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
@ -2349,6 +2436,42 @@ e_source_selector_select_exclusive (ESourceSelector *selector,
g_signal_emit (selector, signals[SELECTION_CHANGED], 0);
}
/**
* 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

View File

@ -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

View File

@ -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)

View File

@ -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 {

View File

@ -423,6 +423,19 @@ action_calendar_search_stop_cb (GtkAction *action,
e_cal_shell_view_search_stop (cal_shell_view);
}
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" },

View File

@ -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) \

View File

@ -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);

View File

@ -297,6 +297,19 @@ action_memo_list_rename_cb (GtkAction *action,
e_source_selector_edit_primary_selection (selector);
}
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" },

View File

@ -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")

View File

@ -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);

View File

@ -321,6 +321,19 @@ action_task_list_rename_cb (GtkAction *action,
e_source_selector_edit_primary_selection (selector);
}
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" },

View File

@ -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")

View File

@ -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 &&

View File

@ -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'/>

View File

@ -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'/>

View File

@ -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'/>