]> www.fi.muni.cz Git - evince.git/commitdiff
Sync EggToolbarEditor with libegg.
authorNickolay V. Shmyrev <nshmyrev@yandex.ru>
Fri, 23 Jan 2009 23:32:40 +0000 (23:32 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Fri, 23 Jan 2009 23:32:40 +0000 (23:32 +0000)
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.

svn path=/trunk/; revision=3377

ChangeLog
cut-n-paste/toolbar-editor/egg-editable-toolbar.c
cut-n-paste/toolbar-editor/egg-toolbar-editor.c
cut-n-paste/toolbar-editor/egg-toolbar-editor.h
cut-n-paste/toolbar-editor/eggmarshalers.list

index 693c101d987121e69e73ad36265edd5360d6cd9f..3de2a6a43bc844a1eb0f5c210a031b8f6f073b38 100644 (file)
--- 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):
index 95b0adddf915cdee85495d8998a40a845ddbb5f5..9ad940a27f890f1934809a4a95be8a95104d159a 100644 (file)
@@ -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;
index cd5f38f2c48cf706586330696cf37b4d4e18e62f..39c00710373b4508a7a2e58e5d763beeaa861919 100644 (file)
@@ -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);
     }
 
index b0d27aa7a4503a283b7be1cb310e6a945770f7fd..ba6e1a999d154e773e69e49d45090b017129ac86 100644 (file)
@@ -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
 
index 97654cb091e4a567dbd1b0ecce3a967bd9a6277f..1f953ddfbed37d42792d4cbc81aec4a403f5db14 100644 (file)
@@ -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