summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthias Clasen <maclas@gmx.de>2003-09-15 19:51:55 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2003-09-15 19:51:55 +0000
commitcaf380c793789e868458e32fbb64a33b5ef1d852 (patch)
treeee65930936942b62c28d6ae7a5de24905059e906 /tests
parentb14b12f9d2b5ba0b554b7d8ec2a3c90a8cd78d4f (diff)
downloadgdk-pixbuf-caf380c793789e868458e32fbb64a33b5ef1d852.tar.gz
Add value parameter to allow setting the currently selected group member
2003-09-15 Matthias Clasen <maclas@gmx.de> * gtk/gtkactiongroup.[hc]: (gtk_action_group_add_radio_actions): (gtk_action_group_add_radio_actions_full): Add value parameter to allow setting the currently selected group member before connecting signals. (GtkToggleActionEntry): Separate struct for constructing toggle actions, including a boolean to initialize the action state before connecting signals. (gtk_action_group_add_toggle_actions): (gtk_action_group_add_toggle_actions_full): New functions to construct toggle actions from an array of GtkToggleActionEntries. * demos/gtk-demo/appwindow.c: * tests/testactions.c: * tests/testmerge.c: Adjust to new action group API. * gtk/gtk-sections.txt: Add gtk_action_group_add_toggle_actions[_full].
Diffstat (limited to 'tests')
-rw-r--r--tests/testactions.c32
-rw-r--r--tests/testmerge.c15
2 files changed, 35 insertions, 12 deletions
diff --git a/tests/testactions.c b/tests/testactions.c
index cae4f0ef9..9c3939b9a 100644
--- a/tests/testactions.c
+++ b/tests/testactions.c
@@ -100,12 +100,8 @@ static GtkActionEntry entries[] = {
"Copy the selected text to the clipboard", G_CALLBACK (activate_action) },
{ "paste", GTK_STOCK_PASTE, "_Paste", "<control>V",
"Paste the text from the clipboard", G_CALLBACK (activate_action) },
- { "bold", GTK_STOCK_BOLD, "_Bold", "<control>B",
- "Change to bold face", G_CALLBACK (toggle_action), TRUE },
{ "quit", GTK_STOCK_QUIT, NULL, "<control>Q",
"Quit the application", G_CALLBACK (gtk_main_quit) },
- { "toggle-cnp", NULL, "Enable Cut/Copy/Paste", NULL,
- "Change the sensitivity of the cut, copy and paste actions", G_CALLBACK (toggle_cnp_actions), TRUE },
{ "customise-accels", NULL, "Customise _Accels", NULL,
"Customise keyboard shortcuts", G_CALLBACK (show_accel_dialog) },
{ "toolbar-small-icons", NULL, "Small Icons", NULL,
@@ -115,6 +111,16 @@ static GtkActionEntry entries[] = {
};
static guint n_entries = G_N_ELEMENTS (entries);
+static GtkToggleActionEntry toggle_entries[] = {
+ { "bold", GTK_STOCK_BOLD, "_Bold", "<control>B",
+ "Change to bold face",
+ G_CALLBACK (toggle_action), FALSE },
+ { "toggle-cnp", NULL, "Enable Cut/Copy/Paste", NULL,
+ "Change the sensitivity of the cut, copy and paste actions",
+ G_CALLBACK (toggle_cnp_actions), TRUE },
+};
+static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
+
enum {
JUSTIFY_LEFT,
JUSTIFY_CENTER,
@@ -254,15 +260,21 @@ main (int argc, char **argv)
gtk_accel_map_load ("accels");
action_group = gtk_action_group_new ("TestActions");
- gtk_action_group_add_actions (action_group, entries, n_entries, NULL);
- gtk_action_group_add_radio_actions (action_group, justify_entries, n_justify_entries,
+ gtk_action_group_add_actions (action_group,
+ entries, n_entries,
+ NULL);
+ gtk_action_group_add_toggle_actions (action_group,
+ toggle_entries, n_toggle_entries,
+ NULL);
+ gtk_action_group_add_radio_actions (action_group,
+ justify_entries, n_justify_entries,
+ JUSTIFY_LEFT,
G_CALLBACK (radio_action), NULL);
- gtk_action_group_add_radio_actions (action_group, toolbar_entries, n_toolbar_entries,
+ gtk_action_group_add_radio_actions (action_group,
+ toolbar_entries, n_toolbar_entries,
+ GTK_TOOLBAR_BOTH,
G_CALLBACK (radio_action), NULL);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_action_group_get_action (action_group, "toggle-cnp")),
- FALSE);
-
create_window (action_group);
gtk_main ();
diff --git a/tests/testmerge.c b/tests/testmerge.c
index 0d50a3915..4b40f1262 100644
--- a/tests/testmerge.c
+++ b/tests/testmerge.c
@@ -126,10 +126,15 @@ static GtkActionEntry entries[] = {
{ "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) },
- { "BoldAction", GTK_STOCK_BOLD, "_Bold", "<control>b", NULL, G_CALLBACK (toggle_action), TRUE },
};
static guint n_entries = G_N_ELEMENTS (entries);
+static GtkToggleActionEntry toggle_entries[] = {
+ { "BoldAction", GTK_STOCK_BOLD, "_Bold", "<control>b", NULL, G_CALLBACK (toggle_action),
+ TRUE },
+};
+static guint n_toggle_entries = G_N_ELEMENTS (toggle_entries);
+
enum {
JUSTIFY_LEFT,
JUSTIFY_CENTER,
@@ -442,9 +447,15 @@ 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, NULL);
+ gtk_action_group_add_actions (action_group,
+ entries, n_entries,
+ NULL);
+ gtk_action_group_add_toggle_actions (action_group,
+ toggle_entries, n_toggle_entries,
+ NULL);
gtk_action_group_add_radio_actions (action_group,
radio_entries, n_radio_entries,
+ JUSTIFY_LEFT,
G_CALLBACK (radio_action_changed), NULL);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);