2
* Copyright (C) 2010 Intel, Inc
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
* Author: Thomas Wood <thomas.wood@intel.com>
22
#include "cc-keyboard-panel.h"
23
#include "keyboard-general.h"
24
#include "keyboard-shortcuts.h"
26
CC_PANEL_REGISTER (CcKeyboardPanel, cc_keyboard_panel)
28
#define KEYBOARD_PANEL_PRIVATE(o) \
29
(G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_KEYBOARD_PANEL, CcKeyboardPanelPrivate))
31
struct _CcKeyboardPanelPrivate
38
cc_keyboard_panel_get_property (GObject *object,
46
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
61
cc_keyboard_panel_set_page (CcKeyboardPanel *panel,
68
if (g_strcmp0 (page, "typing") == 0)
69
page_num = TYPING_PAGE;
70
else if (g_strcmp0 (page, "shortcuts") == 0)
71
page_num = SHORTCUTS_PAGE;
73
g_warning ("Could not switch to non-existent page '%s'", page);
77
notebook = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "keyboard_notebook"));
78
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
80
if (page_num == SHORTCUTS_PAGE &&
82
keyboard_shortcuts_set_section (CC_PANEL (panel), section);
87
cc_keyboard_panel_set_property (GObject *object,
92
CcKeyboardPanel *panel = CC_KEYBOARD_PANEL (object);
99
args = g_value_get_boxed (value);
101
if (args && args[0]) {
102
cc_keyboard_panel_set_page (panel, args[0], args[1]);
108
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
113
cc_keyboard_panel_constructor (GType gtype,
115
GObjectConstructParam *properties)
118
CcKeyboardPanel *self;
119
CcKeyboardPanelPrivate *priv;
122
obj = G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->constructor (gtype, n_properties, properties);
124
self = CC_KEYBOARD_PANEL (obj);
127
keyboard_general_init (CC_PANEL (self), priv->builder);
128
keyboard_shortcuts_init (CC_PANEL (self), priv->builder);
130
widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
131
"keyboard_notebook");
133
gtk_widget_reparent (widget, (GtkWidget *) self);
139
cc_keyboard_panel_get_help_uri (CcPanel *panel)
141
return "help:gnome-help/keyboard";
145
cc_keyboard_panel_dispose (GObject *object)
147
keyboard_general_dispose (CC_PANEL (object));
148
keyboard_shortcuts_dispose (CC_PANEL (object));
150
G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->dispose (object);
154
cc_keyboard_panel_finalize (GObject *object)
156
CcKeyboardPanel *panel = CC_KEYBOARD_PANEL (object);
158
if (panel->priv->builder)
159
g_object_unref (panel->priv->builder);
161
G_OBJECT_CLASS (cc_keyboard_panel_parent_class)->finalize (object);
165
cc_keyboard_panel_class_init (CcKeyboardPanelClass *klass)
167
GObjectClass *object_class = G_OBJECT_CLASS (klass);
168
CcPanelClass *panel_class = CC_PANEL_CLASS (klass);
170
g_type_class_add_private (klass, sizeof (CcKeyboardPanelPrivate));
172
panel_class->get_help_uri = cc_keyboard_panel_get_help_uri;
174
object_class->constructor = cc_keyboard_panel_constructor;
175
object_class->get_property = cc_keyboard_panel_get_property;
176
object_class->set_property = cc_keyboard_panel_set_property;
177
object_class->dispose = cc_keyboard_panel_dispose;
178
object_class->finalize = cc_keyboard_panel_finalize;
180
g_object_class_override_property (object_class, PROP_ARGV, "argv");
184
cc_keyboard_panel_init (CcKeyboardPanel *self)
186
const gchar *uifile = GNOMECC_UI_DIR "/gnome-keyboard-panel.ui";
187
CcKeyboardPanelPrivate *priv;
188
GError *error = NULL;
190
priv = self->priv = KEYBOARD_PANEL_PRIVATE (self);
192
priv->builder = gtk_builder_new ();
194
if (gtk_builder_add_from_file (priv->builder, uifile, &error) == 0)
196
g_warning ("Could not load UI: %s", error->message);
197
g_clear_error (&error);
198
g_object_unref (priv->builder);
199
priv->builder = NULL;
204
cc_keyboard_panel_register (GIOModule *module)
206
cc_keyboard_panel_register_type (G_TYPE_MODULE (module));
207
g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
208
CC_TYPE_KEYBOARD_PANEL,