file chooser: Be more careful with subtitles
authorMatthias Clasen <mclasen@redhat.com>
Wed, 15 Jul 2015 03:48:09 +0000 (23:48 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 15 Jul 2015 03:50:40 +0000 (23:50 -0400)
We were showing things like "Searching in (null)" if the current
folder is not in the sidebar. Avoid that by falling back to using
current_folder.

Pointed out by Carlos Soriano.

gtk/gtkfilechooserwidget.c

index ca414ada4f3432318c0810c8e79c2d05efc11bf1..6d8dfe4fd38421c72239958ecc6a98d2d7dd2c34 100644 (file)
@@ -3160,9 +3160,29 @@ gtk_file_chooser_widget_get_subtitle (GtkFileChooserWidget *impl)
     {
       gchar *location;
 
+      subtitle = _("Searching");
+
       location = gtk_places_sidebar_get_location_title (GTK_PLACES_SIDEBAR (priv->places_sidebar));
-      subtitle = g_strdup_printf (_("Searching in %s"), location);
-      g_free (location);
+      if (location)
+        {
+          subtitle = g_strdup_printf (_("Searching in %s"), location);
+          g_free (location);
+        }
+      else if (priv->current_folder)
+        {
+          GFileInfo *info;
+
+          info = g_file_query_info (priv->current_folder,
+                                    G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
+                                    G_FILE_QUERY_INFO_NONE,
+                                    NULL,
+                                    NULL);
+          if (info)
+            {
+              subtitle = g_strdup_printf (_("Searching in %s"), g_file_info_get_display_name (info));
+              g_object_unref (info);
+            }
+        }
     }
   else if (priv->operation_mode == OPERATION_MODE_ENTER_LOCATION ||
            (priv->operation_mode == OPERATION_MODE_BROWSE &&