summaryrefslogtreecommitdiff
path: root/tests/testfilechooserbutton.c
diff options
context:
space:
mode:
authorJames M. Cape <jcape@ignore-your.tv>2004-10-26 04:29:56 +0000
committerJames M. Cape <jcape@src.gnome.org>2004-10-26 04:29:56 +0000
commitede3c3991802f5ca0a0472e980e81de1a1b36a30 (patch)
tree5a0abd33b49a34c97b7cc10d4e071fda4b1e4df5 /tests/testfilechooserbutton.c
parent64facb3c4b3381c3e8066faf55ce4689ae553cb3 (diff)
downloadgtk+-ede3c3991802f5ca0a0472e980e81de1a1b36a30.tar.gz
Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390,
2004-10-25 James M. Cape <jcape@ignore-your.tv> Rework of GtkFileChooserButton, some cleanups. Fixes #154388, #154390, #154390, #156272. * docs/reference/gtk/gtk-docs.sgml: Moved GtkFileChooserButton below GtkFileChooser. * docs/reference/gtk/gtk-sections.txt: Added gtk_file_chooser_button_get_width_chars(), gtk_file_chooser_button_set_width_chars(), gtk_label_set_width_chars(), gtk_label_get_width_chars(). * docs/reference/gtk/gtk.types: Added gtk_cell_renderer_combo_get_type, gtk_cell_view_get_type, gtk_text_iter_get_type. * docs/reference/gtk/tmpl/gtkaboutdialog.sgml: Add "logo-icon-name" property. * docs/reference/gtk/tmpl/gtkcellview.sgml: Updates for properties (b/c of get_type() inclusion above). * docs/reference/gtk/tmpl/gtkfilechooserbutton.sgml: * docs/reference/gtk/tmpl/gtklabel.sgml: Add "width-chars" property, getters/setters. * docs/reference/gtk/tmpl/gtkcellrenderercombo.sgml: Added. * gtk/gtkentrycompletion.c: (_gtk_entry_completion_popdown): Don't show if the entry isn't mapped. * gtk/gtkfilechooserbutton.[c,h]: (*): About 45% rewritten, adds "width-chars" property, icons, working save modes, volume/Home/Desktop friendly-naming support. * gtk/gtklabel.[c,h]: (gtk_label_class_init), (gtk_label_init), (gtk_label_get_property), (gtk_label_set_property), (gtk_label_get_width_chars), (gtk_label_set_width_chars), (gtk_label_size_request): Add "width-chars" property. * tests/testfilechooserbutton.c: Update, use 4 different buttons for the different ACTIONs. * gtk/.cvsignore: Ignore gtk-update-icon-cache. * tests/.cvsignore: Ignore testimage.
Diffstat (limited to 'tests/testfilechooserbutton.c')
-rw-r--r--tests/testfilechooserbutton.c98
1 files changed, 80 insertions, 18 deletions
diff --git a/tests/testfilechooserbutton.c b/tests/testfilechooserbutton.c
index d453e0f54d..cbf3eaea87 100644
--- a/tests/testfilechooserbutton.c
+++ b/tests/testfilechooserbutton.c
@@ -56,7 +56,7 @@ chooser_current_folder_changed_cb (GtkFileChooser *chooser, gpointer user_data)
folder = gtk_file_chooser_get_current_folder (chooser);
filename = gtk_file_chooser_get_filename (chooser);
- g_message ("%s:%s:\n`%s`\n\tFolder: `%s'\n\tFilename: `%s'", G_STRFUNC, G_STRLOC,
+ g_message ("%s::current-folder-changed\n\tFolder: `%s'\n\tFilename: `%s'\nDone.\n",
G_OBJECT_TYPE_NAME (chooser), folder, filename);
g_free (folder);
g_free (filename);
@@ -66,16 +66,12 @@ chooser_current_folder_changed_cb (GtkFileChooser *chooser, gpointer user_data)
static void
chooser_selection_changed_cb (GtkFileChooser *chooser, gpointer user_data)
{
- GSList *selection;
+ gchar *filename;
- g_message ("%s:%s:\n`%s` Selection:", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser));
- for (selection = gtk_file_chooser_get_filenames (chooser); selection != NULL;
- selection = g_slist_remove_link (selection, selection))
- {
- g_print ("`%s'\n", (const gchar *) selection->data);
- g_free (selection->data);
- }
- g_print ("Done.\n");
+ filename = gtk_file_chooser_get_filename (chooser);
+ g_message ("%s::selection-changed\n\tSelection:`%s'\nDone.\n",
+ G_OBJECT_TYPE_NAME (chooser), filename);
+ g_free (filename);
}
@@ -86,7 +82,8 @@ chooser_file_activated_cb (GtkFileChooser *chooser, gpointer user_data)
folder = gtk_file_chooser_get_current_folder (chooser);
filename = gtk_file_chooser_get_filename (chooser);
- g_message ("%s:%s:\n`%s`\nFolder: `%s'\nFilename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), folder, filename);
+ g_message ("%s::file-activated\n\tFolder: `%s'\n\tFilename: `%s'\nDone.\n",
+ G_OBJECT_TYPE_NAME (chooser), folder, filename);
g_free (folder);
g_free (filename);
}
@@ -98,17 +95,17 @@ chooser_update_preview_cb (GtkFileChooser *chooser, gpointer user_data)
gchar *filename;
filename = gtk_file_chooser_get_preview_filename (chooser);
- g_message ("%s:%s:\n`%s`\nPreview Filename: `%s'", G_STRFUNC, G_STRLOC, G_OBJECT_TYPE_NAME (chooser), filename);
+ g_message ("%s::update-preview\n\tPreview Filename: `%s'\nDone.\n",
+ G_OBJECT_TYPE_NAME (chooser), filename);
g_free (filename);
}
-
int
main (int argc, char *argv[])
{
- GtkWidget *win, *vbox, *frame, *alignment, *group_box, *hbox, *label, *chooser, *button;
+ GtkWidget *win, *vbox, *frame, *alignment, *group_box;
+ GtkWidget *hbox, *label, *chooser, *button;
GtkSizeGroup *label_group;
-
gtk_init (&argc, &argv);
/* to test rtl layout, set RTL=1 in the environment */
@@ -138,15 +135,80 @@ main (int argc, char *argv[])
gtk_container_add (GTK_CONTAINER (alignment), group_box);
hbox = gtk_hbox_new (FALSE, 12);
- gtk_container_add (GTK_CONTAINER (group_box), hbox);
+ gtk_box_pack_start (GTK_BOX (group_box), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic ("_Open:");
gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- chooser = gtk_file_chooser_button_new_with_backend ("Select A File - testfilechooserbutton",
- "gtk+");
+ chooser = gtk_file_chooser_button_new ("Select A File - testfilechooserbutton");
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
+ g_signal_connect (chooser, "current-folder-changed",
+ G_CALLBACK (chooser_current_folder_changed_cb), NULL);
+ g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL);
+ g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL);
+ g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL);
+ gtk_container_add (GTK_CONTAINER (hbox), chooser);
+
+ button = gtk_button_new_with_label ("Properties...");
+ g_signal_connect (button, "clicked", G_CALLBACK (properties_button_clicked_cb), chooser);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (group_box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new_with_mnemonic ("Select _Folder:");
+ gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ chooser = gtk_file_chooser_button_new ("Select A File - testfilechooserbutton");
+ gtk_file_chooser_set_action (GTK_FILE_CHOOSER (chooser), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
+ g_signal_connect (chooser, "current-folder-changed",
+ G_CALLBACK (chooser_current_folder_changed_cb), NULL);
+ g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL);
+ g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL);
+ g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL);
+ gtk_container_add (GTK_CONTAINER (hbox), chooser);
+
+ button = gtk_button_new_with_label ("Properties...");
+ g_signal_connect (button, "clicked", G_CALLBACK (properties_button_clicked_cb), chooser);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (group_box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new_with_mnemonic ("_Save:");
+ gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ chooser = gtk_file_chooser_button_new ("Select A File - testfilechooserbutton");
+ gtk_file_chooser_set_action (GTK_FILE_CHOOSER (chooser), GTK_FILE_CHOOSER_ACTION_SAVE);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
+ g_signal_connect (chooser, "current-folder-changed",
+ G_CALLBACK (chooser_current_folder_changed_cb), NULL);
+ g_signal_connect (chooser, "selection-changed", G_CALLBACK (chooser_selection_changed_cb), NULL);
+ g_signal_connect (chooser, "file-activated", G_CALLBACK (chooser_file_activated_cb), NULL);
+ g_signal_connect (chooser, "update-preview", G_CALLBACK (chooser_update_preview_cb), NULL);
+ gtk_container_add (GTK_CONTAINER (hbox), chooser);
+
+ button = gtk_button_new_with_label ("Properties...");
+ g_signal_connect (button, "clicked", G_CALLBACK (properties_button_clicked_cb), chooser);
+ gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (group_box), hbox, FALSE, FALSE, 0);
+
+ label = gtk_label_new_with_mnemonic ("_Create Folder:");
+ gtk_size_group_add_widget (GTK_SIZE_GROUP (label_group), label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ chooser = gtk_file_chooser_button_new ("Select A File - testfilechooserbutton");
+ gtk_file_chooser_set_action (GTK_FILE_CHOOSER (chooser), GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser);
g_signal_connect (chooser, "current-folder-changed",
G_CALLBACK (chooser_current_folder_changed_cb), NULL);