gtkplacesview: Fix unmounted open in tab/window
authorCarlos Soriano <csoriano@gnome.org>
Fri, 21 Apr 2017 15:58:30 +0000 (17:58 +0200)
committerCarlos Soriano <csoriano@gnome.org>
Sat, 22 Apr 2017 09:51:21 +0000 (11:51 +0200)
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

gtk/gtkplacesview.c

index 5c24a5f785f39dee4edcc6a8163882e13f41e65b..edb8537ce8ec34fb8f92454467895b089a2351f9 100644 (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;
-
-  get_view_and_file (row, &view, &file);
-
-  if (file)
-    emit_open_location (GTK_PLACES_VIEW (view), file, GTK_PLACES_OPEN_NORMAL);
+  GtkPlacesView *self;
 
-  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;
-
-  get_view_and_file (row, &view, &file);
+  GtkPlacesView *self;
 
-  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