mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-04 09:40:19 +00:00
Merge branch 'wip/otte/for-main' into 'main'
GtkDialog: Various API changes See merge request GNOME/gtk!5251
This commit is contained in:
commit
7213bf5b09
@ -228,9 +228,9 @@ open_cb (GtkWidget *button,
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Open file");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_current_folder (dialog, cwd);
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
gtk_file_dialog_open (dialog, GTK_WINDOW (self), NULL, NULL, open_response_cb, self);
|
||||
gtk_file_dialog_open (dialog, GTK_WINDOW (self), NULL, open_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
@ -337,11 +337,10 @@ save_cb (GtkWidget *button,
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Save constraints");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_current_folder (dialog, cwd);
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL, NULL,
|
||||
NULL,
|
||||
save_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
|
@ -124,7 +124,7 @@ activate_open (GSimpleAction *action,
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_open (dialog, NULL, NULL, NULL, open_response_cb, g_object_ref (app));
|
||||
gtk_file_dialog_open (dialog, NULL, NULL, open_response_cb, g_object_ref (app));
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
|
@ -244,8 +244,9 @@ open_file_cb (GtkWidget *button)
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||
NULL,
|
||||
NULL,
|
||||
file_chooser_response, button);
|
||||
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -277,9 +278,11 @@ open_folder_cb (GtkWidget *button)
|
||||
gtk_file_dialog_select_folder (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_ancestor (button, GTK_TYPE_WINDOW)),
|
||||
NULL,
|
||||
NULL,
|
||||
folder_chooser_response, button);
|
||||
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
static void
|
||||
update_paste_button_sensitivity (GdkClipboard *clipboard,
|
||||
GtkWidget *paste_button)
|
||||
|
@ -167,7 +167,6 @@ file_open_cb (GtkWidget *button,
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
NULL,
|
||||
NULL,
|
||||
open_response_cb, stringlist);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
@ -55,7 +55,6 @@ show_file_open (GtkWidget *button,
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
NULL,
|
||||
NULL,
|
||||
open_response_cb, picture);
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ open_file (GtkButton *picker,
|
||||
20,
|
||||
abort_mission, g_object_ref (cancellable), g_object_unref);
|
||||
|
||||
gtk_file_dialog_open (dialog, parent, NULL, cancellable, file_opened, label);
|
||||
gtk_file_dialog_open (dialog, parent, cancellable, file_opened, label);
|
||||
|
||||
g_object_unref (cancellable);
|
||||
g_object_unref (dialog);
|
||||
|
@ -56,7 +56,7 @@ open_clicked_cb (GtkWidget *button,
|
||||
gtk_file_filter_set_name (filter, "Video");
|
||||
g_list_store_append (filters, filter);
|
||||
|
||||
gtk_file_dialog_set_current_filter (dialog, filter);
|
||||
gtk_file_dialog_set_default_filter (dialog, filter);
|
||||
g_object_unref (filter);
|
||||
|
||||
gtk_file_dialog_set_filters (dialog, G_LIST_MODEL (filters));
|
||||
@ -65,7 +65,6 @@ open_clicked_cb (GtkWidget *button,
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (button)),
|
||||
NULL,
|
||||
NULL,
|
||||
open_dialog_response_cb, video);
|
||||
}
|
||||
|
||||
|
@ -569,10 +569,10 @@ show_open_filechooser (NodeEditorWindow *self)
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Open node file");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_current_folder (dialog, cwd);
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
g_object_unref (cwd);
|
||||
gtk_file_dialog_open (dialog, GTK_WINDOW (self),
|
||||
NULL, NULL, open_response_cb, self);
|
||||
NULL, open_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
@ -633,13 +633,12 @@ save_cb (GtkWidget *button,
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "Save node");
|
||||
cwd = g_file_new_for_path (".");
|
||||
gtk_file_dialog_set_current_folder (dialog, cwd);
|
||||
gtk_file_dialog_set_initial_folder (dialog, cwd);
|
||||
gtk_file_dialog_set_initial_name (dialog, "demo.node");
|
||||
g_object_unref (cwd);
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL,
|
||||
"demo.node",
|
||||
NULL,
|
||||
save_response_cb, self);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
@ -742,11 +741,10 @@ export_image_cb (GtkWidget *button,
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, "");
|
||||
gtk_file_dialog_set_initial_name (dialog, "example.png");
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (button))),
|
||||
NULL,
|
||||
"example.png",
|
||||
NULL,
|
||||
export_image_response_cb, texture);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
@ -508,8 +508,6 @@ activate_save_as (GSimpleAction *action,
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (main_window),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
on_save_response, NULL);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
@ -553,7 +551,6 @@ activate_open (GSimpleAction *action,
|
||||
gtk_file_dialog_open (dialog,
|
||||
GTK_WINDOW (main_window),
|
||||
NULL,
|
||||
NULL,
|
||||
on_open_response, NULL);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ activate_open_file (GSimpleAction *action,
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_open (dialog, NULL, NULL, NULL, file_chooser_response, NULL);
|
||||
gtk_file_dialog_open (dialog, NULL, NULL, file_chooser_response, NULL);
|
||||
g_object_unref (dialog);
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ response_received (GDBusConnection *connection,
|
||||
g_task_return_boolean (task, TRUE);
|
||||
break;
|
||||
case XDG_DESKTOP_PORTAL_CANCELLED:
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "The portal dialog was closed");
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_DISMISSED, "The portal dialog was dismissed by the user");
|
||||
break;
|
||||
case XDG_DESKTOP_PORTAL_FAILED:
|
||||
default:
|
||||
@ -252,8 +252,8 @@ canceled (GCancellable *cancellable,
|
||||
send_close (data);
|
||||
|
||||
g_task_return_new_error (task,
|
||||
GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_ABORTED,
|
||||
"The OpenURI portal call was cancelled programmatically");
|
||||
GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED,
|
||||
"The OpenURI portal call was cancelled by the application");
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
@ -390,8 +390,8 @@ open_uri_done (GObject *source,
|
||||
{
|
||||
g_error_free (error);
|
||||
g_task_return_new_error (data->task,
|
||||
GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_ABORTED,
|
||||
"The operation was aborted programmatically");
|
||||
GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED,
|
||||
"The operation was cancelled by the application");
|
||||
}
|
||||
else
|
||||
g_task_return_error (data->task, error);
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "gtkalertdialog.h"
|
||||
|
||||
#include "gtkbutton.h"
|
||||
#include "gtkdialogerror.h"
|
||||
#include "deprecated/gtkmessagedialog.h"
|
||||
#include <glib/gi18n-lib.h>
|
||||
|
||||
@ -606,7 +607,11 @@ response_cb (GTask *task,
|
||||
if (cancellable)
|
||||
g_signal_handlers_disconnect_by_func (cancellable, cancelled_cb, task);
|
||||
|
||||
if (response >= 0)
|
||||
if (response == GTK_RESPONSE_CLOSE)
|
||||
{
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by application");
|
||||
}
|
||||
else if (response >= 0)
|
||||
{
|
||||
g_task_return_int (task, response);
|
||||
}
|
||||
@ -614,7 +619,10 @@ response_cb (GTask *task,
|
||||
{
|
||||
GtkAlertDialog *self = GTK_ALERT_DIALOG (g_task_get_source_object (task));
|
||||
|
||||
g_task_return_int (task, self->cancel_return);
|
||||
if (self->cancel_return >= 0)
|
||||
g_task_return_int (task, self->cancel_return);
|
||||
else
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_DISMISSED, "Dismissed by user");
|
||||
}
|
||||
|
||||
g_object_unref (task);
|
||||
@ -719,6 +727,7 @@ gtk_alert_dialog_choose (GtkAlertDialog *self,
|
||||
* gtk_alert_dialog_choose_finish:
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @result: a `GAsyncResult`
|
||||
* @error: return location for a [enum@Gtk.DialogError] error
|
||||
*
|
||||
* Finishes the [method@Gtk.AlertDialog.choose] call
|
||||
* and returns the index of the button that was clicked.
|
||||
@ -731,13 +740,14 @@ gtk_alert_dialog_choose (GtkAlertDialog *self,
|
||||
*/
|
||||
int
|
||||
gtk_alert_dialog_choose_finish (GtkAlertDialog *self,
|
||||
GAsyncResult *result)
|
||||
GAsyncResult *result,
|
||||
GError **error)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_ALERT_DIALOG (self), -1);
|
||||
g_return_val_if_fail (g_task_is_valid (result, self), -1);
|
||||
g_return_val_if_fail (g_task_get_source_tag (G_TASK (result)) == gtk_alert_dialog_choose, -1);
|
||||
|
||||
return (int) g_task_propagate_int (G_TASK (result), NULL);
|
||||
return (int) g_task_propagate_int (G_TASK (result), error);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -745,11 +755,13 @@ gtk_alert_dialog_choose_finish (GtkAlertDialog *self,
|
||||
* @self: a `GtkAlertDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
*
|
||||
* This function shows the alert to the user.
|
||||
* Show the alert to the user.
|
||||
*
|
||||
* If the alert has more than one button, you should use
|
||||
* [method@Gtk.AlertDialog.choose] instead and provide
|
||||
* a callback that can react to the button that was clicked.
|
||||
* This function is a simple version of [method@Gtk.AlertDialog.choose]
|
||||
* intended for dialogs with a single button.
|
||||
* If you want to cancel the dialog or if the alert has more than one button,
|
||||
* you should use that function instead and provide it with a #GCancellable or
|
||||
* callback respectively.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
|
@ -87,7 +87,8 @@ void gtk_alert_dialog_choose (GtkAlertDialog *self,
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
int gtk_alert_dialog_choose_finish (GtkAlertDialog *self,
|
||||
GAsyncResult *result);
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_alert_dialog_show (GtkAlertDialog *self,
|
||||
|
@ -387,10 +387,10 @@ G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
g_task_return_pointer (task, gdk_rgba_copy (&color), (GDestroyNotify) gdk_rgba_free);
|
||||
}
|
||||
else if (response == GTK_RESPONSE_CLOSE)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_ABORTED, "Aborted by application");
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by application");
|
||||
else if (response == GTK_RESPONSE_CANCEL ||
|
||||
response == GTK_RESPONSE_DELETE_EVENT)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by user");
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_DISMISSED, "Dismissed by user");
|
||||
else
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_FAILED, "Unknown failure (%d)", response);
|
||||
|
||||
|
@ -39,10 +39,10 @@ G_BEGIN_DECLS
|
||||
* GtkDialogError:
|
||||
* @GTK_DIALOG_ERROR_FAILED: Generic error condition for when
|
||||
* an operation fails and no more specific code is applicable
|
||||
* @GTK_DIALOG_ERROR_ABORTED: The async function call was aborted
|
||||
* programmatically (via its `GCancellable`)
|
||||
* @GTK_DIALOG_ERROR_CANCELLED: The async operation was cancelled
|
||||
* by the user (via a Close button)
|
||||
* @GTK_DIALOG_ERROR_CANCELLED: The async function call was cancelled
|
||||
* via its `GCancellable`
|
||||
* @GTK_DIALOG_ERROR_DISMISSED: The operation was cancelled
|
||||
* by the user (via a Cancel or Close button)
|
||||
*
|
||||
* Error codes in the `GTK_DIALOG_ERROR` domain that can be returned
|
||||
* by async dialog functions.
|
||||
@ -52,8 +52,8 @@ G_BEGIN_DECLS
|
||||
typedef enum
|
||||
{
|
||||
GTK_DIALOG_ERROR_FAILED,
|
||||
GTK_DIALOG_ERROR_ABORTED,
|
||||
GTK_DIALOG_ERROR_CANCELLED
|
||||
GTK_DIALOG_ERROR_CANCELLED,
|
||||
GTK_DIALOG_ERROR_DISMISSED
|
||||
} GtkDialogError;
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
|
@ -544,6 +544,7 @@ static void
|
||||
gtk_directory_list_start_loading (GtkDirectoryList *self)
|
||||
{
|
||||
gboolean was_loading;
|
||||
char *glib_apis_suck;
|
||||
|
||||
was_loading = gtk_directory_list_stop_loading (self);
|
||||
gtk_directory_list_clear_items (self);
|
||||
@ -555,14 +556,16 @@ gtk_directory_list_start_loading (GtkDirectoryList *self)
|
||||
return;
|
||||
}
|
||||
|
||||
glib_apis_suck = g_strconcat ("standard::name,", self->attributes, NULL);
|
||||
self->cancellable = g_cancellable_new ();
|
||||
g_file_enumerate_children_async (self->file,
|
||||
self->attributes,
|
||||
glib_apis_suck,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
self->io_priority,
|
||||
self->cancellable,
|
||||
gtk_directory_list_got_enumerator_cb,
|
||||
self);
|
||||
g_free (glib_apis_suck);
|
||||
|
||||
if (!was_loading)
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_LOADING]);
|
||||
@ -861,8 +864,8 @@ gtk_directory_list_get_file (GtkDirectoryList *self)
|
||||
*
|
||||
* Sets the @attributes to be enumerated and starts the enumeration.
|
||||
*
|
||||
* If @attributes is %NULL, no attributes will be queried, but a list
|
||||
* of `GFileInfo`s will still be created.
|
||||
* If @attributes is %NULL, the list of file infos will still be created, it will just
|
||||
* not contain any extra attributes.
|
||||
*/
|
||||
void
|
||||
gtk_directory_list_set_attributes (GtkDirectoryList *self,
|
||||
|
@ -1125,14 +1125,14 @@ typedef struct {
|
||||
} ConfirmDeleteData;
|
||||
|
||||
static void
|
||||
on_confirm_delete_response (GObject *source,
|
||||
on_confirm_delete_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
void *user_data)
|
||||
{
|
||||
ConfirmDeleteData *data = user_data;
|
||||
int button;
|
||||
|
||||
button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result);
|
||||
button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result, NULL);
|
||||
|
||||
if (button == 1)
|
||||
{
|
||||
@ -4955,14 +4955,14 @@ request_response_and_add_to_recent_list (GtkFileChooserWidget *impl)
|
||||
}
|
||||
|
||||
static void
|
||||
on_confirm_overwrite_response (GObject *source,
|
||||
on_confirm_overwrite_response (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
void *user_data)
|
||||
{
|
||||
GtkFileChooserWidget *impl = user_data;
|
||||
int button;
|
||||
|
||||
button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result);
|
||||
button = gtk_alert_dialog_choose_finish (GTK_ALERT_DIALOG (source), result, NULL);
|
||||
|
||||
if (button == 1)
|
||||
{
|
||||
|
@ -57,19 +57,24 @@ struct _GtkFileDialog
|
||||
|
||||
GListModel *filters;
|
||||
GListModel *shortcut_folders;
|
||||
GtkFileFilter *current_filter;
|
||||
GFile *current_folder;
|
||||
GtkFileFilter *default_filter;
|
||||
GFile *initial_folder;
|
||||
char *initial_name;
|
||||
GFile *initial_file;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_TITLE = 1,
|
||||
PROP_MODAL,
|
||||
PROP_FILTERS,
|
||||
PROP_SHORTCUT_FOLDERS,
|
||||
PROP_CURRENT_FILTER,
|
||||
PROP_CURRENT_FOLDER,
|
||||
PROP_0,
|
||||
PROP_ACCEPT_LABEL,
|
||||
PROP_DEFAULT_FILTER,
|
||||
PROP_FILTERS,
|
||||
PROP_INITIAL_FILE,
|
||||
PROP_INITIAL_FOLDER,
|
||||
PROP_INITIAL_NAME,
|
||||
PROP_MODAL,
|
||||
PROP_SHORTCUT_FOLDERS,
|
||||
PROP_TITLE,
|
||||
|
||||
NUM_PROPERTIES
|
||||
};
|
||||
@ -93,8 +98,9 @@ gtk_file_dialog_finalize (GObject *object)
|
||||
g_free (self->accept_label);
|
||||
g_clear_object (&self->filters);
|
||||
g_clear_object (&self->shortcut_folders);
|
||||
g_clear_object (&self->current_filter);
|
||||
g_clear_object (&self->current_folder);
|
||||
g_clear_object (&self->default_filter);
|
||||
g_clear_object (&self->initial_folder);
|
||||
g_free (self->initial_name);
|
||||
|
||||
G_OBJECT_CLASS (gtk_file_dialog_parent_class)->finalize (object);
|
||||
}
|
||||
@ -125,12 +131,20 @@ gtk_file_dialog_get_property (GObject *object,
|
||||
g_value_set_object (value, self->shortcut_folders);
|
||||
break;
|
||||
|
||||
case PROP_CURRENT_FILTER:
|
||||
g_value_set_object (value, self->current_filter);
|
||||
case PROP_DEFAULT_FILTER:
|
||||
g_value_set_object (value, self->default_filter);
|
||||
break;
|
||||
|
||||
case PROP_CURRENT_FOLDER:
|
||||
g_value_set_object (value, self->current_folder);
|
||||
case PROP_INITIAL_FILE:
|
||||
g_value_set_object (value, self->initial_file);
|
||||
break;
|
||||
|
||||
case PROP_INITIAL_FOLDER:
|
||||
g_value_set_object (value, self->initial_folder);
|
||||
break;
|
||||
|
||||
case PROP_INITIAL_NAME:
|
||||
g_value_set_string (value, self->initial_name);
|
||||
break;
|
||||
|
||||
case PROP_ACCEPT_LABEL:
|
||||
@ -169,12 +183,20 @@ gtk_file_dialog_set_property (GObject *object,
|
||||
gtk_file_dialog_set_shortcut_folders (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_CURRENT_FILTER:
|
||||
gtk_file_dialog_set_current_filter (self, g_value_get_object (value));
|
||||
case PROP_DEFAULT_FILTER:
|
||||
gtk_file_dialog_set_default_filter (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_CURRENT_FOLDER:
|
||||
gtk_file_dialog_set_current_folder (self, g_value_get_object (value));
|
||||
case PROP_INITIAL_FILE:
|
||||
gtk_file_dialog_set_initial_file (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_INITIAL_FOLDER:
|
||||
gtk_file_dialog_set_initial_folder (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_INITIAL_NAME:
|
||||
gtk_file_dialog_set_initial_name (self, g_value_get_string (value));
|
||||
break;
|
||||
|
||||
case PROP_ACCEPT_LABEL:
|
||||
@ -225,6 +247,8 @@ gtk_file_dialog_class_init (GtkFileDialogClass *class)
|
||||
*
|
||||
* The list of filters.
|
||||
*
|
||||
* See [property@Gtk.FileDialog:default-filter] about how those two properties interact.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_FILTERS] =
|
||||
@ -245,32 +269,67 @@ gtk_file_dialog_class_init (GtkFileDialogClass *class)
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFileDialog:current-filter: (attributes org.gtk.Property.get=gtk_file_dialog_get_current_filter org.gtk.Property.set=gtk_file_dialog_set_current_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)
|
||||
*
|
||||
* The current filter, that is, the filter that is initially
|
||||
* The default filter, that is, the filter that is initially
|
||||
* active in the file chooser dialog.
|
||||
*
|
||||
* If the default filter is %NULL, the first filter of [property@Gtk.FileDialog:filters]
|
||||
* is used as the default filter. If that property contains no filter, the dialog will
|
||||
* be unfiltered.
|
||||
*
|
||||
* If [property@Gtk.FileDialog:filters] is not %NULL, the default filter should be part
|
||||
* of the list. If it is not, the dialog may choose to not make it available.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_CURRENT_FILTER] =
|
||||
g_param_spec_object ("current-filter", NULL, NULL,
|
||||
properties[PROP_DEFAULT_FILTER] =
|
||||
g_param_spec_object ("default-filter", NULL, NULL,
|
||||
GTK_TYPE_FILE_FILTER,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFileDialog:current-folder: (attributes org.gtk.Property.get=gtk_file_dialog_get_current_folder org.gtk.Property.set=gtk_file_dialog_set_current_folder)
|
||||
* GtkFileDialog:initial-file: (attributes org.gtk.Property.get=gtk_file_dialog_get_initial_file org.gtk.Property.set=gtk_file_dialog_set_initial_file)
|
||||
*
|
||||
* The current folder, that is, the directory that is initially
|
||||
* opened in the file chooser dialog, unless overridden by parameters
|
||||
* of the async call.
|
||||
* The inital file, that is, the file that is initially selected
|
||||
* in the file chooser dialog
|
||||
*
|
||||
* This is a utility property that sets both [property@Gtk.FileDialog:initial-folder] and
|
||||
* [property@Gtk.FileDialog:initial-name].
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_CURRENT_FOLDER] =
|
||||
g_param_spec_object ("current-folder", NULL, NULL,
|
||||
properties[PROP_INITIAL_FILE] =
|
||||
g_param_spec_object ("initial-file", NULL, NULL,
|
||||
G_TYPE_FILE,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFileDialog:initial-folder: (attributes org.gtk.Property.get=gtk_file_dialog_get_initial_folder org.gtk.Property.set=gtk_file_dialog_set_initial_folder)
|
||||
*
|
||||
* The inital folder, that is, the directory that is initially
|
||||
* opened in the file chooser dialog
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_INITIAL_FOLDER] =
|
||||
g_param_spec_object ("initial-folder", NULL, NULL,
|
||||
G_TYPE_FILE,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFileDialog:initial-name: (attributes org.gtk.Property.get=gtk_file_dialog_get_initial_name org.gtk.Property.set=gtk_file_dialog_set_initial_name)
|
||||
*
|
||||
* The inital name, that is, the filename that is initially
|
||||
* selected in the file chooser dialog.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
properties[PROP_INITIAL_NAME] =
|
||||
g_param_spec_string ("initial-name", NULL, NULL,
|
||||
NULL,
|
||||
G_PARAM_READWRITE|G_PARAM_STATIC_STRINGS|G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
/**
|
||||
* GtkFileDialog:accept-label: (attributes org.gtk.Property.get=gtk_file_dialog_get_accept_label org.gtk.Property.set=gtk_file_dialog_set_accept_label)
|
||||
*
|
||||
@ -531,7 +590,7 @@ gtk_file_dialog_set_shortcut_folders (GtkFileDialog *self,
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_dialog_get_current_filter:
|
||||
* gtk_file_dialog_get_default_filter:
|
||||
* @self: a `GtkFileDialog`
|
||||
*
|
||||
* Gets the filter that will be selected by default
|
||||
@ -542,38 +601,42 @@ gtk_file_dialog_set_shortcut_folders (GtkFileDialog *self,
|
||||
* Since: 4.10
|
||||
*/
|
||||
GtkFileFilter *
|
||||
gtk_file_dialog_get_current_filter (GtkFileDialog *self)
|
||||
gtk_file_dialog_get_default_filter (GtkFileDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
|
||||
|
||||
return self->current_filter;
|
||||
return self->default_filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_dialog_set_current_filter:
|
||||
* gtk_file_dialog_set_default_filter:
|
||||
* @self: a `GtkFileDialog`
|
||||
* @filter: (nullable): a `GtkFileFilter`
|
||||
*
|
||||
* Sets the filters that will be selected by default
|
||||
* Sets the filter that will be selected by default
|
||||
* in the file chooser dialog.
|
||||
*
|
||||
* If set to %NULL, the first item in [property@Gtk.FileDialog:filters]
|
||||
* will be used as the default filter. If that list is empty, the dialog
|
||||
* will be unfiltered.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_file_dialog_set_current_filter (GtkFileDialog *self,
|
||||
gtk_file_dialog_set_default_filter (GtkFileDialog *self,
|
||||
GtkFileFilter *filter)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
g_return_if_fail (filter == NULL || GTK_IS_FILE_FILTER (filter));
|
||||
|
||||
if (!g_set_object (&self->current_filter, filter))
|
||||
if (!g_set_object (&self->default_filter, filter))
|
||||
return;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CURRENT_FILTER]);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_DEFAULT_FILTER]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_dialog_get_current_folder:
|
||||
* gtk_file_dialog_get_initial_folder:
|
||||
* @self: a `GtkFileDialog`
|
||||
*
|
||||
* Gets the folder that will be set as the
|
||||
@ -584,36 +647,188 @@ gtk_file_dialog_set_current_filter (GtkFileDialog *self,
|
||||
* Since: 4.10
|
||||
*/
|
||||
GFile *
|
||||
gtk_file_dialog_get_current_folder (GtkFileDialog *self)
|
||||
gtk_file_dialog_get_initial_folder (GtkFileDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
|
||||
|
||||
return self->current_folder;
|
||||
return self->initial_folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_dialog_set_current_folder:
|
||||
* gtk_file_dialog_set_initial_folder:
|
||||
* @self: a `GtkFileDialog`
|
||||
* @folder: (nullable): a `GFile`
|
||||
*
|
||||
* Sets the folder that will be set as the
|
||||
* initial folder in the file chooser dialog,
|
||||
* unless overridden by parameters of the async
|
||||
* call.
|
||||
* initial folder in the file chooser dialog.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_file_dialog_set_current_folder (GtkFileDialog *self,
|
||||
gtk_file_dialog_set_initial_folder (GtkFileDialog *self,
|
||||
GFile *folder)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
g_return_if_fail (folder == NULL || G_IS_FILE (folder));
|
||||
|
||||
if (!g_set_object (&self->current_folder, folder))
|
||||
if (!g_set_object (&self->initial_folder, folder))
|
||||
return;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_CURRENT_FOLDER]);
|
||||
if (self->initial_name && self->initial_folder)
|
||||
{
|
||||
g_clear_object (&self->initial_file);
|
||||
self->initial_file = g_file_get_child_for_display_name (self->initial_folder,
|
||||
self->initial_name,
|
||||
NULL);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FILE]);
|
||||
}
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FOLDER]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_dialog_get_initial_name:
|
||||
* @self: a `GtkFileDialog`
|
||||
*
|
||||
* Gets the name for the file that should be initially set.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the name
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
const char *
|
||||
gtk_file_dialog_get_initial_name (GtkFileDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
|
||||
|
||||
return self->initial_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_dialog_set_initial_name:
|
||||
* @self: a `GtkFileDialog`
|
||||
* @name: (nullable): a UTF8 string
|
||||
*
|
||||
* Sets the name for the file that should be initially set.
|
||||
* For saving dialogs, this will usually be pre-entered into the name field.
|
||||
*
|
||||
* If a file with this name already exists in the directory set via
|
||||
* [property@Gtk.FileDialog:initial-folder], the dialog should preselect it.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_file_dialog_set_initial_name (GtkFileDialog *self,
|
||||
const char *name)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
|
||||
if (!g_set_str (&self->initial_name, name))
|
||||
return;
|
||||
|
||||
if (self->initial_name && self->initial_folder)
|
||||
{
|
||||
g_clear_object (&self->initial_file);
|
||||
self->initial_file = g_file_get_child_for_display_name (self->initial_folder,
|
||||
self->initial_name,
|
||||
NULL);
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FILE]);
|
||||
}
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_NAME]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_dialog_get_initial_file:
|
||||
* @self: a `GtkFileDialog`
|
||||
*
|
||||
* Gets the file that will be initially selected in
|
||||
* the file chooser dialog.
|
||||
*
|
||||
* Returns: (nullable) (transfer none): the file
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
GFile *
|
||||
gtk_file_dialog_get_initial_file (GtkFileDialog *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_FILE_DIALOG (self), NULL);
|
||||
|
||||
return self->initial_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_file_dialog_set_initial_file:
|
||||
* @self: a `GtkFileDialog`
|
||||
* @file: (nullable): a `GFile`
|
||||
*
|
||||
* Sets the file that will be initially selected in
|
||||
* the file chooser dialog.
|
||||
*
|
||||
* This function is a shortcut for calling both
|
||||
* gtk_file_dialog_set_initial_folder() and
|
||||
* gtk_file_dialog_set_initial_name() with the directory and
|
||||
* name of @file respectively.
|
||||
*
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gtk_file_dialog_set_initial_file (GtkFileDialog *self,
|
||||
GFile *file)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
g_return_if_fail (file == NULL || G_IS_FILE (file));
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (self));
|
||||
|
||||
if (file != NULL)
|
||||
{
|
||||
GFile *folder;
|
||||
GFileInfo *info;
|
||||
|
||||
if (g_file_equal (self->initial_file, file))
|
||||
return;
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FILE]);
|
||||
|
||||
folder = g_file_get_parent (file);
|
||||
if (folder == NULL)
|
||||
goto invalid_file;
|
||||
|
||||
if (g_set_object (&self->initial_folder, NULL))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FOLDER]);
|
||||
|
||||
info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME, 0, NULL, NULL);
|
||||
if (g_file_info_get_edit_name (info) != NULL)
|
||||
{
|
||||
if (g_set_str (&self->initial_name, g_file_info_get_edit_name (info)))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_NAME]);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *relative, *name;
|
||||
|
||||
relative = g_file_get_relative_path (folder, file);
|
||||
name = g_filename_display_name (relative);
|
||||
if (g_set_str (&self->initial_name, name))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_NAME]);
|
||||
|
||||
g_free (name);
|
||||
g_free (relative);
|
||||
}
|
||||
g_object_unref (info);
|
||||
g_object_unref (folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
invalid_file:
|
||||
if (g_set_object (&self->initial_file, NULL))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FILE]);
|
||||
if (g_set_object (&self->initial_folder, NULL))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_FOLDER]);
|
||||
if (g_set_str (&self->initial_name, NULL))
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_INITIAL_NAME]);
|
||||
}
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (self));
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
@ -652,10 +867,10 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
else if (response == GTK_RESPONSE_CLOSE)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_ABORTED, "Aborted by application");
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by application");
|
||||
else if (response == GTK_RESPONSE_CANCEL ||
|
||||
response == GTK_RESPONSE_DELETE_EVENT)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by user");
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_DISMISSED, "Dismissed by user");
|
||||
else
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_FAILED, "Unknown failure (%d)", response);
|
||||
|
||||
@ -675,8 +890,6 @@ static GtkFileChooserNative *
|
||||
create_file_chooser (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GtkFileChooserAction action,
|
||||
GFile *current_file,
|
||||
const char *current_name,
|
||||
gboolean select_multiple)
|
||||
{
|
||||
GtkFileChooserNative *chooser;
|
||||
@ -731,15 +944,25 @@ create_file_chooser (GtkFileDialog *self,
|
||||
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (chooser), select_multiple);
|
||||
|
||||
file_chooser_set_filters (GTK_FILE_CHOOSER (chooser), self->filters);
|
||||
if (self->current_filter)
|
||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), self->current_filter);
|
||||
if (self->default_filter)
|
||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), self->default_filter);
|
||||
else if (self->filters)
|
||||
{
|
||||
GtkFileFilter *filter = g_list_model_get_item (self->filters, 0);
|
||||
if (filter)
|
||||
{
|
||||
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (chooser), filter);
|
||||
g_object_unref (filter);
|
||||
}
|
||||
}
|
||||
|
||||
file_chooser_set_shortcut_folders (GTK_FILE_CHOOSER (chooser), self->shortcut_folders);
|
||||
if (self->current_folder)
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), self->current_folder, NULL);
|
||||
if (current_file)
|
||||
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (chooser), current_file, NULL);
|
||||
else if (current_name)
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), current_name);
|
||||
if (self->initial_folder)
|
||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), self->initial_folder, NULL);
|
||||
if (self->initial_file)
|
||||
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (chooser), self->initial_file, NULL);
|
||||
else if (self->initial_name)
|
||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (chooser), self->initial_name);
|
||||
|
||||
return chooser;
|
||||
}
|
||||
@ -783,7 +1006,6 @@ finish_multiple_files_op (GtkFileDialog *self,
|
||||
* gtk_file_dialog_open:
|
||||
* @self: a `GtkFileDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @current_file: (nullable): the file to select initially
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
@ -791,10 +1013,6 @@ finish_multiple_files_op (GtkFileDialog *self,
|
||||
* This function initiates a file selection operation by
|
||||
* presenting a file chooser dialog to the user.
|
||||
*
|
||||
* If you pass @current_file, the file chooser will initially be
|
||||
* opened in the parent directory of that file, otherwise, it
|
||||
* will be in the directory [property@Gtk.FileDialog:current-folder].
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FileDialog.open_finish]
|
||||
* to obtain the result.
|
||||
@ -804,7 +1022,6 @@ finish_multiple_files_op (GtkFileDialog *self,
|
||||
void
|
||||
gtk_file_dialog_open (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_file,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@ -814,8 +1031,7 @@ gtk_file_dialog_open (GtkFileDialog *self,
|
||||
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
current_file, NULL, FALSE);
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_OPEN, FALSE);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_check_cancellable (task, FALSE);
|
||||
@ -860,7 +1076,6 @@ gtk_file_dialog_open_finish (GtkFileDialog *self,
|
||||
* gtk_file_dialog_select_folder:
|
||||
* @self: a `GtkFileDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @current_folder: (nullable): the folder to select initially
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
@ -868,9 +1083,9 @@ gtk_file_dialog_open_finish (GtkFileDialog *self,
|
||||
* This function initiates a directory selection operation by
|
||||
* presenting a file chooser dialog to the user.
|
||||
*
|
||||
* If you pass @current_folder, the file chooser will initially be
|
||||
* If you pass @initial_folder, the file chooser will initially be
|
||||
* opened in the parent directory of that folder, otherwise, it
|
||||
* will be in the directory [property@Gtk.FileDialog:current-folder].
|
||||
* will be in the directory [property@Gtk.FileDialog:initial-folder].
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FileDialog.select_folder_finish]
|
||||
@ -881,7 +1096,6 @@ gtk_file_dialog_open_finish (GtkFileDialog *self,
|
||||
void
|
||||
gtk_file_dialog_select_folder (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_folder,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@ -891,8 +1105,7 @@ gtk_file_dialog_select_folder (GtkFileDialog *self,
|
||||
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
current_folder, NULL, FALSE);
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, FALSE);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_check_cancellable (task, FALSE);
|
||||
@ -937,8 +1150,6 @@ gtk_file_dialog_select_folder_finish (GtkFileDialog *self,
|
||||
* gtk_file_dialog_save:
|
||||
* @self: a `GtkFileDialog`
|
||||
* @parent: (nullable): the parent `GtkWindow`
|
||||
* @current_file: (nullable): the initial file
|
||||
* @current_name: (nullable): the initial filename to offer
|
||||
* @cancellable: (nullable): a `GCancellable` to cancel the operation
|
||||
* @callback: (scope async): a callback to call when the operation is complete
|
||||
* @user_data: (closure callback): data to pass to @callback
|
||||
@ -946,13 +1157,6 @@ gtk_file_dialog_select_folder_finish (GtkFileDialog *self,
|
||||
* This function initiates a file save operation by
|
||||
* presenting a file chooser dialog to the user.
|
||||
*
|
||||
* You should pass either @current_file if you have a file to
|
||||
* save to, or @current_name, if you are creating a new file.
|
||||
*
|
||||
* If you pass @current_file, the file chooser will initially be
|
||||
* opened in the parent directory of that file, otherwise, it
|
||||
* will be in the directory [property@Gtk.FileDialog:current-folder].
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FileDialog.save_finish]
|
||||
* to obtain the result.
|
||||
@ -962,8 +1166,6 @@ gtk_file_dialog_select_folder_finish (GtkFileDialog *self,
|
||||
void
|
||||
gtk_file_dialog_save (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_file,
|
||||
const char *current_name,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
@ -973,8 +1175,7 @@ gtk_file_dialog_save (GtkFileDialog *self,
|
||||
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_SAVE,
|
||||
current_file, current_name, FALSE);
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_SAVE, FALSE);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_check_cancellable (task, FALSE);
|
||||
@ -1027,7 +1228,7 @@ gtk_file_dialog_save_finish (GtkFileDialog *self,
|
||||
* presenting a file chooser dialog to the user.
|
||||
*
|
||||
* The file chooser will initially be opened in the directory
|
||||
* [property@Gtk.FileDialog:current-folder].
|
||||
* [property@Gtk.FileDialog:initial-folder].
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FileDialog.open_multiple_finish]
|
||||
@ -1047,8 +1248,7 @@ gtk_file_dialog_open_multiple (GtkFileDialog *self,
|
||||
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_OPEN,
|
||||
NULL, NULL, TRUE);
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_OPEN, TRUE);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_check_cancellable (task, FALSE);
|
||||
@ -1102,7 +1302,7 @@ gtk_file_dialog_open_multiple_finish (GtkFileDialog *self,
|
||||
* presenting a file chooser dialog to the user.
|
||||
*
|
||||
* The file chooser will initially be opened in the directory
|
||||
* [property@Gtk.FileDialog:current-folder].
|
||||
* [property@Gtk.FileDialog:initial-folder].
|
||||
*
|
||||
* The @callback will be called when the dialog is dismissed.
|
||||
* It should call [method@Gtk.FileDialog.select_multiple_folders_finish]
|
||||
@ -1122,8 +1322,7 @@ gtk_file_dialog_select_multiple_folders (GtkFileDialog *self,
|
||||
|
||||
g_return_if_fail (GTK_IS_FILE_DIALOG (self));
|
||||
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
|
||||
NULL, NULL, TRUE);
|
||||
chooser = create_file_chooser (self, parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, TRUE);
|
||||
|
||||
task = g_task_new (self, cancellable, callback, user_data);
|
||||
g_task_set_check_cancellable (task, FALSE);
|
||||
|
@ -58,10 +58,10 @@ void gtk_file_dialog_set_filters (GtkFileDialog *self
|
||||
GListModel *filters);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GtkFileFilter * gtk_file_dialog_get_current_filter (GtkFileDialog *self);
|
||||
GtkFileFilter * gtk_file_dialog_get_default_filter (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_current_filter (GtkFileDialog *self,
|
||||
void gtk_file_dialog_set_default_filter (GtkFileDialog *self,
|
||||
GtkFileFilter *filter);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
@ -74,16 +74,30 @@ void gtk_file_dialog_set_shortcut_folders
|
||||
GListModel *shortcut_folders);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GFile * gtk_file_dialog_get_current_folder (GtkFileDialog *self);
|
||||
GFile * gtk_file_dialog_get_initial_folder (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_current_folder (GtkFileDialog *self,
|
||||
void gtk_file_dialog_set_initial_folder (GtkFileDialog *self,
|
||||
GFile *folder);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
const char * gtk_file_dialog_get_initial_name (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_initial_name (GtkFileDialog *self,
|
||||
const char *name);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
GFile * gtk_file_dialog_get_initial_file (GtkFileDialog *self);
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_set_initial_file (GtkFileDialog *self,
|
||||
GFile *file);
|
||||
|
||||
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_open (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_file,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
@ -96,7 +110,6 @@ GFile * gtk_file_dialog_open_finish (GtkFileDialog *self
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_select_folder (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_folder,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
@ -110,8 +123,6 @@ GFile * gtk_file_dialog_select_folder_finish
|
||||
GDK_AVAILABLE_IN_4_10
|
||||
void gtk_file_dialog_save (GtkFileDialog *self,
|
||||
GtkWindow *parent,
|
||||
GFile *current_file,
|
||||
const char *current_name,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
|
@ -561,9 +561,10 @@ response_cb (GTask *task,
|
||||
}
|
||||
}
|
||||
else if (response == GTK_RESPONSE_CLOSE)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_ABORTED, "Aborted by application");
|
||||
else if (response == GTK_RESPONSE_CANCEL)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by user");
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_CANCELLED, "Cancelled by application");
|
||||
else if (response == GTK_RESPONSE_CANCEL ||
|
||||
response == GTK_RESPONSE_DELETE_EVENT)
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_DISMISSED, "Dismissed by user");
|
||||
else
|
||||
g_task_return_new_error (task, GTK_DIALOG_ERROR, GTK_DIALOG_ERROR_FAILED, "Unknown failure (%d)", response);
|
||||
|
||||
|
@ -914,9 +914,9 @@ gtk_mount_operation_ask_password (GMountOperation *mount_op,
|
||||
}
|
||||
|
||||
static void
|
||||
question_dialog_button_clicked (GObject *source,
|
||||
question_dialog_button_clicked (GObject *source,
|
||||
GAsyncResult *result,
|
||||
void *user_data)
|
||||
void *user_data)
|
||||
{
|
||||
GtkAlertDialog *dialog = GTK_ALERT_DIALOG (source);
|
||||
GMountOperation *op = user_data;
|
||||
@ -925,7 +925,7 @@ question_dialog_button_clicked (GObject *source,
|
||||
|
||||
operation = GTK_MOUNT_OPERATION (op);
|
||||
|
||||
button = gtk_alert_dialog_choose_finish (dialog, result);
|
||||
button = gtk_alert_dialog_choose_finish (dialog, result, NULL);
|
||||
if (button >= 0)
|
||||
{
|
||||
g_mount_operation_set_choice (op, button);
|
||||
|
@ -707,12 +707,13 @@ filesave_choose_cb (GtkWidget *button,
|
||||
{
|
||||
GtkPrinterOptionWidgetPrivate *priv = widget->priv;
|
||||
GtkFileDialog *dialog;
|
||||
GFile *current_folder = NULL;
|
||||
char *current_name = NULL;
|
||||
|
||||
/* this will be unblocked in the dialog_response_callback function */
|
||||
g_signal_handler_block (priv->source, priv->source_changed_handler);
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, _("Select a filename"));
|
||||
|
||||
/* select the current filename in the dialog */
|
||||
if (priv->source != NULL && priv->source->value != NULL)
|
||||
{
|
||||
@ -720,32 +721,16 @@ filesave_choose_cb (GtkWidget *button,
|
||||
if (priv->last_location)
|
||||
{
|
||||
if (g_file_query_file_type (priv->last_location, 0, NULL) == G_FILE_TYPE_DIRECTORY)
|
||||
{
|
||||
current_folder = g_object_ref (priv->last_location);
|
||||
current_name = NULL;
|
||||
}
|
||||
gtk_file_dialog_set_initial_folder (dialog, priv->last_location);
|
||||
else
|
||||
{
|
||||
current_folder = g_file_get_parent (priv->last_location);
|
||||
current_name = g_file_get_basename (priv->last_location);
|
||||
if (strcmp (current_name, "/") == 0 ||
|
||||
!g_utf8_validate (current_name, -1, NULL))
|
||||
g_clear_pointer (¤t_name, g_free);
|
||||
}
|
||||
gtk_file_dialog_set_initial_file (dialog, priv->last_location);
|
||||
}
|
||||
}
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_title (dialog, _("Select a filename"));
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (widget))),
|
||||
current_folder,
|
||||
current_name,
|
||||
NULL,
|
||||
dialog_response_callback, widget);
|
||||
|
||||
g_object_unref (current_folder);
|
||||
g_free (current_name);
|
||||
}
|
||||
|
||||
static char *
|
||||
|
@ -243,9 +243,9 @@ save_clicked (GtkButton *button,
|
||||
GtkFileDialog *dialog;
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_initial_name (dialog, "custom.css");
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (ce))),
|
||||
NULL, "custom.css",
|
||||
NULL,
|
||||
save_response, ce);
|
||||
g_object_unref (dialog);
|
||||
|
@ -1859,12 +1859,14 @@ render_node_save (GtkButton *button,
|
||||
filename = g_strdup_printf ("%s.node", nodename);
|
||||
|
||||
dialog = gtk_file_dialog_new ();
|
||||
gtk_file_dialog_set_initial_name (dialog, filename);
|
||||
gtk_file_dialog_save (dialog,
|
||||
GTK_WINDOW (gtk_widget_get_root (GTK_WIDGET (recorder))),
|
||||
NULL, filename,
|
||||
NULL,
|
||||
render_node_save_response, node);
|
||||
g_object_unref (dialog);
|
||||
g_free (filename);
|
||||
g_free (nodename);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user