diff options
author | John Sullivan <sullivan@src.gnome.org> | 2000-11-29 00:16:15 +0000 |
---|---|---|
committer | John Sullivan <sullivan@src.gnome.org> | 2000-11-29 00:16:15 +0000 |
commit | 178e9bd9d3ef76e3b7fc6c6d8ad5a438346c895b (patch) | |
tree | 8e3e6d7d7c8e532a5cd1229d3ba9bd8d3de8a438 /libnautilus-private/nautilus-icon-container.c | |
parent | b4cb72f7f7deadb05fc7a11c00be41503fda7886 (diff) | |
download | nautilus-178e9bd9d3ef76e3b7fc6c6d8ad5a438346c895b.tar.gz |
reviewed by: Pavel Cisler <pavel@eazel.com>
Fixed bug 4257 (right click on background in icon or list
view doesn't leave context menus up)
This was a problem with nautilus_pop_up_context_menu. It
wasn't passing the event time, which caused GTK to think
that the button-release was for a later button press, and
consequently to close the context menu. It appears that the
root cause may be a gtk menu handling bug, but this checkin
fixes the problem as far as Nautilus is concerned.
* libnautilus-extensions/nautilus-gtk-extensions.h:
* libnautilus-extensions/nautilus-gtk-extensions.c:
(nautilus_pop_up_context_menu): Now takes event as a
parameter, and passes event->time through to gtk_menu_popup.
Passes 0 for button if event is a button release, to work with
subtle logic in gtk popup menu-handling.
* libnautilus-extensions/nautilus-icon-container.h:
* libnautilus-extensions/nautilus-icon-container.c:
Add event parameters to context-click signal handlers.
(nautilus_icon_container_initialize_class): Change signal
marshal and signature.
(context_menu_parameters_new), (context_menu_parameters_free):
New helper functions to manage callback data when delaying
the appearance of a context menu.
(button_press_event), (button_release_event),
(show_context_menu_callback): Pass event when emitting signal.
(handle_icon_button_press): Pass event as well as container
to idle callback.
* libnautilus-extensions/nautilus-list.h:
* libnautilus-extensions/nautilus-list.c:
Add event parameters to context-click signal handlers.
(nautilus_list_initialize_class): Change signal marshal and
signature.
(context_menu_parameters_new), (context_menu_parameters_free):
New helper functions to manage callback data when delaying
the appearance of a context menu.
(nautilus_list_button_press), (nautilus_list_button_release),
(show_context_menu_callback): Pass event when emitting signal
or setting up idle callback.
* src/file-manager/fm-directory-view.h:
* src/file-manager/fm-directory-view.c:
(fm_directory_view_pop_up_selection_context_menu),
(fm_directory_view_pop_up_background_context_menu):
Take event parameter and pass it to
nautilus_pop_up_context_menu.
* src/file-manager/fm-icon-view.c:
(icon_container_context_click_selection_callback),
(icon_container_context_click_background_callback):
Add event parameter to match signal change, and pass
event when calling fm_directory_view_pop_up_xxx
* src/file-manager/fm-list-view.c:
(context_click_selection_callback),
(context_click_background_callback):
Add event parameter to match signal change, and pass
event when calling fm_directory_view_pop_up_xxx
* src/nautilus-window-toolbars.c:
(back_or_forward_button_clicked_callback):
Pass event for context menu on Back and Forward
buttons (this code is still #ifdeffed out from Bonobo
switchover, awaiting fix for bug 3510).
* src/nautilus-sidebar.c: (nautilus_sidebar_press_event):
Pass event for context menu in sidebar.
* src/nautilus-zoom-control.c:
(nautilus_zoom_control_button_press_event):
Pass event for context menu in zoom control.
Diffstat (limited to 'libnautilus-private/nautilus-icon-container.c')
-rw-r--r-- | libnautilus-private/nautilus-icon-container.c | 75 |
1 files changed, 52 insertions, 23 deletions
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c index b69908117..68196bf51 100644 --- a/libnautilus-private/nautilus-icon-container.c +++ b/libnautilus-private/nautilus-icon-container.c @@ -2334,7 +2334,7 @@ button_press_event (GtkWidget *widget, /* Button 3 does a contextual menu. */ if (event->button == CONTEXTUAL_MENU_BUTTON) { end_renaming_mode (container, TRUE); - gtk_signal_emit (GTK_OBJECT (widget), signals[CONTEXT_CLICK_BACKGROUND]); + gtk_signal_emit (GTK_OBJECT (widget), signals[CONTEXT_CLICK_BACKGROUND], event); return TRUE; } @@ -2530,7 +2530,8 @@ button_release_event (GtkWidget *widget, details->drag_state = DRAG_STATE_INITIAL; gtk_timeout_remove (details->context_menu_timeout_id); gtk_signal_emit (GTK_OBJECT (container), - signals[CONTEXT_CLICK_SELECTION]); + signals[CONTEXT_CLICK_SELECTION], + event); break; } /* fall through */ @@ -2863,16 +2864,18 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class) object_class->type, GTK_SIGNAL_OFFSET (NautilusIconContainerClass, context_click_selection), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, + GTK_TYPE_POINTER); signals[CONTEXT_CLICK_BACKGROUND] = gtk_signal_new ("context_click_background", GTK_RUN_LAST, object_class->type, GTK_SIGNAL_OFFSET (NautilusIconContainerClass, context_click_background), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); + gtk_marshal_NONE__POINTER, + GTK_TYPE_NONE, 1, + GTK_TYPE_POINTER); signals[MIDDLE_CLICK] = gtk_signal_new ("middle_click", GTK_RUN_LAST, @@ -3167,29 +3170,54 @@ nautilus_icon_container_initialize (NautilusIconContainer *container) container->details->has_been_allocated = FALSE; } +typedef struct { + NautilusIconContainer *container; + GdkEventButton *event; +} ContextMenuParameters; + +static ContextMenuParameters * +context_menu_parameters_new (NautilusIconContainer *container, + GdkEventButton *event) +{ + ContextMenuParameters *parameters; + + parameters = g_new (ContextMenuParameters, 1); + parameters->container = container; + parameters->event = (GdkEventButton *)(gdk_event_copy ((GdkEvent *)event)); + + return parameters; +} + +static void +context_menu_parameters_free (ContextMenuParameters *parameters) +{ + gdk_event_free ((GdkEvent *)parameters->event); + g_free (parameters); +} + static gboolean -show_context_menu_callback (void *cast_to_container) +show_context_menu_callback (void *cast_to_parameters) { - NautilusIconContainer *container; + ContextMenuParameters *parameters; - container = (NautilusIconContainer *)cast_to_container; + parameters = (ContextMenuParameters *)cast_to_parameters; - g_assert (NAUTILUS_IS_ICON_CONTAINER (container)); + g_assert (NAUTILUS_IS_ICON_CONTAINER (parameters->container)); - if (container->details->drag_state != DRAG_STATE_MOVE_COPY_OR_MENU) { - /* button was released */ - return TRUE; - } + if (parameters->container->details->drag_state == DRAG_STATE_MOVE_COPY_OR_MENU) { + parameters->container->details->drag_state = DRAG_STATE_INITIAL; + gtk_timeout_remove (parameters->container->details->context_menu_timeout_id); - container->details->drag_state = DRAG_STATE_INITIAL; - gtk_timeout_remove (container->details->context_menu_timeout_id); + /* Context menu applies to all selected items. The only + * odd case is if this click deselected the icon under + * the mouse, but at least the behavior is consistent. + */ + gtk_signal_emit (GTK_OBJECT (parameters->container), + signals[CONTEXT_CLICK_SELECTION], + parameters->event); + } - /* Context menu applies to all selected items. The only - * odd case is if this click deselected the icon under - * the mouse, but at least the behavior is consistent. - */ - gtk_signal_emit (GTK_OBJECT (container), - signals[CONTEXT_CLICK_SELECTION]); + context_menu_parameters_free (parameters); return TRUE; } @@ -3244,7 +3272,8 @@ handle_icon_button_press (NautilusIconContainer *container, */ details->context_menu_timeout_id = gtk_timeout_add ( CONTEXT_MENU_TIMEOUT_INTERVAL, - show_context_menu_callback, container); + show_context_menu_callback, + context_menu_parameters_new (container, event)); } } |