aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui/dialogs
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 /calendar/gui/dialogs
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 'calendar/gui/dialogs')
-rw-r--r--calendar/gui/dialogs/comp-editor.c153
-rw-r--r--calendar/gui/dialogs/comp-editor.h2
2 files changed, 79 insertions, 76 deletions
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index 18bd574728..21384032d9 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -80,6 +80,9 @@ struct _CompEditorPrivate {
gpointer shell; /* weak pointer */
+ /* EFocusTracker keeps selection actions up-to-date. */
+ EFocusTracker *focus_tracker;
+
/* Each CompEditor window gets its own GtkWindowGroup, so it
* doesn't block the main window or other CompEditor windows. */
GtkWindowGroup *window_group;
@@ -133,6 +136,7 @@ enum {
PROP_CHANGED,
PROP_CLIENT,
PROP_FLAGS,
+ PROP_FOCUS_TRACKER,
PROP_SHELL,
PROP_SUMMARY
};
@@ -149,9 +153,10 @@ static const gchar *ui =
" <menuitem action='close'/>"
" </menu>"
" <menu action='edit-menu'>"
-" <menuitem action='cut'/>"
-" <menuitem action='copy'/>"
-" <menuitem action='paste'/>"
+" <menuitem action='cut-clipboard'/>"
+" <menuitem action='copy-clipboard'/>"
+" <menuitem action='paste-clipboard'/>"
+" <menuitem action='delete-selection'/>"
" <separator/>"
" <menuitem action='select-all'/>"
" </menu>"
@@ -677,36 +682,6 @@ action_close_cb (GtkAction *action,
}
static void
-action_copy_cb (GtkAction *action,
- CompEditor *editor)
-{
- GtkWidget *focus;
-
- focus = gtk_window_get_focus (GTK_WINDOW (editor));
-
- if (GTK_IS_ENTRY (focus))
- gtk_editable_copy_clipboard (GTK_EDITABLE (focus));
-
- if (GTK_IS_TEXT_VIEW (focus))
- g_signal_emit_by_name (focus, "copy-clipboard");
-}
-
-static void
-action_cut_cb (GtkAction *action,
- CompEditor *editor)
-{
- GtkWidget *focus;
-
- focus = gtk_window_get_focus (GTK_WINDOW (editor));
-
- if (GTK_IS_ENTRY (focus))
- gtk_editable_cut_clipboard (GTK_EDITABLE (focus));
-
- if (GTK_IS_TEXT_VIEW (focus))
- g_signal_emit_by_name (focus, "cut-clipboard");
-}
-
-static void
action_help_cb (GtkAction *action,
CompEditor *editor)
{
@@ -714,21 +689,6 @@ action_help_cb (GtkAction *action,
}
static void
-action_paste_cb (GtkAction *action,
- CompEditor *editor)
-{
- GtkWidget *focus;
-
- focus = gtk_window_get_focus (GTK_WINDOW (editor));
-
- if (GTK_IS_ENTRY (focus))
- gtk_editable_paste_clipboard (GTK_EDITABLE (focus));
-
- if (GTK_IS_TEXT_VIEW (focus))
- g_signal_emit_by_name (focus, "paste-clipboard");
-}
-
-static void
action_print_cb (GtkAction *action,
CompEditor *editor)
{
@@ -886,23 +846,6 @@ action_save_cb (GtkAction *action,
}
static void
-action_select_all_cb (GtkAction *action,
- CompEditor *editor)
-{
- GtkWidget *focus;
-
- focus = gtk_window_get_focus (GTK_WINDOW (editor));
-
- if (GTK_IS_ENTRY (focus)) {
- gtk_editable_set_position (GTK_EDITABLE (focus), -1);
- gtk_editable_select_region (GTK_EDITABLE (focus), 0, -1);
- }
-
- if (GTK_IS_TEXT_VIEW (focus))
- g_signal_emit_by_name (focus, "select-all", TRUE);
-}
-
-static void
action_view_categories_cb (GtkToggleAction *action,
CompEditor *editor)
{
@@ -995,19 +938,26 @@ static GtkActionEntry core_entries[] = {
N_("Click here to close the current window"),
G_CALLBACK (action_close_cb) },
- { "copy",
+ { "copy-clipboard",
GTK_STOCK_COPY,
NULL,
NULL,
- N_("Copy selected text to the clipboard"),
- G_CALLBACK (action_copy_cb) },
+ N_("Copy the selection"),
+ NULL }, /* Handled by EFocusTracker */
- { "cut",
+ { "cut-clipboard",
GTK_STOCK_CUT,
NULL,
NULL,
- N_("Cut selected text to the clipboard"),
- G_CALLBACK (action_cut_cb) },
+ N_("Cut the selection"),
+ NULL }, /* Handled by EFocusTracker */
+
+ { "delete-selection",
+ GTK_STOCK_DELETE,
+ NULL,
+ NULL,
+ N_("Delete the selection"),
+ NULL }, /* Handled by EFocusTracker */
{ "help",
GTK_STOCK_HELP,
@@ -1016,12 +966,12 @@ static GtkActionEntry core_entries[] = {
N_("Click here to view help available"),
G_CALLBACK (action_help_cb) },
- { "paste",
+ { "paste-clipboard",
GTK_STOCK_PASTE,
NULL,
NULL,
- N_("Paste text from the clipboard"),
- G_CALLBACK (action_paste_cb) },
+ N_("Paste the clipboard"),
+ NULL }, /* Handled by EFocusTracker */
{ "print",
GTK_STOCK_PRINT,
@@ -1047,9 +997,9 @@ static GtkActionEntry core_entries[] = {
{ "select-all",
GTK_STOCK_SELECT_ALL,
NULL,
- NULL,
+ "<Control>a",
N_("Select all text"),
- G_CALLBACK (action_select_all_cb) },
+ NULL }, /* Handled by EFocusTracker */
/* Menus */
@@ -1302,6 +1252,12 @@ comp_editor_get_property (GObject *object,
COMP_EDITOR (object)));
return;
+ case PROP_FOCUS_TRACKER:
+ g_value_set_object (
+ value, comp_editor_get_focus_tracker (
+ COMP_EDITOR (object)));
+ return;
+
case PROP_SHELL:
g_value_set_object (
value, comp_editor_get_shell (
@@ -1331,6 +1287,11 @@ comp_editor_dispose (GObject *object)
priv->shell = NULL;
}
+ if (priv->focus_tracker != NULL) {
+ g_object_unref (priv->focus_tracker);
+ priv->focus_tracker = NULL;
+ }
+
if (priv->window_group != NULL) {
g_object_unref (priv->window_group);
priv->window_group = NULL;
@@ -1566,6 +1527,16 @@ comp_editor_class_init (CompEditorClass *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_SHELL,
g_param_spec_object (
"shell",
@@ -1601,6 +1572,7 @@ comp_editor_init (CompEditor *editor)
CompEditorPrivate *priv;
EAttachmentView *view;
EAttachmentStore *store;
+ EFocusTracker *focus_tracker;
GdkDragAction drag_actions;
GtkTargetList *target_list;
GtkTargetEntry *targets;
@@ -1684,6 +1656,27 @@ comp_editor_init (CompEditor *editor)
priv->ui_manager, action_group, 0);
g_object_unref (action_group);
+ /* Configure an EFocusTracker to manage selection actions. */
+
+ focus_tracker = e_focus_tracker_new (GTK_WINDOW (editor));
+
+ action = comp_editor_get_action (editor, "cut-clipboard");
+ e_focus_tracker_set_cut_clipboard_action (focus_tracker, action);
+
+ action = comp_editor_get_action (editor, "copy-clipboard");
+ e_focus_tracker_set_copy_clipboard_action (focus_tracker, action);
+
+ action = comp_editor_get_action (editor, "paste-clipboard");
+ e_focus_tracker_set_paste_clipboard_action (focus_tracker, action);
+
+ action = comp_editor_get_action (editor, "delete-selection");
+ e_focus_tracker_set_delete_selection_action (focus_tracker, action);
+
+ action = comp_editor_get_action (editor, "select-all");
+ e_focus_tracker_set_select_all_action (focus_tracker, action);
+
+ priv->focus_tracker = focus_tracker;
+
/* Fine Tuning */
action = comp_editor_get_action (editor, "attach");
@@ -2093,6 +2086,14 @@ comp_editor_get_changed (CompEditor *editor)
return editor->priv->changed;
}
+EFocusTracker *
+comp_editor_get_focus_tracker (CompEditor *editor)
+{
+ g_return_val_if_fail (IS_COMP_EDITOR (editor), NULL);
+
+ return editor->priv->focus_tracker;
+}
+
void
comp_editor_set_flags (CompEditor *editor,
CompEditorFlags flags)
diff --git a/calendar/gui/dialogs/comp-editor.h b/calendar/gui/dialogs/comp-editor.h
index 0b3ea047e7..54672ec3b8 100644
--- a/calendar/gui/dialogs/comp-editor.h
+++ b/calendar/gui/dialogs/comp-editor.h
@@ -30,6 +30,7 @@
#include "../itip-utils.h"
#include "comp-editor-page.h"
#include <shell/e-shell.h>
+#include <misc/e-focus-tracker.h>
/* Standard GObject macros */
#define TYPE_COMP_EDITOR \
@@ -92,6 +93,7 @@ GType comp_editor_get_type (void);
void comp_editor_set_changed (CompEditor *editor,
gboolean changed);
gboolean comp_editor_get_changed (CompEditor *editor);
+EFocusTracker * comp_editor_get_focus_tracker (CompEditor *editor);
void comp_editor_set_needs_send (CompEditor *editor,
gboolean needs_send);
gboolean comp_editor_get_needs_send (CompEditor *editor);