From: Matthias Clasen Date: Sun, 31 Aug 2003 13:49:15 +0000 (+0000) Subject: Add gtktoggleactionprivate.h X-Git-Url: http://pileus.org/git/?a=commitdiff_plain;h=2c41fc09187cb52b132686165e25ca8182545298;p=~andy%2Fgtk Add gtktoggleactionprivate.h 2003-08-31 Matthias Clasen * gtk/Makefile.am (IGNORE_HFILES): Add gtktoggleactionprivate.h * gtk/tmpl/gtkuimanager.sgml: * gtk/gtk-sections.txt: Replace gtk_ui_manager_activate by gtk_ui_manager_get_action. * gtk/gtkuimanager.[ch] (gtk_ui_manager_get_action): New function, replaces gtk_ui_manager_activate(). (#120658) * tests/testmerge.c: Use gtk_ui_manager_get_action() instead of gtk_ui_manager_activate(). --- diff --git a/ChangeLog b/ChangeLog index e62ecf6c9..016378a58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2003-08-31 Matthias Clasen + * gtk/gtkuimanager.[ch] (gtk_ui_manager_get_action): New function, + replaces gtk_ui_manager_activate(). (#120658) + + * tests/testmerge.c: Use gtk_ui_manager_get_action() instead of + gtk_ui_manager_activate(). + * gtk/gtkaction.c: * gtk/gtkactiongroup.c: Some doc tweaks. @@ -21,7 +27,7 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular menus, but not to popups. Add a signal "changed", which gets emitted - when the merged ui has changed. + when the merged ui has changed. (#120649, #120656) * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index e62ecf6c9..016378a58 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,11 @@ 2003-08-31 Matthias Clasen + * gtk/gtkuimanager.[ch] (gtk_ui_manager_get_action): New function, + replaces gtk_ui_manager_activate(). (#120658) + + * tests/testmerge.c: Use gtk_ui_manager_get_action() instead of + gtk_ui_manager_activate(). + * gtk/gtkaction.c: * gtk/gtkactiongroup.c: Some doc tweaks. @@ -21,7 +27,7 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular menus, but not to popups. Add a signal "changed", which gets emitted - when the merged ui has changed. + when the merged ui has changed. (#120649, #120656) * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index e62ecf6c9..016378a58 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,5 +1,11 @@ 2003-08-31 Matthias Clasen + * gtk/gtkuimanager.[ch] (gtk_ui_manager_get_action): New function, + replaces gtk_ui_manager_activate(). (#120658) + + * tests/testmerge.c: Use gtk_ui_manager_get_action() instead of + gtk_ui_manager_activate(). + * gtk/gtkaction.c: * gtk/gtkactiongroup.c: Some doc tweaks. @@ -21,7 +27,7 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular menus, but not to popups. Add a signal "changed", which gets emitted - when the merged ui has changed. + when the merged ui has changed. (#120649, #120656) * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index e62ecf6c9..016378a58 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,5 +1,11 @@ 2003-08-31 Matthias Clasen + * gtk/gtkuimanager.[ch] (gtk_ui_manager_get_action): New function, + replaces gtk_ui_manager_activate(). (#120658) + + * tests/testmerge.c: Use gtk_ui_manager_get_action() instead of + gtk_ui_manager_activate(). + * gtk/gtkaction.c: * gtk/gtkactiongroup.c: Some doc tweaks. @@ -21,7 +27,7 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular menus, but not to popups. Add a signal "changed", which gets emitted - when the merged ui has changed. + when the merged ui has changed. (#120649, #120656) * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index e62ecf6c9..016378a58 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,5 +1,11 @@ 2003-08-31 Matthias Clasen + * gtk/gtkuimanager.[ch] (gtk_ui_manager_get_action): New function, + replaces gtk_ui_manager_activate(). (#120658) + + * tests/testmerge.c: Use gtk_ui_manager_get_action() instead of + gtk_ui_manager_activate(). + * gtk/gtkaction.c: * gtk/gtkactiongroup.c: Some doc tweaks. @@ -21,7 +27,7 @@ * gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with setter and getter. If it is set, add tearoff menu items to regular menus, but not to popups. Add a signal "changed", which gets emitted - when the merged ui has changed. + when the merged ui has changed. (#120649, #120656) * tests/testmerge.c: Add button to test the generation of tearoff menu items. diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index c0233b5df..68420bc22 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,5 +1,11 @@ 2003-08-31 Matthias Clasen + * gtk/Makefile.am (IGNORE_HFILES): Add gtktoggleactionprivate.h + + * gtk/tmpl/gtkuimanager.sgml: + * gtk/gtk-sections.txt: Replace gtk_ui_manager_activate by + gtk_ui_manager_get_action. + * gtk/tmpl/gtkuimanager.sgml: * gtk/tmpl/gtkactiongroup.sgml: * gtk/tmpl/gtkaction.sgml: diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am index 52d9bceab..511803a76 100644 --- a/docs/reference/gtk/Makefile.am +++ b/docs/reference/gtk/Makefile.am @@ -47,7 +47,8 @@ IGNORE_HFILES= \ gtktextutil.h \ gtktypebuiltins.h \ gtkxembed.h \ - xembed.h + xembed.h \ + gtktoggleactionprivate.h # CFLAGS and LDFLAGS for compiling scan program. Only needed # if $(DOC_MODULE).types is non-empty. diff --git a/docs/reference/gtk/gtk-sections.txt b/docs/reference/gtk/gtk-sections.txt index 5bfac533f..87ca2c08d 100644 --- a/docs/reference/gtk/gtk-sections.txt +++ b/docs/reference/gtk/gtk-sections.txt @@ -1730,11 +1730,11 @@ gtk_ui_manager_remove_action_group gtk_ui_manager_get_action_groups gtk_ui_manager_get_accel_group gtk_ui_manager_get_widget +gtk_ui_manager_get_action gtk_ui_manager_add_ui_from_string gtk_ui_manager_add_ui_from_file gtk_ui_manager_remove_ui gtk_ui_manager_get_ui -gtk_ui_manager_activate GTK_TYPE_UI_MANAGER GTK_UI_MANAGER diff --git a/docs/reference/gtk/tmpl/gtkuimanager.sgml b/docs/reference/gtk/tmpl/gtkuimanager.sgml index d49356556..3bf4e5f9c 100644 --- a/docs/reference/gtk/tmpl/gtkuimanager.sgml +++ b/docs/reference/gtk/tmpl/gtkuimanager.sgml @@ -63,7 +63,7 @@ siblings in the partially constructed tree. If it is "top", the widget is prepen otherwise it is appended. - + @@ -148,6 +148,16 @@ otherwise it is appended. @Returns: + + + + + +@self: +@path: +@Returns: + + @@ -189,15 +199,6 @@ otherwise it is appended. @Returns: - - - - - -@self: -@path: - - diff --git a/gtk/gtkuimanager.c b/gtk/gtkuimanager.c index 945ceeb07..d27bbf8cd 100644 --- a/gtk/gtkuimanager.c +++ b/gtk/gtkuimanager.c @@ -388,7 +388,7 @@ gtk_ui_manager_set_add_tearoffs (GtkUIManager *self, * gtk_ui_manager_insert_action_group: * @self: a #GtkUIManager object * @action_group: the action group to be inserted - * @pos: the position at which the group will be inserted + * @pos: the position at which the group will be inserted. * * Inserts an action group into the list of action groups associated * with @self. @@ -513,6 +513,42 @@ gtk_ui_manager_get_widget (GtkUIManager *self, return NODE_INFO (node)->proxy; } +/** + * gtk_ui_manager_get_action: + * @self: a #GtkUIManager + * @path: a path + * + * Looks up an action by following a path. The path consists of the names + * specified in the XML description of the UI. separated by '/'. Elements + * which don't have a name attribute in the XML (e.g. <popup>) can be + * addressed by their XML element name (e.g. "popup"). The root element + * (<ui>) can be omitted in the path. + * + * Return value: the action whose proxy widget is found by following the path, + * or %NULL if no widget was found. + * + * Since: 2.4 + **/ +GtkAction * +gtk_ui_manager_get_action (GtkUIManager *self, + const gchar *path) +{ + GNode *node; + + g_return_val_if_fail (GTK_IS_UI_MANAGER (self), NULL); + + /* ensure that there are no pending updates before we get + * the action */ + gtk_ui_manager_ensure_update (self); + + node = gtk_ui_manager_get_node (self, path, GTK_UI_MANAGER_UNDECIDED, FALSE); + + if (node == NULL) + return NULL; + + return NODE_INFO (node)->action; +} + static GNode * get_child_node (GtkUIManager *self, GNode *parent, @@ -1845,31 +1881,3 @@ gtk_ui_manager_get_ui (GtkUIManager *self) return g_string_free (buffer, FALSE); } -/** - * gtk_ui_manager_activate: - * @self: a #GtkUIManager - * @path: a path - * - * Activates the action whose proxy is found by following the given path. - * - * Since: 2.4 - **/ -void -gtk_ui_manager_activate (GtkUIManager *self, - const gchar *path) -{ - GNode *node; - - g_return_if_fail (GTK_IS_UI_MANAGER (self)); - - /* ensure that there are no pending updates before we activate - * the action */ - gtk_ui_manager_ensure_update (self); - - node = gtk_ui_manager_get_node (self, path, GTK_UI_MANAGER_UNDECIDED, FALSE); - - if (node == NULL || NODE_INFO (node)->action == NULL) - return; - - gtk_action_activate (NODE_INFO (node)->action); -} diff --git a/gtk/gtkuimanager.h b/gtk/gtkuimanager.h index 410647caf..4ee647037 100644 --- a/gtk/gtkuimanager.h +++ b/gtk/gtkuimanager.h @@ -90,9 +90,10 @@ GList *gtk_ui_manager_get_action_groups (GtkUIManager *self); GtkAccelGroup *gtk_ui_manager_get_accel_group (GtkUIManager *self); - GtkWidget *gtk_ui_manager_get_widget (GtkUIManager *self, const gchar *path); +GtkAction *gtk_ui_manager_get_action (GtkUIManager *self, + const gchar *path); /* these two functions are for adding UI elements to the merged user * interface */ @@ -108,7 +109,4 @@ void gtk_ui_manager_remove_ui (GtkUIManager *self, gchar *gtk_ui_manager_get_ui (GtkUIManager *self); -void gtk_ui_manager_activate (GtkUIManager *self, - const gchar *path); - #endif /* __GTK_UI_MANAGER_H__ */ diff --git a/tests/testmerge.c b/tests/testmerge.c index 193861329..f8c01e030 100644 --- a/tests/testmerge.c +++ b/tests/testmerge.c @@ -371,7 +371,12 @@ static void activate_path (GtkWidget *button, GtkUIManager *merge) { - gtk_ui_manager_activate (merge, "/menubar/HelpMenu/About"); + GtkAction *action = gtk_ui_manager_get_action (merge, + "/menubar/HelpMenu/About"); + if (action) + gtk_action_activate (action); + else + g_message ("no action found"); } int