aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mail/e-mail-attachment-bar.c64
-rw-r--r--widgets/misc/e-attachment-paned.c62
-rw-r--r--widgets/misc/e-attachment-view.c38
3 files changed, 59 insertions, 105 deletions
diff --git a/mail/e-mail-attachment-bar.c b/mail/e-mail-attachment-bar.c
index f603b719e4..c791b5fba3 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;
@@ -512,7 +482,6 @@ static void
mail_attachment_bar_init (EMailAttachmentBar *bar)
{
EAttachmentView *view;
- GtkTreeSelection *selection;
GtkSizeGroup *size_group;
GtkWidget *container;
GtkWidget *widget;
@@ -558,7 +527,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;
@@ -641,17 +610,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);
@@ -718,9 +676,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) {
@@ -731,6 +695,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");
}
diff --git a/widgets/misc/e-attachment-paned.c b/widgets/misc/e-attachment-paned.c
index 110e858e74..c9282c7718 100644
--- a/widgets/misc/e-attachment-paned.c
+++ b/widgets/misc/e-attachment-paned.c
@@ -92,36 +92,6 @@ attachment_paned_notify_cb (EAttachmentPaned *paned,
}
static void
-attachment_paned_sync_icon_view (EAttachmentPaned *paned)
-{
- EAttachmentView *source;
- EAttachmentView *target;
-
- source = E_ATTACHMENT_VIEW (paned->priv->tree_view);
- target = E_ATTACHMENT_VIEW (paned->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_attachment_paned_get_active_view (paned) == 1)
- e_attachment_view_sync_selection (source, target);
-}
-
-static void
-attachment_paned_sync_tree_view (EAttachmentPaned *paned)
-{
- EAttachmentView *source;
- EAttachmentView *target;
-
- source = E_ATTACHMENT_VIEW (paned->priv->icon_view);
- target = E_ATTACHMENT_VIEW (paned->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_attachment_paned_get_active_view (paned) == 0)
- e_attachment_view_sync_selection (source, target);
-}
-
-static void
attachment_paned_update_status (EAttachmentPaned *paned)
{
EAttachmentView *view;
@@ -509,7 +479,6 @@ static void
attachment_paned_init (EAttachmentPaned *paned)
{
EAttachmentView *view;
- GtkTreeSelection *selection;
GtkSizeGroup *size_group;
GtkWidget *container;
GtkWidget *widget;
@@ -662,17 +631,6 @@ attachment_paned_init (EAttachmentPaned *paned)
paned->priv->status_label = g_object_ref (widget);
gtk_widget_hide (widget);
- selection = gtk_tree_view_get_selection (
- GTK_TREE_VIEW (paned->priv->tree_view));
-
- g_signal_connect_swapped (
- selection, "changed",
- G_CALLBACK (attachment_paned_sync_icon_view), paned);
-
- g_signal_connect_swapped (
- paned->priv->icon_view, "selection-changed",
- G_CALLBACK (attachment_paned_sync_tree_view), paned);
-
g_signal_connect_swapped (
paned->priv->expander, "notify::expanded",
G_CALLBACK (attachment_paned_notify_cb), paned);
@@ -750,11 +708,31 @@ void
e_attachment_paned_set_active_view (EAttachmentPaned *paned,
gint active_view)
{
+ EAttachmentView *source;
+ EAttachmentView *target;
+
g_return_if_fail (E_IS_ATTACHMENT_PANED (paned));
g_return_if_fail (active_view >= 0 && active_view < NUM_VIEWS);
+ if (active_view == paned->priv->active_view)
+ return;
+
paned->priv->active_view = active_view;
+ /* 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 (paned->priv->tree_view);
+ target = E_ATTACHMENT_VIEW (paned->priv->icon_view);
+ } else {
+ /* from icon view to tree view */
+ source = E_ATTACHMENT_VIEW (paned->priv->icon_view);
+ target = E_ATTACHMENT_VIEW (paned->priv->tree_view);
+ }
+
+ e_attachment_view_sync_selection (source, target);
+
g_object_notify (G_OBJECT (paned), "active-view");
}
diff --git a/widgets/misc/e-attachment-view.c b/widgets/misc/e-attachment-view.c
index 3b90941d85..2247809d5f 100644
--- a/widgets/misc/e-attachment-view.c
+++ b/widgets/misc/e-attachment-view.c
@@ -1075,29 +1075,13 @@ e_attachment_view_button_press_event (EAttachmentView *view,
{
GtkTreePath *path;
gboolean editable;
- gboolean item_clicked;
+ gboolean handled = FALSE;
g_return_val_if_fail (E_IS_ATTACHMENT_VIEW (view), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
editable = e_attachment_view_get_editable (view);
-
- /* If the user clicked on a selected item, retain the current
- * selection. If the user clicked on an unselected item, select
- * the clicked item only. If the user did not click on an item,
- * clear the current selection. */
path = e_attachment_view_get_path_at_pos (view, event->x, event->y);
- if (path != NULL) {
- if (!e_attachment_view_path_is_selected (view, path)) {
- e_attachment_view_unselect_all (view);
- e_attachment_view_select_path (view, path);
- }
- gtk_tree_path_free (path);
- item_clicked = TRUE;
- } else {
- e_attachment_view_unselect_all (view);
- item_clicked = FALSE;
- }
/* Cancel drag and drop if there are no selected items,
* or if any of the selected items are loading or saving. */
@@ -1118,17 +1102,31 @@ e_attachment_view_button_press_event (EAttachmentView *view,
}
if (event->button == 3 && event->type == GDK_BUTTON_PRESS) {
+ /* If the user clicked on a selected item, retain the
+ * current selection. If the user clicked on an unselected
+ * item, select the clicked item only. If the user did not
+ * click on an item, clear the current selection. */
+ if (path == NULL)
+ e_attachment_view_unselect_all (view);
+ else if (!e_attachment_view_path_is_selected (view, path)) {
+ e_attachment_view_unselect_all (view);
+ e_attachment_view_select_path (view, path);
+ }
+
/* Non-editable attachment views should only show a
* popup menu when right-clicking on an attachment,
* but editable views can show the menu any time. */
- if (item_clicked || editable) {
+ if (path != NULL || editable) {
e_attachment_view_show_popup_menu (
view, event, NULL, NULL);
- return TRUE;
+ handled = TRUE;
}
}
- return FALSE;
+ if (path != NULL)
+ gtk_tree_path_free (path);
+
+ return handled;
}
gboolean