summaryrefslogtreecommitdiff
path: root/gtk/gtkfilechoosernativewin32.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-07-04 22:08:33 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-07-06 11:03:48 -0400
commit57a225681c4ae8d2f36ab8e7e65ef1f5df265ac4 (patch)
tree2bc12802d3851c9623814f7d6a1ed5943515fcb4 /gtk/gtkfilechoosernativewin32.c
parentea07a9236633ef055e66c742b115b546bcf30d68 (diff)
downloadgtk+-57a225681c4ae8d2f36ab8e7e65ef1f5df265ac4.tar.gz
filechooser: Add gtk_file_chooser_get_shortcuts
Replace gtk_file_chooser_list_shortcuts with a new api that returns a list model. Update all callers.
Diffstat (limited to 'gtk/gtkfilechoosernativewin32.c')
-rw-r--r--gtk/gtkfilechoosernativewin32.c26
1 files changed, 16 insertions, 10 deletions
diff --git a/gtk/gtkfilechoosernativewin32.c b/gtk/gtkfilechoosernativewin32.c
index 722f324ae8..66157ccd69 100644
--- a/gtk/gtkfilechoosernativewin32.c
+++ b/gtk/gtkfilechoosernativewin32.c
@@ -66,7 +66,7 @@ typedef struct {
char *cancel_label;
char *title;
- GSList *shortcut_files;
+ GListModel *shortcut_files;
GArray *choices_selections;
GFile *current_folder;
@@ -330,7 +330,7 @@ filechooser_win32_thread_data_free (FilechooserWin32ThreadData *data)
g_array_free (data->choices_selections, TRUE);
data->choices_selections = NULL;
}
- g_slist_free_full (data->shortcut_files, g_object_unref);
+ g_object_unref (data->shortcut_files);
g_slist_free_full (data->files, g_object_unref);
if (data->self)
g_object_unref (data->self);
@@ -465,7 +465,7 @@ filechooser_win32_thread (gpointer _data)
IFileDialog2 *pfd2 = NULL;
DWORD flags;
DWORD cookie;
- GSList *l;
+ guint j, n_items;
CoInitializeEx (NULL, COINIT_APARTMENTTHREADED);
@@ -531,9 +531,11 @@ filechooser_win32_thread (gpointer _data)
g_free (label);
}
- for (l = data->shortcut_files; l != NULL; l = l->next)
+ n_items = g_list_model_get_n_items (data->shortcut_files);
+ for (j = 0; j < n_items; j++)
{
- IShellItem *item = get_shell_item_for_file (l->data);
+ GFile *file = g_list_model_get_item (data->shortcut_files, j);
+ IShellItem *item = get_shell_item_for_file (file);
if (item)
{
hr = IFileDialog_AddPlace (pfd, item, FDAP_BOTTOM);
@@ -541,6 +543,7 @@ filechooser_win32_thread (gpointer _data)
g_warning_hr ("Can't add dialog shortcut", hr);
IShellItem_Release (item);
}
+ g_object_unref (file);
}
if (data->current_file)
@@ -594,17 +597,16 @@ filechooser_win32_thread (gpointer _data)
if (data->self->current_filter)
{
GListModel *filters;
- guint n_items, i;
guint current_filter_index = GTK_INVALID_LIST_POSITION;
filters = gtk_file_chooser_get_filters (GTK_FILE_CHOOSER (data->self));
n_items = g_list_model_get_n_items (filters);
- for (i = 0; i < n_items; i++)
+ for (j = 0; j < n_items; j++)
{
- gpointer item = g_list_model_get_item (filters, i);
+ gpointer item = g_list_model_get_item (filters, j);
if (item == data->self->current_filter)
{
- current_filter_index = i;
+ current_filter_index = j;
g_object_unref (item);
break;
}
@@ -634,6 +636,8 @@ filechooser_win32_thread (gpointer _data)
hr = IFileDialog_QueryInterface (pfd, &IID_IFileDialogCustomize, (LPVOID *) &pfdc);
if (SUCCEEDED (hr))
{
+ GSList *l;
+
for (l = data->self->choices; l; l = l->next, dialog_control_id++)
{
GtkFileChooserNativeChoice *choice = (GtkFileChooserNativeChoice*) l->data;
@@ -759,6 +763,8 @@ filechooser_win32_thread (gpointer _data)
hr = IFileDialog_QueryInterface (pfd, &IID_IFileDialogCustomize, (LPVOID *) &pfdc);
if (SUCCEEDED (hr))
{
+ GSList *l;
+
for (l = data->self->choices; l; l = l->next)
{
GtkFileChooserNativeChoice *choice = (GtkFileChooserNativeChoice*) l->data;
@@ -915,7 +921,7 @@ gtk_file_chooser_native_win32_show (GtkFileChooserNative *self)
data->self = g_object_ref (self);
data->shortcut_files =
- gtk_file_chooser_list_shortcut_folders (GTK_FILE_CHOOSER (self->dialog));
+ gtk_file_chooser_get_shortcut_folders (GTK_FILE_CHOOSER (self->dialog));
data->accept_label = translate_mnemonics (self->accept_label);
data->cancel_label = translate_mnemonics (self->cancel_label);