From cda91db3e61cacfb6e39267d4d16d075806e2037 Mon Sep 17 00:00:00 2001 From: Christian Neumair Date: Sat, 12 Jul 2008 15:31:09 +0000 Subject: Completely rewrite button press detection. Finally fixes #542269 without 2008-07-12 Christian Neumair * libnautilus-private/nautilus-icon-container.c (button_press_event), (handle_icon_double_click), (handle_icon_button_press), (item_event_callback): * libnautilus-private/nautilus-icon-container.h: Completely rewrite button press detection. Finally fixes #542269 without any side effects. NEWS: Update for release. svn path=/branches/gnome-2-22/; revision=14348 --- ChangeLog | 12 ++++ NEWS | 3 + configure.in | 2 +- libnautilus-private/nautilus-icon-container.c | 79 +++++++++++++++------------ libnautilus-private/nautilus-icon-private.h | 4 +- 5 files changed, 60 insertions(+), 40 deletions(-) diff --git a/ChangeLog b/ChangeLog index fdc65e498..323608e4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2008-07-12 Christian Neumair + + * libnautilus-private/nautilus-icon-container.c + (button_press_event), (handle_icon_double_click), + (handle_icon_button_press), (item_event_callback): + * libnautilus-private/nautilus-icon-container.h: + Completely rewrite button press detection. Finally fixes #542269 + without any side effects. + + NEWS: + Update for release. + 2008-07-12 Christian Neumair * configure.in: diff --git a/NEWS b/NEWS index 1df4e84e6..806a77490 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +Major changes in 2.22.5.1 are: +* Fix double-click activation in icon view without any side effects. + Major changes in 2.22.5 are: * Fix double-click activation in icon view. diff --git a/configure.in b/configure.in index f77ac70b9..a79a1f8a4 100644 --- a/configure.in +++ b/configure.in @@ -27,7 +27,7 @@ dnl Interface break is not allowed. m4_define(nautilus_extension_current, 2) m4_define(nautilus_extension_revision, 0) -AC_INIT([nautilus],[2.22.6], +AC_INIT([nautilus],[2.22.5.1], [http://bugzilla.gnome.org/enter_bug.cgi?product=nautilus]) dnl =========================================================================== diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c index dcba8de50..27601a57f 100644 --- a/libnautilus-private/nautilus-icon-container.c +++ b/libnautilus-private/nautilus-icon-container.c @@ -3288,7 +3288,12 @@ button_press_event (GtkWidget *widget, /* Forget about where we began with the arrow keys now that we're mousing. */ container->details->arrow_key_axis = AXIS_NONE; - + + if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { + /* We use our own double-click detection. */ + return TRUE; + } + /* Invoke the canvas event handler and see if an item picks up the event. */ clicked_on_icon = GTK_WIDGET_CLASS (parent_class)->button_press_event (widget, event); @@ -3303,13 +3308,6 @@ button_press_event (GtkWidget *widget, return TRUE; } - /* An item didn't take the press, so it's a background press. - * We ignore double clicks on the desktop for now. - */ - if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { - return TRUE; - } - if ((event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON) && event->type == GDK_BUTTON_PRESS) { /* Clear the last click icon for double click */ @@ -5176,6 +5174,36 @@ typedef struct { GdkEventButton *event; } ContextMenuParameters; +static gboolean +handle_icon_double_click (NautilusIconContainer *container, + NautilusIcon *icon, + GdkEventButton *event) +{ + NautilusIconContainerDetails *details; + + details = container->details; + + if (!details->single_click_mode && + clicked_within_double_click_interval(container) && + details->double_click_icon[0] == details->double_click_icon[1] && + details->double_click_button[0] == details->double_click_button[1]) { + if (!button_event_modifies_selection (event)) { + if (event->button == MIDDLE_BUTTON) { + activate_selected_items_alternate (container, NULL); + } else { + activate_selected_items (container); + } + return TRUE; + } else if (event->button == DRAG_BUTTON && + (event->state & GDK_SHIFT_MASK) != 0) { + activate_selected_items_alternate (container, icon); + return TRUE; + } + } + + return FALSE; +} + /* NautilusIcon event handling. */ /* Conceptually, pressing button 1 together with CTRL or SHIFT toggles @@ -5196,13 +5224,7 @@ handle_icon_button_press (NautilusIconContainer *container, details = container->details; - if (event->type == GDK_3BUTTON_PRESS) { - return TRUE; - } - - if (details->single_click_mode && - event->type == GDK_2BUTTON_PRESS) { - /* Don't care about double clicks in single click mode */ + if (event->type == GDK_2BUTTON_PRESS || event->type == GDK_3BUTTON_PRESS) { return TRUE; } @@ -5217,32 +5239,21 @@ handle_icon_button_press (NautilusIconContainer *container, /* The next double click has to be on this icon */ details->double_click_icon[1] = details->double_click_icon[0]; details->double_click_icon[0] = icon; + + details->double_click_button[1] = details->double_click_button[0]; + details->double_click_button[0] = event->button; } - if ((event->button == DRAG_BUTTON || event->button == MIDDLE_BUTTON) - && (!details->single_click_mode && clicked_within_double_click_interval(container) && details->icon_revealed)) { + if (handle_icon_double_click (container, icon, event)) { /* Double clicking does not trigger a D&D action. */ details->drag_button = 0; details->drag_icon = NULL; - - if (icon == details->double_click_icon[1]) { - if (!button_event_modifies_selection (event)) { - if (event->button == MIDDLE_BUTTON) { - activate_selected_items_alternate (container, NULL); - } else { - activate_selected_items (container); - } - } else if (event->button == DRAG_BUTTON && - (event->state & GDK_SHIFT_MASK) != 0) { - activate_selected_items_alternate (container, icon); - } - } - details->icon_revealed = FALSE; return TRUE; } + if (event->button == DRAG_BUTTON || event->button == DRAG_MENU_BUTTON) { - details->drag_button = event->button; + details->drag_button = event->button; details->drag_icon = icon; details->drag_x = event->x; details->drag_y = event->y; @@ -5286,12 +5297,9 @@ handle_icon_button_press (NautilusIconContainer *container, signals[SELECTION_CHANGED], 0); } else { select_one_unselect_others (container, icon); - details->icon_revealed = TRUE; g_signal_emit (container, signals[SELECTION_CHANGED], 0); } - } else { - details->icon_revealed = TRUE; } if (event->button == CONTEXTUAL_MENU_BUTTON) { @@ -5321,7 +5329,6 @@ item_event_callback (EelCanvasItem *item, switch (event->type) { case GDK_BUTTON_PRESS: - case GDK_2BUTTON_PRESS: if (handle_icon_button_press (container, icon, &event->button)) { /* Stop the event from being passed along further. Returning * TRUE ain't enough. diff --git a/libnautilus-private/nautilus-icon-private.h b/libnautilus-private/nautilus-icon-private.h index cb9670513..6178a4512 100644 --- a/libnautilus-private/nautilus-icon-private.h +++ b/libnautilus-private/nautilus-icon-private.h @@ -170,6 +170,7 @@ struct NautilusIconContainerDetails { gboolean icon_selected_on_button_down; NautilusIcon *double_click_icon[2]; /* Both clicks in a double click need to be on the same icon */ + guint double_click_button[2]; NautilusIcon *range_selection_base_icon; @@ -274,9 +275,6 @@ struct NautilusIconContainerDetails { GtkWidget *search_entry; guint search_entry_changed_id; guint typeselect_flush_timeout; - - /* Needed for dblclicking activation of partially shown icons, see bug #347423 */ - gboolean icon_revealed; }; /* Private functions shared by mutiple files. */ -- cgit v1.2.1