aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2010-05-20 10:01:49 +0800
committerMatthew Barnes <mbarnes@redhat.com>2010-05-20 10:16:09 +0800
commitbe538a4cff38c7b58468e7b2c7fa05f9dc8cb476 (patch)
tree7c826cbea6384e75b7143a87590024f3560148ff /mail
parentcacfd2114e7dd56cc12613d625bac450cc69b4ae (diff)
downloadgsoc2013-evolution-be538a4cff38c7b58468e7b2c7fa05f9dc8cb476.tar
gsoc2013-evolution-be538a4cff38c7b58468e7b2c7fa05f9dc8cb476.tar.gz
gsoc2013-evolution-be538a4cff38c7b58468e7b2c7fa05f9dc8cb476.tar.bz2
gsoc2013-evolution-be538a4cff38c7b58468e7b2c7fa05f9dc8cb476.tar.lz
gsoc2013-evolution-be538a4cff38c7b58468e7b2c7fa05f9dc8cb476.tar.xz
gsoc2013-evolution-be538a4cff38c7b58468e7b2c7fa05f9dc8cb476.tar.zst
gsoc2013-evolution-be538a4cff38c7b58468e7b2c7fa05f9dc8cb476.zip
Improve attachment bar selection behavior.
Some improvements made while investigating bug #608855. This does not solve the bug however, and in fact I now believe the bug is actually a GTK+ issue after reproducing the bug in gtk-demo. These improvements restore multiple selections via Ctrl+Click and Shift+Click, and also reduces the frequency that we synchronize the selection between Icon View and Tree View.
Diffstat (limited to 'mail')
-rw-r--r--mail/e-mail-attachment-bar.c64
1 files changed, 21 insertions, 43 deletions
diff --git a/mail/e-mail-attachment-bar.c b/mail/e-mail-attachment-bar.c
index 88198438b7..aa5abd09fb 100644
--- a/mail/e-mail-attachment-bar.c
+++ b/mail/e-mail-attachment-bar.c
@@ -64,36 +64,6 @@ enum {
static gpointer parent_class;
static void
-mail_attachment_bar_sync_icon_view (EMailAttachmentBar *bar)
-{
- EAttachmentView *source;
- EAttachmentView *target;
-
- source = E_ATTACHMENT_VIEW (bar->priv->tree_view);
- target = E_ATTACHMENT_VIEW (bar->priv->icon_view);
-
- /* Only sync if the tree view is active. This prevents the
- * two views from endlessly trying to sync with each other. */
- if (e_mail_attachment_bar_get_active_view (bar) == 1)
- e_attachment_view_sync_selection (source, target);
-}
-
-static void
-mail_attachment_bar_sync_tree_view (EMailAttachmentBar *bar)
-{
- EAttachmentView *source;
- EAttachmentView *target;
-
- source = E_ATTACHMENT_VIEW (bar->priv->icon_view);
- target = E_ATTACHMENT_VIEW (bar->priv->tree_view);
-
- /* Only sync if the icon view is active. This prevents the
- * two views from endlessly trying to sync with each other. */
- if (e_mail_attachment_bar_get_active_view (bar) == 0)
- e_attachment_view_sync_selection (source, target);
-}
-
-static void
mail_attachment_bar_update_status (EMailAttachmentBar *bar)
{
EAttachmentView *view;
@@ -516,7 +486,6 @@ static void
mail_attachment_bar_init (EMailAttachmentBar *bar)
{
EAttachmentView *view;
- GtkTreeSelection *selection;
GtkSizeGroup *size_group;
GtkWidget *container;
GtkWidget *widget;
@@ -562,7 +531,7 @@ mail_attachment_bar_init (EMailAttachmentBar *bar)
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0);
bar->priv->tree_frame = g_object_ref (widget);
- gtk_widget_show (widget);
+ gtk_widget_hide (widget);
container = widget;
@@ -645,17 +614,6 @@ mail_attachment_bar_init (EMailAttachmentBar *bar)
bar->priv->status_label = g_object_ref (widget);
gtk_widget_show (widget);
- selection = gtk_tree_view_get_selection (
- GTK_TREE_VIEW (bar->priv->tree_view));
-
- g_signal_connect_swapped (
- selection, "changed",
- G_CALLBACK (mail_attachment_bar_sync_icon_view), bar);
-
- g_signal_connect_swapped (
- bar->priv->icon_view, "selection-changed",
- G_CALLBACK (mail_attachment_bar_sync_tree_view), bar);
-
g_signal_connect_swapped (
bar->priv->model, "notify::num-attachments",
G_CALLBACK (mail_attachment_bar_update_status), bar);
@@ -722,9 +680,15 @@ void
e_mail_attachment_bar_set_active_view (EMailAttachmentBar *bar,
gint active_view)
{
+ EAttachmentView *source;
+ EAttachmentView *target;
+
g_return_if_fail (E_IS_MAIL_ATTACHMENT_BAR (bar));
g_return_if_fail (active_view >= 0 && active_view < NUM_VIEWS);
+ if (active_view == bar->priv->active_view)
+ return;
+
bar->priv->active_view = active_view;
if (active_view == 0) {
@@ -735,6 +699,20 @@ e_mail_attachment_bar_set_active_view (EMailAttachmentBar *bar,
gtk_widget_show (bar->priv->tree_frame);
}
+ /* Synchronize the item selection of the view we're
+ * switching TO with the view we're switching FROM. */
+ if (active_view == 0) {
+ /* from tree view to icon view */
+ source = E_ATTACHMENT_VIEW (bar->priv->tree_view);
+ target = E_ATTACHMENT_VIEW (bar->priv->icon_view);
+ } else {
+ /* from icon view to tree view */
+ source = E_ATTACHMENT_VIEW (bar->priv->icon_view);
+ target = E_ATTACHMENT_VIEW (bar->priv->tree_view);
+ }
+
+ e_attachment_view_sync_selection (source, target);
+
g_object_notify (G_OBJECT (bar), "active-view");
}