[Glade-devel] [patch, glade3] fix scrolled window



--=-/KCAYxjeaVIOkjYWFxo5
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi!

Thanks for reviewing and applying my patches, unfortunately the patch I
sent yesterday  which wrapped the widget properties editor into a
scrolled window is broken (sorry). To see it you can start a new
project, add a window, add a vbox to the window and then try to select
the window from the pop up menu... widget properties will not get shown
in the editor :(

Attached is a patch which takes a (IMHO) better approach wrapping the
vbox into the scrolled window instead of the table. This has the nice
side effect of working for all the tabs in the notebook.

Beside I noticed that using fixed size in pixels was broken; to see it
look at the properties of a window: if you enlarge the editor at the
bottom you'll see properties that were not reachable with the scrollbar.
I removed the two lines which used gtk_widget_set_usize (which is also
deprecated) and set a default size for the whole editor.

If this patch looks right to you please apply, otherwise revert
yesterday's patch.

ciao
        paolo

--=-/KCAYxjeaVIOkjYWFxo5
Content-Disposition: attachment; filename=fix_scrollable.patch
Content-Type: text/x-patch; name=fix_scrollable.patch; charset=UTF-8
Content-Transfer-Encoding: 7bit

diff -upr gnome2/glade3/ChangeLog glade3/ChangeLog
--- gnome2/glade3/ChangeLog     2003-04-17 09:51:54.000000000 +0200
+++ glade3/ChangeLog    2003-04-17 14:38:21.000000000 +0200
@@ -1,3 +1,8 @@
+2003-04-17  Paolo Borelli <pborelli katamail com>
+
+       * src/glade-editor.[ch]: previous patch to add scrollbars was broken,
+       do things properly.
+
 2003-04-16  Paolo Borelli <pborelli katamail com>
 
        * src/glade-placeholder.c: fix an assertion.
diff -upr gnome2/glade3/src/glade-editor.c glade3/src/glade-editor.c
--- gnome2/glade3/src/glade-editor.c    2003-04-17 09:51:55.000000000 +0200
+++ glade3/src/glade-editor.c   2003-04-17 14:40:02.000000000 +0200
@@ -180,16 +180,26 @@ glade_editor_delete_event (GladeEditor *
 }
 
 GtkWidget *
-my_notebook_page (const gchar *name, GtkWidget *notebook)
+glade_editor_notebook_page (const gchar *name, GtkWidget *notebook)
 {
        GtkWidget *vbox;
+       GtkWidget *scrolled_window;
        GtkWidget *label;
        static gint page = 0;
 
        vbox = gtk_vbox_new (FALSE, 0);
-       gtk_widget_set_usize (vbox, -1, 350);
+
+       /* wrap the vbox in a scrolled window */
+       scrolled_window = gtk_scrolled_window_new (NULL, NULL);
+       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
+                                       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+       gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
+                                              GTK_WIDGET (vbox));
+       gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (scrolled_window)->child),
+                                     GTK_SHADOW_NONE);
+
        label = gtk_label_new (name);
-       gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), vbox, label, page++);
+       gtk_notebook_insert_page (GTK_NOTEBOOK (notebook), scrolled_window, label, page++);
 
        return vbox;
 }
@@ -199,10 +209,10 @@ glade_editor_init (GladeEditor *editor)
 {
        editor->tooltips = gtk_tooltips_new ();
 
-       editor->vbox_widget  = my_notebook_page (_("Widget"), GTK_WIDGET (editor));
-       editor->vbox_packing = my_notebook_page (_("Packing"), GTK_WIDGET (editor));
-       editor->vbox_common  = my_notebook_page (_("Common"), GTK_WIDGET (editor));
-       editor->vbox_signals = my_notebook_page (_("Signals"), GTK_WIDGET (editor));
+       editor->vbox_widget  = glade_editor_notebook_page (_("Widget"), GTK_WIDGET (editor));
+       editor->vbox_packing = glade_editor_notebook_page (_("Packing"), GTK_WIDGET (editor));
+       editor->vbox_common  = glade_editor_notebook_page (_("Common"), GTK_WIDGET (editor));
+       editor->vbox_signals = glade_editor_notebook_page (_("Signals"), GTK_WIDGET (editor));
        editor->widget_tables = NULL;
        editor->loading = FALSE;
 
@@ -214,7 +224,13 @@ glade_editor_init (GladeEditor *editor)
 GladeEditor *
 glade_editor_new ()
 {
-       return GLADE_EDITOR (gtk_type_new (glade_editor_get_type ()));
+       GladeEditor *editor;
+
+       editor = GLADE_EDITOR (gtk_type_new (glade_editor_get_type ()));
+
+       gtk_widget_set_size_request (GTK_WIDGET (editor), 350, 450);
+       
+       return editor;
 }
 
 static void
@@ -238,8 +254,6 @@ glade_editor_widget_name_changed (GtkWid
 static void
 glade_editor_table_attach (GtkWidget *table, GtkWidget *child, gint pos, gint row)
 {
-       gtk_widget_set_usize (child, pos == 0 ? 100 : 120, -1);
-       
        gtk_table_attach (GTK_TABLE (table), child,
                          pos, pos+1, row, row +1,
                          GTK_EXPAND | GTK_FILL, 0, 0, 0);
@@ -963,7 +977,6 @@ glade_editor_load_widget_page (GladeEdit
        GladeEditorTable *table;
        GtkContainer *container;
        GList *list;
-       GtkWidget *scrolled_window;
 
        /* Remove the old table that was in this container */
        container = GTK_CONTAINER (editor->vbox_widget);
@@ -977,23 +990,15 @@ glade_editor_load_widget_page (GladeEdit
 
        if (!class)
                return;
-       
+
        table = glade_editor_get_table_from_class (editor, class, FALSE);
        if (table == NULL)
                table = glade_editor_table_create (editor, class, FALSE);
 
        g_return_if_fail (table != NULL);
-       
-       /* wrap the table in a scrolled window */
-       scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
-                                       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-       gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
-                                              table->table_widget);
-       gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (scrolled_window)->child),
-                                     GTK_SHADOW_NONE);
-       gtk_widget_show (scrolled_window);
-       gtk_box_pack_start (GTK_BOX (editor->vbox_widget), scrolled_window,
+
+       /* Attach the new table */
+       gtk_box_pack_start (GTK_BOX (editor->vbox_widget), table->table_widget,
                            TRUE, TRUE, 0);
 }
 
diff -upr gnome2/glade3/src/glade-editor.h glade3/src/glade-editor.h
--- gnome2/glade3/src/glade-editor.h    2003-03-08 17:23:41.000000000 +0100
+++ glade3/src/glade-editor.h   2003-04-17 13:50:49.000000000 +0200
@@ -55,11 +55,12 @@ struct _GladeEditor
                                  * will point to the tooltips for that
                                  * class. Oh well, we'll see
                                  */
-       GtkWidget *vbox_widget;  /* The editor has (at this moment) for tabs
+       GtkWidget *vbox_widget;  /* The editor has (at this moment) four tabs
                                  * this are pointers to the vboxes inside
-                                 * each tab. The vbox_widget is deparented
-                                 * and parented with
-                                 * GladeWidgetClass->table_widget
+                                 * each tab. The vboxes are wrapped into a
+                                 * scrolled window.
+                                 * The vbox_widget is deparented and parented
+                                 * with GladeWidgetClass->table_widget
                                  * when a widget is selecteed.
                                  */
        GtkWidget *vbox_packing;  /* We might not need this pointer. Not yet

--=-/KCAYxjeaVIOkjYWFxo5--





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