[gtk/wip/baedert/for-master] filechooser: Move extract_recent_folders to filechooserwidget
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/baedert/for-master] filechooser: Move extract_recent_folders to filechooserwidget
- Date: Fri, 30 Aug 2019 05:49:44 +0000 (UTC)
commit e3dce0a0074396c2b8c837f0b3fc70faf7ba0a33
Author: Timm Bäder <mail baedert org>
Date: Fri Aug 30 07:13:25 2019 +0200
filechooser: Move extract_recent_folders to filechooserwidget
It's not used anywhere else.
gtk/gtkfilechooserutils.c | 56 ----------------------------------------------
gtk/gtkfilechooserutils.h | 2 --
gtk/gtkfilechooserwidget.c | 46 +++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 58 deletions(-)
---
diff --git a/gtk/gtkfilechooserutils.c b/gtk/gtkfilechooserutils.c
index 3d89ab6012..c022306dca 100644
--- a/gtk/gtkfilechooserutils.c
+++ b/gtk/gtkfilechooserutils.c
@@ -384,62 +384,6 @@ delegate_confirm_overwrite (GtkFileChooser *chooser,
return conf;
}
-static GFile *
-get_parent_for_uri (const char *uri)
-{
- GFile *file;
- GFile *parent;
-
- file = g_file_new_for_uri (uri);
- parent = g_file_get_parent (file);
-
- g_object_unref (file);
- return parent;
-
-}
-
-/* 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_extract_recent_folders (GList *infos)
-{
- GList *l;
- GList *result;
- GHashTable *folders;
-
- result = NULL;
-
- folders = g_hash_table_new (g_file_hash, (GEqualFunc) g_file_equal);
-
- for (l = infos; l; l = l->next)
- {
- GtkRecentInfo *info = l->data;
- const char *uri;
- GFile *parent;
-
- uri = gtk_recent_info_get_uri (info);
- parent = get_parent_for_uri (uri);
-
- if (parent)
- {
- if (!g_hash_table_lookup (folders, parent))
- {
- g_hash_table_insert (folders, parent, (gpointer) 1);
- result = g_list_prepend (result, g_object_ref (parent));
- }
-
- g_object_unref (parent);
- }
- }
-
- result = g_list_reverse (result);
-
- g_hash_table_destroy (folders);
-
- return result;
-}
-
GSettings *
_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget)
{
diff --git a/gtk/gtkfilechooserutils.h b/gtk/gtkfilechooserutils.h
index 21b98b0297..6938791515 100644
--- a/gtk/gtkfilechooserutils.h
+++ b/gtk/gtkfilechooserutils.h
@@ -50,8 +50,6 @@ void _gtk_file_chooser_set_delegate (GtkFileChooser *receiver,
GQuark _gtk_file_chooser_delegate_get_quark (void) G_GNUC_CONST;
-GList *_gtk_file_chooser_extract_recent_folders (GList *infos);
-
GSettings *_gtk_file_chooser_get_settings_for_widget (GtkWidget *widget);
gchar * _gtk_file_chooser_label_for_file (GFile *file);
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index d136782059..3315fbb453 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -737,6 +737,52 @@ get_toplevel (GtkWidget *widget)
return NULL;
}
+/* Extracts the parent folders out of the supplied list of GtkRecentInfo* items, and returns
+ * a list of GFile* for those unique parents.
+ */
+static GList *
+_gtk_file_chooser_extract_recent_folders (GList *infos)
+{
+ GList *l;
+ GList *result;
+ GHashTable *folders;
+
+ result = NULL;
+
+ folders = g_hash_table_new (g_file_hash, (GEqualFunc) g_file_equal);
+
+ for (l = infos; l; l = l->next)
+ {
+ GtkRecentInfo *info = l->data;
+ const char *uri;
+ GFile *parent;
+ GFile *file;
+
+ uri = gtk_recent_info_get_uri (info);
+
+ file = g_file_new_for_uri (uri);
+ parent = g_file_get_parent (file);
+ g_object_unref (file);
+
+ if (parent)
+ {
+ if (!g_hash_table_lookup (folders, parent))
+ {
+ g_hash_table_insert (folders, parent, (gpointer) 1);
+ result = g_list_prepend (result, g_object_ref (parent));
+ }
+
+ g_object_unref (parent);
+ }
+ }
+
+ result = g_list_reverse (result);
+
+ g_hash_table_destroy (folders);
+
+ return result;
+}
+
/* Shows an error dialog for the file chooser */
static void
error_message (GtkFileChooserWidget *impl,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]