summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-06-09 19:56:48 +0000
committerChristian Persch <chpe@src.gnome.org>2004-06-09 19:56:48 +0000
commit589ca9edd2f003a239ddd5218bd5260e53fb7ddc (patch)
treea16216eb3847d919ebd64a05b1b2cd1185e4447a
parentb65b133d47d7dfd8690cbeb50ab1df089bc7d824 (diff)
downloadepiphany-bookmarks-toolbars-changes.tar.gz
2004-06-09 Christian Persch <chpe@cvs.gnome.org>bookmarks-toolbars-changes
* lib/egg/egg-editable-toolbar.c: (drag_data_get_cb), (set_item_drag_source), (create_item_from_action), (create_item), (drag_data_received_cb), (egg_editable_toolbar_set_edit_mode): * lib/egg/egg-toolbar-editor.c: (model_has_action): * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_to_xml), (toolbars_item_new), (free_item_node), (egg_toolbars_model_add_separator), (impl_add_item), (parse_item_list), (egg_toolbars_model_load), (impl_get_item_name), (egg_toolbars_model_class_init), (egg_toolbars_model_init), (egg_toolbars_model_item_nth), (egg_toolbars_model_get_item_id), (egg_toolbars_model_get_item_name): * lib/egg/egg-toolbars-model.h: * src/bookmarks/ephy-bookmarksbar-model.c: (get_toolbar_and_item_pos), (item_added_cb), (impl_get_item_name), (ephy_bookmarksbar_model_class_init): * src/toolbar.c: (toolbar_get_type), (toolbar_added_cb), (ephy_toolbar_realize), (ephy_toolbar_unrealize), (toolbar_class_init):
-rw-r--r--ChangeLog23
-rwxr-xr-xlib/egg/egg-editable-toolbar.c82
-rwxr-xr-xlib/egg/egg-toolbar-editor.c13
-rwxr-xr-xlib/egg/egg-toolbars-model.c68
-rwxr-xr-xlib/egg/egg-toolbars-model.h14
-rwxr-xr-xsrc/toolbar.c87
6 files changed, 209 insertions, 78 deletions
diff --git a/ChangeLog b/ChangeLog
index a47faf62e..832540f48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2004-06-09 Christian Persch <chpe@cvs.gnome.org>
+
+ * lib/egg/egg-editable-toolbar.c: (drag_data_get_cb),
+ (set_item_drag_source), (create_item_from_action), (create_item),
+ (drag_data_received_cb), (egg_editable_toolbar_set_edit_mode):
+ * lib/egg/egg-toolbar-editor.c: (model_has_action):
+ * lib/egg/egg-toolbars-model.c: (egg_toolbars_model_to_xml),
+ (toolbars_item_new), (free_item_node),
+ (egg_toolbars_model_add_separator), (impl_add_item),
+ (parse_item_list), (egg_toolbars_model_load), (impl_get_item_name),
+ (egg_toolbars_model_class_init), (egg_toolbars_model_init),
+ (egg_toolbars_model_item_nth), (egg_toolbars_model_get_item_id),
+ (egg_toolbars_model_get_item_name):
+ * lib/egg/egg-toolbars-model.h:
+ * src/bookmarks/ephy-bookmarksbar-model.c:
+ (get_toolbar_and_item_pos), (item_added_cb), (impl_get_item_name),
+ (ephy_bookmarksbar_model_class_init):
+ * src/toolbar.c: (toolbar_get_type), (toolbar_added_cb),
+ (ephy_toolbar_realize), (ephy_toolbar_unrealize),
+ (toolbar_class_init):
+
+ Merge toolbar changes from HEAD, and fix bookmarksmodel accordingly.
+
2004-06-08 Christian Persch <chpe@cvs.gnome.org>
* data/ui/epiphany-bookmarksbar.xml:
diff --git a/lib/egg/egg-editable-toolbar.c b/lib/egg/egg-editable-toolbar.c
index 563106d3a..71b3992a3 100755
--- a/lib/egg/egg-editable-toolbar.c
+++ b/lib/egg/egg-editable-toolbar.c
@@ -239,6 +239,8 @@ drag_data_get_cb (GtkWidget *widget,
target = g_object_get_data (G_OBJECT (widget), "name");
+ g_return_if_fail (target != NULL);
+
gtk_selection_data_set (selection_data,
selection_data->target, 8, target, strlen (target));
}
@@ -270,13 +272,14 @@ unset_drag_cursor (GtkWidget *widget)
}
static void
-set_item_drag_source (GtkWidget *item,
- GtkAction *action,
- gboolean is_separator,
- const char *type,
- const char *name)
+set_item_drag_source (EggToolbarsModel *model,
+ GtkWidget *item,
+ GtkAction *action,
+ gboolean is_separator,
+ const char *type)
{
GtkTargetEntry target_entry;
+ char *name;
target_entry.target = (char *)type;
target_entry.flags = GTK_TARGET_SAME_APP;
@@ -286,24 +289,27 @@ set_item_drag_source (GtkWidget *item,
&target_entry, 1,
GDK_ACTION_MOVE);
- g_object_set_data_full (G_OBJECT (item), "name",
- g_strdup (name), g_free);
-
if (is_separator)
{
GtkWidget *icon;
GdkPixbuf *pixbuf;
+ name = g_strdup ("separator");
+
icon = _egg_editable_toolbar_new_separator_image ();
pixbuf = gtk_image_get_pixbuf (GTK_IMAGE (icon));
gtk_drag_source_set_icon_pixbuf (item, pixbuf);
}
else
{
+ const char *action_name;
const char *stock_id;
GValue value = { 0, };
GdkPixbuf *pixbuf;
+ action_name = gtk_action_get_name (action);
+ name = egg_toolbars_model_get_item_name (model, type, action_name);
+
g_value_init (&value, G_TYPE_STRING);
g_object_get_property (G_OBJECT (action), "stock_id", &value);
stock_id = g_value_get_string (&value);
@@ -324,14 +330,17 @@ set_item_drag_source (GtkWidget *item,
g_value_unset (&value);
}
+
+ g_object_set_data_full (G_OBJECT (item), "name",
+ name, g_free);
}
static GtkWidget *
-create_item_from_name (EggEditableToolbar *t,
- const char *type,
- const char *name,
- gboolean is_separator,
- GtkAction **ret_action)
+create_item_from_action (EggEditableToolbar *t,
+ const char *action_name,
+ const char *type,
+ gboolean is_separator,
+ GtkAction **ret_action)
{
GtkWidget *item;
GtkAction *action;
@@ -343,11 +352,6 @@ create_item_from_name (EggEditableToolbar *t,
}
else
{
- EggToolbarsModel *model = t->priv->model;
- char *action_name;
-
- action_name = egg_toolbars_model_get_item_id (model, type, name);
-
g_signal_emit (G_OBJECT (t), egg_editable_toolbar_signals[ACTION_REQUEST],
0, action_name);
@@ -359,9 +363,7 @@ create_item_from_name (EggEditableToolbar *t,
else
{
return NULL;
- }
-
- g_free (action_name);
+ }
}
gtk_widget_show (item);
@@ -379,7 +381,8 @@ create_item_from_name (EggEditableToolbar *t,
{
set_drag_cursor (item);
gtk_widget_set_sensitive (item, TRUE);
- set_item_drag_source (item, action, is_separator, type, name);
+ set_item_drag_source (t->priv->model, item, action,
+ is_separator, type);
gtk_tool_item_set_use_drag_window (GTK_TOOL_ITEM (item), TRUE);
}
@@ -398,12 +401,13 @@ create_item (EggEditableToolbar *t,
int position,
GtkAction **ret_action)
{
- const char *name, *type;
+ const char *action_name, *type;
gboolean is_separator;
egg_toolbars_model_item_nth (model, toolbar_position, position,
- &is_separator, &type, &name);
- return create_item_from_name (t, type, name, is_separator, ret_action);
+ &is_separator, &action_name, &type);
+ return create_item_from_action (t, action_name, type,
+ is_separator, ret_action);
}
static gboolean
@@ -423,12 +427,13 @@ drag_data_received_cb (GtkWidget *widget,
EggEditableToolbar *etoolbar)
{
char *type;
- const char *name = selection_data->data;
+ char *id;
GdkAtom target;
target = gtk_drag_dest_find_target (widget, context, NULL);
type = egg_toolbars_model_get_item_type (etoolbar->priv->model, target);
+ id = egg_toolbars_model_get_item_id (etoolbar->priv->model, type, selection_data->data);
/* This function can be called for two reasons
*
@@ -441,7 +446,7 @@ drag_data_received_cb (GtkWidget *widget,
* actually add a new item to the toolbar.
*/
- if (name == NULL)
+ if (id == NULL)
{
etoolbar->priv->pending = FALSE;
g_free (type);
@@ -452,8 +457,8 @@ drag_data_received_cb (GtkWidget *widget,
{
etoolbar->priv->pending = FALSE;
etoolbar->priv->dragged_item =
- create_item_from_name (etoolbar, type, selection_data->data,
- data_is_separator (name), NULL);
+ create_item_from_action (etoolbar, id, type,
+ data_is_separator (id), NULL);
g_object_ref (etoolbar->priv->dragged_item);
gtk_object_sink (GTK_OBJECT (etoolbar->priv->dragged_item));
}
@@ -472,7 +477,7 @@ drag_data_received_cb (GtkWidget *widget,
else
{
egg_toolbars_model_add_item (etoolbar->priv->model,
- toolbar_pos, pos, name, type);
+ toolbar_pos, pos, id, type);
}
gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE,
@@ -480,6 +485,7 @@ drag_data_received_cb (GtkWidget *widget,
}
g_free (type);
+ g_free (id);
}
static void
@@ -1144,7 +1150,6 @@ egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
gboolean mode)
{
int i, l, n_toolbars, n_items;
- EggToolbarsModel *model = etoolbar->priv->model;
etoolbar->priv->edit_mode = mode;
@@ -1158,16 +1163,13 @@ egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
for (l = 0; l < n_items; l++)
{
GtkToolItem *item;
- const char *name, *type;
- char *action_name;
+ const char *action_name, *type;
gboolean is_separator;
- GtkAction *action = NULL;
+ GtkAction *action;
- egg_toolbars_model_item_nth (model, i, l, &is_separator,
- &type, &name);
- action_name = egg_toolbars_model_get_item_id (model, type, name);
+ egg_toolbars_model_item_nth (etoolbar->priv->model, i, l,
+ &is_separator, &action_name, &type);
action = find_action (etoolbar, action_name);
- g_free (action_name);
item = gtk_toolbar_get_nth_item (GTK_TOOLBAR (toolbar), l);
gtk_tool_item_set_use_drag_window (item, mode);
@@ -1176,8 +1178,8 @@ egg_editable_toolbar_set_edit_mode (EggEditableToolbar *etoolbar,
{
set_drag_cursor (GTK_WIDGET (item));
gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
- set_item_drag_source (GTK_WIDGET (item), action, is_separator,
- type, name);
+ set_item_drag_source (etoolbar->priv->model, GTK_WIDGET (item),
+ action, is_separator, type);
}
else
{
diff --git a/lib/egg/egg-toolbar-editor.c b/lib/egg/egg-toolbar-editor.c
index 5403f96b0..360cb50c6 100755
--- a/lib/egg/egg-toolbar-editor.c
+++ b/lib/egg/egg-toolbar-editor.c
@@ -645,16 +645,13 @@ model_has_action (EggToolbarsModel *model, GtkAction *action)
n_items = egg_toolbars_model_n_items (model, i);
for (l = 0; l < n_items; l++)
{
- const char *name, *type, *action_name2;
- char *action_name1;
+ const char *name;
+ const char *action_name;
gboolean sep;
- egg_toolbars_model_item_nth (model, i, l, &sep, &type, &name);
- action_name1 = egg_toolbars_model_get_item_id (model, type, name);
- action_name2 = gtk_action_get_name (action);
- if (!sep && strcmp (action_name1, action_name2) == 0)
- return TRUE;
- g_free (action_name1);
+ egg_toolbars_model_item_nth (model, i, l, &sep, &name, NULL);
+ action_name = gtk_action_get_name (action);
+ if (!sep && strcmp (name, action_name) == 0) return TRUE;
}
}
diff --git a/lib/egg/egg-toolbars-model.c b/lib/egg/egg-toolbars-model.c
index 8990a3d5a..7535c7d66 100755
--- a/lib/egg/egg-toolbars-model.c
+++ b/lib/egg/egg-toolbars-model.c
@@ -46,7 +46,7 @@ typedef struct
typedef struct
{
- char *name;
+ char *id;
char *type;
gboolean separator;
} EggToolbarsItem;
@@ -123,9 +123,13 @@ egg_toolbars_model_to_xml (EggToolbarsModel *t)
}
else
{
+ char *name;
+
node = xmlNewChild (tnode, NULL, "toolitem", NULL);
+ name = egg_toolbars_model_get_item_name (t, item->type, item->id);
xmlSetProp (node, "type", item->type);
- xmlSetProp (node, "name", item->name);
+ xmlSetProp (node, "name", name);
+ g_free (name);
}
}
}
@@ -219,17 +223,17 @@ toolbars_toolbar_new (const char *name)
}
static EggToolbarsItem *
-toolbars_item_new (const char *name,
+toolbars_item_new (const char *id,
const char *type,
gboolean separator)
{
EggToolbarsItem *item;
- g_return_val_if_fail (name != NULL, NULL);
+ g_return_val_if_fail (id != NULL, NULL);
g_return_val_if_fail (type != NULL, NULL);
item = g_new0 (EggToolbarsItem, 1);
- item->name = g_strdup (name);
+ item->id = g_strdup (id);
item->type = g_strdup (type);
item->separator = separator;
@@ -250,7 +254,7 @@ free_item_node (EggToolbarsItem *item)
{
g_return_if_fail (item != NULL);
- g_free (item->name);
+ g_free (item->id);
g_free (item->type);
g_free (item);
}
@@ -302,7 +306,7 @@ egg_toolbars_model_add_separator (EggToolbarsModel *t,
g_return_if_fail (EGG_IS_TOOLBARS_MODEL (t));
parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- item = toolbars_item_new ("separator", EGG_TOOLBAR_ITEM_TYPE, TRUE);
+ item = toolbars_item_new ("separator", "separator", TRUE);
node = g_node_new (item);
g_node_insert (parent_node, position, node);
@@ -316,7 +320,7 @@ static gboolean
impl_add_item (EggToolbarsModel *t,
int toolbar_position,
int position,
- const char *name,
+ const char *id,
const char *type)
{
GNode *parent_node;
@@ -325,11 +329,11 @@ impl_add_item (EggToolbarsModel *t,
int real_position;
g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), FALSE);
- g_return_val_if_fail (name != NULL, FALSE);
+ g_return_val_if_fail (id != NULL, FALSE);
g_return_val_if_fail (type != NULL, FALSE);
parent_node = g_node_nth_child (t->priv->toolbars, toolbar_position);
- item = toolbars_item_new (name, type, FALSE);
+ item = toolbars_item_new (id, type, FALSE);
node = g_node_new (item);
g_node_insert (parent_node, position, node);
@@ -351,6 +355,7 @@ parse_item_list (EggToolbarsModel *t,
if (xmlStrEqual (child->name, "toolitem"))
{
xmlChar *name, *type;
+ char *id;
name = xmlGetProp (child, "name");
type = xmlGetProp (child, "type");
@@ -358,12 +363,15 @@ parse_item_list (EggToolbarsModel *t,
{
type = g_strdup (EGG_TOOLBAR_ITEM_TYPE);
}
- if (name != NULL)
+
+ id = egg_toolbars_model_get_item_id (t, type, name);
+ if (id != NULL)
{
- egg_toolbars_model_add_item (t, position, -1, name, type);
+ egg_toolbars_model_add_item (t, position, -1, id, type);
}
xmlFree (name);
g_free (type);
+ g_free (id);
}
else if (xmlStrEqual (child->name, "separator"))
{
@@ -434,8 +442,6 @@ egg_toolbars_model_load (EggToolbarsModel *t,
g_return_val_if_fail (EGG_IS_TOOLBARS_MODEL (t), FALSE);
- if (!xml_file || !g_file_test (xml_file, G_FILE_TEST_EXISTS)) return FALSE;
-
doc = xmlParseFile (xml_file);
if (doc == NULL)
{
@@ -444,6 +450,7 @@ egg_toolbars_model_load (EggToolbarsModel *t,
}
root = xmlDocGetRootElement (doc);
+ t->priv->toolbars = g_node_new (NULL);
parse_toolbars (t, root->children);
xmlFreeDoc (doc);
@@ -465,6 +472,19 @@ impl_get_item_id (EggToolbarsModel *t,
}
static char *
+impl_get_item_name (EggToolbarsModel *t,
+ const char *type,
+ const char *id)
+{
+ if (strcmp (type, EGG_TOOLBAR_ITEM_TYPE) == 0)
+ {
+ return g_strdup (id);
+ }
+
+ return NULL;
+}
+
+static char *
impl_get_item_type (EggToolbarsModel *t,
GdkAtom type)
{
@@ -487,6 +507,7 @@ egg_toolbars_model_class_init (EggToolbarsModelClass *klass)
klass->add_item = impl_add_item;
klass->get_item_id = impl_get_item_id;
+ klass->get_item_name = impl_get_item_name;
klass->get_item_type = impl_get_item_type;
egg_toolbars_model_signals[ITEM_ADDED] =
@@ -533,7 +554,7 @@ egg_toolbars_model_init (EggToolbarsModel *t)
{
t->priv =EGG_TOOLBARS_MODEL_GET_PRIVATE (t);
- t->priv->toolbars = g_node_new (NULL);
+ t->priv->toolbars = NULL;
}
static void
@@ -616,8 +637,8 @@ egg_toolbars_model_item_nth (EggToolbarsModel *t,
int toolbar_position,
int position,
gboolean *is_separator,
- const char **type,
- const char **name)
+ const char **id,
+ const char **type)
{
GNode *toolbar;
GNode *item;
@@ -633,9 +654,9 @@ egg_toolbars_model_item_nth (EggToolbarsModel *t,
*is_separator = idata->separator;
- if (name)
+ if (id)
{
- *name = idata->name;
+ *id = idata->id;
}
if (type)
@@ -686,6 +707,15 @@ egg_toolbars_model_get_item_id (EggToolbarsModel *t,
}
char *
+egg_toolbars_model_get_item_name (EggToolbarsModel *t,
+ const char *type,
+ const char *id)
+{
+ EggToolbarsModelClass *klass = EGG_TOOLBARS_MODEL_GET_CLASS (t);
+ return klass->get_item_name (t, type, id);
+}
+
+char *
egg_toolbars_model_get_item_type (EggToolbarsModel *t,
GdkAtom type)
{
diff --git a/lib/egg/egg-toolbars-model.h b/lib/egg/egg-toolbars-model.h
index dc925ef69..c5fbfafc3 100755
--- a/lib/egg/egg-toolbars-model.h
+++ b/lib/egg/egg-toolbars-model.h
@@ -85,6 +85,9 @@ struct EggToolbarsModelClass
char * (* get_item_id) (EggToolbarsModel *t,
const char *type,
const char *name);
+ char * (* get_item_name) (EggToolbarsModel *t,
+ const char *type,
+ const char *id);
};
GType egg_toolbars_model_get_type (void);
@@ -110,10 +113,13 @@ char *egg_toolbars_model_get_item_type (EggToolbarsModel *t,
char *egg_toolbars_model_get_item_id (EggToolbarsModel *t,
const char *type,
const char *name);
+char *egg_toolbars_model_get_item_name (EggToolbarsModel *t,
+ const char *type,
+ const char *id);
gboolean egg_toolbars_model_add_item (EggToolbarsModel *t,
int toolbar_position,
int position,
- const char *name,
+ const char *id,
const char *type);
void egg_toolbars_model_remove_toolbar (EggToolbarsModel *t,
int position);
@@ -122,12 +128,12 @@ void egg_toolbars_model_remove_item (EggToolbarsModel *t,
int position);
int egg_toolbars_model_n_items (EggToolbarsModel *t,
int toolbar_position);
-void egg_toolbars_model_item_nth (EggToolbarsModel *t,
+void egg_toolbars_model_item_nth (EggToolbarsModel *t,
int toolbar_position,
int position,
gboolean *is_separator,
- const char **type,
- const char **name);
+ const char **id,
+ const char **type);
int egg_toolbars_model_n_toolbars (EggToolbarsModel *t);
const char *egg_toolbars_model_toolbar_nth (EggToolbarsModel *t,
int position);
diff --git a/src/toolbar.c b/src/toolbar.c
index d523a8df3..7f316f313 100755
--- a/src/toolbar.c
+++ b/src/toolbar.c
@@ -37,16 +37,19 @@
#include "ephy-stock-icons.h"
#include "window-commands.h"
#include "eel-gconf-extensions.h"
+#include "ephy-dnd.h"
#include "ephy-debug.h"
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtkuimanager.h>
-static void toolbar_class_init (ToolbarClass *klass);
-static void toolbar_init (Toolbar *t);
-static void toolbar_finalize (GObject *object);
-static void toolbar_set_window (Toolbar *t, EphyWindow *window);
+static GtkTargetEntry drag_targets[] =
+{
+ { EGG_TOOLBAR_ITEM_TYPE, GTK_TARGET_SAME_APP, 0 },
+ { EPHY_DND_URL_TYPE, 0, 1 }
+};
+static int n_drag_targets = G_N_ELEMENTS (drag_targets);
enum
{
@@ -54,8 +57,6 @@ enum
PROP_WINDOW
};
-static GObjectClass *parent_class = NULL;
-
#define CONF_LOCKDOWN_DISABLE_ARBITRARY_URL "/apps/epiphany/lockdown/disable_arbitrary_url"
#define EPHY_TOOLBAR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_TOOLBAR, ToolbarPrivate))
@@ -69,6 +70,13 @@ struct ToolbarPrivate
guint disable_arbitrary_url_notifier_id;
};
+static void toolbar_class_init (ToolbarClass *klass);
+static void toolbar_init (Toolbar *t);
+static void toolbar_finalize (GObject *object);
+static void toolbar_set_window (Toolbar *t, EphyWindow *window);
+
+static GObjectClass *parent_class = NULL;
+
GType
toolbar_get_type (void)
{
@@ -90,7 +98,7 @@ toolbar_get_type (void)
};
toolbar_type = g_type_register_static (EGG_TYPE_EDITABLE_TOOLBAR,
- "Toolbar",
+ "EphyToolbar",
&our_info, 0);
}
@@ -149,6 +157,67 @@ zoom_to_level_cb (GtkAction *action, float zoom, EphyWindow *window)
}
static void
+toolbar_added_cb (EggToolbarsModel *model,
+ int position,
+ EggEditableToolbar *toolbar)
+{
+ const char *t_name;
+
+ t_name = egg_toolbars_model_toolbar_nth (model, position);
+ g_return_if_fail (t_name != NULL);
+
+ egg_editable_toolbar_set_drag_dest
+ (toolbar, drag_targets, n_drag_targets, t_name);
+}
+
+static void
+ephy_toolbar_realize (GtkWidget *widget)
+{
+ EggEditableToolbar *eggtoolbar = EGG_EDITABLE_TOOLBAR (widget);
+ Toolbar *toolbar = EPHY_TOOLBAR (widget);
+ EggToolbarsModel *model;
+ int i, n_toolbars;
+
+ GTK_WIDGET_CLASS (parent_class)->realize (widget);
+
+ g_object_get (widget, "ToolbarsModel", &model, NULL);
+
+ g_signal_connect (model, "toolbar_added",
+ G_CALLBACK (toolbar_added_cb), toolbar);
+
+ /* now that the toolbar has been constructed, set drag dests */
+ n_toolbars = egg_toolbars_model_n_toolbars (model);
+ for (i = 0; i < n_toolbars; i++)
+ {
+ const char *t_name;
+
+ t_name = egg_toolbars_model_toolbar_nth (model, i);
+ g_return_if_fail (t_name != NULL);
+
+ egg_editable_toolbar_set_drag_dest
+ (eggtoolbar, drag_targets, n_drag_targets, t_name);
+ }
+
+ g_object_unref (model);
+}
+
+static void
+ephy_toolbar_unrealize (GtkWidget *widget)
+{
+ Toolbar *toolbar = EPHY_TOOLBAR (widget);
+ EggToolbarsModel *model;
+
+ g_object_get (widget, "ToolbarsModel", &model, NULL);
+
+ g_signal_handlers_disconnect_by_func
+ (model, G_CALLBACK (toolbar_added_cb), toolbar);
+
+ g_object_unref (model);
+
+ GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
+}
+
+static void
toolbar_set_property (GObject *object,
guint prop_id,
const GValue *value,
@@ -178,6 +247,7 @@ static void
toolbar_class_init (ToolbarClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@@ -185,6 +255,9 @@ toolbar_class_init (ToolbarClass *klass)
object_class->set_property = toolbar_set_property;
object_class->get_property = toolbar_get_property;
+ widget_class->realize = ephy_toolbar_realize;
+ widget_class->unrealize = ephy_toolbar_unrealize;
+
g_object_class_install_property (object_class,
PROP_WINDOW,
g_param_spec_object ("window",