Commit c00489f8 authored by Juan Pablo Ugarte's avatar Juan Pablo Ugarte

added packing actions to glade_popup_action_populate_menu()

* gladeui/glade-popup.c: added packing actions to glade_popup_action_populate_menu()

* gladeui/glade-widget-action.c: fixed a couple of typos in glade_widget_action_constructor()

* gladeui/glade-widget-adaptor.[ch]:

  - Added packing actions, just like properties the action tag should be inside an actions or
    packing-actions tag, also you can put an action tag inside other action tag :p

  - added GladeChildActionActivatedFunc child_action_activate to GladeWidgetAdaptorClass

  - added packing_actions list to GladeWidgetAdaptor

  - added new functions:
    glade_widget_adaptor_pack_action_add(), glade_widget_adaptor_pack_action_remove()
    and glade_widget_adaptor_child_action_activate()

* gladeui/glade-widget.[ch]:

  - added packing_actions list to GladeWidget

  - set packing actions in glade_widget_set_parent()

  - added glade_widget_get_pack_action() and glade_widget_remove_pack_action()

* gladeui/glade-xml-utils.h:

  - new tags GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION, GLADE_TAG_ACTIONS 
    and GLADE_TAG_PACKING_ACTIONS.

  - removed unused tag GLADE_TAG_ACTION_GROUP

