From 5f45a608055226f06cd013a414439293174121f4 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Thu, 3 Dec 2009 22:25:15 -0500 Subject: [PATCH] Improved object editor default page selection 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 | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/object-editor.c b/src/object-editor.c index ba112d71..cab3477e 100644 --- a/src/object-editor.c +++ b/src/object-editor.c @@ -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); } -- 2.39.5