bonobo toolbar separator patch



I ran into a bug in the bonobo toolbar insert-separator code. Here's the
patch. I'll wait until tomorrow to see if anyone responds, but if not I'll
check it in tomorrow.

John Sullivan

ChangeLog entry:
================

2000-03-17  John Sullivan  <sullivan@eazel.com>

    * bonobo/bonobo-uih-toolbar.c:
    (toolbar_toplevel_item_create_widgets): Check for NULL
    toolbar_item before reffing and adding to hash table.
    The separator case does not create a widget. Added comments
    explaining this and why it is bad (can't remove later).
    (toolbar_toplevel_item_set_sensitivity_internal): Handle
    the NULL toolbar_widget case, since it's legitimate when
    the item is a separator. Added explanatory comment.

    * bonobo/bonobo-ui-handler.h:
    (bonobo_ui_handler_toolbar_get_orientation),
    (bonobo_ui_handler_toolbar_set_orientation): Eliminated
    duplicate prototypes.

Patch:
======


Index: bonobo/bonobo-ui-handler.h
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-ui-handler.h,v
retrieving revision 1.36
diff -u -r1.36 bonobo-ui-handler.h
--- bonobo/bonobo-ui-handler.h    2000/03/02 20:05:59    1.36
+++ bonobo/bonobo-ui-handler.h    2000/03/17 23:43:42
@@ -343,11 +343,6 @@
 void                 bonobo_ui_handler_remove_toolbar    (BonoboUIHandler
*uih, const char *name);
 GList                *bonobo_ui_handler_get_toolbar_list
(BonoboUIHandler *uih);
 
-void                 bonobo_ui_handler_toolbar_set_orientation
(BonoboUIHandler *uih, const char *path,
-                                       GtkOrientation orientation);
-GtkOrientation             bonobo_ui_handler_toolbar_get_orientation
(BonoboUIHandler *uih, const char *path);
-
-
 
 void                 bonobo_ui_handler_toolbar_new        (BonoboUIHandler
*uih, const char *path,
                                      BonoboUIHandlerToolbarItemType type,
Index: bonobo/bonobo-uih-toolbar.c
===================================================================
RCS file: /cvs/gnome/bonobo/bonobo/bonobo-uih-toolbar.c,v
retrieving revision 1.6
diff -u -r1.6 bonobo-uih-toolbar.c
--- bonobo/bonobo-uih-toolbar.c    2000/03/08 00:28:23    1.6
+++ bonobo/bonobo-uih-toolbar.c    2000/03/17 23:43:48
@@ -1140,6 +1140,10 @@
         break;
 
     case BONOBO_UI_HANDLER_TOOLBAR_SEPARATOR:
+        /* No toolbar_item in this case because GtkToolbar doesn't create a
widget. */
+        /* FIXME: Is it OK that you can't remove this item because it has
no representing widget?
+         * That probably will cause havoc with removing the whole list of
toolbar items.
+         */
         gtk_toolbar_insert_space (GTK_TOOLBAR (toolbar),
internal->item->pos);
         break;
 
@@ -1197,9 +1201,12 @@
         return;
     }
 
-    /* FIXME: Connect to signals and gtk_widget_add_accelerator */
-        gtk_object_ref (GTK_OBJECT (toolbar_item));
-    g_hash_table_insert (uih->top->path_to_toolbar_item_widget, g_strdup
(internal->item->path), toolbar_item);
+    /* toolbar_item is legitimately (?) NULL in at least the
BONOBO_UI_HANDLER_TOOLBAR_SEPARATOR case. */
+    if (toolbar_item != NULL) {
+        /* FIXME: Connect to signals and gtk_widget_add_accelerator */
+            gtk_object_ref (GTK_OBJECT (toolbar_item));
+        g_hash_table_insert (uih->top->path_to_toolbar_item_widget,
g_strdup (internal->item->path), toolbar_item);
+    }
 }
 
 static void
@@ -1302,9 +1309,11 @@
         return;
 
     toolbar_widget = toolbar_toplevel_item_get_widget (uih,
internal->item->path);
-    g_return_if_fail (toolbar_widget != NULL);
 
-    gtk_widget_set_sensitive (toolbar_widget, sensitive);
+    if (toolbar_widget != NULL) {
+        /* toolbar_widget is legitimately (?) NULL in at least the
BONOBO_UI_HANDLER_TOOLBAR_SEPARATOR case. */
+        gtk_widget_set_sensitive (toolbar_widget, sensitive);
+    }
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]