Skip to content

Commit

Permalink
gproject: Fix opening already opened files from the sidebar
Browse files Browse the repository at this point in the history
Also always focus the editor window when changing a file.
  • Loading branch information
techee committed Oct 4, 2014
1 parent 81cd2a2 commit aef37b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
9 changes: 8 additions & 1 deletion gproject/src/gproject-sidebar.c
Expand Up @@ -378,8 +378,11 @@ static void on_open_clicked(void)
static gboolean on_button_press(G_GNUC_UNUSED GtkWidget * widget, GdkEventButton * event,
G_GNUC_UNUSED gpointer user_data)
{
if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
if (event->button == 1 && event->type == GDK_2BUTTON_PRESS)
{
on_open_clicked();
return TRUE;
}

return FALSE;
}
Expand All @@ -391,7 +394,10 @@ static gboolean on_key_press(G_GNUC_UNUSED GtkWidget * widget, GdkEventKey * eve
|| event->keyval == GDK_ISO_Enter
|| event->keyval == GDK_KP_Enter
|| event->keyval == GDK_space)
{
on_open_clicked();
return TRUE;
}
return FALSE;
}

Expand Down Expand Up @@ -719,6 +725,7 @@ static gboolean on_button_release(G_GNUC_UNUSED GtkWidget * widget, GdkEventButt

gtk_menu_popup(GTK_MENU(s_popup_menu.widget), NULL, NULL, NULL, NULL,
event->button, event->time);
return TRUE;
}

return FALSE;
Expand Down
13 changes: 2 additions & 11 deletions gproject/src/gproject-utils.c
Expand Up @@ -138,19 +138,10 @@ void open_file(gchar *utf8_name)
doc = document_find_by_filename(utf8_name);

if (!doc)
{
document_open_file(name, FALSE, NULL, NULL);
}
else
{
GtkNotebook *notebook;
gint page_num;

notebook = GTK_NOTEBOOK(geany->main_widgets->notebook);
page_num = gtk_notebook_page_num(notebook, GTK_WIDGET(doc->editor->sci));

gtk_notebook_set_current_page(notebook, page_num);
}
document_show_tab(doc);
document_grab_focus(doc);

g_free(name);
}
Expand Down

0 comments on commit aef37b0

Please sign in to comment.