aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/widgets/ephy-editable-toolbar.c38
-rwxr-xr-xlib/widgets/ephy-toolbars-group.c30
-rwxr-xr-xlib/widgets/ephy-toolbars-group.h4
3 files changed, 42 insertions, 30 deletions
diff --git a/lib/widgets/ephy-editable-toolbar.c b/lib/widgets/ephy-editable-toolbar.c
index bb3288805..fd6dd3d4c 100755
--- a/lib/widgets/ephy-editable-toolbar.c
+++ b/lib/widgets/ephy-editable-toolbar.c
@@ -288,6 +288,21 @@ drag_data_get_cb (GtkWidget *widget,
8, target, strlen (target));
}
+static GtkWidget *
+get_item_widget (EphyEditableToolbar *t, gpointer data)
+{
+ GtkWidget *widget;
+ char *path;
+
+ path = ephy_toolbars_group_get_path (t->priv->group, data);
+ g_return_val_if_fail (path != NULL, NULL);
+
+ widget = egg_menu_merge_get_widget (t->priv->merge, path);
+ g_free (path);
+
+ return widget;
+}
+
static void
connect_item_drag_source (EphyToolbarsItem *item, EphyEditableToolbar *etoolbar)
{
@@ -296,7 +311,7 @@ connect_item_drag_source (EphyToolbarsItem *item, EphyEditableToolbar *etoolbar)
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
g_return_if_fail (item != NULL);
- toolitem = item->widget;
+ toolitem = get_item_widget (etoolbar, item);
if (!g_object_get_data (G_OBJECT (toolitem), "drag_source_set"))
{
@@ -320,7 +335,7 @@ disconnect_item_drag_source (EphyToolbarsItem *item, EphyEditableToolbar *etoolb
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
g_return_if_fail (item != NULL);
- toolitem = item->widget;
+ toolitem = get_item_widget (etoolbar, item);
if (g_object_get_data (G_OBJECT (toolitem), "drag_source_set"))
{
@@ -340,22 +355,16 @@ static void
setup_toolbar (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar)
{
GtkWidget *widget;
- char *path;
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (etoolbar));
g_return_if_fail (toolbar != NULL);
- path = ephy_toolbars_group_get_path (etoolbar->priv->group, toolbar);
- g_return_if_fail (path != NULL);
-
- widget = egg_menu_merge_get_widget (etoolbar->priv->merge, path);
+ widget = get_item_widget (etoolbar, toolbar);
g_object_set_data (G_OBJECT (widget), "toolbar_data", toolbar);
- g_return_if_fail (toolbar != NULL);
- toolbar->widget = widget;
if (!g_object_get_data (G_OBJECT (widget), "drag_dest_set"))
{
- LOG ("Setup drag dest for toolbar %s", path)
+ LOG ("Setup drag dest for toolbar %s", toolbar->id)
g_object_set_data (G_OBJECT (widget), "drag_dest_set",
GINT_TO_POINTER (TRUE));
gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL,
@@ -367,8 +376,6 @@ setup_toolbar (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *etoolbar)
}
etoolbar->priv->last_toolbar = widget;
-
- g_free (path);
}
static void
@@ -383,10 +390,7 @@ setup_item (EphyToolbarsItem *item, EphyEditableToolbar *etoolbar)
path = ephy_toolbars_group_get_path (etoolbar->priv->group, item);
g_return_if_fail (path != NULL);
- toolitem = egg_menu_merge_get_widget (etoolbar->priv->merge, path);
- g_return_if_fail (toolitem != NULL);
- item->widget = toolitem;
-
+ toolitem = get_item_widget (etoolbar, item);
g_object_set_data (G_OBJECT (toolitem), "item_data", item);
LOG ("Setup drag dest for toolbar item %s %p", path, toolitem);
@@ -414,7 +418,7 @@ ensure_toolbar_min_size (EphyToolbarsToolbar *toolbar, EphyEditableToolbar *t)
g_return_if_fail (IS_EPHY_EDITABLE_TOOLBAR (t));
g_return_if_fail (toolbar != NULL);
- widget = toolbar->widget;
+ widget = get_item_widget (t, toolbar);
if (EGG_TOOLBAR (widget)->num_children == 0)
{
diff --git a/lib/widgets/ephy-toolbars-group.c b/lib/widgets/ephy-toolbars-group.c
index 98e36feb9..3711efe2d 100755
--- a/lib/widgets/ephy-toolbars-group.c
+++ b/lib/widgets/ephy-toolbars-group.c
@@ -129,9 +129,12 @@ static EphyToolbarsToolbar *
toolbars_toolbar_new (void)
{
EphyToolbarsToolbar *toolbar;
+ static int id = 0;
toolbar = g_new0 (EphyToolbarsToolbar, 1);
- toolbar->widget = NULL;
+ toolbar->id = g_strdup_printf ("Toolbar%d", id);
+
+ id++;
return toolbar;
}
@@ -140,13 +143,16 @@ static EphyToolbarsItem *
toolbars_item_new (const char *action, gboolean separator)
{
EphyToolbarsItem *item;
+ static int id = 0;
g_return_val_if_fail (action != NULL, NULL);
item = g_new0 (EphyToolbarsItem, 1);
item->action = g_strdup (action);
item->separator = separator;
- item->widget = NULL;
+ item->id = g_strdup_printf ("TI%d", id);
+
+ id++;
return item;
}
@@ -156,6 +162,7 @@ free_toolbar_node (EphyToolbarsToolbar *toolbar)
{
g_return_if_fail (toolbar != NULL);
+ g_free (toolbar->id);
g_free (toolbar);
}
@@ -165,6 +172,7 @@ free_item_node (EphyToolbarsItem *item)
g_return_if_fail (item != NULL);
g_free (item->action);
+ g_free (item->id);
g_free (item);
}
@@ -382,16 +390,16 @@ ephy_toolbars_group_to_string (EphyToolbarsGroup *t)
{
g_string_append_printf
(s, "<placeholder name=\"PlaceHolder%d-%d\">"
- "<separator name=\"TS\"/>"
- "</placeholder>\n", i, k);
+ "<separator name=\"%s\"/>"
+ "</placeholder>\n", i, k, item->id);
}
else
{
g_string_append_printf
(s, "<placeholder name=\"PlaceHolder%d-%d\">"
- "<toolitem name=\"TI%s\" verb=\"%s\"/>"
+ "<toolitem name=\"%s\" verb=\"%s\"/>"
"</placeholder>\n",
- i, k, item->action, item->action);
+ i, k, item->id, item->action);
}
i++;
}
@@ -617,27 +625,27 @@ ephy_toolbars_group_get_path (EphyToolbarsGroup *t,
GNode *node;
char *path = NULL;
EphyToolbarsItem *titem;
+ EphyToolbarsToolbar *toolbar;
g_return_val_if_fail (IS_EPHY_TOOLBARS_GROUP (t), NULL);
node = g_node_find (t->priv->toolbars, G_IN_ORDER, G_TRAVERSE_ALL, item);
g_return_val_if_fail (node != NULL, NULL);
titem = (EphyToolbarsItem *)node->data;
+ toolbar = (EphyToolbarsToolbar *)node->data;
switch (g_node_depth (node))
{
case 2:
- path = g_strdup_printf ("/Toolbar%d",
- g_node_child_position (node->parent, node));
+ path = g_strdup_printf ("/%s", toolbar->id);
break;
case 3:
path = g_strdup_printf
- ("/Toolbar%d/PlaceHolder%d-%d/%s%s",
+ ("/Toolbar%d/PlaceHolder%d-%d/%s",
g_node_child_position (node->parent->parent, node->parent),
g_node_child_position (node->parent, node),
g_node_child_position (node->parent->parent, node->parent),
- titem->separator ? "TS" : "TI",
- titem->separator ? "" : titem->action);
+ titem->id);
break;
default:
g_assert_not_reached ();
diff --git a/lib/widgets/ephy-toolbars-group.h b/lib/widgets/ephy-toolbars-group.h
index d44a5c44c..8be71cb23 100755
--- a/lib/widgets/ephy-toolbars-group.h
+++ b/lib/widgets/ephy-toolbars-group.h
@@ -39,14 +39,14 @@ typedef struct EphyToolbarsGroupPrivate EphyToolbarsGroupPrivate;
typedef struct
{
- GtkWidget *widget;
+ char *id;
} EphyToolbarsToolbar;
typedef struct
{
+ char *id;
gboolean separator;
char *action;
- GtkWidget *widget;
EphyToolbarsToolbar *parent;
} EphyToolbarsItem;