Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

projectorganizer: Add a keybinding for for focusing the sidebar #920

Merged
merged 1 commit into from
Oct 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projectorganizer/src/prjorg-menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum
KB_FIND_IN_PROJECT,
KB_FIND_FILE,
KB_FIND_TAG,
KB_FOCUS_SIDEBAR,
KB_COUNT
};

Expand Down Expand Up @@ -417,6 +418,9 @@ void prjorg_menu_init(void)
keybindings_set_item(key_group, KB_SWAP_HEADER_SOURCE, NULL,
0, 0, "swap_header_source", _("Swap header/source"), s_shs_item);

keybindings_set_item(key_group, KB_FOCUS_SIDEBAR, (GeanyKeyCallback)prjorg_sidebar_focus_project_tab,
0, 0, "focus_project_sidebar", _("Focus Project Sidebar"), NULL);

s_context_sep_item = gtk_separator_menu_item_new();
gtk_widget_show(s_context_sep_item);
gtk_menu_shell_prepend(GTK_MENU_SHELL(geany->main_widgets->editor_menu), s_context_sep_item);
Expand Down
19 changes: 19 additions & 0 deletions projectorganizer/src/prjorg-sidebar.c
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,25 @@ void prjorg_sidebar_find_tag_in_active(void)
}


void prjorg_sidebar_focus_project_tab(void)
{
GtkNotebook *notebook = GTK_NOTEBOOK(geany_data->main_widgets->sidebar_notebook);
gint pagenum = gtk_notebook_get_n_pages(notebook);
gint i;

for (i = 0; i < pagenum; i++)
{
GtkWidget *page = gtk_notebook_get_nth_page(notebook, i);
if (page == s_file_view_vbox)
{
gtk_notebook_set_current_page(notebook, i);
gtk_widget_grab_focus(s_file_view);
break;
}
}
}


static void sidebar_realized_cb (GtkWidget *widget) {
if (s_pending_reload)
prjorg_sidebar_update(TRUE);
Expand Down
1 change: 1 addition & 0 deletions projectorganizer/src/prjorg-sidebar.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ void prjorg_sidebar_find_tag_in_active(void);

void prjorg_sidebar_update(gboolean reload);

void prjorg_sidebar_focus_project_tab(void);


#endif