mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 06:21:14 +00:00
filechooser: Move extract_recent_folders to filechooserwidget
It's not used anywhere else.
This commit is contained in:
parent
c102387916
commit
ae75d4b565
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user