summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-09-09 18:44:31 +0000
committerMatthias Clasen <mclasen@redhat.com>2022-09-09 18:44:31 +0000
commit7dd3289837041056590c0915a3a8bfc22e1a10f5 (patch)
tree2419e3718405d626b80d73ef1aa0dfa6719cd90e
parentae2964c7c6ec7d16c565def61fda3ffec6725fac (diff)
parentf050a9e8899fac1a74175f049442ab0f017fe084 (diff)
downloadgtk+-7dd3289837041056590c0915a3a8bfc22e1a10f5.tar.gz
Merge branch 'widget-factory-filechooser' into 'main'
widget-factory: Add a file chooser See merge request GNOME/gtk!5015
-rw-r--r--demos/widget-factory/widget-factory.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 7e30b8b9e8..4ec907d531 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -214,6 +214,31 @@ activate_background (GSimpleAction *action,
}
static void
+file_chooser_response (GtkNativeDialog *self,
+ int response)
+{
+ gtk_native_dialog_destroy (self);
+}
+
+static void
+activate_open_file (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkFileChooserNative *chooser;
+
+ chooser = gtk_file_chooser_native_new ("Open file",
+ NULL,
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ "Open",
+ "Cancel");
+
+ g_signal_connect (chooser, "response", G_CALLBACK (file_chooser_response), NULL);
+
+ gtk_native_dialog_show (GTK_NATIVE_DIALOG (chooser));
+}
+
+static void
activate_open (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -2451,7 +2476,7 @@ main (int argc, char *argv[])
{ "share", activate_action, NULL, NULL, NULL },
{ "labels", activate_action, NULL, NULL, NULL },
{ "new", activate_action, NULL, NULL, NULL },
- { "open", activate_action, NULL, NULL, NULL },
+ { "open", activate_open_file, NULL, NULL, NULL },
{ "open-in", activate_action, NULL, NULL, NULL },
{ "open-tab", activate_action, NULL, NULL, NULL },
{ "open-window", activate_action, NULL, NULL, NULL },