]> git.sur5r.net Git - glabels/commitdiff
Improved object editor default page selection
authorJim Evins <evins@snaught.com>
Fri, 4 Dec 2009 03:25:15 +0000 (22:25 -0500)
committerJim Evins <evins@snaught.com>
Fri, 4 Dec 2009 03:25:15 +0000 (22:25 -0500)
Whenever the object is changed, an attempt is made to either keep the same
page active or if that page is no longer visible, set to the first visible
page.

src/object-editor.c

index ba112d71a79a57faa15cfd0af9c3605e6b131932..cab3477e211dd9ffb09d7a53b3230d977c184ccd 100644 (file)
@@ -284,6 +284,7 @@ set_object (glObjectEditor  *editor,
         gchar         *title;
         gchar         *s;
         GtkTextBuffer *buffer;
+        gint           old_page, new_page;
 
        gl_debug (DEBUG_EDITOR, "START");
 
@@ -300,6 +301,8 @@ set_object (glObjectEditor  *editor,
 
                 object_changed_cb (object, editor);
 
+                old_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (editor->priv->notebook));
+
                 if (GL_IS_LABEL_BOX (object))
                 {
                         image = GL_STOCK_BOX;
@@ -429,6 +432,19 @@ set_object (glObjectEditor  *editor,
 
                 gtk_widget_show (editor->priv->notebook);
 
+                /* if the old active page is no longer visible, set to 1st visible page. */
+                new_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (editor->priv->notebook));
+                if ( old_page != new_page )
+                {
+                        /* Trick: try in reverse order, only the last visible attempt will stick. */
+                        gtk_notebook_set_current_page (GTK_NOTEBOOK (editor->priv->notebook), 5);
+                        gtk_notebook_set_current_page (GTK_NOTEBOOK (editor->priv->notebook), 4);
+                        gtk_notebook_set_current_page (GTK_NOTEBOOK (editor->priv->notebook), 3);
+                        gtk_notebook_set_current_page (GTK_NOTEBOOK (editor->priv->notebook), 2);
+                        gtk_notebook_set_current_page (GTK_NOTEBOOK (editor->priv->notebook), 1);
+                        gtk_notebook_set_current_page (GTK_NOTEBOOK (editor->priv->notebook), 0);
+                }
+
                 g_signal_connect (G_OBJECT (object), "changed",
                                   G_CALLBACK (object_changed_cb), editor);
         }