diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2009-12-08 00:31:17 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2009-12-26 04:42:17 +0800 |
commit | abc0e4c694fb3d9624e890384880def730769fa0 (patch) | |
tree | 8d411f90f4edb0859ffe0b260c85e02e7d273088 /widgets/misc/e-signature-editor.c | |
parent | 83dc7625983470bff4ce8b9070fbc23c3370c472 (diff) | |
download | gsoc2013-evolution-abc0e4c694fb3d9624e890384880def730769fa0.tar.gz 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-signature-editor.c')
-rw-r--r-- | widgets/misc/e-signature-editor.c | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/widgets/misc/e-signature-editor.c b/widgets/misc/e-signature-editor.c index 9266425494..91a4d81c8d 100644 --- a/widgets/misc/e-signature-editor.c +++ b/widgets/misc/e-signature-editor.c @@ -26,6 +26,7 @@ #include <e-util/e-alert-dialog.h> #include <e-util/e-signature-utils.h> +#include <misc/e-web-view.h> #define E_SIGNATURE_EDITOR_GET_PRIVATE(obj) \ (G_TYPE_INSTANCE_GET_PRIVATE \ @@ -33,11 +34,13 @@ enum { PROP_0, + PROP_FOCUS_TRACKER, PROP_SIGNATURE }; struct _ESignatureEditorPrivate { GtkActionGroup *action_group; + EFocusTracker *focus_tracker; ESignature *signature; GtkWidget *entry; gchar *original_name; @@ -255,6 +258,12 @@ signature_editor_get_property (GObject *object, GParamSpec *pspec) { switch (property_id) { + case PROP_FOCUS_TRACKER: + g_value_set_object ( + value, e_signature_editor_get_focus_tracker ( + E_SIGNATURE_EDITOR (object))); + return; + case PROP_SIGNATURE: g_value_set_object ( value, e_signature_editor_get_signature ( @@ -277,6 +286,11 @@ signature_editor_dispose (GObject *object) priv->action_group = NULL; } + if (priv->focus_tracker != NULL) { + g_object_unref (priv->focus_tracker); + priv->focus_tracker = NULL; + } + if (priv->signature != NULL) { g_object_unref (priv->signature); priv->signature = NULL; @@ -320,6 +334,16 @@ signature_editor_class_init (ESignatureEditorClass *class) g_object_class_install_property ( object_class, + PROP_FOCUS_TRACKER, + g_param_spec_object ( + "focus-tracker", + NULL, + NULL, + E_TYPE_FOCUS_TRACKER, + G_PARAM_READABLE)); + + g_object_class_install_property ( + object_class, PROP_SIGNATURE, g_param_spec_object ( "signature", @@ -333,7 +357,10 @@ static void signature_editor_init (ESignatureEditor *editor) { GtkActionGroup *action_group; + EFocusTracker *focus_tracker; + GtkhtmlEditor *gtkhtml_editor; GtkUIManager *ui_manager; + GtkAction *action; GtkWidget *container; GtkWidget *widget; GtkWidget *vbox; @@ -342,7 +369,8 @@ signature_editor_init (ESignatureEditor *editor) editor->priv = E_SIGNATURE_EDITOR_GET_PRIVATE (editor); vbox = GTKHTML_EDITOR (editor)->vbox; - ui_manager = gtkhtml_editor_get_ui_manager (GTKHTML_EDITOR (editor)); + gtkhtml_editor = GTKHTML_EDITOR (editor); + ui_manager = gtkhtml_editor_get_ui_manager (gtkhtml_editor); gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, &error); handle_error (&error); @@ -383,6 +411,28 @@ signature_editor_init (ESignatureEditor *editor) G_CALLBACK (signature_editor_delete_event_cb), NULL); e_signature_editor_set_signature (editor, NULL); + + /* Configure an EFocusTracker to manage selection actions. + * + * XXX GtkhtmlEditor does not manage its own selection actions, + * which is technically a bug but works in our favor here + * because it won't cause any conflicts with EFocusTracker. */ + + focus_tracker = e_focus_tracker_new (GTK_WINDOW (editor)); + + action = gtkhtml_editor_get_action (gtkhtml_editor, "cut"); + e_focus_tracker_set_cut_clipboard_action (focus_tracker, action); + + action = gtkhtml_editor_get_action (gtkhtml_editor, "copy"); + e_focus_tracker_set_copy_clipboard_action (focus_tracker, action); + + action = gtkhtml_editor_get_action (gtkhtml_editor, "paste"); + e_focus_tracker_set_paste_clipboard_action (focus_tracker, action); + + action = gtkhtml_editor_get_action (gtkhtml_editor, "select-all"); + e_focus_tracker_set_select_all_action (focus_tracker, action); + + editor->priv->focus_tracker = focus_tracker; } GType @@ -415,7 +465,17 @@ e_signature_editor_get_type (void) GtkWidget * e_signature_editor_new (void) { - return g_object_new (E_TYPE_SIGNATURE_EDITOR, NULL); + return g_object_new ( + E_TYPE_SIGNATURE_EDITOR, + "html", e_web_view_new (), NULL); +} + +EFocusTracker * +e_signature_editor_get_focus_tracker (ESignatureEditor *editor) +{ + g_return_val_if_fail (E_IS_SIGNATURE_EDITOR (editor), NULL); + + return editor->priv->focus_tracker; } ESignature * |