aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/misc/e-web-view.c
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 /widgets/misc/e-web-view.c
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 'widgets/misc/e-web-view.c')
-rw-r--r--widgets/misc/e-web-view.c78
1 files changed, 71 insertions, 7 deletions
diff --git a/widgets/misc/e-web-view.c b/widgets/misc/e-web-view.c
index f52d7399eb..a873731014 100644
--- a/widgets/misc/e-web-view.c
+++ b/widgets/misc/e-web-view.c
@@ -33,6 +33,7 @@
#include "e-util/e-plugin-ui.h"
#include "e-popup-action.h"
+#include "e-selectable.h"
#define E_WEB_VIEW_GET_PRIVATE(obj) \
(G_TYPE_INSTANCE_GET_PRIVATE \
@@ -89,7 +90,7 @@ static guint signals[LAST_SIGNAL];
static const gchar *ui =
"<ui>"
" <popup name='context'>"
-" <menuitem action='clipboard-copy'/>"
+" <menuitem action='copy-clipboard'/>"
" <separator/>"
" <placeholder name='custom-actions-1'>"
" <menuitem action='open'/>"
@@ -240,10 +241,10 @@ web_view_request_read_cb (GFile *file,
}
static void
-action_clipboard_copy_cb (GtkAction *action,
+action_copy_clipboard_cb (GtkAction *action,
EWebView *web_view)
{
- e_web_view_clipboard_copy (web_view);
+ e_web_view_copy_clipboard (web_view);
}
static void
@@ -372,12 +373,12 @@ static GtkActionEntry mailto_entries[] = {
static GtkActionEntry selection_entries[] = {
- { "clipboard-copy",
+ { "copy-clipboard",
GTK_STOCK_COPY,
NULL,
NULL,
- N_("Copy the selection to the clipboard"),
- G_CALLBACK (action_clipboard_copy_cb) },
+ N_("Copy the selection"),
+ G_CALLBACK (action_copy_clipboard_cb) },
};
static GtkActionEntry standard_entries[] = {
@@ -859,6 +860,52 @@ web_view_update_actions (EWebView *web_view)
}
static void
+web_view_selectable_update_actions (ESelectable *selectable,
+ EFocusTracker *focus_tracker,
+ GdkAtom *clipboard_targets,
+ gint n_clipboard_targets)
+{
+ EWebView *web_view;
+ GtkAction *action;
+ const gchar *tooltip;
+ gboolean sensitive;
+
+ web_view = E_WEB_VIEW (selectable);
+
+ /* Copy Clipboard */
+
+ action = e_web_view_get_action (web_view, "copy-clipboard");
+ sensitive = gtk_action_get_sensitive (action);
+ tooltip = gtk_action_get_tooltip (action);
+
+ action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
+ gtk_action_set_sensitive (action, sensitive);
+ gtk_action_set_tooltip (action, tooltip);
+
+ /* Select All */
+
+ action = e_web_view_get_action (web_view, "select-all");
+ sensitive = gtk_action_get_sensitive (action);
+ tooltip = gtk_action_get_tooltip (action);
+
+ action = e_focus_tracker_get_select_all_action (focus_tracker);
+ gtk_action_set_sensitive (action, sensitive);
+ gtk_action_set_tooltip (action, tooltip);
+}
+
+static void
+web_view_selectable_copy_clipboard (ESelectable *selectable)
+{
+ e_web_view_copy_clipboard (E_WEB_VIEW (selectable));
+}
+
+static void
+web_view_selectable_select_all (ESelectable *selectable)
+{
+ e_web_view_select_all (E_WEB_VIEW (selectable));
+}
+
+static void
web_view_class_init (EWebViewClass *class)
{
GObjectClass *object_class;
@@ -1010,6 +1057,14 @@ web_view_class_init (EWebViewClass *class)
}
static void
+web_view_selectable_init (ESelectableInterface *interface)
+{
+ interface->update_actions = web_view_selectable_update_actions;
+ interface->copy_clipboard = web_view_selectable_copy_clipboard;
+ interface->select_all = web_view_selectable_select_all;
+}
+
+static void
web_view_init (EWebView *web_view)
{
GtkUIManager *ui_manager;
@@ -1140,8 +1195,17 @@ e_web_view_get_type (void)
NULL /* value_table */
};
+ static const GInterfaceInfo selectable_info = {
+ (GInterfaceInitFunc) web_view_selectable_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL /* interface_data */
+ };
+
type = g_type_register_static (
GTK_TYPE_HTML, "EWebView", &type_info, 0);
+
+ g_type_add_interface_static (
+ type, E_TYPE_SELECTABLE, &selectable_info);
}
return type;
@@ -1411,7 +1475,7 @@ e_web_view_extract_uri (EWebView *web_view,
}
void
-e_web_view_clipboard_copy (EWebView *web_view)
+e_web_view_copy_clipboard (EWebView *web_view)
{
g_return_if_fail (E_IS_WEB_VIEW (web_view));