2010-05-21 23:22:29 +01:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*
|
2010-05-22 12:13:24 +01:00
|
|
|
* Author: Sergey Udaltsov <svu@gnome.org>
|
2010-05-21 23:22:29 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-10-31 23:24:40 -04:00
|
|
|
#include "cc-region-panel.h"
|
2013-01-04 16:04:21 +01:00
|
|
|
#include "cc-region-resources.h"
|
|
|
|
|
2010-05-21 23:22:29 +01:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2012-05-16 23:05:00 +02:00
|
|
|
#include "gnome-region-panel-input.h"
|
2011-01-24 18:35:21 +00:00
|
|
|
#include "gnome-region-panel-lang.h"
|
2011-06-14 17:39:41 +02:00
|
|
|
#include "gnome-region-panel-formats.h"
|
2011-07-04 12:25:43 +02:00
|
|
|
#include "gnome-region-panel-system.h"
|
2011-01-21 18:06:26 +00:00
|
|
|
|
2012-08-21 14:29:22 -04:00
|
|
|
CC_PANEL_REGISTER (CcRegionPanel, cc_region_panel)
|
2011-01-21 18:06:26 +00:00
|
|
|
|
|
|
|
#define REGION_PANEL_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_REGION_PANEL, CcRegionPanelPrivate))
|
|
|
|
|
2010-10-31 23:24:40 -04:00
|
|
|
struct _CcRegionPanelPrivate {
|
2010-05-21 23:22:29 +01:00
|
|
|
GtkBuilder *builder;
|
|
|
|
};
|
|
|
|
|
2011-09-08 17:23:10 +01:00
|
|
|
enum {
|
|
|
|
PROP_0,
|
|
|
|
PROP_ARGV
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
LANGUAGE_PAGE,
|
|
|
|
FORMATS_PAGE,
|
|
|
|
LAYOUTS_PAGE,
|
|
|
|
SYSTEM_PAGE
|
|
|
|
};
|
2010-05-21 23:22:29 +01:00
|
|
|
|
|
|
|
static void
|
2011-09-08 17:23:10 +01:00
|
|
|
cc_region_panel_set_page (CcRegionPanel *panel,
|
|
|
|
const char *page)
|
2010-05-21 23:22:29 +01:00
|
|
|
{
|
2011-09-08 17:23:10 +01:00
|
|
|
GtkWidget *notebook;
|
|
|
|
int page_num;
|
|
|
|
|
|
|
|
if (g_strcmp0 (page, "formats") == 0)
|
|
|
|
page_num = FORMATS_PAGE;
|
|
|
|
else if (g_strcmp0 (page, "layouts") == 0)
|
|
|
|
page_num = LAYOUTS_PAGE;
|
|
|
|
else if (g_strcmp0 (page, "system") == 0)
|
|
|
|
page_num = SYSTEM_PAGE;
|
|
|
|
else
|
|
|
|
page_num = LANGUAGE_PAGE;
|
|
|
|
|
|
|
|
notebook = GTK_WIDGET (gtk_builder_get_object (panel->priv->builder, "region_notebook"));
|
|
|
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page_num);
|
2010-05-21 23:22:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-31 23:24:40 -04:00
|
|
|
cc_region_panel_set_property (GObject * object,
|
2011-09-08 17:23:10 +01:00
|
|
|
guint property_id,
|
|
|
|
const GValue * value,
|
|
|
|
GParamSpec * pspec)
|
2010-05-21 23:22:29 +01:00
|
|
|
{
|
2011-09-08 17:23:10 +01:00
|
|
|
CcRegionPanel *self;
|
|
|
|
|
|
|
|
self = CC_REGION_PANEL (object);
|
|
|
|
|
2010-05-21 23:22:29 +01:00
|
|
|
switch (property_id) {
|
2011-09-08 17:23:10 +01:00
|
|
|
case PROP_ARGV: {
|
|
|
|
gchar **args;
|
|
|
|
|
|
|
|
args = g_value_get_boxed (value);
|
|
|
|
|
|
|
|
if (args && args[0]) {
|
|
|
|
cc_region_panel_set_page (self, args[0]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-05-21 23:22:29 +01:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
|
|
|
|
pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-09-08 17:23:10 +01:00
|
|
|
cc_region_panel_finalize (GObject * object)
|
2010-05-21 23:22:29 +01:00
|
|
|
{
|
2011-09-08 17:23:10 +01:00
|
|
|
CcRegionPanel *panel;
|
2010-05-21 23:22:29 +01:00
|
|
|
|
2011-09-08 17:23:10 +01:00
|
|
|
panel = CC_REGION_PANEL (object);
|
2010-05-21 23:22:29 +01:00
|
|
|
|
2011-09-08 17:23:10 +01:00
|
|
|
if (panel->priv && panel->priv->builder)
|
|
|
|
g_object_unref (panel->priv->builder);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (cc_region_panel_parent_class)->finalize (object);
|
2010-05-21 23:22:29 +01:00
|
|
|
}
|
|
|
|
|
2012-05-18 17:06:51 +02:00
|
|
|
static const char *
|
|
|
|
cc_region_panel_get_help_uri (CcPanel *panel)
|
|
|
|
{
|
|
|
|
return "help:gnome-help/prefs-language";
|
|
|
|
}
|
|
|
|
|
2010-05-21 23:22:29 +01:00
|
|
|
static void
|
2010-10-31 23:24:40 -04:00
|
|
|
cc_region_panel_class_init (CcRegionPanelClass * klass)
|
2010-05-21 23:22:29 +01:00
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2012-05-18 17:06:51 +02:00
|
|
|
CcPanelClass * panel_class = CC_PANEL_CLASS (klass);
|
2010-05-21 23:22:29 +01:00
|
|
|
|
2010-10-31 23:24:40 -04:00
|
|
|
g_type_class_add_private (klass, sizeof (CcRegionPanelPrivate));
|
2010-05-21 23:22:29 +01:00
|
|
|
|
2012-05-18 17:06:51 +02:00
|
|
|
panel_class->get_help_uri = cc_region_panel_get_help_uri;
|
|
|
|
|
2010-10-31 23:24:40 -04:00
|
|
|
object_class->set_property = cc_region_panel_set_property;
|
2011-09-08 17:23:10 +01:00
|
|
|
object_class->finalize = cc_region_panel_finalize;
|
|
|
|
|
|
|
|
g_object_class_override_property (object_class, PROP_ARGV, "argv");
|
2010-05-21 23:22:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-10-31 23:24:40 -04:00
|
|
|
cc_region_panel_init (CcRegionPanel * self)
|
2010-05-21 23:22:29 +01:00
|
|
|
{
|
2010-10-31 23:24:40 -04:00
|
|
|
CcRegionPanelPrivate *priv;
|
2010-05-21 23:22:29 +01:00
|
|
|
GtkWidget *prefs_widget;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
2010-10-31 23:24:40 -04:00
|
|
|
priv = self->priv = REGION_PANEL_PRIVATE (self);
|
2013-01-04 16:04:21 +01:00
|
|
|
g_resources_register (cc_region_get_resource ());
|
2010-05-21 23:22:29 +01:00
|
|
|
|
|
|
|
priv->builder = gtk_builder_new ();
|
|
|
|
|
2013-01-04 16:04:21 +01:00
|
|
|
gtk_builder_add_from_resource (priv->builder,
|
|
|
|
"/org/gnome/control-center/region/gnome-region-panel.ui",
|
|
|
|
&error);
|
2010-05-21 23:22:29 +01:00
|
|
|
if (error != NULL) {
|
|
|
|
g_warning ("Error loading UI file: %s", error->message);
|
2011-02-21 19:16:47 +00:00
|
|
|
g_error_free (error);
|
2010-05-21 23:22:29 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
|
2010-10-31 23:24:40 -04:00
|
|
|
"region_notebook");
|
2011-01-21 18:06:26 +00:00
|
|
|
gtk_widget_set_size_request (GTK_WIDGET (prefs_widget), -1, 400);
|
2010-05-21 23:22:29 +01:00
|
|
|
|
|
|
|
gtk_widget_reparent (prefs_widget, GTK_WIDGET (self));
|
2011-01-25 18:44:21 +00:00
|
|
|
|
2012-05-16 23:05:00 +02:00
|
|
|
setup_input_tabs (priv->builder, self);
|
2011-01-25 18:44:21 +00:00
|
|
|
setup_language (priv->builder);
|
2011-06-14 17:39:41 +02:00
|
|
|
setup_formats (priv->builder);
|
2011-07-04 12:25:43 +02:00
|
|
|
setup_system (priv->builder);
|
2010-05-21 23:22:29 +01:00
|
|
|
}
|