X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=tests%2Ftestactions.c;h=e59fa886013e00010d733d80afa10050022af1ea;hb=9d0febc9a64a5bfb0fcfc3a88de4757f6c1ff090;hp=4f971c2fdbe4fcd900cad6d3b5d193243293d490;hpb=06e735a652a9aefc787c696b44bfcc666ed61ef2;p=~andy%2Fgtk diff --git a/tests/testactions.c b/tests/testactions.c index 4f971c2fd..e59fa8860 100644 --- a/tests/testactions.c +++ b/tests/testactions.c @@ -12,13 +12,10 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library. If not, see . */ -#undef GTK_DISABLE_DEPRECATED -#include +#include "config.h" #include static GtkActionGroup *action_group = NULL; @@ -55,6 +52,19 @@ radio_action (GtkAction *action) gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action))); } +static void +recent_action (GtkAction *action) +{ + const gchar *name = gtk_action_get_name (action); + const gchar *typename = G_OBJECT_TYPE_NAME (action); + gchar *uri = gtk_recent_chooser_get_current_uri (GTK_RECENT_CHOOSER (action)); + + g_message ("Action %s (type=%s) activated (uri=%s)", + name, typename, + uri ? uri : "no item selected"); + g_free (uri); +} + static void toggle_cnp_actions (GtkAction *action) { @@ -82,13 +92,15 @@ show_accel_dialog (GtkAction *action) } static void -toolbar_style (GtkAction *action, - gpointer user_data) +toolbar_style (GtkAction *action) { GtkToolbarStyle style; g_return_if_fail (toolbar != NULL); - style = GPOINTER_TO_INT (user_data); + + radio_action (action); + + style = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action)); gtk_toolbar_set_style (toolbar, style); } @@ -115,6 +127,8 @@ static GtkActionEntry entries[] = { { "Menu2Action", NULL, "Menu _2" }, { "Menu3Action", NULL, "_Dynamic Menu" }, + { "attach", "mail-attachment", "_Attachment...", "m", + "Attach a file", G_CALLBACK (activate_action) }, { "cut", GTK_STOCK_CUT, "C_ut", "X", "Cut the selected text to the clipboard", G_CALLBACK (activate_action) }, { "copy", GTK_STOCK_COPY, "_Copy", "C", @@ -181,46 +195,50 @@ static const gchar *ui_info = " \n" " \n" " \n" -" \n" +" \n" " \n" +" \n" +" \n" " \n" " \n" " \n" " \n" " \n" " \n" -" \n" -" \n" " \n" +" \n" +" \n" " \n" " \n" " \n" " \n" -" \n" -" \n" " \n" +" \n" +" \n" " \n" " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" - " \n" +" \n" " \n" " \n" +" \n" " \n" " \n" " \n" -" \n" -" \n" +" \n" " \n" +" \n" +" \n" " \n" " \n" " \n" " \n" -" \n" +" \n" " \n" " \n" " \n" @@ -340,7 +358,7 @@ create_window (GtkActionGroup *action_group) g_signal_connect_swapped (window, "destroy", G_CALLBACK (g_object_unref), merge); g_signal_connect (window, "destroy", G_CALLBACK (gtk_main_quit), NULL); - box = gtk_vbox_new (FALSE, 0); + box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), box); gtk_widget_show (box); @@ -356,7 +374,7 @@ create_window (GtkActionGroup *action_group) g_error_free (error); } - hbox = gtk_hbox_new (FALSE, 0); + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_end (GTK_BOX (box), hbox, FALSE, FALSE, 0); gtk_widget_show (hbox); @@ -383,11 +401,23 @@ create_window (GtkActionGroup *action_group) int main (int argc, char **argv) { + GtkAction *action; + gtk_init (&argc, &argv); if (g_file_test ("accels", G_FILE_TEST_IS_REGULAR)) gtk_accel_map_load ("accels"); + action = gtk_recent_action_new ("recent", + "Open Recent", "Open recent files", + NULL); + g_signal_connect (action, "item-activated", + G_CALLBACK (recent_action), + NULL); + g_signal_connect (action, "activate", + G_CALLBACK (recent_action), + NULL); + action_group = gtk_action_group_new ("TestActions"); gtk_action_group_add_actions (action_group, entries, n_entries, @@ -402,7 +432,8 @@ main (int argc, char **argv) gtk_action_group_add_radio_actions (action_group, toolbar_entries, n_toolbar_entries, GTK_TOOLBAR_BOTH, - G_CALLBACK (radio_action), NULL); + G_CALLBACK (toolbar_style), NULL); + gtk_action_group_add_action_with_accel (action_group, action, NULL); create_window (action_group); @@ -422,7 +453,8 @@ main (int argc, char **argv) } } #endif - + + g_object_unref (action); g_object_unref (action_group); gtk_accel_map_save ("accels");