pathbar: handle context menu

NautilusView is an abstract class that manages
various context menus, depending on the view's
location, the clicked point and the implementation
details.

While this in theory provides a good isolation
from other classes, in practice NautilusView
manages the pathbar context menu, which is not
necessary, as it doesn't depend on the current
view anymore after the GAction rework.

Fix that by making NautilusPathBar manage the
context menu by itself instead of the view. To
cleanly implement that, add a new signal that
matches GtkPlacesSidebar::open-location signature,
and adapt NautilusWindow to reuse the existing
methods to handle pathbar's new signal.

https://bugzilla.gnome.org/show_bug.cgi?id=753158
parent e0245b62
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<menu id="pathbar-menu">
<section>
<item>
<attribute name="label" translatable="yes">Open In New _Tab</attribute>
<attribute name="action">pathbar.open-item-new-tab</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Open In New _Window</attribute>
<attribute name="action">pathbar.open-item-new-window</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">P_roperties</attribute>
<attribute name="action">pathbar.properties</attribute>
</item>
</section>
</menu>
</interface>
......@@ -24,18 +24,20 @@
#include <gio/gio.h>
#include "nautilus-pathbar.h"
#include "nautilus-properties-window.h"
#include <libnautilus-private/nautilus-file.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-icon-names.h>
#include <libnautilus-private/nautilus-trash-monitor.h>
#include <libnautilus-private/nautilus-ui-utilities.h>
#include "nautilus-window-slot-dnd.h"
enum {
OPEN_LOCATION,
PATH_CLICKED,
PATH_EVENT,
LAST_SIGNAL
};
......@@ -91,6 +93,12 @@ struct _NautilusPathBarDetails {
unsigned int drag_slider_timeout;
gboolean drag_slider_timeout_for_up_button;
GActionGroup *action_group;
GMenu *context_menu;
NautilusFile *context_menu_file;
GdkEventButton *context_menu_event;
};
......@@ -112,6 +120,85 @@ static void nautilus_path_bar_update_button_state (ButtonData *but
gboolean current_dir);
static void nautilus_path_bar_update_path (NautilusPathBar *path_bar,
GFile *file_path);
static void unschedule_pop_up_context_menu (NautilusPathBar *path_bar);
static void action_pathbar_open_item_new_window (GSimpleAction *action,
GVariant *state,
gpointer user_data);
static void action_pathbar_open_item_new_tab (GSimpleAction *action,
GVariant *state,
gpointer user_data);
static void action_pathbar_properties (GSimpleAction *action,
GVariant *state,
gpointer user_data);
const GActionEntry path_bar_actions[] = {
{ "open-item-new-tab", action_pathbar_open_item_new_tab },
{ "open-item-new-window", action_pathbar_open_item_new_window },
{ "properties", action_pathbar_properties}
};
static void
action_pathbar_open_item_new_tab (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusPathBar *path_bar;
GFile *location;
path_bar = NAUTILUS_PATH_BAR (user_data);
if (!path_bar->priv->context_menu_file) {
return;
}
location = nautilus_file_get_location (path_bar->priv->context_menu_file);
if (location) {
g_signal_emit (user_data, path_bar_signals[OPEN_LOCATION], 0, location, GTK_PLACES_OPEN_NEW_TAB);
g_object_unref (location);
}
}
static void
action_pathbar_open_item_new_window (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusPathBar *path_bar;
GFile *location;
path_bar = NAUTILUS_PATH_BAR (user_data);
if (!path_bar->priv->context_menu_file) {
return;
}
location = nautilus_file_get_location (path_bar->priv->context_menu_file);
if (location) {
g_signal_emit (user_data, path_bar_signals[OPEN_LOCATION], 0, location, GTK_PLACES_OPEN_NEW_WINDOW);
g_object_unref (location);
}
}
static void
action_pathbar_properties (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusPathBar *path_bar;
GList *files;
path_bar = NAUTILUS_PATH_BAR (user_data);
g_assert (NAUTILUS_IS_FILE (path_bar->priv->context_menu_file));
files = g_list_append (NULL, nautilus_file_ref (path_bar->priv->context_menu_file));
nautilus_properties_window_present (files, GTK_WIDGET (path_bar), NULL);
nautilus_file_list_free (files);
}
static GtkWidget *
get_slider_button (NautilusPathBar *path_bar,
......@@ -200,8 +287,25 @@ nautilus_path_bar_slider_drag_leave (GtkWidget *widget,
static void
nautilus_path_bar_init (NautilusPathBar *path_bar)
{
GtkBuilder *builder;
path_bar->priv = G_TYPE_INSTANCE_GET_PRIVATE (path_bar, NAUTILUS_TYPE_PATH_BAR, NautilusPathBarDetails);
/* Action group */
path_bar->priv->action_group = G_ACTION_GROUP (g_simple_action_group_new ());
g_action_map_add_action_entries (G_ACTION_MAP (path_bar->priv->action_group),
path_bar_actions,
G_N_ELEMENTS (path_bar_actions),
path_bar);
gtk_widget_insert_action_group (GTK_WIDGET (path_bar),
"pathbar",
G_ACTION_GROUP (path_bar->priv->action_group));
/* Context menu */
builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-pathbar-context-menu.xml");
path_bar->priv->context_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "pathbar-menu")));
g_object_unref (builder);
gtk_widget_set_has_window (GTK_WIDGET (path_bar), FALSE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
......@@ -262,6 +366,11 @@ nautilus_path_bar_finalize (GObject *object)
g_list_free (path_bar->priv->button_list);
unschedule_pop_up_context_menu (NAUTILUS_PATH_BAR (object));
if (path_bar->priv->context_menu_event) {
gdk_event_free ((GdkEvent *) path_bar->priv->context_menu_event);
}
G_OBJECT_CLASS (nautilus_path_bar_parent_class)->finalize (object);
}
......@@ -1001,6 +1110,15 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
container_class->remove = nautilus_path_bar_remove;
container_class->get_path_for_child = nautilus_path_bar_get_path_for_child;
path_bar_signals [OPEN_LOCATION] =
g_signal_new ("open-location",
G_OBJECT_CLASS_TYPE (path_bar_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusPathBarClass, open_location),
NULL, NULL, NULL,
G_TYPE_NONE, 2,
G_TYPE_FILE,
GTK_TYPE_PLACES_OPEN_FLAGS);
path_bar_signals [PATH_CLICKED] =
g_signal_new ("path-clicked",
G_OBJECT_CLASS_TYPE (path_bar_class),
......@@ -1010,15 +1128,6 @@ nautilus_path_bar_class_init (NautilusPathBarClass *path_bar_class)
g_cclosure_marshal_VOID__OBJECT,
G_TYPE_NONE, 1,
G_TYPE_FILE);
path_bar_signals [PATH_EVENT] =
g_signal_new ("path-event",
G_OBJECT_CLASS_TYPE (path_bar_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (NautilusPathBarClass, path_event),
NULL, NULL, NULL,
G_TYPE_BOOLEAN, 2,
G_TYPE_FILE,
GDK_TYPE_EVENT);
gtk_container_class_handle_border_width (container_class);
g_type_class_add_private (path_bar_class, sizeof (NautilusPathBarDetails));
......@@ -1282,36 +1391,127 @@ button_clicked_cb (GtkWidget *button,
g_signal_emit (path_bar, path_bar_signals [PATH_CLICKED], 0, button_data->path);
}
static void
real_pop_up_pathbar_context_menu (NautilusPathBar *path_bar)
{
nautilus_pop_up_context_menu (GTK_WIDGET (path_bar),
path_bar->priv->context_menu,
path_bar->priv->context_menu_event);
}
static void
pathbar_popup_file_attributes_ready (NautilusFile *file,
gpointer data)
{
NautilusPathBar *path_bar;
path_bar = NAUTILUS_PATH_BAR (data);
g_assert (NAUTILUS_IS_PATH_BAR (path_bar));
g_assert (file == path_bar->priv->context_menu_file);
real_pop_up_pathbar_context_menu (path_bar);
}
static void
unschedule_pop_up_context_menu (NautilusPathBar *path_bar)
{
if (path_bar->priv->context_menu_file) {
g_assert (NAUTILUS_IS_FILE (path_bar->priv->context_menu_file));
nautilus_file_cancel_call_when_ready (path_bar->priv->context_menu_file,
pathbar_popup_file_attributes_ready,
path_bar);
g_clear_pointer (&path_bar->priv->context_menu_file, nautilus_file_unref);
}
}
static void
schedule_pop_up_context_menu (NautilusPathBar *path_bar,
GdkEventButton *event,
NautilusFile *file)
{
g_assert (NAUTILUS_IS_FILE (file));
if (path_bar->priv->context_menu_event != NULL) {
gdk_event_free ((GdkEvent *) path_bar->priv->context_menu_event);
}
path_bar->priv->context_menu_event = (GdkEventButton *) gdk_event_copy ((GdkEvent *)event);
if (file == path_bar->priv->context_menu_file) {
if (nautilus_file_check_if_ready (file,
NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO)) {
real_pop_up_pathbar_context_menu (path_bar);
}
} else {
unschedule_pop_up_context_menu (path_bar);
path_bar->priv->context_menu_file = nautilus_file_ref (file);
nautilus_file_call_when_ready (path_bar->priv->context_menu_file,
NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO,
pathbar_popup_file_attributes_ready,
path_bar);
}
}
static void
pop_up_pathbar_context_menu (NautilusPathBar *path_bar,
GdkEventButton *event,
NautilusFile *file)
{
if (file) {
schedule_pop_up_context_menu (path_bar, event, file);
nautilus_file_unref (file);
}
}
static gboolean
button_event_cb (GtkWidget *button,
GdkEventButton *event,
gpointer data)
{
GtkPlacesOpenFlags flags;
ButtonData *button_data;
NautilusPathBar *path_bar;
GList *button_list;
gboolean retval;
int mask;
button_data = BUTTON_DATA (data);
path_bar = NAUTILUS_PATH_BAR (gtk_widget_get_parent (button));
if (event->type == GDK_BUTTON_PRESS) {
g_object_set_data (G_OBJECT (button), "handle-button-release",
GINT_TO_POINTER (TRUE));
}
g_object_set_data (G_OBJECT (button), "handle-button-release", GINT_TO_POINTER (TRUE));
if (event->type == GDK_BUTTON_RELEASE &&
!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button),
"handle-button-release"))) {
return FALSE;
}
if (event->button == 3) {
pop_up_pathbar_context_menu (path_bar, event, button_data->file);
return TRUE;
}
button_list = g_list_find (path_bar->priv->button_list, button_data);
g_assert (button_list != NULL);
} else if (event->type == GDK_BUTTON_RELEASE) {
mask = event->state & gtk_accelerator_get_default_mod_mask ();
flags = 0;
if (!GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (button), "handle-button-release"))) {
return FALSE;
}
g_signal_emit (path_bar, path_bar_signals [PATH_EVENT], 0, button_data->path, event, &retval);
if (event->button == 2 && mask == 0) {
flags = GTK_PLACES_OPEN_NEW_TAB;
} else if (event->button == 1 && mask == GDK_CONTROL_MASK) {
flags = GTK_PLACES_OPEN_NEW_WINDOW;
}
return retval;
if (flags != 0) {
g_signal_emit (path_bar, path_bar_signals[OPEN_LOCATION], 0, button_data->path, flags);
}
return FALSE;
}
return FALSE;
}
static void
......
......@@ -47,9 +47,9 @@ struct _NautilusPathBarClass
void (* path_clicked) (NautilusPathBar *path_bar,
GFile *location);
gboolean (* path_event) (NautilusPathBar *path_bar,
GdkEventButton *event,
GFile *location);
void (* open_location) (NautilusPathBar *path_bar,
GFile *location,
GtkPlacesOpenFlags flags);
};
GType nautilus_path_bar_get_type (void) G_GNUC_CONST;
......
......@@ -223,24 +223,4 @@
</item>
</section>
</menu>
<menu id="pathbar-menu">
<section>
<item>
<attribute name="label" translatable="yes">Open In New _Window</attribute>
<attribute name="action">view.pathbar-open-item-new-window</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
<item>
<attribute name="label" translatable="yes">Open In New _Tab</attribute>
<attribute name="action">view.pathbar-open-item-new-tab</attribute>
<attribute name="hidden-when">action-disabled</attribute>
</item>
</section>
<section>
<item>
<attribute name="label" translatable="yes">P_roperties</attribute>
<attribute name="action">view.pathbar-properties</attribute>
</item>
</section>
</menu>
</interface>
......@@ -157,8 +157,6 @@ struct NautilusViewDetails
NautilusWindowSlot *slot;
NautilusDirectory *model;
NautilusFile *directory_as_file;
NautilusFile *pathbar_popup_directory_as_file;
GdkEventButton *pathbar_popup_event;
guint dir_merge_id;
gint dialog_duplicated_name_label_timeout_id;
......@@ -227,7 +225,6 @@ struct NautilusViewDetails
GMenu *selection_menu;
GMenu *background_menu;
GMenu *pathbar_menu;
GActionGroup *view_action_group;
......@@ -283,8 +280,6 @@ static void update_templates_directory (NautilusView *vi
static void check_empty_states (NautilusView *view);
static void unschedule_pop_up_pathbar_context_menu (NautilusView *view);
G_DEFINE_TYPE (NautilusView, nautilus_view, GTK_TYPE_OVERLAY);
static void
......@@ -1223,26 +1218,6 @@ action_open_item_new_tab (GSimpleAction *action,
nautilus_file_list_free (selection);
}
static void
action_pathbar_open_item_new_tab (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusView *view;
NautilusFile *file;
view = NAUTILUS_VIEW (user_data);
file = view->details->pathbar_popup_directory_as_file;
if (file == NULL) {
return;
}
nautilus_view_activate_file (view,
file,
NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB);
}
static void
app_chooser_dialog_response_cb (GtkDialog *dialog,
gint response_id,
......@@ -2234,26 +2209,6 @@ action_properties (GSimpleAction *action,
nautilus_file_list_free (selection);
}
static void
action_pathbar_properties (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusView *view;
GList *files;
g_assert (NAUTILUS_IS_VIEW (user_data));
view = NAUTILUS_VIEW (user_data);
g_assert (NAUTILUS_IS_FILE (view->details->pathbar_popup_directory_as_file));
files = g_list_append (NULL, nautilus_file_ref (view->details->pathbar_popup_directory_as_file));
nautilus_properties_window_present (files, GTK_WIDGET (view), NULL);
nautilus_file_list_free (files);
}
static void
nautilus_view_set_show_hidden_files (NautilusView *view,
gboolean show_hidden)
......@@ -2349,26 +2304,6 @@ action_open_item_new_window (GSimpleAction *action,
nautilus_file_list_free (selection);
}
static void
action_pathbar_open_item_new_window (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
NautilusView *view;
NautilusFile *file;
view = NAUTILUS_VIEW (user_data);
file = view->details->pathbar_popup_directory_as_file;
if (file == NULL) {
return;
}
nautilus_view_activate_file (view,
file,
NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW);
}
static void
paste_clipboard_data (NautilusView *view,
GtkSelectionData *selection_data,
......@@ -2853,11 +2788,6 @@ nautilus_view_finalize (GObject *object)
g_signal_handlers_disconnect_by_func (gnome_lockdown_preferences,
schedule_update_context_menus, view);
unschedule_pop_up_pathbar_context_menu (view);
if (view->details->pathbar_popup_event != NULL) {
gdk_event_free ((GdkEvent *) view->details->pathbar_popup_event);
}
g_hash_table_destroy (view->details->non_ready_files);
G_OBJECT_CLASS (nautilus_view_parent_class)->finalize (object);
......@@ -6010,10 +5940,6 @@ const GActionEntry view_entries[] = {
{ "start-volume", action_start_volume },
{ "stop-volume", action_stop_volume },
{ "detect-media", action_detect_media },
/* Pathbar menu */
{ "pathbar-open-item-new-window", action_pathbar_open_item_new_window },
{ "pathbar-open-item-new-tab", action_pathbar_open_item_new_tab },
{ "pathbar-properties", action_pathbar_properties},
/* Only accesible by shorcuts */
{ "select-pattern", action_select_pattern },
{ "invert-selection", action_invert_selection },
......@@ -6779,13 +6705,11 @@ real_update_context_menus (NautilusView *view)
{
g_clear_object (&view->details->background_menu);
g_clear_object (&view->details->selection_menu);
g_clear_object (&view->details->pathbar_menu);
GtkBuilder *builder;
builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/nautilus-view-context-menus.xml");
view->details->background_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "background-menu")));
view->details->selection_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "selection-menu")));
view->details->pathbar_menu = g_object_ref (G_MENU (gtk_builder_get_object (builder, "pathbar-menu")));
g_object_unref (builder);
update_selection_menu (view);
......@@ -6886,109 +6810,7 @@ nautilus_view_pop_up_background_context_menu (NautilusView *view,
}
static void
real_pop_up_pathbar_context_menu (NautilusView *view)
{
/* Make the context menu items not flash as they update to proper disabled,
* etc. states by forcing menus to update now.
*/
update_context_menus_if_pending (view);
update_context_menu_position_from_event (view, view->details->pathbar_popup_event);
nautilus_pop_up_context_menu (GTK_WIDGET (view), view->details->pathbar_menu, view->details->pathbar_popup_event);
}
static void
pathbar_popup_file_attributes_ready (NautilusFile *file,
gpointer data)
{
NautilusView *view;
view = NAUTILUS_VIEW (data);
g_assert (NAUTILUS_IS_VIEW (view));
g_assert (file == view->details->pathbar_popup_directory_as_file);
real_pop_up_pathbar_context_menu (view);
}
static void
unschedule_pop_up_pathbar_context_menu (NautilusView *view)
{
if (view->details->pathbar_popup_directory_as_file != NULL) {
g_assert (NAUTILUS_IS_FILE (view->details->pathbar_popup_directory_as_file));
nautilus_file_cancel_call_when_ready (view->details->pathbar_popup_directory_as_file,
pathbar_popup_file_attributes_ready,
view);
nautilus_file_unref (view->details->pathbar_popup_directory_as_file);
view->details->pathbar_popup_directory_as_file = NULL;
}
}
static void
schedule_pop_up_pathbar_context_menu (NautilusView *view,
GdkEventButton *event,
NautilusFile *file)
{
g_assert (NAUTILUS_IS_FILE (file));
if (view->details->pathbar_popup_event != NULL) {
gdk_event_free ((GdkEvent *) view->details->pathbar_popup_event);
}
view->details->pathbar_popup_event = (GdkEventButton *) gdk_event_copy ((GdkEvent *)event);
if (file == view->details->pathbar_popup_directory_as_file) {
if (nautilus_file_check_if_ready (file, NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO)) {
real_pop_up_pathbar_context_menu (view);
}
} else {
unschedule_pop_up_pathbar_context_menu (view);
view->details->pathbar_popup_directory_as_file = nautilus_file_ref (file);
nautilus_file_call_when_ready (view->details->pathbar_popup_directory_as_file,
NAUTILUS_FILE_ATTRIBUTE_INFO |
NAUTILUS_FILE_ATTRIBUTE_MOUNT |
NAUTILUS_FILE_ATTRIBUTE_FILESYSTEM_INFO,
pathbar_popup_file_attributes_ready,
view);
}
}
/**
* nautilus_view_pop_up_pathbar_context_menu
*
* Pop up a context menu appropriate to the view globally.
* @view: NautilusView of interest.
* @event: GdkEventButton triggering the popup.
* @location: The location the popup-menu should be created for,
* or NULL for the currently displayed location.
*
**/
void
nautilus_view_pop_up_pathbar_context_menu (NautilusView *view,
GdkEventButton *event,
const char *location)
{
NautilusFile *file;
g_assert (NAUTILUS_IS_VIEW (view));
if (location != NULL) {
file = nautilus_file_get_by_uri (location);
} else {
file = nautilus_file_ref (view->details->directory_as_file);
}
if (file != NULL) {
schedule_pop_up_pathbar_context_menu (view, event, file);
nautilus_file_unref (file);
}
}
static void
schedule_update_context_menus (NautilusView *view)
schedule_update_context_menus (NautilusView *view)
{
g_assert (NAUTILUS_IS_VIEW (view));
......
......@@ -377,9 +377,6 @@ void nautilus_view_zoom_to_level (NautilusView *v
void nautilus_view_restore_default_zoom_level (NautilusView *view);
gboolean nautilus_view_can_zoom_in (NautilusView *view);
gboolean nautilus_view_can_zoom_out (NautilusView *view);
void nautilus_view_pop_up_pathbar_context_menu (NautilusView *view,
GdkEventButton *event,
const char *location);
void nautilus_view_update_menus (NautilusView *view);
void nautilus_view_update_context_menus (NautilusView *view);
......
......@@ -937,12 +937,10 @@ nautilus_window_location_opened (NautilusWindow *window,
/* Callback used when the places sidebar changes location; we need to change the displayed folder */
static void
places_sidebar_open_location_cb (GtkPlacesSidebar *sidebar,
GFile *location,
GtkPlacesOpenFlags open_flags,
gpointer user_data)
open_location_cb (NautilusWindow *window,
GFile *location,
GtkPlacesOpenFlags open_flags)
{
NautilusWindow *window = NAUTILUS_WINDOW (user_data);
NautilusWindowOpenFlags flags;
switch (open_flags) {
......@@ -1280,8 +1278,8 @@ nautilus_window_set_up_sidebar (NautilusWindow *window)
| GTK_PLACES_OPEN_NEW_WINDOW));
gtk_places_sidebar_set_show_connect_to_server (GTK_PLACES_SIDEBAR (window->priv->places_sidebar), TRUE);
g_signal_connect (window->priv->places_sidebar, "open-location",
G_CALLBACK (places_sidebar_open_location_cb), window);
g_signal_connect_swapped (window->priv->places_sidebar, "open-location",
G_CALLBACK (open_location_cb), window);
g_signal_connect (window->priv->places_sidebar, "show-error-message",
G_CALLBACK (places_sidebar_show_error_message_cb), window);
g_signal_connect (window->priv->places_sidebar, "show-connect-to-server",
......@@ -1648,53 +1646,6 @@ path_bar_location_changed_callback (GtkWidget *widget,
}
}
static gboolean
path_bar_path_event_callback (NautilusPathBar *path_bar,
GFile *location,
GdkEventButton *event,
NautilusWindow *window)
{
NautilusWindowSlot *slot;
NautilusWindowOpenFlags flags;
int mask;
NautilusView *view;
char *uri;
if (event->type == GDK_BUTTON_RELEASE) {
mask = event->state & gtk_accelerator_get_default_mod_mask ();
flags = 0;
if (event->button == 2 && mask == 0) {
flags = NAUTILUS_WINDOW_OPEN_FLAG_NEW_TAB;
} else if (event->button == 1 && mask == GDK_CONTROL_MASK) {
flags = NAUTILUS_WINDOW_OPEN_FLAG_NEW_WINDOW;
}
if (flags != 0) {
slot = nautilus_window_get_active_slot (window);
nautilus_window_slot_open_location (slot, location, flags);
}
return FALSE;
}
if (event->button == 3) {
slot = nautilus_window_get_active_slot (window);
view = nautilus_window_slot_get_view (slot);
if (view != NULL) {
uri = g_file_get_uri (location);
nautilus_view_pop_up_pathbar_context_menu (view, event, uri);
g_free (uri);
}
return TRUE;
} else if (event->button == 2) {
return TRUE;
}
return FALSE;
}
static void
notebook_popup_menu_new_tab_cb (GtkMenuItem *menuitem,
gpointer user_data)
......@@ -1859,8 +1810,8 @@ setup_toolbar (NautilusWindow *window)
g_signal_connect_object (path_bar, "path-clicked",
G_CALLBACK (path_bar_location_changed_callback), window, 0);
g_signal_connect_object (path_bar, "path-event",