diff --git a/demos/gtk-demo/listview_words.c b/demos/gtk-demo/listview_words.c
index 867f74e652..e2a5a1e2fa 100644
--- a/demos/gtk-demo/listview_words.c
+++ b/demos/gtk-demo/listview_words.c
@@ -142,16 +142,42 @@ load_file (GtkStringList *list,
}
static void
-file_selected_cb (GtkWidget *button,
+open_response_cb (GtkWidget *dialog,
+ int response,
GtkStringList *stringlist)
{
- GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
+ gtk_widget_hide (dialog);
- if (file)
+ if (response == GTK_RESPONSE_ACCEPT)
{
+ GFile *file;
+
+ file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
load_file (stringlist, file);
g_object_unref (file);
}
+
+ gtk_window_destroy (GTK_WINDOW (dialog));
+}
+
+static void
+file_open_cb (GtkWidget *button,
+ GtkStringList *stringlist)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_file_chooser_dialog_new ("Open file",
+ GTK_WINDOW (gtk_widget_get_root (button)),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ "_Cancel", GTK_RESPONSE_CANCEL,
+ "_Load", GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
+ g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), stringlist);
+ gtk_widget_show (dialog);
}
GtkWidget *
@@ -189,8 +215,8 @@ do_listview_words (GtkWidget *do_widget)
header = gtk_header_bar_new ();
gtk_header_bar_set_show_title_buttons (GTK_HEADER_BAR (header), TRUE);
- open_button = gtk_file_chooser_button_new ("_Open", GTK_FILE_CHOOSER_ACTION_OPEN);
- g_signal_connect (open_button, "file-set", G_CALLBACK (file_selected_cb), stringlist);
+ open_button = gtk_button_new_with_mnemonic ("_Open");
+ g_signal_connect (open_button, "clicked", G_CALLBACK (file_open_cb), stringlist);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), open_button);
gtk_window_set_titlebar (GTK_WINDOW (window), header);
diff --git a/demos/gtk-demo/paintable_svg.c b/demos/gtk-demo/paintable_svg.c
index eab506f4ed..9d87f121ac 100644
--- a/demos/gtk-demo/paintable_svg.c
+++ b/demos/gtk-demo/paintable_svg.c
@@ -13,19 +13,50 @@
static void
-file_set (GtkFileChooserButton *button,
- GtkWidget *picture)
+open_response_cb (GtkWidget *dialog,
+ int response,
+ GtkPicture *picture)
{
- GFile *file;
- GdkPaintable *paintable;
+ gtk_widget_hide (dialog);
- file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (button));
+ if (response == GTK_RESPONSE_ACCEPT)
+ {
+ GFile *file;
+ GdkPaintable *paintable;
- paintable = svg_paintable_new (file);
- gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
+ file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog));
+ paintable = svg_paintable_new (file);
+ gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
+ g_object_unref (paintable);
+ g_object_unref (file);
+ }
- g_object_unref (paintable);
- g_object_unref (file);
+ gtk_window_destroy (GTK_WINDOW (dialog));
+}
+
+static void
+show_file_open (GtkWidget *button,
+ GtkPicture *picture)
+{
+ GtkFileFilter *filter;
+ GtkWidget *dialog;
+
+ dialog = gtk_file_chooser_dialog_new ("Open node file",
+ GTK_WINDOW (gtk_widget_get_root (button)),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ "_Cancel", GTK_RESPONSE_CANCEL,
+ "_Load", GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ filter = gtk_file_filter_new ();
+ gtk_file_filter_add_mime_type (filter, "image/svg+xml");
+ gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter);
+
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_ACCEPT);
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+
+ g_signal_connect (dialog, "response", G_CALLBACK (open_response_cb), picture);
+ gtk_widget_show (dialog);
}
static GtkWidget *window;
@@ -35,7 +66,6 @@ do_paintable_svg (GtkWidget *do_widget)
{
GtkWidget *header;
GtkWidget *picture;
- GtkFileFilter *filter;
GtkWidget *button;
GFile *file;
GdkPaintable *paintable;
@@ -49,17 +79,14 @@ do_paintable_svg (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Paintable — SVG");
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *)&window);
- button = gtk_file_chooser_button_new ("Select an SVG file", GTK_FILE_CHOOSER_ACTION_OPEN);
- filter = gtk_file_filter_new ();
- gtk_file_filter_add_mime_type (filter, "image/svg+xml");
- gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (button), filter);
+ button = gtk_button_new_with_mnemonic ("_Open");
gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button);
picture = gtk_picture_new ();
gtk_picture_set_can_shrink (GTK_PICTURE (picture), TRUE);
gtk_widget_set_size_request (picture, 16, 16);
- g_signal_connect (button, "file-set", G_CALLBACK (file_set), picture);
+ g_signal_connect (button, "clicked", G_CALLBACK (show_file_open), picture);
gtk_window_set_child (GTK_WINDOW (window), picture);
diff --git a/demos/gtk-demo/pickers.c b/demos/gtk-demo/pickers.c
index 0b42034030..e5f6ef99d4 100644
--- a/demos/gtk-demo/pickers.c
+++ b/demos/gtk-demo/pickers.c
@@ -63,9 +63,6 @@ do_pickers (GtkWidget *do_widget)
if (!window)
{
- char *dir;
- GFile *file;
-
window = gtk_window_new ();
gtk_window_set_display (GTK_WINDOW (window),
gtk_widget_get_display (do_widget));
@@ -129,41 +126,6 @@ do_pickers (GtkWidget *do_widget)
gtk_widget_set_hexpand (label, TRUE);
gtk_grid_attach (GTK_GRID (table), label, 0, 2, 1, 1);
- picker = gtk_file_chooser_button_new ("Pick a File",
- GTK_FILE_CHOOSER_ACTION_OPEN);
- gtk_grid_attach (GTK_GRID (table), picker, 1, 2, 1, 1);
-
- picker = gtk_file_chooser_button_new ("Pick a File",
- GTK_FILE_CHOOSER_ACTION_OPEN);
-
- dir = g_get_current_dir ();
- file = g_file_new_for_path (dir);
- gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (picker), file, NULL);
- g_object_unref (file);
- g_free (dir);
-
- gtk_file_chooser_add_choice (GTK_FILE_CHOOSER (picker),
- "choice",
- "Encoding",
- (const char *[]) { "option1", "option2", NULL },
- (const char *[]) { "UTF-8", "Other Encoding", NULL });
- gtk_file_chooser_set_choice (GTK_FILE_CHOOSER (picker), "choice", "option1");
- gtk_file_chooser_add_choice (GTK_FILE_CHOOSER (picker),
- "check",
- "Read backwards",
- NULL, NULL);
- gtk_file_chooser_set_choice (GTK_FILE_CHOOSER (picker), "check", "false");
-
- gtk_grid_attach (GTK_GRID (table), picker, 2, 2, 1, 1);
-
- label = gtk_label_new ("Folder:");
- gtk_widget_set_halign (label, GTK_ALIGN_START);
- gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
- picker = gtk_file_chooser_button_new ("Pick a Folder",
- GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
- gtk_grid_attach (GTK_GRID (table), label, 0, 3, 1, 1);
- gtk_grid_attach (GTK_GRID (table), picker, 1, 3, 1, 1);
-
label = gtk_label_new ("Mail:");
gtk_widget_set_halign (label, GTK_ALIGN_START);
gtk_widget_set_valign (label, GTK_ALIGN_CENTER);
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index ba2378ba34..6d6f539140 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -878,9 +878,6 @@ Suspendisse feugiat quam quis dolor accumsan cursus.
1
-
-
-
-
-
-
-
-
-
-
-
-