Connect to "destroy" on toolbar, rather than to "remove" on handlebox.

2003-08-30  Matthias Clasen  <maclas@gmx.de>

	* tests/testmerge.c (add_widget): Connect to "destroy" on toolbar,
	rather than to "remove" on handlebox.

	* gtk/gtkuimanager.[hc] (gtk_ui_manager_activate): New method to
	activate an action found by following a path.  (#120658)

	* tests/testmerge.c: Add a button to test gtk_ui_manager_activate().
This commit is contained in:
Matthias Clasen 2003-08-30 21:18:43 +00:00 committed by Matthias Clasen
parent 5f6d00b486
commit e5eaa52b07
8 changed files with 171 additions and 70 deletions

View File

@ -1,5 +1,13 @@
2003-08-30 Matthias Clasen <maclas@gmx.de>
* tests/testmerge.c (add_widget): Connect to "destroy" on toolbar,
rather than to "remove" on handlebox.
* gtk/gtkuimanager.[hc] (gtk_ui_manager_activate): New method to
activate an action found by following a path. (#120658)
* tests/testmerge.c: Add a button to test gtk_ui_manager_activate().
* tests/testmerge.c (add_widget): Put toolbars in handleboxes.
* gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with
@ -12,11 +20,12 @@
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full): Actually
group the actions together rather than putting each in its own group.
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
Actually group the actions together rather than putting each in its
own group.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on proxy
menu items for radio actions.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on
proxy menu items for radio actions.
* gtk/gtkgamma.c (gamma_ok_callback): Use g_strtod instead of strtod.
@ -31,8 +40,9 @@ Fri Aug 29 21:40:01 2003 Soeren Sandmann <sandmann@daimi.au.dk>
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install "draw_as_radio"
as a separate property, not as an alias of "inconsistent".
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install
"draw_as_radio" as a separate property, not as an alias of
"inconsistent".
(gtk_check_menu_item_get_property):
(gtk_check_menu_item_set_property): Also support "draw_as_radio".
@ -80,13 +90,14 @@ Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
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
* 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

View File

@ -1,5 +1,13 @@
2003-08-30 Matthias Clasen <maclas@gmx.de>
* tests/testmerge.c (add_widget): Connect to "destroy" on toolbar,
rather than to "remove" on handlebox.
* gtk/gtkuimanager.[hc] (gtk_ui_manager_activate): New method to
activate an action found by following a path. (#120658)
* tests/testmerge.c: Add a button to test gtk_ui_manager_activate().
* tests/testmerge.c (add_widget): Put toolbars in handleboxes.
* gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with
@ -12,11 +20,12 @@
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full): Actually
group the actions together rather than putting each in its own group.
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
Actually group the actions together rather than putting each in its
own group.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on proxy
menu items for radio actions.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on
proxy menu items for radio actions.
* gtk/gtkgamma.c (gamma_ok_callback): Use g_strtod instead of strtod.
@ -31,8 +40,9 @@ Fri Aug 29 21:40:01 2003 Soeren Sandmann <sandmann@daimi.au.dk>
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install "draw_as_radio"
as a separate property, not as an alias of "inconsistent".
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install
"draw_as_radio" as a separate property, not as an alias of
"inconsistent".
(gtk_check_menu_item_get_property):
(gtk_check_menu_item_set_property): Also support "draw_as_radio".
@ -80,13 +90,14 @@ Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
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
* 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

View File

@ -1,5 +1,13 @@
2003-08-30 Matthias Clasen <maclas@gmx.de>
* tests/testmerge.c (add_widget): Connect to "destroy" on toolbar,
rather than to "remove" on handlebox.
* gtk/gtkuimanager.[hc] (gtk_ui_manager_activate): New method to
activate an action found by following a path. (#120658)
* tests/testmerge.c: Add a button to test gtk_ui_manager_activate().
* tests/testmerge.c (add_widget): Put toolbars in handleboxes.
* gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with
@ -12,11 +20,12 @@
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full): Actually
group the actions together rather than putting each in its own group.
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
Actually group the actions together rather than putting each in its
own group.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on proxy
menu items for radio actions.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on
proxy menu items for radio actions.
* gtk/gtkgamma.c (gamma_ok_callback): Use g_strtod instead of strtod.
@ -31,8 +40,9 @@ Fri Aug 29 21:40:01 2003 Soeren Sandmann <sandmann@daimi.au.dk>
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install "draw_as_radio"
as a separate property, not as an alias of "inconsistent".
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install
"draw_as_radio" as a separate property, not as an alias of
"inconsistent".
(gtk_check_menu_item_get_property):
(gtk_check_menu_item_set_property): Also support "draw_as_radio".
@ -80,13 +90,14 @@ Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
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
* 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

View File

@ -1,5 +1,13 @@
2003-08-30 Matthias Clasen <maclas@gmx.de>
* tests/testmerge.c (add_widget): Connect to "destroy" on toolbar,
rather than to "remove" on handlebox.
* gtk/gtkuimanager.[hc] (gtk_ui_manager_activate): New method to
activate an action found by following a path. (#120658)
* tests/testmerge.c: Add a button to test gtk_ui_manager_activate().
* tests/testmerge.c (add_widget): Put toolbars in handleboxes.
* gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with
@ -12,11 +20,12 @@
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full): Actually
group the actions together rather than putting each in its own group.
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
Actually group the actions together rather than putting each in its
own group.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on proxy
menu items for radio actions.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on
proxy menu items for radio actions.
* gtk/gtkgamma.c (gamma_ok_callback): Use g_strtod instead of strtod.
@ -31,8 +40,9 @@ Fri Aug 29 21:40:01 2003 Soeren Sandmann <sandmann@daimi.au.dk>
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install "draw_as_radio"
as a separate property, not as an alias of "inconsistent".
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install
"draw_as_radio" as a separate property, not as an alias of
"inconsistent".
(gtk_check_menu_item_get_property):
(gtk_check_menu_item_set_property): Also support "draw_as_radio".
@ -80,13 +90,14 @@ Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
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
* 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

View File

@ -1,5 +1,13 @@
2003-08-30 Matthias Clasen <maclas@gmx.de>
* tests/testmerge.c (add_widget): Connect to "destroy" on toolbar,
rather than to "remove" on handlebox.
* gtk/gtkuimanager.[hc] (gtk_ui_manager_activate): New method to
activate an action found by following a path. (#120658)
* tests/testmerge.c: Add a button to test gtk_ui_manager_activate().
* tests/testmerge.c (add_widget): Put toolbars in handleboxes.
* gtk/gtkuimanager.[hc]: Add a boolean property, "add_tearoffs" with
@ -12,11 +20,12 @@
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full): Actually
group the actions together rather than putting each in its own group.
* gtk/gtkactiongroup.c (gtk_action_group_add_radio_actions_full):
Actually group the actions together rather than putting each in its
own group.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on proxy
menu items for radio actions.
* gtk/gtkradioaction.c (create_menu_item): Set "draw_as_radio" on
proxy menu items for radio actions.
* gtk/gtkgamma.c (gamma_ok_callback): Use g_strtod instead of strtod.
@ -31,8 +40,9 @@ Fri Aug 29 21:40:01 2003 Soeren Sandmann <sandmann@daimi.au.dk>
2003-08-29 Matthias Clasen <maclas@gmx.de>
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install "draw_as_radio"
as a separate property, not as an alias of "inconsistent".
* gtk/gtkcheckmenuitem.c (gtk_check_menu_item_class_init): Install
"draw_as_radio" as a separate property, not as an alias of
"inconsistent".
(gtk_check_menu_item_get_property):
(gtk_check_menu_item_set_property): Also support "draw_as_radio".
@ -80,13 +90,14 @@ Fri Aug 29 20:32:07 2003 Soeren Sandmann <sandmann@daimi.au.dk>
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
* 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

View File

@ -508,6 +508,8 @@ gtk_ui_manager_get_widget (GtkUIManager *self,
{
GNode *node;
g_return_val_if_fail (GTK_IS_UI_MANAGER (self), NULL);
/* ensure that there are no pending updates before we get the
* widget */
gtk_ui_manager_ensure_update (self);
@ -1850,3 +1852,32 @@ 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);
}

View File

@ -110,5 +110,7 @@ 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__ */

View File

@ -111,7 +111,8 @@ add_widget (GtkUIManager *merge,
gtk_widget_show (handle_box);
gtk_container_add (GTK_CONTAINER (handle_box), widget);
gtk_box_pack_start (box, handle_box, FALSE, FALSE, 0);
g_signal_connect (handle_box, "remove", gtk_widget_destroy, 0);
g_signal_connect_swapped (widget, "destroy",
G_CALLBACK (gtk_widget_destroy), handle_box);
}
else
gtk_box_pack_start (box, widget, FALSE, FALSE, 0);
@ -366,20 +367,28 @@ area_press (GtkWidget *drawing_area,
}
static void
activate_path (GtkWidget *button,
GtkUIManager *merge)
{
gtk_ui_manager_activate (merge, "/menubar/HelpMenu/About");
}
int
main (int argc, char **argv)
{
GtkActionGroup *action_group;
GtkUIManager *merge;
GtkWidget *window, *table, *frame, *menu_box, *vbox, *view, *area;
GtkWidget *button;
GtkWidget *window, *table, *frame, *menu_box, *vbox, *view;
GtkWidget *button, *area;
gint i;
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_radio_actions (action_group, radio_entries, n_radio_entries,
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);
@ -438,7 +447,11 @@ main (int argc, char **argv)
g_signal_connect (button, "clicked", G_CALLBACK (toggle_tearoffs), merge);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_mnemonic ("_Dump Tree");
button = gtk_button_new_with_label ("Activate path");
g_signal_connect (button, "clicked", G_CALLBACK (activate_path), merge);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
button = gtk_button_new_with_label ("Dump Tree");
g_signal_connect (button, "clicked", G_CALLBACK (dump_tree), merge);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);