Skip to content

Commit

Permalink
Properly mirror document_get_from_page() in document_get_notebook_page()
Browse files Browse the repository at this point in the history
Now document_get_from_page() supports arbitrary nesting inside the
notebook page, update document_get_notebook_page() to support it also,
by searching up for the direct notebook child rather than assuming it
is the ScintillaWidget's direct parent.
  • Loading branch information
b4n committed May 27, 2014
1 parent d399957 commit 46f01bf
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/document.c
Expand Up @@ -222,13 +222,20 @@ GeanyDocument *document_find_by_sci(ScintillaObject *sci)
gint document_get_notebook_page(GeanyDocument *doc)
{
GtkWidget *parent;
GtkWidget *child;

g_return_val_if_fail(doc != NULL, -1);

parent = gtk_widget_get_parent(GTK_WIDGET(doc->editor->sci));
g_return_val_if_fail(GTK_IS_BOX(parent), -1);
child = GTK_WIDGET(doc->editor->sci);
parent = gtk_widget_get_parent(child);
/* search for the direct notebook child, mirroring document_get_from_page() */
while (parent && ! GTK_IS_NOTEBOOK(parent))
{
child = parent;
parent = gtk_widget_get_parent(child);
}

return gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook), parent);
return gtk_notebook_page_num(GTK_NOTEBOOK(main_widgets.notebook), child);
}


Expand Down

0 comments on commit 46f01bf

Please sign in to comment.