]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfilechooserutils.c
docs: Typo fix
[~andy/gtk] / gtk / gtkfilechooserutils.c
index 4e327a9418084f4f07bf6a4ba193f574de9d8005..43148aa9c34654a9f33749f6b70978e18d213d51 100644 (file)
@@ -14,9 +14,7 @@
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
@@ -361,16 +359,6 @@ delegate_confirm_overwrite (GtkFileChooser    *chooser,
   return conf;
 }
 
-static gint
-recent_sort_mru (gconstpointer a,
-                 gconstpointer b)
-{
-  GtkRecentInfo *info_a = (GtkRecentInfo *) a;
-  GtkRecentInfo *info_b = (GtkRecentInfo *) b;
-
-  return (gtk_recent_info_get_modified (info_b) - gtk_recent_info_get_modified (info_a));
-}
-
 static GFile *
 get_parent_for_uri (const char *uri)
 {
@@ -385,22 +373,18 @@ get_parent_for_uri (const char *uri)
        
 }
 
-/* Extracts the parent folders out of the recent items, and returns
- * a list of GFile* for those parents in MRU-first order.
+/* Extracts the parent folders out of the supplied list of GtkRecentInfo* items, and returns
+ * a list of GFile* for those unique parents.
  */
 GList *
-_gtk_file_chooser_list_recent_folders (GtkRecentManager *manager)
+_gtk_file_chooser_extract_recent_folders (GList *infos)
 {
-  GList *infos;
   GList *l;
   GList *result;
   GHashTable *folders;
 
   result = NULL;
 
-  infos = gtk_recent_manager_get_items (manager);
-  infos = g_list_sort (infos, recent_sort_mru);
-
   folders = g_hash_table_new (g_file_hash, (GEqualFunc) g_file_equal);
 
   for (l = infos; l; l = l->next)
@@ -427,8 +411,33 @@ _gtk_file_chooser_list_recent_folders (GtkRecentManager *manager)
   result = g_list_reverse (result);
 
   g_hash_table_destroy (folders);
-  g_list_foreach (infos, (GFunc) gtk_recent_info_unref, NULL);
-  g_list_free (infos);
 
   return result;
 }
+
+GSettings *
+_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget)
+{
+  static GQuark file_chooser_settings_quark = 0;
+  GtkSettings *gtksettings;
+  GSettings *settings;
+
+  if (G_UNLIKELY (file_chooser_settings_quark == 0))
+    file_chooser_settings_quark = g_quark_from_static_string ("-gtk-file-chooser-settings");
+
+  gtksettings = gtk_widget_get_settings (widget);
+  settings = g_object_get_qdata (G_OBJECT (gtksettings), file_chooser_settings_quark);
+
+  if (G_UNLIKELY (settings == NULL))
+    {
+      settings = g_settings_new ("org.gtk.Settings.FileChooser");
+      g_settings_delay (settings);
+
+      g_object_set_qdata_full (G_OBJECT (gtksettings),
+                               file_chooser_settings_quark,
+                               settings,
+                               g_object_unref);
+    }
+
+  return settings;
+}