gtkplacesview: Fix unmounted open in tab/window

We were send the "open-location" signal without mounting first the
location if necessary, making the open in tab/window context menu not
work for those.

This patch makes sure we mount the location before emitting the signal.

https://bugzilla.gnome.org/show_bug.cgi?id=771269
This commit is contained in:
Carlos Soriano 2017-04-21 17:58:30 +02:00
parent b5eb37eba4
commit fba4e8fb47

View File

@ -1535,83 +1535,34 @@ popup_menu_detach_cb (GtkWidget *attach_widget,
priv->popup_menu = NULL;
}
static void
get_view_and_file (GtkPlacesViewRow *row,
GtkWidget **view,
GFile **file)
{
if (view)
*view = gtk_widget_get_ancestor (GTK_WIDGET (row), GTK_TYPE_PLACES_VIEW);
if (file)
{
GVolume *volume;
GMount *mount;
volume = gtk_places_view_row_get_volume (row);
mount = gtk_places_view_row_get_mount (row);
if (mount)
{
*file = g_mount_get_default_location (mount);
}
else if (volume)
{
*file = g_volume_get_activation_root (volume);
}
else
{
*file = gtk_places_view_row_get_file (row);
if (*file) {
g_object_ref (*file);
}
}
}
}
static void
open_cb (GtkMenuItem *item,
GtkPlacesViewRow *row)
{
GtkWidget *view;
GFile *file;
GtkPlacesView *self;
get_view_and_file (row, &view, &file);
if (file)
emit_open_location (GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NORMAL);
g_clear_object (&file);
self = GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), GTK_TYPE_PLACES_VIEW));
activate_row (self, row, GTK_PLACES_OPEN_NORMAL);
}
static void
open_in_new_tab_cb (GtkMenuItem *item,
GtkPlacesViewRow *row)
{
GtkWidget *view;
GFile *file;
GtkPlacesView *self;
get_view_and_file (row, &view, &file);
if (file)
emit_open_location (GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NEW_TAB);
g_clear_object (&file);
self = GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), GTK_TYPE_PLACES_VIEW));
activate_row (self, row, GTK_PLACES_OPEN_NEW_TAB);
}
static void
open_in_new_window_cb (GtkMenuItem *item,
GtkPlacesViewRow *row)
{
GtkWidget *view;
GFile *file;
GtkPlacesView *self;
get_view_and_file (row, &view, &file);
if (file)
emit_open_location (GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NEW_WINDOW);
g_clear_object (&file);
self = GTK_PLACES_VIEW (gtk_widget_get_ancestor (GTK_WIDGET (row), GTK_TYPE_PLACES_VIEW));
activate_row (self, row, GTK_PLACES_OPEN_NEW_WINDOW);
}
static void