From 0adb1b260a6197f2a46bf2bafc4d901155ebacd4 Mon Sep 17 00:00:00 2001 From: Manish Singh Date: Sun, 17 Feb 2002 01:16:24 +0000 Subject: [PATCH] redid the filesel test. Added a way to set select multiple as a toggle 2002-02-16 Manish Singh * tests/testgtk.c: redid the filesel test. Added a way to set select multiple as a toggle button, and made show/hide fileops toggle buttons as well. get_selections() is called on OK and all the filenames selected are printed. --- ChangeLog | 7 +++++ ChangeLog.pre-2-0 | 7 +++++ ChangeLog.pre-2-10 | 7 +++++ ChangeLog.pre-2-2 | 7 +++++ ChangeLog.pre-2-4 | 7 +++++ ChangeLog.pre-2-6 | 7 +++++ ChangeLog.pre-2-8 | 7 +++++ tests/testgtk.c | 73 +++++++++++++++++++++++++++++++--------------- 8 files changed, 99 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index e18ebae9db..36d665706a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2002-02-16 Manish Singh + + * tests/testgtk.c: redid the filesel test. Added a way to set select + multiple as a toggle button, and made show/hide fileops toggle + buttons as well. get_selections() is called on OK and all the + filenames selected are printed. + 2002-02-17 Tor Lillqvist * README.win32: Remove comment about the gtk-1-3-win32-production diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index e18ebae9db..36d665706a 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,10 @@ +2002-02-16 Manish Singh + + * tests/testgtk.c: redid the filesel test. Added a way to set select + multiple as a toggle button, and made show/hide fileops toggle + buttons as well. get_selections() is called on OK and all the + filenames selected are printed. + 2002-02-17 Tor Lillqvist * README.win32: Remove comment about the gtk-1-3-win32-production diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e18ebae9db..36d665706a 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,10 @@ +2002-02-16 Manish Singh + + * tests/testgtk.c: redid the filesel test. Added a way to set select + multiple as a toggle button, and made show/hide fileops toggle + buttons as well. get_selections() is called on OK and all the + filenames selected are printed. + 2002-02-17 Tor Lillqvist * README.win32: Remove comment about the gtk-1-3-win32-production diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index e18ebae9db..36d665706a 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,10 @@ +2002-02-16 Manish Singh + + * tests/testgtk.c: redid the filesel test. Added a way to set select + multiple as a toggle button, and made show/hide fileops toggle + buttons as well. get_selections() is called on OK and all the + filenames selected are printed. + 2002-02-17 Tor Lillqvist * README.win32: Remove comment about the gtk-1-3-win32-production diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e18ebae9db..36d665706a 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,10 @@ +2002-02-16 Manish Singh + + * tests/testgtk.c: redid the filesel test. Added a way to set select + multiple as a toggle button, and made show/hide fileops toggle + buttons as well. get_selections() is called on OK and all the + filenames selected are printed. + 2002-02-17 Tor Lillqvist * README.win32: Remove comment about the gtk-1-3-win32-production diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e18ebae9db..36d665706a 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,10 @@ +2002-02-16 Manish Singh + + * tests/testgtk.c: redid the filesel test. Added a way to set select + multiple as a toggle button, and made show/hide fileops toggle + buttons as well. get_selections() is called on OK and all the + filenames selected are printed. + 2002-02-17 Tor Lillqvist * README.win32: Remove comment about the gtk-1-3-win32-production diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e18ebae9db..36d665706a 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,10 @@ +2002-02-16 Manish Singh + + * tests/testgtk.c: redid the filesel test. Added a way to set select + multiple as a toggle button, and made show/hide fileops toggle + buttons as well. get_selections() is called on OK and all the + filenames selected are printed. + 2002-02-17 Tor Lillqvist * README.win32: Remove comment about the gtk-1-3-win32-production diff --git a/tests/testgtk.c b/tests/testgtk.c index c0f1da52c4..87524256ac 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -6467,17 +6467,42 @@ create_color_selection (void) */ void -file_selection_hide_fileops (GtkWidget *widget, - GtkFileSelection *fs) +show_fileops (GtkWidget *widget, + GtkFileSelection *fs) { - gtk_file_selection_hide_fileop_buttons (fs); + gboolean show_ops; + + show_ops = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + + if (show_ops) + gtk_file_selection_show_fileop_buttons (fs); + else + gtk_file_selection_hide_fileop_buttons (fs); } void -file_selection_ok (GtkWidget *w, - GtkFileSelection *fs) +select_multiple (GtkWidget *widget, + GtkFileSelection *fs) { - g_print ("%s\n", gtk_file_selection_get_filename (fs)); + gboolean select_multiple; + + select_multiple = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); + gtk_file_selection_set_select_multiple (fs, select_multiple); +} + +void +file_selection_ok (GtkFileSelection *fs) +{ + int i; + gchar **selections; + + selections = gtk_file_selection_get_selections (fs); + + for (i = 0; selections[i] != NULL; i++) + g_print ("%s\n", selections[i]); + + g_strfreev (selections); + gtk_widget_destroy (GTK_WIDGET (fs)); } @@ -6495,29 +6520,31 @@ create_file_selection (void) gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE); - gtk_signal_connect (GTK_OBJECT (window), "destroy", - GTK_SIGNAL_FUNC(gtk_widget_destroyed), - &window); + g_signal_connect (window, "destroy", + G_CALLBACK (gtk_widget_destroyed), + &window); - gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (window)->ok_button), - "clicked", GTK_SIGNAL_FUNC(file_selection_ok), - window); - gtk_signal_connect_object (GTK_OBJECT (GTK_FILE_SELECTION (window)->cancel_button), - "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), - GTK_OBJECT (window)); + g_signal_connect_swapped (GTK_FILE_SELECTION (window)->ok_button, + "clicked", + G_CALLBACK (file_selection_ok), + window); + g_signal_connect_swapped (GTK_FILE_SELECTION (window)->cancel_button, + "clicked", + G_CALLBACK (gtk_widget_destroy), + window); - button = gtk_button_new_with_label ("Hide Fileops"); - gtk_signal_connect (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) file_selection_hide_fileops, - (gpointer) window); + button = gtk_toggle_button_new_with_label ("Show Fileops"); + g_signal_connect (button, "toggled", + G_CALLBACK (show_fileops), + window); gtk_box_pack_start (GTK_BOX (GTK_FILE_SELECTION (window)->action_area), button, FALSE, FALSE, 0); gtk_widget_show (button); - button = gtk_button_new_with_label ("Show Fileops"); - gtk_signal_connect_object (GTK_OBJECT (button), "clicked", - (GtkSignalFunc) gtk_file_selection_show_fileop_buttons, - (gpointer) window); + button = gtk_toggle_button_new_with_label ("Select Multiple"); + g_signal_connect (button, "clicked", + G_CALLBACK (select_multiple), + window); gtk_box_pack_start (GTK_BOX (GTK_FILE_SELECTION (window)->action_area), button, FALSE, FALSE, 0); gtk_widget_show (button);