cc-region-panel.c 3.66 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 * Copyright (C) 2010 Intel, Inc
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
Sergey V. Udaltsov's avatar
Sergey V. Udaltsov committed
18
 * Author: Sergey Udaltsov <svu@gnome.org>
19
20
21
 *
 */

22
#include "cc-region-panel.h"
23
24
#include <gtk/gtk.h>

25
26
27
28
#include "gnome-region-panel-xkb.h"

#define WID(s) GTK_WIDGET (gtk_builder_get_object (dialog, s))

29
G_DEFINE_DYNAMIC_TYPE (CcRegionPanel, cc_region_panel, CC_TYPE_PANEL)
30
31
32

#define REGION_PANEL_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_REGION_PANEL, CcRegionPanelPrivate))

33
struct _CcRegionPanelPrivate {
34
35
36
37
38
	GtkBuilder *builder;
};


static void
39
cc_region_panel_get_property (GObject * object,
40
41
42
43
44
45
46
47
48
49
50
				guint property_id,
				GValue * value, GParamSpec * pspec)
{
	switch (property_id) {
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
						   pspec);
	}
}

static void
51
cc_region_panel_set_property (GObject * object,
52
53
54
55
56
57
58
59
60
61
62
				guint property_id,
				const GValue * value, GParamSpec * pspec)
{
	switch (property_id) {
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
						   pspec);
	}
}

static void
63
cc_region_panel_dispose (GObject * object)
64
{
65
	CcRegionPanelPrivate *priv = CC_REGION_PANEL (object)->priv;
66
67
68
69
70
71

	if (priv->builder) {
		g_object_unref (priv->builder);
		priv->builder = NULL;
	}

72
	G_OBJECT_CLASS (cc_region_panel_parent_class)->dispose (object);
73
74
75
}

static void
76
cc_region_panel_class_init (CcRegionPanelClass * klass)
77
78
79
{
	GObjectClass *object_class = G_OBJECT_CLASS (klass);

80
	g_type_class_add_private (klass, sizeof (CcRegionPanelPrivate));
81

82
83
84
	object_class->get_property = cc_region_panel_get_property;
	object_class->set_property = cc_region_panel_set_property;
	object_class->dispose = cc_region_panel_dispose;
85
86
87
}

static void
88
cc_region_panel_class_finalize (CcRegionPanelClass * klass)
89
90
91
{
}

92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
static void
setup_images (GtkBuilder * dialog)
{
	GtkWidget *image;

	image =
	    gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_BUTTON);
	gtk_button_set_image (GTK_BUTTON (WID ("xkb_layouts_add")), image);

	image =
	    gtk_image_new_from_stock (GTK_STOCK_REFRESH,
				      GTK_ICON_SIZE_BUTTON);
	gtk_button_set_image (GTK_BUTTON (WID ("xkb_reset_to_defaults")),
			      image);
}
107
108

static void
109
cc_region_panel_init (CcRegionPanel * self)
110
{
111
	CcRegionPanelPrivate *priv;
112
113
114
	GtkWidget *prefs_widget;
	GError *error = NULL;

115
	priv = self->priv = REGION_PANEL_PRIVATE (self);
116
117
118
119
120

	priv->builder = gtk_builder_new ();

	gtk_builder_add_from_file (priv->builder,
				   GNOMECC_UI_DIR
121
				   "/gnome-region-panel.ui",
122
123
124
125
126
127
				   &error);
	if (error != NULL) {
		g_warning ("Error loading UI file: %s", error->message);
		return;
	}

128
129
	setup_images (priv->builder);
	setup_xkb_tabs (priv->builder);
130
131

	prefs_widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
132
							     "region_notebook");
133
	gtk_widget_set_size_request (GTK_WIDGET (prefs_widget), -1, 400);
134
135
136
137
138

	gtk_widget_reparent (prefs_widget, GTK_WIDGET (self));
}

void
139
cc_region_panel_register (GIOModule * module)
140
{
141
	cc_region_panel_register_type (G_TYPE_MODULE (module));
142
	g_io_extension_point_implement (CC_SHELL_PANEL_EXTENSION_POINT,
143
144
					CC_TYPE_REGION_PANEL,
					"region", 0);
145
}