+2009-01-24 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * cut-n-paste/toolbar-editor/egg-editable-toolbar.c
+ (drag_begin_cb), (drag_end_cb), (configure_item_tooltip),
+ (new_separator_pixbuf):
+ * cut-n-paste/toolbar-editor/egg-toolbar-editor.c
+ (egg_toolbar_editor_disconnect_model),
+ (egg_toolbar_editor_set_model), (egg_toolbar_editor_class_init),
+ (egg_toolbar_editor_finalize):
+ * cut-n-paste/toolbar-editor/egg-toolbar-editor.h:
+ * cut-n-paste/toolbar-editor/eggmarshalers.list:
+
+ Sync EggToolbarEditor with libegg.
+
2009-01-22 Michael J. Chudobiak <mjc@svn.gnome.org>
* libdocument/ev-file-helpers.c: (ev_xfer_uri_simple):
gtk_widget_hide (widget);
- action = g_object_get_data (G_OBJECT (widget), "gtk-action");
+ action = gtk_widget_get_action (widget);
if (action == NULL) return;
flags = egg_toolbars_model_get_name_flags (etoolbar->priv->model,
{
gtk_widget_show (widget);
- action = g_object_get_data (G_OBJECT (widget), "gtk-action");
+ action = gtk_widget_get_action (widget);
if (action == NULL) return;
flags = egg_toolbars_model_get_name_flags (etoolbar->priv->model,
static void
configure_item_tooltip (GtkToolItem *item)
{
- GtkAction *action = g_object_get_data (G_OBJECT (item),
- "gtk-action");
+ GtkAction *action = gtk_widget_get_action (GTK_WIDGET (item));
if (action != NULL)
{
}
static GdkPixbuf *
-new_separator_pixbuf ()
+new_separator_pixbuf (void)
{
GtkWidget *separator;
GdkPixbuf *pixbuf;
PROP_TOOLBARS_MODEL
};
+enum
+{
+ SIGNAL_HANDLER_ITEM_ADDED,
+ SIGNAL_HANDLER_ITEM_REMOVED,
+ SIGNAL_HANDLER_TOOLBAR_REMOVED,
+ SIGNAL_HANDLER_LIST_SIZE /* Array size */
+};
+
#define EGG_TOOLBAR_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EGG_TYPE_TOOLBAR_EDITOR, EggToolbarEditorPrivate))
struct EggToolbarEditorPrivate
GtkWidget *scrolled_window;
GList *actions_list;
GList *factory_list;
+
+ /* These handlers need to be sanely disconnected when switching models */
+ gulong sig_handlers[SIGNAL_HANDLER_LIST_SIZE];
};
G_DEFINE_TYPE (EggToolbarEditor, egg_toolbar_editor, GTK_TYPE_VBOX);
}
static void
+egg_toolbar_editor_disconnect_model (EggToolbarEditor *t)
+{
+ EggToolbarEditorPrivate *priv = t->priv;
+ EggToolbarsModel *model = priv->model;
+ gulong handler;
+ int i;
+
+ for (i = 0; i < SIGNAL_HANDLER_LIST_SIZE; i++)
+ {
+ handler = priv->sig_handlers[i];
+
+ if (handler != 0)
+ {
+ if (g_signal_handler_is_connected (model, handler))
+ {
+ g_signal_handler_disconnect (model, handler);
+ }
+
+ priv->sig_handlers[i] = 0;
+ }
+ }
+}
+
+void
egg_toolbar_editor_set_model (EggToolbarEditor *t,
EggToolbarsModel *model)
{
+ EggToolbarEditorPrivate *priv;
+
g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (t));
+ g_return_if_fail (model != NULL);
- t->priv->model = g_object_ref (model);
-
- update_editor_sheet (t);
+ priv = t->priv;
+
+ if (priv->model)
+ {
+ if (G_UNLIKELY (priv->model == model)) return;
+
+ egg_toolbar_editor_disconnect_model (t);
+ g_object_unref (priv->model);
+ }
- g_signal_connect_object (model, "item_added",
- G_CALLBACK (item_added_or_removed_cb), t, 0);
- g_signal_connect_object (model, "item_removed",
- G_CALLBACK (item_added_or_removed_cb), t, 0);
- g_signal_connect_object (model, "toolbar_removed",
- G_CALLBACK (toolbar_removed_cb), t, 0);
+ priv->model = g_object_ref (model);
+
+ update_editor_sheet (t);
+
+ priv->sig_handlers[SIGNAL_HANDLER_ITEM_ADDED] =
+ g_signal_connect_object (model, "item_added",
+ G_CALLBACK (item_added_or_removed_cb), t, 0);
+ priv->sig_handlers[SIGNAL_HANDLER_ITEM_REMOVED] =
+ g_signal_connect_object (model, "item_removed",
+ G_CALLBACK (item_added_or_removed_cb), t, 0);
+ priv->sig_handlers[SIGNAL_HANDLER_TOOLBAR_REMOVED] =
+ g_signal_connect_object (model, "toolbar_removed",
+ G_CALLBACK (toolbar_removed_cb), t, 0);
}
static void
"Toolbars Model",
EGG_TYPE_TOOLBARS_MODEL,
G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
- G_PARAM_CONSTRUCT_ONLY));
+ G_PARAM_CONSTRUCT));
g_type_class_add_private (object_class, sizeof (EggToolbarEditorPrivate));
}
if (editor->priv->model)
{
+ egg_toolbar_editor_disconnect_model (editor);
g_object_unref (editor->priv->model);
}