SF.net SVN: geany:[4062] trunk
eht16 at users.sourceforge.net
eht16 at xxxxx
Sun Aug 9 11:17:00 UTC 2009
Revision: 4062
http://geany.svn.sourceforge.net/geany/?rev=4062&view=rev
Author: eht16
Date: 2009-08-09 11:17:00 +0000 (Sun, 09 Aug 2009)
Log Message:
-----------
Switching notebook tabs now works for the currently used notebook widget instead of always using the documents notebook.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/keybindings.c
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-08-09 10:10:23 UTC (rev 4061)
+++ trunk/ChangeLog 2009-08-09 11:17:00 UTC (rev 4062)
@@ -2,6 +2,9 @@
* data/filetypes.ada:
Add missing file.
+ * src/keybindings.c:
+ Switching notebook tabs now works for the currently used notebook
+ widget instead of always using the documents notebook.
2009-08-02 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/src/keybindings.c
===================================================================
--- trunk/src/keybindings.c 2009-08-09 10:10:23 UTC (rev 4061)
+++ trunk/src/keybindings.c 2009-08-09 11:17:00 UTC (rev 4062)
@@ -1487,36 +1487,56 @@
}
-static void switch_document(gint direction)
+static void switch_notebook_page(gint direction)
{
- gint page_count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(main_widgets.notebook));
- gint cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
+ gint page_count, cur_page;
+ gboolean parent_is_notebook = FALSE;
+ GtkNotebook *notebook;
+ GtkWidget *focusw = gtk_window_get_focus(GTK_WINDOW(main_widgets.window));
+ /* check whether the current widget is a GtkNotebook or a child of a GtkNotebook */
+ do
+ {
+ parent_is_notebook = GTK_IS_NOTEBOOK(focusw);
+ }
+ while (! parent_is_notebook && (focusw = gtk_widget_get_parent(focusw)) != NULL);
+
+ /* if we found a GtkNotebook widget, use it. Otherwise fallback to the documents notebook */
+ if (parent_is_notebook)
+ notebook = GTK_NOTEBOOK(focusw);
+ else
+ notebook = GTK_NOTEBOOK(main_widgets.notebook);
+
+ /* now switch pages */
+ page_count = gtk_notebook_get_n_pages(notebook);
+ cur_page = gtk_notebook_get_current_page(notebook);
+
if (direction == GTK_DIR_LEFT)
{
if (cur_page > 0)
- gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), cur_page - 1);
+ gtk_notebook_set_current_page(notebook, cur_page - 1);
else
- gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), page_count - 1);
+ gtk_notebook_set_current_page(notebook, page_count - 1);
}
else if (direction == GTK_DIR_RIGHT)
{
if (cur_page < page_count - 1)
- gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), cur_page + 1);
+ gtk_notebook_set_current_page(notebook, cur_page + 1);
else
- gtk_notebook_set_current_page(GTK_NOTEBOOK(main_widgets.notebook), 0);
+ gtk_notebook_set_current_page(notebook, 0);
}
}
static void cb_func_switch_tableft(G_GNUC_UNUSED guint key_id)
{
- switch_document(GTK_DIR_LEFT);
+ switch_notebook_page(GTK_DIR_LEFT);
}
+
static void cb_func_switch_tabright(G_GNUC_UNUSED guint key_id)
{
- switch_document(GTK_DIR_RIGHT);
+ switch_notebook_page(GTK_DIR_RIGHT);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list