aboutsummaryrefslogtreecommitdiffstats
path: root/mail
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 /mail
parent83dc7625983470bff4ce8b9070fbc23c3370c472 (diff)
downloadgsoc2013-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 'mail')
-rw-r--r--mail/e-mail-reader.c83
-rw-r--r--mail/message-list.c106
-rw-r--r--mail/message-list.h111
3 files changed, 150 insertions, 150 deletions
diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c
index 6dae4ded13..9b7cc4d887 100644
--- a/mail/e-mail-reader.c
+++ b/mail/e-mail-reader.c
@@ -166,19 +166,6 @@ action_mail_check_for_junk_cb (GtkAction *action,
}
static void
-action_mail_clipboard_copy_cb (GtkAction *action,
- EMailReader *reader)
-{
- EMFormatHTMLDisplay *html_display;
- EWebView *web_view;
-
- html_display = e_mail_reader_get_html_display (reader);
- web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
-
- e_web_view_clipboard_copy (web_view);
-}
-
-static void
action_mail_copy_cb (GtkAction *action,
EMailReader *reader)
{
@@ -875,26 +862,6 @@ action_mail_search_folder_from_subject_cb (GtkAction *action,
}
static void
-action_mail_select_all_cb (GtkAction *action,
- EMailReader *reader)
-{
- EMFormatHTMLDisplay *html_display;
- EWebView *web_view;
- const gchar *action_name;
- gboolean selection_active;
-
- html_display = e_mail_reader_get_html_display (reader);
- web_view = E_WEB_VIEW (EM_FORMAT_HTML (html_display)->html);
-
- e_web_view_select_all (web_view);
-
- action_name = "mail-clipboard-copy";
- action = e_mail_reader_get_action (reader, action_name);
- selection_active = e_web_view_is_selection_active (web_view);
- gtk_action_set_sensitive (action, selection_active);
-}
-
-static void
action_mail_show_all_headers_cb (GtkToggleAction *action,
EMailReader *reader)
{
@@ -1112,13 +1079,6 @@ static GtkActionEntry mail_reader_entries[] = {
N_("Filter the selected messages for junk status"),
G_CALLBACK (action_mail_check_for_junk_cb) },
- { "mail-clipboard-copy",
- GTK_STOCK_COPY,
- NULL,
- NULL,
- N_("Copy selected messages to the clipboard"),
- G_CALLBACK (action_mail_clipboard_copy_cb) },
-
{ "mail-copy",
"mail-copy",
N_("_Copy to Folder..."),
@@ -1441,13 +1401,6 @@ static GtkActionEntry mail_reader_entries[] = {
N_("Create a search folder for this subject"),
G_CALLBACK (action_mail_search_folder_from_subject_cb) },
- { "mail-select-all",
- NULL,
- N_("Select _All Text"),
- "<Shift><Control>x",
- N_("Select all the text in a message"),
- G_CALLBACK (action_mail_select_all_cb) },
-
{ "mail-show-source",
NULL,
N_("_Message Source"),
@@ -1544,10 +1497,6 @@ static GtkActionEntry mail_reader_entries[] = {
static EPopupActionEntry mail_reader_popup_entries[] = {
- { "mail-popup-clipboard-copy",
- NULL,
- "mail-clipboard-copy" },
-
{ "mail-popup-copy",
NULL,
"mail-copy" },
@@ -1644,25 +1593,6 @@ static GtkToggleActionEntry mail_reader_toggle_entries[] = {
FALSE }
};
-static gboolean
-mail_reader_button_release_event_cb (EMailReader *reader,
- GdkEventButton *button,
- GtkHTML *html)
-{
- GtkAction *action;
- EWebView *web_view;
- const gchar *action_name;
- gboolean selection_active;
-
- web_view = E_WEB_VIEW (html);
- action_name = "mail-clipboard-copy";
- action = e_mail_reader_get_action (reader, action_name);
- selection_active = e_web_view_is_selection_active (web_view);
- gtk_action_set_sensitive (action, selection_active);
-
- return FALSE;
-}
-
static void
mail_reader_double_click_cb (EMailReader *reader,
gint row,
@@ -2377,11 +2307,6 @@ mail_reader_update_actions (EMailReader *reader)
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
- action_name = "mail-select-all";
- sensitive = single_message_selected;
- action = e_mail_reader_get_action (reader, action_name);
- gtk_action_set_sensitive (action, sensitive);
-
action_name = "mail-show-source";
sensitive = single_message_selected;
action = e_mail_reader_get_action (reader, action_name);
@@ -2585,10 +2510,6 @@ e_mail_reader_init (EMailReader *reader)
/* Fine tuning. */
- action_name = "mail-clipboard-copy";
- action = e_mail_reader_get_action (reader, action_name);
- gtk_action_set_sensitive (action, FALSE);
-
action_name = "mail-delete";
action = e_mail_reader_get_action (reader, action_name);
g_object_set (action, "short-label", _("Delete"), NULL);
@@ -2661,10 +2582,6 @@ e_mail_reader_init (EMailReader *reader)
/* Connect signals. */
g_signal_connect_swapped (
- web_view, "button-release-event",
- G_CALLBACK (mail_reader_button_release_event_cb), reader);
-
- g_signal_connect_swapped (
web_view, "key-press-event",
G_CALLBACK (mail_reader_key_press_event_cb), reader);
diff --git a/mail/message-list.c b/mail/message-list.c
index dcf2e4fed1..49a839a7ba 100644
--- a/mail/message-list.c
+++ b/mail/message-list.c
@@ -52,6 +52,7 @@
#include "e-util/e-util.h"
#include "misc/e-gui-utils.h"
+#include "misc/e-selectable.h"
#include "shell/e-shell.h"
#include "shell/e-shell-settings.h"
@@ -126,6 +127,8 @@ enum {
PROP_SHELL_BACKEND
};
+static gpointer parent_class;
+
static struct {
const gchar *target;
GdkAtom atom;
@@ -197,8 +200,6 @@ struct _EMailAddress {
typedef struct _EMailAddress EMailAddress;
#endif /* SMART_ADDRESS_COMPARE */
-G_DEFINE_TYPE (MessageList, message_list, E_TREE_TYPE)
-
static void on_cursor_activated_cmd (ETree *tree, gint row, ETreePath path, gpointer user_data);
static void on_selection_changed_cmd(ETree *tree, MessageList *ml);
static gint on_click (ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event, MessageList *list);
@@ -718,6 +719,18 @@ message_list_select_next_thread (MessageList *ml)
}
}
+static gboolean
+message_list_select_all_timeout_cb (MessageList *message_list)
+{
+ ESelectionModel *etsm;
+
+ etsm = e_tree_get_selection_model (E_TREE (message_list));
+
+ e_selection_model_select_all (etsm);
+
+ return FALSE;
+}
+
/**
* message_list_select_all:
* @message_list: Message List widget
@@ -727,11 +740,21 @@ message_list_select_next_thread (MessageList *ml)
void
message_list_select_all (MessageList *message_list)
{
- ESelectionModel *etsm;
-
- etsm = e_tree_get_selection_model (E_TREE (message_list));
+ g_return_if_fail (IS_MESSAGE_LIST (message_list));
- e_selection_model_select_all (etsm);
+ if (message_list->threaded) {
+ /* XXX The timeout below is added so that the execution
+ * thread to expand all conversation threads would
+ * have completed. The timeout 505 is just to ensure
+ * that the value is a small delta more than the
+ * timeout value in mail_regen_list(). */
+ g_timeout_add (
+ 505, (GSourceFunc)
+ message_list_select_all_timeout_cb,
+ message_list);
+ } else
+ /* If there is no threading, just select all immediately. */
+ message_list_select_all_timeout_cb (message_list);
}
typedef struct thread_select_info {
@@ -2295,9 +2318,6 @@ message_list_init (MessageList *message_list)
message_list->priv = MESSAGE_LIST_GET_PRIVATE (message_list);
-/* adjustment = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, G_MAXDOUBLE, 0.0, 0.0, 0.0);
- gtk_scrolled_window_set_vadjustment ((GtkScrolledWindow *) message_list, adjustment);*/
-
message_list->normalised_hash = g_hash_table_new_full (
g_str_hash, g_str_equal,
(GDestroyNotify) NULL,
@@ -2390,7 +2410,7 @@ message_list_destroy(GtkObject *object)
}
/* Chain up to parent's destroy() method. */
- GTK_OBJECT_CLASS (message_list_parent_class)->destroy(object);
+ GTK_OBJECT_CLASS (parent_class)->destroy(object);
}
static void
@@ -2440,7 +2460,7 @@ message_list_dispose (GObject *object)
}
/* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (message_list_parent_class)->dispose (object);
+ G_OBJECT_CLASS (parent_class)->dispose (object);
}
static void
@@ -2480,7 +2500,7 @@ message_list_finalize (GObject *object)
clear_selection(message_list, &priv->clipboard);
/* Chain up to parent's finalize() method. */
- G_OBJECT_CLASS (message_list_parent_class)->finalize (object);
+ G_OBJECT_CLASS (parent_class)->finalize (object);
}
static void
@@ -2490,6 +2510,25 @@ message_list_built (MessageList *message_list)
}
static void
+message_list_selectable_update_actions (ESelectable *selectable,
+ EFocusTracker *focus_tracker,
+ GdkAtom *clipboard_targets,
+ gint n_clipboard_targets)
+{
+ GtkAction *action;
+
+ action = e_focus_tracker_get_select_all_action (focus_tracker);
+ gtk_action_set_tooltip (action, _("Select all visible messages"));
+ gtk_action_set_sensitive (action, TRUE);
+}
+
+static void
+message_list_selectable_select_all (ESelectable *selectable)
+{
+ message_list_select_all (MESSAGE_LIST (selectable));
+}
+
+static void
message_list_class_init (MessageListClass *class)
{
GObjectClass *object_class;
@@ -2499,6 +2538,7 @@ message_list_class_init (MessageListClass *class)
for (i = 0; i < G_N_ELEMENTS (ml_drag_info); i++)
ml_drag_info[i].atom = gdk_atom_intern(ml_drag_info[i].target, FALSE);
+ parent_class = g_type_class_peek_parent (class);
g_type_class_add_private (class, sizeof (MessageListPrivate));
object_class = G_OBJECT_CLASS (class);
@@ -2546,6 +2586,13 @@ message_list_class_init (MessageListClass *class)
message_list_init_images ();
}
+static void
+message_list_selectable_init (ESelectableInterface *interface)
+{
+ interface->update_actions = message_list_selectable_update_actions;
+ interface->select_all = message_list_selectable_select_all;
+}
+
static gboolean
read_boolean_with_default (GConfClient *gconf, const gchar *key, gboolean def_value)
{
@@ -2668,6 +2715,41 @@ message_list_construct (MessageList *message_list)
G_CALLBACK (ml_tree_sorting_changed), message_list);
}
+GType
+message_list_get_type (void)
+{
+ static GType type = 0;
+
+ if (G_UNLIKELY (type == 0)) {
+ static const GTypeInfo type_info = {
+ sizeof (MessageListClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) message_list_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (MessageList),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) message_list_init,
+ NULL /* value_table */
+ };
+
+ static const GInterfaceInfo selectable_info = {
+ (GInterfaceInitFunc) message_list_selectable_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL /* interface_data */
+ };
+
+ type = g_type_register_static (
+ E_TREE_TYPE, "MessageList", &type_info, 0);
+
+ g_type_add_interface_static (
+ type, E_TYPE_SELECTABLE, &selectable_info);
+ }
+
+ return type;
+}
+
/**
* message_list_new:
*
diff --git a/mail/message-list.h b/mail/message-list.h
index 72960babe1..e239944783 100644
--- a/mail/message-list.h
+++ b/mail/message-list.h
@@ -170,9 +170,9 @@ struct _MessageListClass {
ETreeClass parent_class;
/* signals - select a message */
- void (*message_selected) (MessageList *ml, const gchar *uid);
- void (*message_list_built) (MessageList *ml);
- void (*message_list_scrolled) (MessageList *ml);
+ void (*message_selected) (MessageList *message_list, const gchar *uid);
+ void (*message_list_built) (MessageList *message_list);
+ void (*message_list_scrolled) (MessageList *message_list);
};
typedef enum {
@@ -182,58 +182,59 @@ typedef enum {
MESSAGE_LIST_SELECT_WRAP = 1<<1 /* option bit */
} MessageListSelectDirection;
-GType message_list_get_type (void);
-GtkWidget *message_list_new (EShellBackend *shell_backend);
-EShellBackend *message_list_get_shell_backend (MessageList *message_list);
-void message_list_set_folder (MessageList *message_list, CamelFolder *camel_folder, const gchar *uri, gboolean outgoing);
-
-void message_list_freeze(MessageList *ml);
-void message_list_thaw(MessageList *ml);
-
-GPtrArray *message_list_get_uids(MessageList *message_list);
-GPtrArray *message_list_get_selected(MessageList *ml);
-void message_list_set_selected(MessageList *ml, GPtrArray *uids);
-
-/* select next/prev message helpers */
-gboolean message_list_select (MessageList *message_list,
- MessageListSelectDirection direction,
- guint32 flags,
- guint32 mask);
-gboolean message_list_can_select(MessageList *ml, MessageListSelectDirection direction, guint32 flags, guint32 mask);
-
-void message_list_select_uid (MessageList *message_list,
- const gchar *uid);
-
-void message_list_select_next_thread (MessageList *ml);
-
-/* selection manipulation */
-void message_list_select_all (MessageList *ml);
-void message_list_select_thread (MessageList *ml);
-void message_list_select_subthread (MessageList *ml);
-void message_list_invert_selection (MessageList *ml);
-
-/* clipboard stuff */
-void message_list_copy(MessageList *ml, gboolean cut);
-void message_list_paste (MessageList *ml);
-
-/* info */
-guint message_list_length (MessageList *ml);
-guint message_list_hidden (MessageList *ml);
-
-/* hide specific messages */
-void message_list_hide_add (MessageList *ml, const gchar *expr, guint lower, guint upper);
-void message_list_hide_uids (MessageList *ml, GPtrArray *uids);
-void message_list_hide_clear (MessageList *ml);
-
-void message_list_set_threaded (MessageList *ml, gboolean threaded);
-void message_list_set_threaded_expand_all (MessageList *ml);
-void message_list_set_threaded_collapse_all (MessageList *ml);
-
-void message_list_set_hidedeleted (MessageList *ml, gboolean hidedeleted);
-void message_list_set_search (MessageList *ml, const gchar *search);
-void message_list_ensure_message (MessageList *ml, const gchar *uid);
-
-void message_list_save_state (MessageList *ml);
+GType message_list_get_type (void);
+GtkWidget * message_list_new (EShellBackend *shell_backend);
+EShellBackend * message_list_get_shell_backend (MessageList *message_list);
+void message_list_set_folder (MessageList *message_list,
+ CamelFolder *camel_folder,
+ const gchar *uri,
+ gboolean outgoing);
+void message_list_freeze (MessageList *message_list);
+void message_list_thaw (MessageList *message_list);
+GPtrArray * message_list_get_uids (MessageList *message_list);
+GPtrArray * message_list_get_selected (MessageList *message_list);
+void message_list_set_selected (MessageList *message_list,
+ GPtrArray *uids);
+gboolean message_list_select (MessageList *message_list,
+ MessageListSelectDirection direction,
+ guint32 flags,
+ guint32 mask);
+gboolean message_list_can_select (MessageList *message_list,
+ MessageListSelectDirection direction,
+ guint32 flags,
+ guint32 mask);
+void message_list_select_uid (MessageList *message_list,
+ const gchar *uid);
+void message_list_select_next_thread (MessageList *message_list);
+void message_list_select_all (MessageList *message_list);
+void message_list_select_thread (MessageList *message_list);
+void message_list_select_subthread (MessageList *message_list);
+void message_list_invert_selection (MessageList *message_list);
+void message_list_copy (MessageList *message_list,
+ gboolean cut);
+void message_list_paste (MessageList *message_list);
+guint message_list_length (MessageList *message_list);
+guint message_list_hidden (MessageList *message_list);
+void message_list_hide_add (MessageList *message_list,
+ const gchar *expr,
+ guint lower,
+ guint upper);
+void message_list_hide_uids (MessageList *message_list,
+ GPtrArray *uids);
+void message_list_hide_clear (MessageList *message_list);
+void message_list_set_threaded (MessageList *message_list,
+ gboolean threaded);
+void message_list_set_threaded_expand_all
+ (MessageList *message_list);
+void message_list_set_threaded_collapse_all
+ (MessageList *message_list);
+void message_list_set_hidedeleted (MessageList *message_list,
+ gboolean hidedeleted);
+void message_list_set_search (MessageList *message_list,
+ const gchar *search);
+void message_list_ensure_message (MessageList *message_list,
+ const gchar *uid);
+void message_list_save_state (MessageList *message_list);
#define MESSAGE_LIST_LOCK(m, l) g_mutex_lock(((MessageList *)m)->l)
#define MESSAGE_LIST_UNLOCK(m, l) g_mutex_unlock(((MessageList *)m)->l)