diff options
author | Matthias Clasen <maclas@gmx.de> | 2003-08-27 22:22:28 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2003-08-27 22:22:28 +0000 |
commit | cbc20c4dde539ed01dede8356d9cd1dc56479799 (patch) | |
tree | 7f01eba754c3806ac3b7c9101f5feb7ed7023f50 /tests/testmerge.c | |
parent | bebc663c5a27c63246956ecc10c0c4c953d26ba7 (diff) | |
download | gtk+-cbc20c4dde539ed01dede8356d9cd1dc56479799.tar.gz |
Change the XML format: <Root> element is replaced by <ui>, <menu> element
2003-08-28 Matthias Clasen <maclas@gmx.de>
* gtk/gtkuimanager.c: Change the XML format:
<Root> element is replaced by <ui>,
<menu> element is replaced by <menubar>,
<submenu> element is replaced by <menu>,
<dockitem> element is replaced by <toolbar>,
<popups> element is gone,
verb attribute is replaced by action,
name defaults to action or the element name.
* gtk/gtkactiongroup.[hc]: Replace GtkActionGroupEntry by GtkActionEntry
and GtkRadioActionEntry. GtkActionEntry is simplified by removing
the user_data, entry_type and extra_data fields, GtkRadioActionEntry is
further simplified by removing the callback. The user_data can now be
specified as an argument to gtk_action_group_add_actions(). There is
a new method gtk_action_group_add_radio_actions(), which is similar
to gtk_action_group_add_actions(), but takes GtkRadioActionEntrys
and a callback parameter in addition to the user_data. The callback
is connected to the ::changed signal of the first group member.
There are _full() variants taking a GDestroyNotify of
gtk_action_group_add_[radio_]actions().
* gtk/gtkradioaction.[hc]: Add a ::changed signal which gets emitted
on every member of the radio group when the active member is changed.
Add an integer property "value", and a getter for the value of "value"
on the currently active group member.
* tests/testactions.c:
* tests/testmerge.c:
* tests/merge-[123].ui:
* demos/gtk-demo/appwindow.c: Adjust to these changes.
* gtk/gtktoolbar.c (gtk_toolbar_append_element): Trivial doc fix.
Diffstat (limited to 'tests/testmerge.c')
-rw-r--r-- | tests/testmerge.c | 90 |
1 files changed, 49 insertions, 41 deletions
diff --git a/tests/testmerge.c b/tests/testmerge.c index 2bfd78601b..0b9e800716 100644 --- a/tests/testmerge.c +++ b/tests/testmerge.c @@ -2,11 +2,6 @@ #include <string.h> #include <gtk/gtk.h> -#ifndef _ -# define _(String) (String) -# define N_(String) (String) -#endif - struct { const gchar *filename; guint merge_id; } merge_ids[] = { { "merge-1.ui", 0 }, { "merge-2.ui", 0 }, @@ -44,43 +39,54 @@ toggle_action (GtkAction *action) } -static GtkActionGroupEntry entries[] = { - { "StockFileMenuAction", N_("_File"), NULL, NULL, NULL, NULL, NULL }, - { "StockEditMenuAction", N_("_Edit"), NULL, NULL, NULL, NULL, NULL }, - { "StockHelpMenuAction", N_("_Help"), NULL, NULL, NULL, NULL, NULL }, - { "Test", N_("Test"), NULL, NULL, NULL, NULL, NULL }, - - { "NewAction", NULL, GTK_STOCK_NEW, "<control>n", NULL, - G_CALLBACK (activate_action), NULL }, - { "New2Action", NULL, GTK_STOCK_NEW, "<control>m", NULL, - G_CALLBACK (activate_action), NULL }, - { "OpenAction", NULL, GTK_STOCK_OPEN, "<control>o", NULL, - G_CALLBACK (activate_action), NULL }, - { "QuitAction", NULL, GTK_STOCK_QUIT, "<control>q", NULL, - G_CALLBACK (gtk_main_quit), NULL }, - { "CutAction", NULL, GTK_STOCK_CUT, "<control>x", NULL, - G_CALLBACK (activate_action), NULL }, - { "CopyAction", NULL, GTK_STOCK_COPY, "<control>c", NULL, - G_CALLBACK (activate_action), NULL }, - { "PasteAction", NULL, GTK_STOCK_PASTE, "<control>v", NULL, - G_CALLBACK (activate_action), NULL }, - { "justify-left", NULL, GTK_STOCK_JUSTIFY_LEFT, "<control>L", - N_("Left justify the text"), - G_CALLBACK (toggle_action), NULL, GTK_ACTION_RADIO, NULL }, - { "justify-center", NULL, GTK_STOCK_JUSTIFY_CENTER, "<control>E", - N_("Center justify the text"), - G_CALLBACK (toggle_action), NULL, GTK_ACTION_RADIO, "justify-left" }, - { "justify-right", NULL, GTK_STOCK_JUSTIFY_RIGHT, "<control>R", - N_("Right justify the text"), - G_CALLBACK (toggle_action), NULL, GTK_ACTION_RADIO, "justify-left" }, - { "justify-fill", NULL, GTK_STOCK_JUSTIFY_FILL, "<control>J", - N_("Fill justify the text"), - G_CALLBACK (toggle_action), NULL, GTK_ACTION_RADIO, "justify-left" }, - { "AboutAction", N_("_About"), NULL, NULL, NULL, - G_CALLBACK (activate_action), NULL }, +static void +radio_action_changed (GtkAction *action, GtkRadioAction *current) +{ + g_message ("Action %s (type=%s) activated (active=%d) (value %d)", + gtk_action_get_name (GTK_ACTION (current)), + G_OBJECT_TYPE_NAME (GTK_ACTION (current)), + gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (current)), + gtk_radio_action_get_current_value (current)); +} + + +static GtkActionEntry entries[] = { + { "FileMenuAction", NULL, "_File" }, + { "EditMenuAction", NULL, "_Edit" }, + { "HelpMenuAction", NULL, "_Help" }, + { "JustifyMenuAction", NULL, "_Justify" }, + { "Test", NULL, "Test" }, + + { "QuitAction", GTK_STOCK_QUIT, NULL, "<control>q", NULL, G_CALLBACK (gtk_main_quit) }, + { "NewAction", GTK_STOCK_NEW, NULL, "<control>n", NULL, G_CALLBACK (activate_action) }, + { "New2Action", GTK_STOCK_NEW, NULL, "<control>m", NULL, G_CALLBACK (activate_action) }, + { "OpenAction", GTK_STOCK_OPEN, NULL, "<control>o", NULL, G_CALLBACK (activate_action) }, + { "CutAction", GTK_STOCK_CUT, NULL, "<control>x", NULL, G_CALLBACK (activate_action) }, + { "CopyAction", GTK_STOCK_COPY, NULL, "<control>c", NULL, G_CALLBACK (activate_action) }, + { "PasteAction", GTK_STOCK_PASTE, NULL, "<control>v", NULL, G_CALLBACK (activate_action) }, + { "AboutAction", NULL, "_About", NULL, NULL, G_CALLBACK (activate_action) }, }; static guint n_entries = G_N_ELEMENTS (entries); +enum { + JUSTIFY_LEFT, + JUSTIFY_CENTER, + JUSTIFY_RIGHT, + JUSTIFY_FILL +}; + +static GtkRadioActionEntry radio_entries[] = { + { "justify-left", GTK_STOCK_JUSTIFY_LEFT, NULL, "<control>L", + "Left justify the text", JUSTIFY_LEFT }, + { "justify-center", GTK_STOCK_JUSTIFY_CENTER, NULL, "<control>E", + "Center justify the text", JUSTIFY_CENTER }, + { "justify-right", GTK_STOCK_JUSTIFY_RIGHT, NULL, "<control>R", + "Right justify the text", JUSTIFY_RIGHT }, + { "justify-fill", GTK_STOCK_JUSTIFY_FILL, NULL, "<control>J", + "Fill justify the text", JUSTIFY_FILL }, +}; +static guint n_radio_entries = G_N_ELEMENTS (radio_entries); + static void add_widget (GtkUIManager *merge, GtkWidget *widget, @@ -322,7 +328,7 @@ area_press (GtkWidget *drawing_area, if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { - GtkWidget *menu = gtk_ui_manager_get_widget (merge, "/popups/FileMenu"); + GtkWidget *menu = gtk_ui_manager_get_widget (merge, "/FileMenu"); if (GTK_IS_MENU (menu)) { @@ -349,7 +355,9 @@ main (int argc, char **argv) gtk_init (&argc, &argv); action_group = gtk_action_group_new ("TestActions"); - gtk_action_group_add_actions (action_group, entries, n_entries); + gtk_action_group_add_actions (action_group, entries, n_entries, NULL); + gtk_action_group_add_radio_actions (action_group, radio_entries, n_radio_entries, + G_CALLBACK (radio_action_changed), NULL); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size (GTK_WINDOW (window), -1, 400); |