Avoid code duplication in document_get_current()

This commit is contained in:
Colomban Wendling 2014-05-27 17:59:48 +02:00
parent 46f01bff59
commit 7a4b524661

View File

@ -304,24 +304,12 @@ GeanyDocument *document_get_from_page(guint page_num)
**/ **/
GeanyDocument *document_get_current(void) GeanyDocument *document_get_current(void)
{ {
gint cur_page; gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
GtkWidget *parent;
ScintillaObject *sci;
cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
if (cur_page == -1) if (cur_page == -1)
return NULL; return NULL;
else else
{ return document_get_from_page((guint) cur_page);
parent = gtk_notebook_get_nth_page(GTK_NOTEBOOK(main_widgets.notebook), cur_page);
g_return_val_if_fail(GTK_IS_BOX(parent), NULL);
sci = locate_sci_in_container(parent);
g_return_val_if_fail(IS_SCINTILLA(sci), NULL);
return document_find_by_sci(sci);
}
} }