* plugins/gtk+/gtk+.xml.in: Added a couple of child packing actions (fixes #438881)

  - GtkBox:  insert_before and insert_after

  - GtkTable: insert_row/after, insert_row/before, insert_column/after and insert_column/before

* plugins/gtk+/glade-gtk.c: added child-action-activate-function functions
  glade_gtk_box_child_action_activate () and glade_gtk_table_child_action_activate()

svn path=/trunk/; revision=1330
parent 7db080a1
2007-05-31 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* gladeui/glade-popup.c: added packing actions to glade_popup_action_populate_menu()
* gladeui/glade-widget-action.c: fixed a couple of typos in glade_widget_action_constructor()
* gladeui/glade-widget-adaptor.[ch]:
- Added packing actions, just like properties the action tag should be inside an actions or
packing-actions tag, also you can put an action tag inside other action tag :p
- added GladeChildActionActivatedFunc child_action_activate to GladeWidgetAdaptorClass
- added packing_actions list to GladeWidgetAdaptor
- added new functions:
glade_widget_adaptor_pack_action_add(), glade_widget_adaptor_pack_action_remove()
and glade_widget_adaptor_child_action_activate()
* gladeui/glade-widget.[ch]:
- added packing_actions list to GladeWidget
- set packing actions in glade_widget_set_parent()
- added glade_widget_get_pack_action() and glade_widget_remove_pack_action()
* gladeui/glade-xml-utils.h:
- new tags GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION, GLADE_TAG_ACTIONS
and GLADE_TAG_PACKING_ACTIONS.
- removed unused tag GLADE_TAG_ACTION_GROUP
* plugins/gtk+/gtk+.xml.in: Added a couple of child packing actions (fixes #438881)
- GtkBox: insert_before and insert_after
- GtkTable: insert_row/after, insert_row/before, insert_column/after and insert_column/before
* plugins/gtk+/glade-gtk.c: added child-action-activate-function functions
glade_gtk_box_child_action_activate () and glade_gtk_table_child_action_activate()
2007-05-24 Juan Pablo Ugarte <juanpablougarte@gmail.com>
* gladeui/glade-widget-action.[ch]:
......
......@@ -186,16 +186,29 @@ glade_popup_menuitem_activated (GtkMenuItem *item, const gchar *action_path)
action_path);
}
static void
glade_popup_menuitem_packing_activated (GtkMenuItem *item, const gchar *action_path)
{
GladeWidget *widget;
if ((widget = g_object_get_data (G_OBJECT (item), "glade-widget")))
glade_widget_adaptor_child_action_activate (widget->parent->adaptor,
widget->parent->object,
widget->object,
action_path);
}
static gint
glade_popup_action_populate_menu_real (GtkWidget *menu,
GladeWidget *widget,
GladeWidgetAction *action)
GladeWidgetAction *action,
gboolean packing)
{
GtkWidget *item;
GList *list;
gint n = 0;
for (list = (action) ? action->actions : widget->actions;
for (list = (action) ? action->actions : (packing) ? widget->packing_actions : widget->actions;
list;
list = g_list_next (list))
{
......@@ -205,13 +218,15 @@ glade_popup_action_populate_menu_real (GtkWidget *menu,
if (a->actions)
{
submenu = gtk_menu_new ();
n += glade_popup_action_populate_menu (submenu, widget, a);
n += glade_popup_action_populate_menu_real (submenu, widget, a, packing);
}
item = glade_popup_append_item (menu,
a->klass->stock,
a->klass->label, TRUE,
(a->actions) ? NULL : glade_popup_menuitem_activated,
(a->actions) ? NULL : (packing)
? glade_popup_menuitem_packing_activated
: glade_popup_menuitem_activated,
(a->actions) ? NULL : a->klass->path);
g_object_set_data (G_OBJECT (item), "glade-widget", widget);
......@@ -241,16 +256,37 @@ glade_popup_action_populate_menu (GtkWidget *menu,
GladeWidget *widget,
GladeWidgetAction *action)
{
gint n;
g_return_val_if_fail (GTK_IS_MENU (menu), 0);
g_return_val_if_fail (GLADE_IS_WIDGET (widget), 0);
if (action)
{
g_return_val_if_fail (GLADE_IS_WIDGET_ACTION (action), 0);
if (action != glade_widget_get_action (widget, action->klass->path))
return 0;
if (glade_widget_get_action (widget, action->klass->path))
return glade_popup_action_populate_menu_real (menu, widget, action, FALSE);
if (glade_widget_get_pack_action (widget, action->klass->path))
return glade_popup_action_populate_menu_real (menu, widget, action, TRUE);
return 0;
}
return glade_popup_action_populate_menu_real (menu, widget, action);
n = glade_popup_action_populate_menu_real (menu, widget, action, FALSE);
if (widget->packing_actions)
{
if (n)
{
GtkWidget *separator = gtk_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (menu), separator);
gtk_widget_show (separator);
}
n += glade_popup_action_populate_menu_real (menu, widget, action, TRUE);
}
return n;
}
static GtkWidget *
......@@ -275,7 +311,7 @@ glade_popup_create_menu (GladeWidget *widget)
glade_popup_append_item (popup_menu, GTK_STOCK_DELETE, NULL, TRUE,
glade_popup_delete_cb, widget);
if (widget->actions)
if (widget->actions || widget->packing_actions)
{
GtkWidget *separator = gtk_menu_item_new ();
gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator);
......
......@@ -71,7 +71,7 @@ glade_widget_action_constructor(GType type,
if (action->klass == NULL)
{
g_warning ("GLadeWidgetAction constructed without klass properties");
g_warning ("GladeWidgetAction constructed without class property");
return object;
}
......@@ -79,7 +79,7 @@ glade_widget_action_constructor(GType type,
{
GWActionClass *action_class = l->data;
GObject *obj = g_object_new (GLADE_TYPE_WIDGET_ACTION,
"klass", action_class,
"class", action_class,
NULL);
action->actions = g_list_prepend (action->actions,
......
......@@ -523,17 +523,30 @@ glade_widget_adaptor_constructor (GType type,
g_strdup (parent_adaptor->priv->special_child_type) : NULL;
/* Copy parent actions */
if (parent_adaptor && parent_adaptor->actions)
if (parent_adaptor)
{
GList *l;
for (l = parent_adaptor->actions; l; l = g_list_next (l))
if (parent_adaptor->actions)
{
GWActionClass *child = glade_widget_action_class_clone (l->data);
adaptor->actions = g_list_append (adaptor->actions, child);
for (l = parent_adaptor->actions; l; l = g_list_next (l))
{
GWActionClass *child = glade_widget_action_class_clone (l->data);
adaptor->actions = g_list_prepend (adaptor->actions, child);
}
adaptor->actions = g_list_reverse (adaptor->actions);
}
if (parent_adaptor->packing_actions)
{
for (l = parent_adaptor->packing_actions; l; l = g_list_next (l))
{
GWActionClass *child = glade_widget_action_class_clone (l->data);
adaptor->packing_actions = g_list_prepend (adaptor->packing_actions, child);
}
adaptor->packing_actions = g_list_reverse (adaptor->packing_actions);
}
}
else
adaptor->actions = NULL;
return ret_obj;
}
......@@ -591,9 +604,20 @@ glade_widget_adaptor_finalize (GObject *object)
if (adaptor->icon_name) g_free (adaptor->icon_name);
if (adaptor->actions)
{
g_list_foreach (adaptor->actions,
(GFunc) glade_widget_action_class_free,
NULL);
g_list_free (adaptor->actions);
}
if (adaptor->packing_actions)
{
g_list_foreach (adaptor->packing_actions,
(GFunc) glade_widget_action_class_free,
NULL);
g_list_free (adaptor->packing_actions);
}
g_free (adaptor->priv);
......@@ -709,6 +733,16 @@ glade_widget_adaptor_object_action_activate (GladeWidgetAdaptor *adaptor,
adaptor->name, action_id);
}
static void
glade_widget_adaptor_object_child_action_activate (GladeWidgetAdaptor *adaptor,
GObject *container,
GObject *object,
const gchar *action_id)
{
g_message ("No child_action_activate() support in adaptor %s for action '%s'",
adaptor->name, action_id);
}
/*******************************************************************************
GladeWidgetAdaptor type registration and class initializer
*******************************************************************************/
......@@ -746,6 +780,7 @@ glade_widget_adaptor_class_init (GladeWidgetAdaptorClass *adaptor_class)
adaptor_class->child_set_property = NULL;
adaptor_class->child_get_property = NULL;
adaptor_class->action_activate = glade_widget_adaptor_object_action_activate;
adaptor_class->child_action_activate= glade_widget_adaptor_object_child_action_activate;
/* Base defaults here */
adaptor_class->fixed = FALSE;
......@@ -899,7 +934,6 @@ gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass *klass,
GladeXmlNode *node,
GModule *module)
{
GladeWidgetAdaptorClass *parent_class = g_type_class_peek_parent (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
gpointer symbol;
......@@ -913,9 +947,6 @@ gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass *klass,
GLADE_TAG_CONSTRUCTOR_FUNCTION,
&symbol))
object_class->constructor = symbol;
else
/* Chain up with parent, this way GWA_GET_OCLASS can work */
object_class->constructor = ((GObjectClass*)parent_class)->constructor;
if (glade_xml_load_sym_from_node (node, module,
GLADE_TAG_POST_CREATE_FUNCTION,
......@@ -981,9 +1012,11 @@ gwa_extend_with_node_load_sym (GladeWidgetAdaptorClass *klass,
GLADE_TAG_ACTION_ACTIVATE_FUNCTION,
&symbol))
klass->action_activate = symbol;
else
/* Chain up with parent */
klass->action_activate = parent_class->action_activate;
if (glade_xml_load_sym_from_node (node, module,
GLADE_TAG_CHILD_ACTION_ACTIVATE_FUNCTION,
&symbol))
klass->child_action_activate = symbol;
}
static void
......@@ -1285,6 +1318,7 @@ gwa_update_properties_from_node (GladeWidgetAdaptor *adaptor,
static void
gwa_action_update_from_node (GladeWidgetAdaptor *adaptor,
gboolean is_packing,
GladeXmlNode *node,
gchar *group_path)
{
......@@ -1295,8 +1329,7 @@ gwa_action_update_from_node (GladeWidgetAdaptor *adaptor,
for (child = glade_xml_node_get_children (node);
child; child = glade_xml_node_next (child))
{
if ((group = glade_xml_node_verify_silent (child, GLADE_TAG_ACTION_GROUP)) == FALSE &&
glade_xml_node_verify_silent (child, GLADE_TAG_ACTION) == FALSE)
if ((group = glade_xml_node_verify_silent (child, GLADE_TAG_ACTION)) == FALSE)
continue;
id = glade_xml_get_property_string_required
......@@ -1312,9 +1345,12 @@ gwa_action_update_from_node (GladeWidgetAdaptor *adaptor,
label = glade_xml_get_property_string (child, GLADE_TAG_NAME);
stock = glade_xml_get_property_string (child, GLADE_TAG_STOCK);
glade_widget_adaptor_action_add (adaptor, action_path, label, stock);
if (is_packing)
glade_widget_adaptor_pack_action_add (adaptor, action_path, label, stock);
else
glade_widget_adaptor_action_add (adaptor, action_path, label, stock);
if (group) gwa_action_update_from_node (adaptor, child, action_path);
if (group) gwa_action_update_from_node (adaptor, is_packing, child, action_path);
g_free (id);
g_free (label);
......@@ -1355,8 +1391,15 @@ gwa_extend_with_node (GladeWidgetAdaptor *adaptor,
glade_xml_search_child (node, GLADE_TAG_PACKING_DEFAULTS)) != NULL)
gwa_set_packing_defaults_from_node (adaptor, child);
/* Update actions from node */
gwa_action_update_from_node (adaptor, node, NULL);
/* Update actions from child node */
if ((child =
glade_xml_search_child (node, GLADE_TAG_ACTIONS)) != NULL)
gwa_action_update_from_node (adaptor, FALSE, child, NULL);
/* Update packing actions from child node */
if ((child =
glade_xml_search_child (node, GLADE_TAG_PACKING_ACTIONS)) != NULL)
gwa_action_update_from_node (adaptor, TRUE, child, NULL);
return TRUE;
}
......@@ -2361,59 +2404,39 @@ gwa_action_lookup (GList *actions, const gchar *action_id)
}
static GWActionClass *
gwa_action_get_last_group (GladeWidgetAdaptor *adaptor,
const gchar *action_path)
gwa_action_get_last_group (GList *actions, const gchar *action_path)
{
gchar **tokens = g_strsplit (action_path, "/", 0);
GList *list = adaptor->actions;
GWActionClass *group = NULL;
gint i;
for (i = 0; tokens[i] && tokens[i+1]; i++)
{
if ((group = gwa_action_lookup (list, tokens[i])) == NULL)
if ((group = gwa_action_lookup (actions, tokens[i])) == NULL)
{
g_strfreev (tokens);
return NULL;
}
list = group->actions;
actions = group->actions;
}
g_strfreev (tokens);
return group;
}
/**
* glade_widget_adaptor_action_add:
* @adaptor: A #GladeWidgetAdaptor
* @action_path: The identifier of this action in the action tree
* @label: A translated label to show in the UI for this action
* @stock: If set, this stock item will be shown in the UI along side the label.
*
* Add an action to @adaptor.
* If the action is present then it overrides label and stock
*
* Returns: whether or not the action was added/updated.
*/
gboolean
glade_widget_adaptor_action_add (GladeWidgetAdaptor *adaptor,
const gchar *action_path,
const gchar *label,
const gchar *stock)
static gboolean
glade_widget_adaptor_action_add_real (GList **list,
const gchar *action_path,
const gchar *label,
const gchar *stock)
{
GWActionClass *action, *group;
const gchar *id;
GList **list;
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
g_return_val_if_fail (action_path != NULL, FALSE);
id = gwa_action_path_get_id (action_path);
if ((group = gwa_action_get_last_group (adaptor, action_path)))
if ((group = gwa_action_get_last_group (*list, action_path)))
list = &group->actions;
else
list = &adaptor->actions;
if ((action = gwa_action_lookup (*list, id)))
{
......@@ -2430,37 +2453,75 @@ glade_widget_adaptor_action_add (GladeWidgetAdaptor *adaptor,
action->label = (label) ? g_strdup (label) : NULL;
action->stock = (stock) ? g_strdup (stock) : NULL;
*list = g_list_prepend (*list, action);
*list = g_list_append (*list, action);
return TRUE;
}
/**
* glade_widget_adaptor_action_remove:
* glade_widget_adaptor_action_add:
* @adaptor: A #GladeWidgetAdaptor
* @action_path: The identifier of this action in the action tree
* @label: A translated label to show in the UI for this action
* @stock: If set, this stock item will be shown in the UI along side the label.
*
* Remove an @adaptor's action.
* Add an action to @adaptor.
* If the action is present then it overrides label and stock
*
* Returns: whether or not the action was removed.
* Returns: whether or not the action was added/updated.
*/
gboolean
glade_widget_adaptor_action_remove (GladeWidgetAdaptor *adaptor,
const gchar *action_path)
glade_widget_adaptor_action_add (GladeWidgetAdaptor *adaptor,
const gchar *action_path,
const gchar *label,
const gchar *stock)
{
GWActionClass *action, *group;
const gchar *id;
GList **list;
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
g_return_val_if_fail (action_path != NULL, FALSE);
return glade_widget_adaptor_action_add_real (&adaptor->actions,
action_path,
label,
stock);
}
/**
* glade_widget_adaptor_pack_action_add:
* @adaptor: A #GladeWidgetAdaptor
* @action_path: The identifier of this action in the action tree
* @label: A translated label to show in the UI for this action
* @stock: If set, this stock item will be shown in the UI along side the label.
*
* Add a packing action to @adaptor.
* If the action is present then it overrides label and stock
*
* Returns: whether or not the action was added/updated.
*/
gboolean
glade_widget_adaptor_pack_action_add (GladeWidgetAdaptor *adaptor,
const gchar *action_path,
const gchar *label,
const gchar *stock)
{
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
g_return_val_if_fail (action_path != NULL, FALSE);
return glade_widget_adaptor_action_add_real (&adaptor->packing_actions,
action_path,
label,
stock);
}
static gboolean
glade_widget_adaptor_action_remove_real (GList **list, const gchar *action_path)
{
GWActionClass *action, *group;
const gchar *id;
id = gwa_action_path_get_id (action_path);
if ((group = gwa_action_get_last_group (adaptor, action_path)))
if ((group = gwa_action_get_last_group (*list, action_path)))
list = &group->actions;
else
list = &adaptor->actions;
if ((action = gwa_action_lookup (*list, id)) == NULL) return FALSE;
......@@ -2471,6 +2532,46 @@ glade_widget_adaptor_action_remove (GladeWidgetAdaptor *adaptor,
return TRUE;
}
/**
* glade_widget_adaptor_action_remove:
* @adaptor: A #GladeWidgetAdaptor
* @action_path: The identifier of this action in the action tree
*
* Remove an @adaptor's action.
*
* Returns: whether or not the action was removed.
*/
gboolean
glade_widget_adaptor_action_remove (GladeWidgetAdaptor *adaptor,
const gchar *action_path)
{
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
g_return_val_if_fail (action_path != NULL, FALSE);
return glade_widget_adaptor_action_remove_real (&adaptor->actions,
action_path);
}
/**
* glade_widget_adaptor_pack_action_remove:
* @adaptor: A #GladeWidgetAdaptor
* @action_path: The identifier of this action in the action tree
*
* Remove an @adaptor's packing action.
*
* Returns: whether or not the action was removed.
*/
gboolean
glade_widget_adaptor_pack_action_remove (GladeWidgetAdaptor *adaptor,
const gchar *action_path)
{
g_return_val_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor), FALSE);
g_return_val_if_fail (action_path != NULL, FALSE);
return glade_widget_adaptor_action_remove_real (&adaptor->packing_actions,
action_path);
}
/**
* glade_widget_adaptor_action_activate:
* @adaptor: A #GladeWidgetAdaptor
......@@ -2488,6 +2589,27 @@ glade_widget_adaptor_action_activate (GladeWidgetAdaptor *adaptor,
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (object), adaptor->type));
if (GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_activate)
GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_activate (adaptor, object, action_path);
GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->action_activate (adaptor, object, action_path);
}
/**
* glade_widget_adaptor_child_action_activate:
* @adaptor: A #GladeWidgetAdaptor
* @object: The #GObject
* @action_path: The action identifier in the action tree
*
* An adaptor function to be called on widget actions.
*/
void
glade_widget_adaptor_child_action_activate (GladeWidgetAdaptor *adaptor,
GObject *container,
GObject *object,
const gchar *action_path)
{
g_return_if_fail (GLADE_IS_WIDGET_ADAPTOR (adaptor));
g_return_if_fail (G_IS_OBJECT (container));
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (g_type_is_a (G_OBJECT_TYPE (container), adaptor->type));
GLADE_WIDGET_ADAPTOR_GET_CLASS (adaptor)->child_action_activate (adaptor, container, object, action_path);
}
......@@ -313,14 +313,29 @@ typedef GObject *(* GladeGetInternalFunc) (GladeWidgetAdaptor *adaptor,
* GladeActionActivatedFunc:
* @adaptor: A #GladeWidgetAdaptor
* @object: The #GObject
* @action_id: The action identifier
* @action_path: The action path
*
* This delagate function is used to catch actions from the core.
*
*/
typedef void (* GladeActionActivateFunc) (GladeWidgetAdaptor *adaptor,
GObject *object,
const gchar *action_id);
const gchar *action_path);
/**
* GladeChildActionActivatedFunc:
* @adaptor: A #GladeWidgetAdaptor
* @container: The #GtkContainer
* @object: The #GObject
* @action_path: The action path
*
* This delagate function is used to catch packing actions from the core.
*
*/
typedef void (* GladeChildActionActivateFunc) (GladeWidgetAdaptor *adaptor,
GObject *container,
GObject *object,
const gchar *action_path);
/* GladeSignalClass contains all the info we need for a given signal, such as
* the signal name, and maybe more in the future
......@@ -378,6 +393,8 @@ struct _GladeWidgetAdaptor
GList *child_packings; /* Default packing property values */
GList *actions; /* A list of GWActionClass */
GList *packing_actions;/* A list of GWActionClass for child objects */
GladeWidgetAdaptorPrivate *priv;
......@@ -451,7 +468,8 @@ struct _GladeWidgetAdaptorClass
* a widget and viceversa.
*/
GladeActionActivateFunc action_activate; /* This method is used to catch actions */
GladeActionActivateFunc action_activate; /* This method is used to catch actions */
GladeChildActionActivateFunc child_action_activate; /* This method is used to catch packing actions */
};
#define glade_widget_adaptor_create_widget(adaptor, query, ...) \
......@@ -579,12 +597,25 @@ gboolean glade_widget_adaptor_action_add (GladeWidgetAdaptor
const gchar *label,
const gchar *stock);
gboolean glade_widget_adaptor_pack_action_add (GladeWidgetAdaptor *adaptor,
const gchar *action_path,
const gchar *label,
const gchar *stock);
gboolean glade_widget_adaptor_action_remove (GladeWidgetAdaptor *adaptor,
const gchar *action_path);
gboolean glade_widget_adaptor_pack_action_remove (GladeWidgetAdaptor *adaptor,
const gchar *action_path);
void glade_widget_adaptor_action_activate (GladeWidgetAdaptor *adaptor,
GObject *object,
const gchar *action_path);
void glade_widget_adaptor_child_action_activate (GladeWidgetAdaptor *adaptor,
GObject *container,
GObject *object,
const gchar *action_path);
G_END_DECLS
#endif /* __GLADE_WIDGET_ADAPTOR_H__ */
......@@ -109,6 +109,30 @@ static GQuark glade_widget_name_quark = 0;
/*******************************************************************************
GladeWidget class methods
*******************************************************************************/
static void
glade_widget_set_packing_actions (GladeWidget *widget, GladeWidget *parent)
{
GList *l;
if (widget->packing_actions)
{
g_list_foreach (widget->packing_actions, (GFunc)g_object_unref, NULL);
g_list_free (widget->packing_actions);
widget->packing_actions = NULL;
}
for (l = parent->adaptor->packing_actions; l; l = g_list_next (l))
{
GWActionClass *action = l->data;
GObject *obj = g_object_new (GLADE_TYPE_WIDGET_ACTION,
"class", action, NULL);
widget->packing_actions = g_list_prepend (widget->packing_actions,
GLADE_WIDGET_ACTION (obj));
}
widget->packing_actions = g_list_reverse (widget->packing_actions);
}
static void
glade_widget_add_child_impl (GladeWidget *widget,
GladeWidget *child,
......@@ -124,6 +148,7 @@ glade_widget_add_child_impl (GladeWidget *widget,
(widget->adaptor, widget->object, child->object);
glade_widget_set_packing_properties (child, widget);
glade_widget_set_packing_actions (child, widget);
}
static void
......@@ -153,8 +178,11 @@ glade_widget_replace_child_impl (GladeWidget *widget,
/* Setup packing properties here so we can introspect the new
* values from the backend.
*/
if (gnew_widget)
if (gnew_widget)
{
glade_widget_set_packing_properties (gnew_widget, widget);
glade_widget_set_packing_actions (gnew_widget, widget);
}
}
static void
......@@ -760,7 +788,13 @@ glade_widget_dispose (GObject *object)
g_list_foreach (widget->actions, (GFunc)g_object_unref, NULL);
g_list_free (widget->actions);
}
if (widget->packing_actions)
{
g_list_foreach (widget->packing_actions, (GFunc)g_object_unref, NULL);
g_list_free (widget->packing_actions);
}
if (G_OBJECT_CLASS(parent_class)->dispose)
G_OBJECT_CLASS(parent_class)->dispose(object);
}
......@@ -3343,6 +3377,8 @@ glade_widget_set_parent (GladeWidget *widget,
else
glade_widget_sync_packing_props (widget);
}
if (parent) glade_widget_set_packing_actions (widget, parent);
g_object_notify (G_OBJECT (widget), "parent");
}
......@@ -3861,6 +3897,24 @@ glade_widget_get_action (GladeWidget *widget, const gchar *action_path)
return glade_widget_action_lookup (&widget->actions, action_path, FALSE);
}
/**
* glade_widget_get_pack_action:
* @widget: a #GladeWidget
* @action_path: a full action path including groups
*
* Returns a #GladeWidgetAction object indentified by @action_path.
*
* Returns: the action or NULL if not found.
*/
GladeWidgetAction *
glade_widget_get_pack_action (GladeWidget *widget, const gchar *action_path)
{
g_return_val_if_fail (GLADE_IS_WIDGET (widget), NULL);
g_return_val_if_fail (action_path != NULL, NULL);
return glade_widget_action_lookup (&widget->packing_actions, action_path, FALSE);
}
/**
* glade_widget_remove_action:
* @widget: a #GladeWidget
......@@ -3877,6 +3931,22 @@ glade_widget_remove_action (GladeWidget *widget, const gchar *action_path)
glade_widget_action_lookup (&widget->actions, action_path, TRUE);
}
/**
* glade_widget_remove_pack_action:
* @widget: a #GladeWidget
* @action_path: a full action path including groups
*