summaryrefslogtreecommitdiff
path: root/tests/testactions.c
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2007-03-15 19:33:57 +0000
committerEmmanuele Bassi <ebassi@src.gnome.org>2007-03-15 19:33:57 +0000
commitccf49466a64602051ddffca43488b77576abeab2 (patch)
tree2695b60d9ff5e30516ee4950860bd3ac0a778254 /tests/testactions.c
parent0b1c9b7cc26d293477a6823a40d3e1feebbd6df7 (diff)
downloadgtk+-ccf49466a64602051ddffca43488b77576abeab2.tar.gz
Add GtkActionClass::get_submenu() vfunc: actions providing a menu item or
2007-03-15 Emmanuele Bassi <ebassi@gnome.org> * gtk/gtkaction.[ch]: Add GtkActionClass::get_submenu() vfunc: actions providing a menu item or a menu tool button with already a submenu should return the GtkMenu widget. * gtk/gtkuimanager.c (update_node): If an action provides its own submenu, use it instead of adding an empty one * gtk/gtkrecentaction.[ch]: Add GtkRecentAction, an action implementing the GtkRecentChooser interface for displaying the list of recently used files into menus and toolbars generated using GtkUIManager. (#338843) * gtk/Makefile.am: * gtk/gtk.h: * gtk/gtk.symbols: Add GtkRecentAction API to the build. * tests/testactions.c: Exercise the GtkRecentAction API. svn path=/trunk/; revision=17524
Diffstat (limited to 'tests/testactions.c')
-rw-r--r--tests/testactions.c52
1 files changed, 41 insertions, 11 deletions
diff --git a/tests/testactions.c b/tests/testactions.c
index 4f971c2fdb..01b6655171 100644
--- a/tests/testactions.c
+++ b/tests/testactions.c
@@ -56,6 +56,19 @@ radio_action (GtkAction *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)
{
gboolean sensitive;
@@ -181,46 +194,49 @@ static const gchar *ui_info =
" <menuitem name=\"bold1\" action=\"bold\" />\n"
" <menuitem name=\"bold2\" action=\"bold\" />\n"
" <separator name=\"sep2\" />\n"
-" <menuitem name=\"toggle-cnp\" action=\"toggle-cnp\" />\n"
+" <menuitem name=\"recent\" action=\"recent\" />\n"
" <separator name=\"sep3\" />\n"
+" <menuitem name=\"toggle-cnp\" action=\"toggle-cnp\" />\n"
+" <separator name=\"sep4\" />\n"
" <menuitem name=\"quit\" action=\"quit\" />\n"
" </menu>\n"
" <menu name=\"Menu _2\" action=\"Menu2Action\">\n"
" <menuitem name=\"cut\" action=\"cut\" />\n"
" <menuitem name=\"copy\" action=\"copy\" />\n"
" <menuitem name=\"paste\" action=\"paste\" />\n"
-" <separator name=\"sep4\"/>\n"
-" <menuitem name=\"bold\" action=\"bold\" />\n"
" <separator name=\"sep5\"/>\n"
+" <menuitem name=\"bold\" action=\"bold\" />\n"
+" <separator name=\"sep6\"/>\n"
" <menuitem name=\"justify-left\" action=\"justify-left\" />\n"
" <menuitem name=\"justify-center\" action=\"justify-center\" />\n"
" <menuitem name=\"justify-right\" action=\"justify-right\" />\n"
" <menuitem name=\"justify-fill\" action=\"justify-fill\" />\n"
-" <separator name=\"sep6\"/>\n"
-" <menuitem name=\"customise-accels\" action=\"customise-accels\" />\n"
" <separator name=\"sep7\"/>\n"
+" <menuitem name=\"customise-accels\" action=\"customise-accels\" />\n"
+" <separator name=\"sep8\"/>\n"
" <menuitem action=\"toolbar-icons\" />\n"
" <menuitem action=\"toolbar-text\" />\n"
" <menuitem action=\"toolbar-both\" />\n"
" <menuitem action=\"toolbar-both-horiz\" />\n"
-" <separator name=\"sep8\"/>\n"
+" <separator name=\"sep9\"/>\n"
" <menuitem action=\"toolbar-small-icons\" />\n"
" <menuitem action=\"toolbar-large-icons\" />\n"
" </menu>\n"
- " <menu name=\"DynamicMenu\" action=\"Menu3Action\" />\n"
+" <menu name=\"DynamicMenu\" action=\"Menu3Action\" />\n"
" </menubar>\n"
" <toolbar name=\"toolbar\">\n"
" <toolitem name=\"cut\" action=\"cut\" />\n"
" <toolitem name=\"copy\" action=\"copy\" />\n"
" <toolitem name=\"paste\" action=\"paste\" />\n"
-" <separator name=\"sep9\" />\n"
-" <toolitem name=\"bold\" action=\"bold\" />\n"
+" <toolitem name=\"recent\" action=\"recent\" />\n"
" <separator name=\"sep10\" />\n"
+" <toolitem name=\"bold\" action=\"bold\" />\n"
+" <separator name=\"sep11\" />\n"
" <toolitem name=\"justify-left\" action=\"justify-left\" />\n"
" <toolitem name=\"justify-center\" action=\"justify-center\" />\n"
" <toolitem name=\"justify-right\" action=\"justify-right\" />\n"
" <toolitem name=\"justify-fill\" action=\"justify-fill\" />\n"
-" <separator name=\"sep11\"/>\n"
+" <separator name=\"sep12\"/>\n"
" <toolitem name=\"quit\" action=\"quit\" />\n"
" </toolbar>\n"
" <popup name=\"popup\">\n"
@@ -383,11 +399,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,
@@ -403,6 +431,7 @@ main (int argc, char **argv)
toolbar_entries, n_toolbar_entries,
GTK_TOOLBAR_BOTH,
G_CALLBACK (radio_action), NULL);
+ gtk_action_group_add_action_with_accel (action_group, action, NULL);
create_window (action_group);
@@ -422,7 +451,8 @@ main (int argc, char **argv)
}
}
#endif
-
+
+ g_object_unref (action);
g_object_unref (action_group);
gtk_accel_map_save ("accels");