filedialog: Drop shortcut folders

The filechooser portal does not support this,
and we are defaulting to using the portal now.
Lets not offer a non-functional API.
This commit is contained in:
Matthias Clasen 2023-01-06 07:40:57 -05:00
parent 7eb8439047
commit 9356dfc404
3 changed files with 0 additions and 117 deletions

View File

@ -56,7 +56,6 @@ struct _GtkFileDialog
unsigned int modal : 1; unsigned int modal : 1;
GListModel *filters; GListModel *filters;
GListModel *shortcut_folders;
GtkFileFilter *default_filter; GtkFileFilter *default_filter;
GFile *initial_folder; GFile *initial_folder;
char *initial_name; char *initial_name;
@ -73,7 +72,6 @@ enum
PROP_INITIAL_FOLDER, PROP_INITIAL_FOLDER,
PROP_INITIAL_NAME, PROP_INITIAL_NAME,
PROP_MODAL, PROP_MODAL,
PROP_SHORTCUT_FOLDERS,
PROP_TITLE, PROP_TITLE,
NUM_PROPERTIES NUM_PROPERTIES
@ -97,7 +95,6 @@ gtk_file_dialog_finalize (GObject *object)
g_free (self->title); g_free (self->title);
g_free (self->accept_label); g_free (self->accept_label);
g_clear_object (&self->filters); g_clear_object (&self->filters);
g_clear_object (&self->shortcut_folders);
g_clear_object (&self->default_filter); g_clear_object (&self->default_filter);
g_clear_object (&self->initial_folder); g_clear_object (&self->initial_folder);
g_free (self->initial_name); g_free (self->initial_name);
@ -127,10 +124,6 @@ gtk_file_dialog_get_property (GObject *object,
g_value_set_object (value, self->filters); g_value_set_object (value, self->filters);
break; break;
case PROP_SHORTCUT_FOLDERS:
g_value_set_object (value, self->shortcut_folders);
break;
case PROP_DEFAULT_FILTER: case PROP_DEFAULT_FILTER:
g_value_set_object (value, self->default_filter); g_value_set_object (value, self->default_filter);
break; break;
@ -179,10 +172,6 @@ gtk_file_dialog_set_property (GObject *object,
gtk_file_dialog_set_filters (self, g_value_get_object (value)); gtk_file_dialog_set_filters (self, g_value_get_object (value));
break; break;
case PROP_SHORTCUT_FOLDERS:
gtk_file_dialog_set_shortcut_folders (self, g_value_get_object (value));
break;
case PROP_DEFAULT_FILTER: case PROP_DEFAULT_FILTER:
gtk_file_dialog_set_default_filter (self, g_value_get_object (value)); gtk_file_dialog_set_default_filter (self, g_value_get_object (value));
break; break;
@ -256,18 +245,6 @@ gtk_file_dialog_class_init (GtkFileDialogClass *class)
G_TYPE_LIST_MODEL, G_TYPE_LIST_MODEL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY); G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkFileDialog:shortcut-folders: (attributes org.gtk.Property.get=gtk_file_dialog_get_shortcut_folders org.gtk.Property.set=gtk_file_dialog_set_shortcut_folders)
*
* The list of shortcut folders.
*
* Since: 4.10
*/
properties[PROP_SHORTCUT_FOLDERS] =
g_param_spec_object ("shortcut-folders", NULL, NULL,
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
/** /**
* GtkFileDialog:default-filter: (attributes org.gtk.Property.get=gtk_file_dialog_get_default_filter org.gtk.Property.set=gtk_file_dialog_set_default_filter) * GtkFileDialog:default-filter: (attributes org.gtk.Property.get=gtk_file_dialog_get_default_filter org.gtk.Property.set=gtk_file_dialog_set_default_filter)
* *
@ -365,30 +342,6 @@ G_GNUC_END_IGNORE_DEPRECATIONS
} }
} }
static void
file_chooser_set_shortcut_folders (GtkFileChooser *chooser,
GListModel *shortcut_folders)
{
if (!shortcut_folders)
return;
for (unsigned int i = 0; i < g_list_model_get_n_items (shortcut_folders); i++)
{
GFile *folder = g_list_model_get_item (shortcut_folders, i);
GError *error = NULL;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
if (!gtk_file_chooser_add_shortcut_folder (chooser, folder, &error))
{
g_critical ("%s", error->message);
g_clear_error (&error);
}
G_GNUC_END_IGNORE_DEPRECATIONS
g_object_unref (folder);
}
}
/* }}} */ /* }}} */
/* {{{ API: Constructor */ /* {{{ API: Constructor */
@ -546,49 +499,6 @@ gtk_file_dialog_set_filters (GtkFileDialog *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FILTERS]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FILTERS]);
} }
/**
* gtk_file_dialog_get_shortcut_folders:
* @self: a `GtkFileDialog`
*
* Gets the shortcut folders that will be available to
* the user in the file chooser dialog.
*
* Returns: (nullable) (transfer none): the shortcut
* folders, as a `GListModel` of `GFiles`
*
* Since: 4.10
*/
GListModel *
gtk_file_dialog_get_shortcut_folders (GtkFileDialog *self)
{
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
return self->shortcut_folders;
}
/**
* gtk_file_dialog_set_shortcut_folders:
* @self: a `GtkFileDialog`
* @shortcut_folders: a `GListModel` of `GFiles`
*
* Sets the shortcut folders that will be available to
* the user in the file chooser dialog.
*
* Since: 4.10
*/
void
gtk_file_dialog_set_shortcut_folders (GtkFileDialog *self,
GListModel *shortcut_folders)
{
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
g_return_if_fail (G_IS_LIST_MODEL (shortcut_folders));
if (!g_set_object (&self->shortcut_folders, shortcut_folders))
return;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHORTCUT_FOLDERS]);
}
/** /**
* gtk_file_dialog_get_default_filter: * gtk_file_dialog_get_default_filter:
* @self: a `GtkFileDialog` * @self: a `GtkFileDialog`
@ -956,7 +866,6 @@ create_file_chooser (GtkFileDialog *self,
} }
} }
file_chooser_set_shortcut_folders (GTK_FILE_CHOOSER (chooser), self->shortcut_folders);
if (self->initial_folder) if (self->initial_folder)
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), self->initial_folder, NULL); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), self->initial_folder, NULL);
if (self->initial_file) if (self->initial_file)

View File

@ -64,15 +64,6 @@ GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_default_filter (GtkFileDialog *self, void gtk_file_dialog_set_default_filter (GtkFileDialog *self,
GtkFileFilter *filter); GtkFileFilter *filter);
GDK_AVAILABLE_IN_4_10
GListModel * gtk_file_dialog_get_shortcut_folders
(GtkFileDialog *self);
GDK_AVAILABLE_IN_4_10
void gtk_file_dialog_set_shortcut_folders
(GtkFileDialog *self,
GListModel *shortcut_folders);
GDK_AVAILABLE_IN_4_10 GDK_AVAILABLE_IN_4_10
GFile * gtk_file_dialog_get_initial_folder (GtkFileDialog *self); GFile * gtk_file_dialog_get_initial_folder (GtkFileDialog *self);

View File

@ -149,7 +149,6 @@ main (int argc, char *argv[])
GCancellable *cancellable; GCancellable *cancellable;
char *title = NULL; char *title = NULL;
gboolean modal = TRUE; gboolean modal = TRUE;
char **shortcut_folders = NULL;
char *initial_folder = NULL; char *initial_folder = NULL;
char *initial_name = NULL; char *initial_name = NULL;
char *initial_file = NULL; char *initial_file = NULL;
@ -158,7 +157,6 @@ main (int argc, char *argv[])
GOptionEntry options[] = { GOptionEntry options[] = {
{ "title", 0, 0, G_OPTION_ARG_STRING, &title, "Title", "TITLE" }, { "title", 0, 0, G_OPTION_ARG_STRING, &title, "Title", "TITLE" },
{ "nonmodal", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &modal, "Non-modal", NULL }, { "nonmodal", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &modal, "Non-modal", NULL },
{ "shortcut-folders", 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &shortcut_folders, "Shortcut folders", "FOLDER" },
{ "initial-folder", 0, 0, G_OPTION_ARG_FILENAME, &initial_folder, "Initial folder", "FOLDER" }, { "initial-folder", 0, 0, G_OPTION_ARG_FILENAME, &initial_folder, "Initial folder", "FOLDER" },
{ "initial-name", 0, 0, G_OPTION_ARG_STRING, &initial_name, "Initial name", "NAME" }, { "initial-name", 0, 0, G_OPTION_ARG_STRING, &initial_name, "Initial name", "NAME" },
{ "initial-file", 0, 0, G_OPTION_ARG_FILENAME, &initial_file, "Initial file", "FILE" }, { "initial-file", 0, 0, G_OPTION_ARG_FILENAME, &initial_file, "Initial file", "FILE" },
@ -187,21 +185,6 @@ main (int argc, char *argv[])
if (title) if (title)
gtk_file_dialog_set_title (dialog, title); gtk_file_dialog_set_title (dialog, title);
gtk_file_dialog_set_modal (dialog, modal); gtk_file_dialog_set_modal (dialog, modal);
if (shortcut_folders)
{
GListStore *store;
store = g_list_store_new (G_TYPE_FILE);
for (int i = 0; shortcut_folders[i]; i++)
{
GFile *file = g_file_new_for_commandline_arg (shortcut_folders[i]);
g_list_store_append (store, file);
g_object_unref (file);
}
gtk_file_dialog_set_shortcut_folders (dialog, G_LIST_MODEL (store));
g_object_unref (store);
}
if (initial_folder) if (initial_folder)
{ {
GFile *file = g_file_new_for_commandline_arg (initial_folder); GFile *file = g_file_new_for_commandline_arg (initial_folder);