aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
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 /addressbook
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 'addressbook')
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.c230
-rw-r--r--addressbook/gui/widgets/e-addressbook-view.h4
2 files changed, 154 insertions, 80 deletions
diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c
index a48ea8c351..91fdb16e4b 100644
--- a/addressbook/gui/widgets/e-addressbook-view.c
+++ b/addressbook/gui/widgets/e-addressbook-view.c
@@ -28,6 +28,7 @@
#include <table/e-table-model.h>
#include <table/e-cell-date.h>
#include <misc/e-gui-utils.h>
+#include <misc/e-selectable.h>
#include <widgets/menus/gal-view-factory-etable.h>
#include <filter/e-rule-editor.h>
#include <widgets/menus/gal-view-etable.h>
@@ -539,6 +540,140 @@ addressbook_view_constructed (GObject *object)
}
static void
+addressbook_view_update_actions (ESelectable *selectable,
+ EFocusTracker *focus_tracker,
+ GdkAtom *clipboard_targets,
+ gint n_clipboard_targets)
+{
+ EAddressbookView *view;
+ EAddressbookModel *model;
+ ESelectionModel *selection_model;
+ GtkAction *action;
+ gboolean clipboard_has_directory;
+ gboolean source_is_editable;
+ gboolean sensitive;
+ const gchar *tooltip;
+ gint n_contacts;
+ gint n_selected;
+
+ view = E_ADDRESSBOOK_VIEW (selectable);
+ model = e_addressbook_view_get_model (view);
+ selection_model = e_addressbook_view_get_selection_model (view);
+
+ source_is_editable = e_addressbook_model_get_editable (model);
+ n_contacts = (selection_model != NULL) ?
+ e_selection_model_row_count (selection_model) : 0;
+ n_selected = (selection_model != NULL) ?
+ e_selection_model_selected_count (selection_model) : 0;
+
+ clipboard_has_directory = (clipboard_targets != NULL) &&
+ e_targets_include_directory (
+ clipboard_targets, n_clipboard_targets);
+
+ action = e_focus_tracker_get_cut_clipboard_action (focus_tracker);
+ sensitive = source_is_editable && (n_selected > 0);
+ tooltip = _("Cut selected contacts to the clipboard");
+ gtk_action_set_sensitive (action, sensitive);
+ gtk_action_set_tooltip (action, tooltip);
+
+ action = e_focus_tracker_get_copy_clipboard_action (focus_tracker);
+ sensitive = (n_selected > 0);
+ tooltip = _("Copy selected contacts to the clipboard");
+ gtk_action_set_sensitive (action, sensitive);
+ gtk_action_set_tooltip (action, tooltip);
+
+ action = e_focus_tracker_get_paste_clipboard_action (focus_tracker);
+ sensitive = source_is_editable && clipboard_has_directory;
+ tooltip = _("Paste contacts from the clipboard");
+ gtk_action_set_sensitive (action, sensitive);
+ gtk_action_set_tooltip (action, tooltip);
+
+ action = e_focus_tracker_get_select_all_action (focus_tracker);
+ sensitive = (n_contacts > 0);
+ tooltip = _("Select all visible contacts");
+ gtk_action_set_sensitive (action, sensitive);
+ gtk_action_set_tooltip (action, tooltip);
+}
+
+static void
+addressbook_view_cut_clipboard (ESelectable *selectable)
+{
+ EAddressbookView *view;
+
+ view = E_ADDRESSBOOK_VIEW (selectable);
+
+ e_selectable_copy_clipboard (selectable);
+ e_addressbook_view_delete_selection (view, FALSE);
+}
+
+static void
+addressbook_view_copy_clipboard (ESelectable *selectable)
+{
+ EAddressbookView *view;
+ GtkClipboard *clipboard;
+ GList *contact_list;
+ gchar *string;
+
+ view = E_ADDRESSBOOK_VIEW (selectable);
+ clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+
+ contact_list = e_addressbook_view_get_selected (view);
+
+ string = eab_contact_list_to_string (contact_list);
+ e_clipboard_set_directory (clipboard, string, -1);
+ g_free (string);
+
+ g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
+ g_list_free (contact_list);
+}
+
+static void
+addressbook_view_paste_clipboard (ESelectable *selectable)
+{
+ EBook *book;
+ EAddressbookView *view;
+ EAddressbookModel *model;
+ GtkClipboard *clipboard;
+ GList *contact_list, *iter;
+ gchar *string;
+
+ view = E_ADDRESSBOOK_VIEW (selectable);
+ clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
+
+ if (!e_clipboard_wait_is_directory_available (clipboard))
+ return;
+
+ model = e_addressbook_view_get_model (view);
+ book = e_addressbook_model_get_book (model);
+
+ string = e_clipboard_wait_for_directory (clipboard);
+ contact_list = eab_contact_list_from_string (string);
+ g_free (string);
+
+ for (iter = contact_list; iter != NULL; iter = iter->next) {
+ EContact *contact = iter->data;
+
+ eab_merging_book_add_contact (book, contact, NULL, NULL);
+ }
+
+ g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
+ g_list_free (contact_list);
+}
+
+static void
+addressbook_view_select_all (ESelectable *selectable)
+{
+ EAddressbookView *view;
+ ESelectionModel *selection_model;
+
+ view = E_ADDRESSBOOK_VIEW (selectable);
+ selection_model = e_addressbook_view_get_selection_model (view);
+
+ if (selection_model != NULL)
+ e_selection_model_select_all (selection_model);
+}
+
+static void
addressbook_view_class_init (EAddressbookViewClass *class)
{
GObjectClass *object_class;
@@ -641,6 +776,16 @@ addressbook_view_init (EAddressbookView *view)
GTK_SCROLLED_WINDOW (view), GTK_SHADOW_IN);
}
+static void
+addressbook_view_selectable_init (ESelectableInterface *interface)
+{
+ interface->update_actions = addressbook_view_update_actions;
+ interface->cut_clipboard = addressbook_view_cut_clipboard;
+ interface->copy_clipboard = addressbook_view_copy_clipboard;
+ interface->paste_clipboard = addressbook_view_paste_clipboard;
+ interface->select_all = addressbook_view_select_all;
+}
+
GType
e_addressbook_view_get_type (void)
{
@@ -660,9 +805,18 @@ e_addressbook_view_get_type (void)
NULL /* value_table */
};
+ static const GInterfaceInfo selectable_info = {
+ (GInterfaceInitFunc) addressbook_view_selectable_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL /* interface_data */
+ };
+
type = g_type_register_static (
GTK_TYPE_SCROLLED_WINDOW, "EAddressbookView",
&type_info, 0);
+
+ g_type_add_interface_static (
+ type, E_TYPE_SELECTABLE, &selectable_info);
}
return type;
@@ -1238,82 +1392,6 @@ e_addressbook_view_view (EAddressbookView *view)
}
void
-e_addressbook_view_cut (EAddressbookView *view)
-{
- g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
-
- e_addressbook_view_copy (view);
- e_addressbook_view_delete_selection (view, FALSE);
-}
-
-void
-e_addressbook_view_copy (EAddressbookView *view)
-{
- GtkClipboard *clipboard;
- GList *contact_list;
- gchar *string;
-
- g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
-
- contact_list = e_addressbook_view_get_selected (view);
-
- string = eab_contact_list_to_string (contact_list);
- e_clipboard_set_directory (clipboard, string, -1);
- g_free (string);
-
- g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
- g_list_free (contact_list);
-}
-
-void
-e_addressbook_view_paste (EAddressbookView *view)
-{
- EBook *book;
- EAddressbookModel *model;
- GtkClipboard *clipboard;
- GList *contact_list, *iter;
- gchar *string;
-
- g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
-
- clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
-
- if (!e_clipboard_wait_is_directory_available (clipboard))
- return;
-
- model = e_addressbook_view_get_model (view);
- book = e_addressbook_model_get_book (model);
-
- string = e_clipboard_wait_for_directory (clipboard);
- contact_list = eab_contact_list_from_string (string);
- g_free (string);
-
- for (iter = contact_list; iter != NULL; iter = iter->next) {
- EContact *contact = iter->data;
-
- eab_merging_book_add_contact (book, contact, NULL, NULL);
- }
-
- g_list_foreach (contact_list, (GFunc) g_object_unref, NULL);
- g_list_free (contact_list);
-}
-
-void
-e_addressbook_view_select_all (EAddressbookView *view)
-{
- ESelectionModel *model;
-
- g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
-
- model = e_addressbook_view_get_selection_model (view);
- g_return_if_fail (model);
-
- e_selection_model_select_all (model);
-}
-
-void
e_addressbook_view_show_all (EAddressbookView *view)
{
g_return_if_fail (E_IS_ADDRESSBOOK_VIEW (view));
diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h
index 319d060b89..55f114a538 100644
--- a/addressbook/gui/widgets/e-addressbook-view.h
+++ b/addressbook/gui/widgets/e-addressbook-view.h
@@ -103,10 +103,6 @@ void e_addressbook_view_print (EAddressbookView *view,
void e_addressbook_view_delete_selection
(EAddressbookView *view,
gboolean is_delete);
-void e_addressbook_view_cut (EAddressbookView *view);
-void e_addressbook_view_copy (EAddressbookView *view);
-void e_addressbook_view_paste (EAddressbookView *view);
-void e_addressbook_view_select_all (EAddressbookView *view);
void e_addressbook_view_show_all (EAddressbookView *view);
void e_addressbook_view_stop (EAddressbookView *view);
void e_addressbook_view_copy_to_folder