SF.net SVN: geany-plugins:[1999] trunk/geany-plugins/webhelper/src/ gwh-plugin.c

colombanw at users.sourceforge.net colombanw at xxxxx
Tue Mar 22 15:36:59 UTC 2011


Revision: 1999
          http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1999&view=rev
Author:   colombanw
Date:     2011-03-22 15:36:59 +0000 (Tue, 22 Mar 2011)

Log Message:
-----------
WebHelper: Simplify and improve notebook page removing

Don't track the page number, simply remove the child from the parent
notebook.

Also, don't blindly expect the parent to be the one in which we added
the page initially, so we support the page to have been reparented,
e.g. by a notebook DnD.

Modified Paths:
--------------
    trunk/geany-plugins/webhelper/src/gwh-plugin.c

Modified: trunk/geany-plugins/webhelper/src/gwh-plugin.c
===================================================================
--- trunk/geany-plugins/webhelper/src/gwh-plugin.c	2011-03-19 14:15:42 UTC (rev 1998)
+++ trunk/geany-plugins/webhelper/src/gwh-plugin.c	2011-03-22 15:36:59 UTC (rev 1999)
@@ -66,8 +66,6 @@
   guint       type;
   GtkWidget  *widget;
   
-  /* only valid if type == CONTAINER_NOTEBOOK */
-  gint        page_num;
   /* only valid if type == CONTAINER_WINDOW */
   gboolean    visible;
 } G_container;
@@ -184,9 +182,8 @@
     } else {
       G_container.widget = geany_data->main_widgets->message_window_notebook;
     }
-    G_container.page_num = gtk_notebook_append_page (GTK_NOTEBOOK (G_container.widget),
-                                                     G_browser,
-                                                     gtk_label_new (_("Web preview")));
+    gtk_notebook_append_page (GTK_NOTEBOOK (G_container.widget),
+                              G_browser, gtk_label_new (_("Web preview")));
     gwh_browser_set_inspector_transient_for (GWH_BROWSER (G_browser),
                                              GTK_WINDOW (geany_data->main_widgets->window));
   }
@@ -199,27 +196,8 @@
     separate_window_set_visible (FALSE); /* saves the geometry */
     gtk_widget_destroy (G_container.widget);
   } else {
-    GtkNotebook  *notebook = GTK_NOTEBOOK (G_container.widget);
-    gint          page_num = G_container.page_num;
-    
-    /* remove the page we added. we handle the case where the page were
-     * reordered */
-    if (gtk_notebook_get_nth_page (notebook, page_num) != G_browser) {
-      gint i;
-      gint n;
-      
-      page_num = -1;
-      n = gtk_notebook_get_n_pages (notebook);
-      for (i = 0; i < n; i++) {
-        if (gtk_notebook_get_nth_page (notebook, i) == G_browser) {
-          page_num = i;
-          break;
-        }
-      }
-    }
-    if (page_num >= 0) {
-      gtk_notebook_remove_page (notebook, page_num);
-    }
+    gtk_container_remove (GTK_CONTAINER (gtk_widget_get_parent (G_browser)),
+                          G_browser);
   }
 }
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Plugins-Commits mailing list