aboutsummaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2009-12-08 00:31:17 +0800
committerMatthew Barnes <mbarnes@redhat.com>2009-12-26 04:42:17 +0800
commitabc0e4c694fb3d9624e890384880def730769fa0 (patch)
tree8d411f90f4edb0859ffe0b260c85e02e7d273088 /shell
parent83dc7625983470bff4ce8b9070fbc23c3370c472 (diff)
downloadgsoc2013-evolution-abc0e4c694fb3d9624e890384880def730769fa0.tar
gsoc2013-evolution-abc0e4c694fb3d9624e890384880def730769fa0.tar.gz
gsoc2013-evolution-abc0e4c694fb3d9624e890384880def730769fa0.tar.bz2
gsoc2013-evolution-abc0e4c694fb3d9624e890384880def730769fa0.tar.lz
gsoc2013-evolution-abc0e4c694fb3d9624e890384880def730769fa0.tar.xz
gsoc2013-evolution-abc0e4c694fb3d9624e890384880def730769fa0.tar.zst
gsoc2013-evolution-abc0e4c694fb3d9624e890384880def730769fa0.zip
Introduce ESelectable and EFocusTracker.
EFocusTracker tracks the input focus within a window and helps keep the sensitivity of "selectable" actions in the main menu up-to-date. Selectable actions include Cut, Copy, Paste, Select All and Delete. EFocusTracker has built-in support for widgets that implement the GtkEditable interface such as GtkEntry and GtkTextView. It also supports custom widgets that implement the ESelectable interface, which is a subset of GtkEditable and can apply to anything that displays selectable content (esp. tree views and ETables). This commit integrates EFocusTracker with EShellWindow, CompEditor, EMsgComposer, and ESignatureManager. It also bumps the GtkHTML requirement to 2.29.5 to utilize the new GtkhtmlEditor:html constructor property.
Diffstat (limited to 'shell')
-rw-r--r--shell/e-shell-view.c45
-rw-r--r--shell/e-shell-window-actions.c73
-rw-r--r--shell/e-shell-window-actions.h10
-rw-r--r--shell/e-shell-window-private.c1
-rw-r--r--shell/e-shell-window-private.h2
-rw-r--r--shell/e-shell-window.c40
-rw-r--r--shell/e-shell-window.h2
7 files changed, 157 insertions, 16 deletions
diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c
index d87f8b7632..fdffe92fd6 100644
--- a/shell/e-shell-view.c
+++ b/shell/e-shell-view.c
@@ -507,21 +507,6 @@ shell_view_constructed (GObject *object)
}
static void
-shell_view_clear_search (EShellView *shell_view)
-{
- e_shell_view_set_search_rule (shell_view, NULL);
- e_shell_view_execute_search (shell_view);
-}
-
-static void
-shell_view_custom_search (EShellView *shell_view,
- EFilterRule *custom_rule)
-{
- e_shell_view_set_search_rule (shell_view, custom_rule);
- e_shell_view_execute_search (shell_view);
-}
-
-static void
shell_view_toggled (EShellView *shell_view)
{
EShellViewPrivate *priv = shell_view->priv;
@@ -553,6 +538,33 @@ shell_view_toggled (EShellView *shell_view)
}
static void
+shell_view_clear_search (EShellView *shell_view)
+{
+ e_shell_view_set_search_rule (shell_view, NULL);
+ e_shell_view_execute_search (shell_view);
+}
+
+static void
+shell_view_custom_search (EShellView *shell_view,
+ EFilterRule *custom_rule)
+{
+ e_shell_view_set_search_rule (shell_view, custom_rule);
+ e_shell_view_execute_search (shell_view);
+}
+
+static void
+shell_view_update_actions (EShellView *shell_view)
+{
+ EShellWindow *shell_window;
+ EFocusTracker *focus_tracker;
+
+ shell_window = e_shell_view_get_shell_window (shell_view);
+ focus_tracker = e_shell_window_get_focus_tracker (shell_window);
+
+ e_focus_tracker_update_actions (focus_tracker);
+}
+
+static void
shell_view_class_init (EShellViewClass *class)
{
GObjectClass *object_class;
@@ -574,9 +586,10 @@ shell_view_class_init (EShellViewClass *class)
class->new_shell_sidebar = e_shell_sidebar_new;
class->new_shell_taskbar = e_shell_taskbar_new;
+ class->toggled = shell_view_toggled;
class->clear_search = shell_view_clear_search;
class->custom_search = shell_view_custom_search;
- class->toggled = shell_view_toggled;
+ class->update_actions = shell_view_update_actions;
/**
* EShellView:action:
diff --git a/shell/e-shell-window-actions.c b/shell/e-shell-window-actions.c
index 4483347beb..5cdf2a932f 100644
--- a/shell/e-shell-window-actions.c
+++ b/shell/e-shell-window-actions.c
@@ -1437,6 +1437,27 @@ static GtkActionEntry shell_entries[] = {
N_("Open the Evolution User Guide"),
G_CALLBACK (action_contents_cb) },
+ { "copy-clipboard",
+ GTK_STOCK_COPY,
+ NULL,
+ NULL,
+ N_("Copy the selection"),
+ NULL }, /* Handled by EFocusTracker */
+
+ { "cut-clipboard",
+ GTK_STOCK_CUT,
+ NULL,
+ NULL,
+ N_("Cut the selection"),
+ NULL }, /* Handled by EFocusTracker */
+
+ { "delete-selection",
+ GTK_STOCK_DELETE,
+ NULL,
+ NULL,
+ N_("Delete the selection"),
+ NULL }, /* Handled by EFocusTracker */
+
{ "faq",
"help-faq",
N_("Evolution _FAQ"),
@@ -1465,6 +1486,13 @@ static GtkActionEntry shell_entries[] = {
N_("Create a new window displaying this view"),
G_CALLBACK (action_new_window_cb) },
+ { "paste-clipboard",
+ GTK_STOCK_PASTE,
+ NULL,
+ NULL,
+ N_("Paste the clipboard"),
+ NULL }, /* Handled by EFocusTracker */
+
{ "preferences",
GTK_STOCK_PREFERENCES,
NULL,
@@ -1528,6 +1556,13 @@ static GtkActionEntry shell_entries[] = {
N_("Save the current search parameters"),
G_CALLBACK (action_search_save_cb) },
+ { "select-all",
+ GTK_STOCK_SELECT_ALL,
+ NULL,
+ "<Control>a",
+ N_("Select all text"),
+ NULL }, /* Handled by EFocusTracker */
+
{ "send-receive",
"mail-send-receive",
N_("Send / _Receive"),
@@ -1629,6 +1664,25 @@ static GtkActionEntry shell_entries[] = {
NULL }
};
+static EPopupActionEntry shell_popup_entries[] = {
+
+ { "popup-copy-clipboard",
+ NULL,
+ "copy-clipboard" },
+
+ { "popup-cut-clipboard",
+ NULL,
+ "cut-clipboard" },
+
+ { "popup-delete-selection",
+ NULL,
+ "delete-selection" },
+
+ { "popup-paste-clipboard",
+ NULL,
+ "paste-clipboard" }
+};
+
static GtkToggleActionEntry shell_toggle_entries[] = {
{ "show-sidebar",
@@ -1811,6 +1865,7 @@ void
e_shell_window_actions_init (EShellWindow *shell_window)
{
GtkActionGroup *action_group;
+ EFocusTracker *focus_tracker;
GtkUIManager *ui_manager;
g_return_if_fail (E_IS_SHELL_WINDOW (shell_window));
@@ -1824,6 +1879,9 @@ e_shell_window_actions_init (EShellWindow *shell_window)
gtk_action_group_add_actions (
action_group, shell_entries,
G_N_ELEMENTS (shell_entries), shell_window);
+ e_action_group_add_popup_actions (
+ action_group, shell_popup_entries,
+ G_N_ELEMENTS (shell_popup_entries));
gtk_action_group_add_toggle_actions (
action_group, shell_toggle_entries,
G_N_ELEMENTS (shell_toggle_entries), shell_window);
@@ -1854,6 +1912,21 @@ e_shell_window_actions_init (EShellWindow *shell_window)
G_N_ELEMENTS (shell_lockdown_print_setup_entries),
shell_window);
+ /* Configure an EFocusTracker to manage selection actions. */
+
+ focus_tracker = e_focus_tracker_new (GTK_WINDOW (shell_window));
+ e_focus_tracker_set_cut_clipboard_action (
+ focus_tracker, ACTION (CUT_CLIPBOARD));
+ e_focus_tracker_set_copy_clipboard_action (
+ focus_tracker, ACTION (COPY_CLIPBOARD));
+ e_focus_tracker_set_paste_clipboard_action (
+ focus_tracker, ACTION (PASTE_CLIPBOARD));
+ e_focus_tracker_set_delete_selection_action (
+ focus_tracker, ACTION (DELETE_SELECTION));
+ e_focus_tracker_set_select_all_action (
+ focus_tracker, ACTION (SELECT_ALL));
+ shell_window->priv->focus_tracker = focus_tracker;
+
/* Fine tuning. */
gtk_action_set_sensitive (ACTION (SEARCH_QUICK), FALSE);
diff --git a/shell/e-shell-window-actions.h b/shell/e-shell-window-actions.h
index 8636b69648..4833ad0c9f 100644
--- a/shell/e-shell-window-actions.h
+++ b/shell/e-shell-window-actions.h
@@ -35,6 +35,12 @@
E_SHELL_WINDOW_ACTION ((window), "close")
#define E_SHELL_WINDOW_ACTION_CONTENTS(window) \
E_SHELL_WINDOW_ACTION ((window), "contents")
+#define E_SHELL_WINDOW_ACTION_COPY_CLIPBOARD(window) \
+ E_SHELL_WINDOW_ACTION ((window), "copy-clipboard")
+#define E_SHELL_WINDOW_ACTION_CUT_CLIPBOARD(window) \
+ E_SHELL_WINDOW_ACTION ((window), "cut-clipboard")
+#define E_SHELL_WINDOW_ACTION_DELETE_SELECTION(window) \
+ E_SHELL_WINDOW_ACTION ((window), "delete-selection")
#define E_SHELL_WINDOW_ACTION_FAQ(window) \
E_SHELL_WINDOW_ACTION ((window), "faq")
#define E_SHELL_WINDOW_ACTION_FORGET_PASSWORDS(window) \
@@ -51,6 +57,8 @@
E_SHELL_WINDOW_ACTION ((window), "new-window")
#define E_SHELL_WINDOW_ACTION_PAGE_SETUP(window) \
E_SHELL_WINDOW_ACTION ((window), "page-setup")
+#define E_SHELL_WINDOW_ACTION_PASTE_CLIPBOARD(window) \
+ E_SHELL_WINDOW_ACTION ((window), "paste-clipboard")
#define E_SHELL_WINDOW_ACTION_PREFERENCES(window) \
E_SHELL_WINDOW_ACTION ((window), "preferences")
#define E_SHELL_WINDOW_ACTION_QUICK_REFERENCE(window) \
@@ -69,6 +77,8 @@
E_SHELL_WINDOW_ACTION ((window), "search-quick")
#define E_SHELL_WINDOW_ACTION_SEARCH_SAVE(window) \
E_SHELL_WINDOW_ACTION ((window), "search-save")
+#define E_SHELL_WINDOW_ACTION_SELECT_ALL(window) \
+ E_SHELL_WINDOW_ACTION ((window), "select-all")
#define E_SHELL_WINDOW_ACTION_SEND_RECEIVE(window) \
E_SHELL_WINDOW_ACTION ((window), "send-receive")
#define E_SHELL_WINDOW_ACTION_SHOW_SIDEBAR(window) \
diff --git a/shell/e-shell-window-private.c b/shell/e-shell-window-private.c
index 0d9dda59cb..a2805f46bf 100644
--- a/shell/e-shell-window-private.c
+++ b/shell/e-shell-window-private.c
@@ -473,6 +473,7 @@ e_shell_window_private_dispose (EShellWindow *shell_window)
priv->shell = NULL;
}
+ DISPOSE (priv->focus_tracker);
DISPOSE (priv->ui_manager);
g_hash_table_remove_all (priv->loaded_views);
diff --git a/shell/e-shell-window-private.h b/shell/e-shell-window-private.h
index 635b6b6630..87e18646c4 100644
--- a/shell/e-shell-window-private.h
+++ b/shell/e-shell-window-private.h
@@ -34,6 +34,7 @@
#include <widgets/misc/e-import-assistant.h>
#include <widgets/misc/e-menu-tool-button.h>
#include <widgets/misc/e-online-button.h>
+#include <widgets/misc/e-popup-action.h>
#include <e-shell.h>
#include <e-shell-content.h>
@@ -70,6 +71,7 @@ struct _EShellWindowPrivate {
/*** UI Management ***/
+ EFocusTracker *focus_tracker;
GtkUIManager *ui_manager;
guint custom_rule_merge_id;
guint gal_view_merge_id;
diff --git a/shell/e-shell-window.c b/shell/e-shell-window.c
index 25b56caecb..d3d6107e24 100644
--- a/shell/e-shell-window.c
+++ b/shell/e-shell-window.c
@@ -29,6 +29,7 @@
enum {
PROP_0,
PROP_ACTIVE_VIEW,
+ PROP_FOCUS_TRACKER,
PROP_GEOMETRY,
PROP_SAFE_MODE,
PROP_SHELL,
@@ -234,6 +235,12 @@ shell_window_get_property (GObject *object,
E_SHELL_WINDOW (object)));
return;
+ case PROP_FOCUS_TRACKER:
+ g_value_set_object (
+ value, e_shell_window_get_focus_tracker (
+ E_SHELL_WINDOW (object)));
+ return;
+
case PROP_SAFE_MODE:
g_value_set_boolean (
value, e_shell_window_get_safe_mode (
@@ -609,6 +616,21 @@ shell_window_class_init (EShellWindowClass *class)
G_PARAM_READWRITE));
/**
+ * EShellWindow:focus-tracker
+ *
+ * The shell window's #EFocusTracker.
+ **/
+ g_object_class_install_property (
+ object_class,
+ PROP_FOCUS_TRACKER,
+ g_param_spec_object (
+ "focus-tracker",
+ _("Focus Tracker"),
+ _("The shell window's EFocusTracker"),
+ E_TYPE_FOCUS_TRACKER,
+ G_PARAM_READABLE));
+
+ /**
* EShellWindow:geometry
*
* User-specified initial window geometry string.
@@ -886,6 +908,24 @@ e_shell_window_get_shell_view_action (EShellWindow *shell_window,
}
/**
+ * e_shell_window_get_focus_tracker:
+ * @shell_window: an #EShellWindow
+ *
+ * Returns @shell_window<!-- -->'s focus tracker, which directs
+ * Cut, Copy, Paste and Select All main menu activations to the
+ * appropriate editable or selectable widget.
+ *
+ * Returns: the #EFocusTracker for @shell_window
+ **/
+EFocusTracker *
+e_shell_window_get_focus_tracker (EShellWindow *shell_window)
+{
+ g_return_val_if_fail (E_IS_SHELL_WINDOW (shell_window), NULL);
+
+ return shell_window->priv->focus_tracker;
+}
+
+/**
* e_shell_window_get_ui_manager:
* @shell_window: an #EShellWindow
*
diff --git a/shell/e-shell-window.h b/shell/e-shell-window.h
index bb88003955..4ac76ba5d4 100644
--- a/shell/e-shell-window.h
+++ b/shell/e-shell-window.h
@@ -29,6 +29,7 @@
#define E_SHELL_WINDOW_H
#include <shell/e-shell.h>
+#include <misc/e-focus-tracker.h>
/* Standard GObject macros */
#define E_TYPE_SHELL_WINDOW \
@@ -94,6 +95,7 @@ struct _EShellView *
GtkAction * e_shell_window_get_shell_view_action
(EShellWindow *shell_window,
const gchar *view_name);
+EFocusTracker * e_shell_window_get_focus_tracker(EShellWindow *shell_window);
GtkUIManager * e_shell_window_get_ui_manager (EShellWindow *shell_window);
GtkAction * e_shell_window_get_action (EShellWindow *shell_window,
const gchar *action_name);