From: Ira W. Snyder Date: Tue, 29 Jan 2008 20:14:50 +0000 (-0800) Subject: [Window] Add accelerator support X-Git-Url: https://www.irasnyder.com/gitweb/?p=tilda-gobject.git;a=commitdiff_plain;h=f9193eb723cbe6619673a0291be6ce226b079914 [Window] Add accelerator support This adds all of the accelerators that were present in Tilda 0.9.*. Of course, they are all configurable. The defaults are set to the gnome-terminal defaults, which were the hard-coded values in Tilda 0.9.*. --- diff --git a/share-tilda.conf b/share-tilda.conf index 1e8b474..d2c4460 100644 --- a/share-tilda.conf +++ b/share-tilda.conf @@ -23,6 +23,23 @@ stick = true hidden-at-start = false centered-horizontally = false centered-vertically = false +accelerator-quit = q +accelerator-next-tab = Page_Down +accelerator-previous-tab = Page_Up +accelerator-add-terminal = t +accelerator-remove-terminal = w +accelerator-copy = c +accelerator-paste = v +accelerator-goto-1 = 1 +accelerator-goto-2 = 2 +accelerator-goto-3 = 3 +accelerator-goto-4 = 4 +accelerator-goto-5 = 5 +accelerator-goto-6 = 6 +accelerator-goto-7 = 7 +accelerator-goto-8 = 8 +accelerator-goto-9 = 9 +accelerator-goto-10 = 0 [terminal-defaults] font = Bitstream Vera Sans Mono 12 diff --git a/tilda-window.c b/tilda-window.c index 6a5b84e..351efa0 100644 --- a/tilda-window.c +++ b/tilda-window.c @@ -352,6 +352,295 @@ tilda_window_dbus_register_object (TildaWindow *self) g_free (object_path); } +/******************************************************************************* + * All accelerator-related stuff below + ******************************************************************************/ + +typedef gboolean (*TildaWindowAccelCallback) (TildaWindow *self, gpointer data); + +/** + * This function updates the accelerator used to call the given function for this + * TildaWindow. If accel is NULL, then func will be removed (no accelerator will + * cause func to be called). + * + * Returns: TRUE on success, FALSE on failure + */ +static gboolean +tilda_window_update_accelerator (TildaWindow *self, /* object */ + gchar **accel_to_update, /* self->??? */ + const gchar *accel, /* new accel */ + const TildaWindowAccelCallback func) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + debug_assert (accel_to_update != NULL); + debug_assert (func != NULL); + + gboolean ret; + guint key; + GdkModifierType mod; + GClosure *closure; + + /* Remove the old accelerator if there was a previous one set */ + if (*accel_to_update != NULL) + { + /* This should always parse, we've done it before! */ + gtk_accelerator_parse (*accel_to_update, &key, &mod); + ret = gtk_accel_group_disconnect_key (self->accel_group, key, mod); + } + + /* If we are just removing the old accelerator, we're already done */ + if (accel == NULL) + { + g_free (*accel_to_update); + *accel_to_update = NULL; + return TRUE; + } + + /* Create the closure for this function */ + closure = g_cclosure_new_swap (G_CALLBACK(func), self, NULL); + + /* Try to parse the new accelerator */ + gtk_accelerator_parse (accel, &key, &mod); + + if (!gtk_accelerator_valid (key, mod)) + { + g_warning (_("Failed to parse accelerator: %s\n"), accel); + + /* Re-install the old accelerator */ + if (*accel_to_update != NULL) + { + gtk_accelerator_parse (*accel_to_update, &key, &mod); + gtk_accel_group_connect (self->accel_group, key, mod, GTK_ACCEL_VISIBLE, closure); + } + return FALSE; + } + + /* All good, g_free() the old accelerator, g_strdup() the new one */ + g_free (*accel_to_update); + *accel_to_update = g_strdup(accel); + + /* Add the new accelerator */ + gtk_accel_group_connect (self->accel_group, key, mod, GTK_ACCEL_VISIBLE, closure); + + return TRUE; +} + +static gboolean +tilda_window_accel_quit_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + tilda_window_close (self); + + /* Do not keep propagating */ + return TRUE; +} + +static gboolean +tilda_window_accel_next_tab_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + gint num_pages; + gint current_page; + + num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK(self->notebook)); + current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK(self->notebook)); + + /* Go to next page (with wrapping) */ + if (num_pages != (current_page + num_pages)) + gtk_notebook_next_page (GTK_NOTEBOOK(self->notebook)); + else + gtk_notebook_set_current_page (GTK_NOTEBOOK(self->notebook), num_pages-1); + + /* Do not keep propagating */ + return TRUE; +} + +static gboolean +tilda_window_accel_prev_tab_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + gint num_pages; + gint current_page; + + num_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK(self->notebook)); + current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK(self->notebook)); + + if ((num_pages-1) != current_page) + gtk_notebook_prev_page (GTK_NOTEBOOK(self->notebook)); + else + gtk_notebook_set_current_page (GTK_NOTEBOOK(self->notebook), 0); + + /* Do not keep propagating */ + return TRUE; +} + +static gboolean +tilda_window_accel_add_term_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + tilda_window_add_terminal (self); + + /* Do not keep propagating */ + return TRUE; +} + +static gboolean +tilda_window_accel_remove_term_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + TildaTerminal *tt = tilda_window_find_current_terminal (self); + + tilda_window_remove_terminal (self, tt->number); + + /* Do not keep propagating */ + return TRUE; +} + +static gboolean +tilda_window_accel_copy_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + TildaTerminal *tt = tilda_window_find_current_terminal (self); + + vte_terminal_copy_clipboard (VTE_TERMINAL(tt->vte_term)); + + /* Do not keep propagating */ + return TRUE; +} + +static gboolean +tilda_window_accel_paste_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + TildaTerminal *tt = tilda_window_find_current_terminal (self); + + vte_terminal_paste_clipboard (VTE_TERMINAL(tt->vte_term)); + + /* Do not keep propagating */ + return TRUE; +} + +static gboolean +tilda_window_accel_goto_generic (TildaWindow *self, guint number) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + if (self->terms->len > (number - 1)) + { + gint temp = self->terms->len - number; + gtk_notebook_set_current_page (GTK_NOTEBOOK(self->notebook), temp); + } + + /* Do not keep propagating */ + return TRUE; +} + +static gboolean +tilda_window_accel_goto_1_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 1); +} + +static gboolean +tilda_window_accel_goto_2_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 2); +} + +static gboolean +tilda_window_accel_goto_3_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 3); +} + +static gboolean +tilda_window_accel_goto_4_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 4); +} + +static gboolean +tilda_window_accel_goto_5_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 5); +} + +static gboolean +tilda_window_accel_goto_6_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 6); +} + +static gboolean +tilda_window_accel_goto_7_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 7); +} + +static gboolean +tilda_window_accel_goto_8_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 8); +} + +static gboolean +tilda_window_accel_goto_9_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 9); +} + +static gboolean +tilda_window_accel_goto_10_cb (TildaWindow *self, gpointer data) +{ + debug_enter (); + debug_assert (TILDA_IS_WINDOW(self)); + + return tilda_window_accel_goto_generic (self, 10); +} + /******************************************************************************* * ALL GOBJECT STUFF BELOW PLEASE ******************************************************************************/ @@ -362,6 +651,24 @@ enum tilda_window_properties { TILDA_WINDOW_NUMBER = 1, TILDA_WINDOW_CONTROLLER, + TILDA_WINDOW_ACCEL_QUIT, + TILDA_WINDOW_ACCEL_NEXT_TAB, + TILDA_WINDOW_ACCEL_PREV_TAB, + TILDA_WINDOW_ACCEL_ADD_TERM, + TILDA_WINDOW_ACCEL_REMOVE_TERM, + TILDA_WINDOW_ACCEL_COPY, + TILDA_WINDOW_ACCEL_PASTE, + TILDA_WINDOW_ACCEL_GOTO_1, + TILDA_WINDOW_ACCEL_GOTO_2, + TILDA_WINDOW_ACCEL_GOTO_3, + TILDA_WINDOW_ACCEL_GOTO_4, + TILDA_WINDOW_ACCEL_GOTO_5, + TILDA_WINDOW_ACCEL_GOTO_6, + TILDA_WINDOW_ACCEL_GOTO_7, + TILDA_WINDOW_ACCEL_GOTO_8, + TILDA_WINDOW_ACCEL_GOTO_9, + TILDA_WINDOW_ACCEL_GOTO_10, + TILDA_WINDOW_KEY, TILDA_WINDOW_HEIGHT, @@ -398,6 +705,10 @@ tilda_window_instance_init (GTypeInstance *instance, self->notebook = gtk_notebook_new (); self->terms = g_ptr_array_new (); + /* Accelerators */ + self->accel_group = gtk_accel_group_new (); + gtk_window_add_accel_group (GTK_WINDOW(self->window), self->accel_group); + /* Somewhat of a "poison" value, incase we don't set this */ self->number = 0xdeadbeef; self->controller = NULL; @@ -425,6 +736,142 @@ tilda_window_set_property (GObject *object, debug_printf ("window controller: 0x%x\n", self->controller); break; + case TILDA_WINDOW_ACCEL_QUIT: + tilda_window_update_accelerator (self, + &self->accel_quit, + g_value_get_string (value), + tilda_window_accel_quit_cb); + debug_printf ("window accel quit: %s\n", self->accel_quit); + break; + + case TILDA_WINDOW_ACCEL_NEXT_TAB: + tilda_window_update_accelerator (self, + &self->accel_next_tab, + g_value_get_string (value), + tilda_window_accel_next_tab_cb); + debug_printf ("window accel next tab: %s\n", self->accel_next_tab); + break; + + case TILDA_WINDOW_ACCEL_PREV_TAB: + tilda_window_update_accelerator (self, + &self->accel_prev_tab, + g_value_get_string (value), + tilda_window_accel_prev_tab_cb); + debug_printf ("window accel prev tab: %s\n", self->accel_prev_tab); + break; + + case TILDA_WINDOW_ACCEL_ADD_TERM: + tilda_window_update_accelerator (self, + &self->accel_add_term, + g_value_get_string (value), + tilda_window_accel_add_term_cb); + debug_printf ("window accel add term: %s\n", self->accel_add_term); + break; + + case TILDA_WINDOW_ACCEL_REMOVE_TERM: + tilda_window_update_accelerator (self, + &self->accel_remove_term, + g_value_get_string (value), + tilda_window_accel_remove_term_cb); + debug_printf ("window accel remove term: %s\n", self->accel_remove_term); + break; + + case TILDA_WINDOW_ACCEL_COPY: + tilda_window_update_accelerator (self, + &self->accel_copy, + g_value_get_string (value), + tilda_window_accel_copy_cb); + debug_printf ("window accel copy: %s\n", self->accel_copy); + break; + + case TILDA_WINDOW_ACCEL_PASTE: + tilda_window_update_accelerator (self, + &self->accel_paste, + g_value_get_string (value), + tilda_window_accel_paste_cb); + debug_printf ("window accel paste: %s\n", self->accel_paste); + break; + + case TILDA_WINDOW_ACCEL_GOTO_1: + tilda_window_update_accelerator (self, + &self->accel_goto_1, + g_value_get_string (value), + tilda_window_accel_goto_1_cb); + debug_printf ("window accel goto 1: %s\n", self->accel_goto_1); + break; + + case TILDA_WINDOW_ACCEL_GOTO_2: + tilda_window_update_accelerator (self, + &self->accel_goto_2, + g_value_get_string (value), + tilda_window_accel_goto_2_cb); + debug_printf ("window accel goto 2: %s\n", self->accel_goto_2); + break; + + case TILDA_WINDOW_ACCEL_GOTO_3: + tilda_window_update_accelerator (self, + &self->accel_goto_3, + g_value_get_string (value), + tilda_window_accel_goto_3_cb); + debug_printf ("window accel goto 3: %s\n", self->accel_goto_3); + break; + + case TILDA_WINDOW_ACCEL_GOTO_4: + tilda_window_update_accelerator (self, + &self->accel_goto_4, + g_value_get_string (value), + tilda_window_accel_goto_4_cb); + debug_printf ("window accel goto 4: %s\n", self->accel_goto_4); + break; + + case TILDA_WINDOW_ACCEL_GOTO_5: + tilda_window_update_accelerator (self, + &self->accel_goto_5, + g_value_get_string (value), + tilda_window_accel_goto_5_cb); + debug_printf ("window accel goto 5: %s\n", self->accel_goto_5); + break; + + case TILDA_WINDOW_ACCEL_GOTO_6: + tilda_window_update_accelerator (self, + &self->accel_goto_6, + g_value_get_string (value), + tilda_window_accel_goto_6_cb); + debug_printf ("window accel goto 6: %s\n", self->accel_goto_6); + break; + + case TILDA_WINDOW_ACCEL_GOTO_7: + tilda_window_update_accelerator (self, + &self->accel_goto_7, + g_value_get_string (value), + tilda_window_accel_goto_7_cb); + debug_printf ("window accel goto 7: %s\n", self->accel_goto_7); + break; + + case TILDA_WINDOW_ACCEL_GOTO_8: + tilda_window_update_accelerator (self, + &self->accel_goto_8, + g_value_get_string (value), + tilda_window_accel_goto_8_cb); + debug_printf ("window accel goto 8: %s\n", self->accel_goto_8); + break; + + case TILDA_WINDOW_ACCEL_GOTO_9: + tilda_window_update_accelerator (self, + &self->accel_goto_9, + g_value_get_string (value), + tilda_window_accel_goto_9_cb); + debug_printf ("window accel goto 9: %s\n", self->accel_goto_9); + break; + + case TILDA_WINDOW_ACCEL_GOTO_10: + tilda_window_update_accelerator (self, + &self->accel_goto_10, + g_value_get_string (value), + tilda_window_accel_goto_10_cb); + debug_printf ("window accel goto 10: %s\n", self->accel_goto_10); + break; + case TILDA_WINDOW_KEY: tilda_window_try_to_bind_key (self, g_value_get_string (value)); debug_printf ("window key %s\n", self->key); @@ -547,6 +994,74 @@ tilda_window_get_property (GObject *object, g_value_set_pointer (value, self->controller); break; + case TILDA_WINDOW_ACCEL_QUIT: + g_value_set_string (value, self->accel_quit); + break; + + case TILDA_WINDOW_ACCEL_NEXT_TAB: + g_value_set_string (value, self->accel_next_tab); + break; + + case TILDA_WINDOW_ACCEL_PREV_TAB: + g_value_set_string (value, self->accel_prev_tab); + break; + + case TILDA_WINDOW_ACCEL_ADD_TERM: + g_value_set_string (value, self->accel_prev_tab); + break; + + case TILDA_WINDOW_ACCEL_REMOVE_TERM: + g_value_set_string (value, self->accel_remove_term); + break; + + case TILDA_WINDOW_ACCEL_COPY: + g_value_set_string (value, self->accel_copy); + break; + + case TILDA_WINDOW_ACCEL_PASTE: + g_value_set_string (value, self->accel_paste); + break; + + case TILDA_WINDOW_ACCEL_GOTO_1: + g_value_set_string (value, self->accel_goto_1); + break; + + case TILDA_WINDOW_ACCEL_GOTO_2: + g_value_set_string (value, self->accel_goto_2); + break; + + case TILDA_WINDOW_ACCEL_GOTO_3: + g_value_set_string (value, self->accel_goto_3); + break; + + case TILDA_WINDOW_ACCEL_GOTO_4: + g_value_set_string (value, self->accel_goto_4); + break; + + case TILDA_WINDOW_ACCEL_GOTO_5: + g_value_set_string (value, self->accel_goto_5); + break; + + case TILDA_WINDOW_ACCEL_GOTO_6: + g_value_set_string (value, self->accel_goto_6); + break; + + case TILDA_WINDOW_ACCEL_GOTO_7: + g_value_set_string (value, self->accel_goto_7); + break; + + case TILDA_WINDOW_ACCEL_GOTO_8: + g_value_set_string (value, self->accel_goto_8); + break; + + case TILDA_WINDOW_ACCEL_GOTO_9: + g_value_set_string (value, self->accel_goto_9); + break; + + case TILDA_WINDOW_ACCEL_GOTO_10: + g_value_set_string (value, self->accel_goto_10); + break; + case TILDA_WINDOW_KEY: g_value_set_string (value, self->key); break; @@ -664,6 +1179,24 @@ tilda_window_constructor (GType type, g_critical ("HACK: start the wizard here\n"); } + tilda_window_set_property_from_config (self, "accelerator-quit"); + tilda_window_set_property_from_config (self, "accelerator-next-tab"); + tilda_window_set_property_from_config (self, "accelerator-previous-tab"); + tilda_window_set_property_from_config (self, "accelerator-add-terminal"); + tilda_window_set_property_from_config (self, "accelerator-remove-terminal"); + tilda_window_set_property_from_config (self, "accelerator-copy"); + tilda_window_set_property_from_config (self, "accelerator-paste"); + tilda_window_set_property_from_config (self, "accelerator-goto-1"); + tilda_window_set_property_from_config (self, "accelerator-goto-2"); + tilda_window_set_property_from_config (self, "accelerator-goto-3"); + tilda_window_set_property_from_config (self, "accelerator-goto-4"); + tilda_window_set_property_from_config (self, "accelerator-goto-5"); + tilda_window_set_property_from_config (self, "accelerator-goto-6"); + tilda_window_set_property_from_config (self, "accelerator-goto-7"); + tilda_window_set_property_from_config (self, "accelerator-goto-8"); + tilda_window_set_property_from_config (self, "accelerator-goto-9"); + tilda_window_set_property_from_config (self, "accelerator-goto-10"); + tilda_window_set_property_from_config (self, "height"); tilda_window_set_property_from_config (self, "width"); tilda_window_set_property_from_config (self, "x-position"); @@ -721,6 +1254,7 @@ tilda_window_dispose (GObject *obj) * NOTE: See the following for how to deal with GtkObject-derived things: * http://library.gnome.org/devel/gtk/unstable/GtkObject.html */ + g_object_unref (G_OBJECT(self->accel_group)); g_ptr_array_foreach (self->terms, g_object_unref, NULL); gtk_widget_destroy (self->window); @@ -792,6 +1326,176 @@ tilda_window_class_init (gpointer g_class, TILDA_WINDOW_CONTROLLER, pspec); + pspec = g_param_spec_string ("accelerator-quit", + _("Accelerator to quit this window"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_QUIT, + pspec); + + pspec = g_param_spec_string ("accelerator-next-tab", + _("Accelerator to go to the next tab"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_NEXT_TAB, + pspec); + + pspec = g_param_spec_string ("accelerator-previous-tab", + _("Accelerator to go to the previous tab"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_PREV_TAB, + pspec); + + pspec = g_param_spec_string ("accelerator-add-terminal", + _("Accelerator to add a terminal"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_ADD_TERM, + pspec); + + pspec = g_param_spec_string ("accelerator-remove-terminal", + _("Accelerator to remove a terminal"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_REMOVE_TERM, + pspec); + + pspec = g_param_spec_string ("accelerator-copy", + _("Accelerator to copy to the clipboard"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_COPY, + pspec); + + pspec = g_param_spec_string ("accelerator-paste", + _("Accelerator to paste from the clipboard"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_PASTE, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-1", + _("Accelerator to go to tab 1"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_1, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-2", + _("Accelerator to go to tab 2"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_2, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-3", + _("Accelerator to go to tab 3"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_3, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-4", + _("Accelerator to go to tab 4"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_4, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-5", + _("Accelerator to go to tab 5"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_5, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-6", + _("Accelerator to go to tab 6"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_6, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-7", + _("Accelerator to go to tab 7"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_7, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-8", + _("Accelerator to go to tab 8"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_8, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-9", + _("Accelerator to go to tab 9"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_9, + pspec); + + pspec = g_param_spec_string ("accelerator-goto-10", + _("Accelerator to go to tab 10"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_WINDOW_ACCEL_GOTO_10, + pspec); + pspec = g_param_spec_string ("key", _("Window's drop-down keybinding"), NULL, diff --git a/tilda-window.h b/tilda-window.h index 54bc2af..2af640c 100644 --- a/tilda-window.h +++ b/tilda-window.h @@ -41,6 +41,26 @@ struct _TildaWindow { GtkWidget *notebook; GPtrArray *terms; + /* Accelerator-related instance members */ + GtkAccelGroup *accel_group; + gchar *accel_quit; + gchar *accel_next_tab; + gchar *accel_prev_tab; + gchar *accel_add_term; + gchar *accel_remove_term; + gchar *accel_copy; + gchar *accel_paste; + gchar *accel_goto_1; + gchar *accel_goto_2; + gchar *accel_goto_3; + gchar *accel_goto_4; + gchar *accel_goto_5; + gchar *accel_goto_6; + gchar *accel_goto_7; + gchar *accel_goto_8; + gchar *accel_goto_9; + gchar *accel_goto_10; + gint number; GObject *controller; /* pointer back to TildaController */ enum window_states { WINDOW_UP, WINDOW_DOWN } state;