[gtk/widget-factory-filechooser] widget-factory: Add a file chooser
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/widget-factory-filechooser] widget-factory: Add a file chooser
- Date: Fri, 9 Sep 2022 18:30:52 +0000 (UTC)
commit f050a9e8899fac1a74175f049442ab0f017fe084
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Sep 9 14:28:08 2022 -0400
widget-factory: Add a file chooser
We don't have a readily accessible file chooser
in our demo apps. Fix that by making the Open
menu item on page 2 bring up a file chooser.
demos/widget-factory/widget-factory.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
---
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
@@ -213,6 +213,31 @@ activate_background (GSimpleAction *action,
populate_flowbox (flowbox);
}
+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,
@@ -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 },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]