[gnome-builder] greeter: Use GtkFileChooserNative instead of GtkFileChooserDialog
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] greeter: Use GtkFileChooserNative instead of GtkFileChooserDialog
- Date: Tue, 21 Dec 2021 00:15:10 +0000 (UTC)
commit 85aee7693da257f4346799a5443021375502cd69
Author: Corentin Noël <corentin noel collabora com>
Date: Fri Mar 19 16:16:55 2021 +0100
greeter: Use GtkFileChooserNative instead of GtkFileChooserDialog
This allows to use the File dialog from the portal when used with Flatpak.
src/libide/greeter/ide-greeter-workspace-actions.c | 35 +++++++++-------------
1 file changed, 14 insertions(+), 21 deletions(-)
---
diff --git a/src/libide/greeter/ide-greeter-workspace-actions.c
b/src/libide/greeter/ide-greeter-workspace-actions.c
index 7afb6e22f..7d1b7ba99 100644
--- a/src/libide/greeter/ide-greeter-workspace-actions.c
+++ b/src/libide/greeter/ide-greeter-workspace-actions.c
@@ -31,12 +31,12 @@
static void
ide_greeter_workspace_dialog_response (IdeGreeterWorkspace *self,
gint response_id,
- GtkFileChooserDialog *dialog)
+ GtkFileChooserNative *dialog)
{
g_assert (IDE_IS_GREETER_WORKSPACE (self));
- g_assert (GTK_IS_FILE_CHOOSER_DIALOG (dialog));
+ g_assert (GTK_IS_FILE_CHOOSER_NATIVE (dialog));
- if (response_id == GTK_RESPONSE_OK)
+ if (response_id == GTK_RESPONSE_ACCEPT)
{
g_autoptr(IdeProjectInfo) project_info = NULL;
g_autoptr(GFile) project_file = NULL;
@@ -65,13 +65,13 @@ ide_greeter_workspace_dialog_response (IdeGreeterWorkspace *self,
ide_greeter_workspace_open_project (self, project_info);
}
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_object_unref (dialog);
}
static void
ide_greeter_workspace_dialog_notify_filter (IdeGreeterWorkspace *self,
GParamSpec *pspec,
- GtkFileChooserDialog *dialog)
+ GtkFileChooserNative *dialog)
{
GtkFileFilter *filter;
GtkFileChooserAction action;
@@ -79,7 +79,7 @@ ide_greeter_workspace_dialog_notify_filter (IdeGreeterWorkspace *self,
g_assert (IDE_IS_GREETER_WORKSPACE (self));
g_assert (pspec != NULL);
- g_assert (GTK_IS_FILE_CHOOSER_DIALOG (dialog));
+ g_assert (GTK_IS_FILE_CHOOSER_NATIVE (dialog));
filter = gtk_file_chooser_get_filter (GTK_FILE_CHOOSER (dialog));
@@ -95,7 +95,7 @@ ide_greeter_workspace_dialog_notify_filter (IdeGreeterWorkspace *self,
}
gtk_file_chooser_set_action (GTK_FILE_CHOOSER (dialog), action);
- gtk_window_set_title (GTK_WINDOW (dialog), title);
+ gtk_native_dialog_set_title (GTK_NATIVE_DIALOG (dialog), title);
}
static void
@@ -104,7 +104,7 @@ ide_greeter_workspace_actions_open (GSimpleAction *action,
gpointer user_data)
{
IdeGreeterWorkspace *self = user_data;
- GtkFileChooserDialog *dialog;
+ GtkFileChooserNative *dialog;
GtkFileFilter *all_filter;
const GList *list;
gint64 last_priority = G_MAXINT64;
@@ -115,18 +115,11 @@ ide_greeter_workspace_actions_open (GSimpleAction *action,
list = peas_engine_get_plugin_list (peas_engine_get_default ());
- dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG,
- "action", GTK_FILE_CHOOSER_ACTION_OPEN,
- "transient-for", self,
- "modal", TRUE,
- "title", _("Select Project Folder"),
- "visible", TRUE,
- NULL);
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("_Cancel"), GTK_RESPONSE_CANCEL,
- _("_Open"), GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+ dialog = gtk_file_chooser_native_new (_("Select Project Folder"),
+ (GtkWindow *) gtk_widget_get_ancestor (GTK_WIDGET (self),
GTK_TYPE_WINDOW),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ _("_Open"),
+ _("_Cancel"));
g_signal_connect_object (dialog,
"notify::filter",
@@ -235,7 +228,7 @@ ide_greeter_workspace_actions_open (GSimpleAction *action,
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog),
ide_get_projects_dir ());
- ide_gtk_window_present (GTK_WINDOW (dialog));
+ gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
}
static const GActionEntry actions[] = {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]