From: Jim Evins Date: Fri, 4 Dec 2009 03:25:15 +0000 (-0500) Subject: Improved object editor default page selection X-Git-Tag: glabels-2_3_0~121 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=5f45a608055226f06cd013a414439293174121f4;p=glabels 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. --- 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); }