[Glade-devel] GtkNotebook decrease pages fix.



On Thu, 2003-08-07 at 22:21, Archit Baweja wrote:

diff -u -r1.28 glade-gtk.c
--- src/glade-gtk.c   14 Jun 2003 15:53:49 -0000      1.28
+++ src/glade-gtk.c   6 Aug 2003 22:56:47 -0000
@@ -282,14 +282,28 @@
              }
      } else {/* new_size < old_size */
              /* The notebook has shrunk. Remove pages  */
+             GladeWidget *child_gwidget;
+             GtkWidget *child_widget;
+
+             /*
+              * Thing to remember is that GtkNotebook starts the
+              * page numbers from 0, not 1 (C-style). So we need to do
+              * old_size-1, where we're referring to "nth" widget.
+              */
              while (old_size > new_size) {
-                     /*
-                      * This is broken, we should also remove the widgets that
-                      * are in the page from the project!
+                     /* Get the last widget. */
+                     child_widget = gtk_notebook_get_nth_page (notebook, old_size-1);

        Maybe it's better to check if child_widget is not NULL?

+                     child_gwidget = glade_widget_get_from_gtk_widget (child_widget);
+
+                     /* 
+                      * If we got it, and its not a placeholder, remove it
+                      * from project.
                       */
-#if 0
-                     gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), old_size);
-#endif
+                     if (child_gwidget) {
+                             glade_project_remove_widget (child_gwidget);
+                     }
+
+                     gtk_notebook_remove_page (notebook, old_size-1);
                      old_size--;
              }
      }


Other than that, it looks good to me. Thanks Archit!

ciao
        paolo





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