[gedit/wip/redesign2] Add bindings for alt+# keys
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/wip/redesign2] Add bindings for alt+# keys
- Date: Fri, 3 Jan 2014 12:33:13 +0000 (UTC)
commit 3d3e1a7657da9f19facfdefadfe1ef1824cd9244
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Fri Jan 3 12:55:09 2014 +0100
Add bindings for alt+# keys
gedit/gedit-marshal.list | 1 +
gedit/gedit-notebook.c | 42 ++++++++++++++++++++++++++++++++++++++++++
gedit/gedit-notebook.h | 2 ++
3 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-marshal.list b/gedit/gedit-marshal.list
index d646838..9762ba2 100644
--- a/gedit/gedit-marshal.list
+++ b/gedit/gedit-marshal.list
@@ -1,5 +1,6 @@
BOOLEAN:NONE
BOOLEAN:OBJECT
+BOOLEAN:INT
VOID:BOOLEAN
VOID:BOOLEAN,POINTER
VOID:BOXED,BOXED
diff --git a/gedit/gedit-notebook.c b/gedit/gedit-notebook.c
index 2c09041..d6364eb 100644
--- a/gedit/gedit-notebook.c
+++ b/gedit/gedit-notebook.c
@@ -79,6 +79,7 @@ enum
{
TAB_CLOSE_REQUEST,
SHOW_POPUP_MENU,
+ CHANGE_TO_PAGE,
LAST_SIGNAL
};
@@ -475,6 +476,25 @@ gedit_notebook_remove (GtkContainer *container,
nb->priv->ignore_focused_page_update = FALSE;
}
+static gboolean
+gedit_notebook_change_to_page (GeditNotebook *notebook,
+ gint page_num)
+{
+ gint n_pages;
+
+ n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook));
+
+ if (page_num > n_pages - 1)
+ {
+ return FALSE;
+ }
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
+ page_num);
+
+ return TRUE;
+}
+
static void
gedit_notebook_class_init (GeditNotebookClass *klass)
{
@@ -482,6 +502,8 @@ gedit_notebook_class_init (GeditNotebookClass *klass)
GtkWidgetClass *gtkwidget_class = GTK_WIDGET_CLASS (klass);
GtkNotebookClass *notebook_class = GTK_NOTEBOOK_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
+ GtkBindingSet *binding_set;
+ gint i;
object_class->dispose = gedit_notebook_dispose;
object_class->finalize = gedit_notebook_finalize;
@@ -498,6 +520,8 @@ gedit_notebook_class_init (GeditNotebookClass *klass)
container_class->remove = gedit_notebook_remove;
+ klass->change_to_page = gedit_notebook_change_to_page;
+
g_object_class_install_property (object_class, PROP_SHOW_TABS_MODE,
g_param_spec_enum ("show-tabs-mode",
"Show Tabs Mode",
@@ -528,6 +552,24 @@ gedit_notebook_class_init (GeditNotebookClass *klass)
2,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
GEDIT_TYPE_TAB);
+ signals[CHANGE_TO_PAGE] =
+ g_signal_new ("change-to-page",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GeditNotebookClass, change_to_page),
+ NULL, NULL,
+ gedit_marshal_BOOLEAN__INT,
+ G_TYPE_BOOLEAN, 1,
+ G_TYPE_INT);
+
+ binding_set = gtk_binding_set_by_class (klass);
+ for (i = 1; i < 10; i++)
+ {
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_0 + i, GDK_MOD1_MASK,
+ "change-to-page", 1,
+ G_TYPE_INT, i - 1);
+ }
}
/**
diff --git a/gedit/gedit-notebook.h b/gedit/gedit-notebook.h
index f081abb..165578c 100644
--- a/gedit/gedit-notebook.h
+++ b/gedit/gedit-notebook.h
@@ -92,6 +92,8 @@ struct _GeditNotebookClass
void (* show_popup_menu) (GeditNotebook *notebook,
GdkEvent *event,
GeditTab *tab);
+ gboolean(* change_to_page) (GeditNotebook *notebook,
+ gint page_num);
};
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]