Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog14
-rw-r--r--cut-n-paste/toolbar-editor/egg-editable-toolbar.c9
-rw-r--r--cut-n-paste/toolbar-editor/egg-toolbar-editor.c72
-rw-r--r--cut-n-paste/toolbar-editor/egg-toolbar-editor.h2
-rw-r--r--cut-n-paste/toolbar-editor/eggmarshalers.list19
5 files changed, 82 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index 693c101..3de2a6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+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):
diff --git a/cut-n-paste/toolbar-editor/egg-editable-toolbar.c b/cut-n-paste/toolbar-editor/egg-editable-toolbar.c
index 95b0add..9ad940a 100644
--- a/cut-n-paste/toolbar-editor/egg-editable-toolbar.c
+++ b/cut-n-paste/toolbar-editor/egg-editable-toolbar.c
@@ -200,7 +200,7 @@ drag_begin_cb (GtkWidget *widget,
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,
@@ -226,7 +226,7 @@ drag_end_cb (GtkWidget *widget,
{
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,
@@ -497,8 +497,7 @@ configure_item_cursor (GtkToolItem *item,
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)
{
@@ -1808,7 +1807,7 @@ new_pixbuf_from_widget (GtkWidget *widget)
}
static GdkPixbuf *
-new_separator_pixbuf ()
+new_separator_pixbuf (void)
{
GtkWidget *separator;
GdkPixbuf *pixbuf;
diff --git a/cut-n-paste/toolbar-editor/egg-toolbar-editor.c b/cut-n-paste/toolbar-editor/egg-toolbar-editor.c
index cd5f38f..39c0071 100644
--- a/cut-n-paste/toolbar-editor/egg-toolbar-editor.c
+++ b/cut-n-paste/toolbar-editor/egg-toolbar-editor.c
@@ -47,6 +47,14 @@ enum
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
@@ -58,6 +66,9 @@ 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);
@@ -128,21 +139,61 @@ toolbar_removed_cb (EggToolbarsModel *model,
}
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
@@ -207,7 +258,7 @@ egg_toolbar_editor_class_init (EggToolbarEditorClass *klass)
"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));
}
@@ -224,6 +275,7 @@ egg_toolbar_editor_finalize (GObject *object)
if (editor->priv->model)
{
+ egg_toolbar_editor_disconnect_model (editor);
g_object_unref (editor->priv->model);
}
diff --git a/cut-n-paste/toolbar-editor/egg-toolbar-editor.h b/cut-n-paste/toolbar-editor/egg-toolbar-editor.h
index b0d27aa..ba6e1a9 100644
--- a/cut-n-paste/toolbar-editor/egg-toolbar-editor.h
+++ b/cut-n-paste/toolbar-editor/egg-toolbar-editor.h
@@ -55,6 +55,8 @@ struct EggToolbarEditorClass
GType egg_toolbar_editor_get_type (void);
GtkWidget *egg_toolbar_editor_new (GtkUIManager *manager,
EggToolbarsModel *model);
+void egg_toolbar_editor_set_model (EggToolbarEditor *t,
+ EggToolbarsModel *model);
G_END_DECLS
diff --git a/cut-n-paste/toolbar-editor/eggmarshalers.list b/cut-n-paste/toolbar-editor/eggmarshalers.list
index 97654cb..1f953dd 100644
--- a/cut-n-paste/toolbar-editor/eggmarshalers.list
+++ b/cut-n-paste/toolbar-editor/eggmarshalers.list
@@ -1,20 +1 @@
-VOID:OBJECT,OBJECT
-VOID:OBJECT,STRING,LONG,LONG
-VOID:OBJECT,LONG
-VOID:OBJECT,STRING,STRING
-VOID:UINT,UINT
-BOOLEAN:INT
-BOOLEAN:ENUM
-BOOLEAN:VOID
-OBJECT:VOID
-VOID:VOID
VOID:INT,INT
-VOID:UINT,UINT
-VOID:BOOLEAN
-VOID:OBJECT,ENUM,BOXED
-VOID:BOXED
-BOOLEAN:BOOLEAN
-BOOLEAN:OBJECT,STRING,STRING
-BOOLEAN:ENUM,INT
-STRING:POINTER
-STRING:STRING,STRING