[gnome-control-center] region: Add code to manage the new Formats tab
- From: Rodrigo Moya <rodrigo src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] region: Add code to manage the new Formats tab
- Date: Tue, 14 Jun 2011 17:03:11 +0000 (UTC)
commit 68763a928bf98065e83c9586f8460493dc05247b
Author: Rodrigo Moya <rodrigo gnome-db org>
Date: Tue Jun 14 17:39:41 2011 +0200
region: Add code to manage the new Formats tab
panels/region/Makefile.am | 2 +
panels/region/cc-region-panel.c | 2 +
panels/region/gnome-region-panel-formats.c | 103 +++++++++++++++
panels/region/gnome-region-panel-formats.h | 29 ++++
panels/region/gnome-region-panel.ui | 195 +++++++++++++++++++++++++--
5 files changed, 316 insertions(+), 15 deletions(-)
---
diff --git a/panels/region/Makefile.am b/panels/region/Makefile.am
index 83cfea2..3222a8c 100644
--- a/panels/region/Makefile.am
+++ b/panels/region/Makefile.am
@@ -17,6 +17,8 @@ libregion_la_SOURCES = \
region-module.c \
cc-region-panel.c \
cc-region-panel.h \
+ gnome-region-panel-formats.c \
+ gnome-region-panel-formats.h \
gnome-region-panel-lang.c \
gnome-region-panel-lang.h \
gnome-region-panel-xkb.c \
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 06d57f1..2519374 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -24,6 +24,7 @@
#include "gnome-region-panel-xkb.h"
#include "gnome-region-panel-lang.h"
+#include "gnome-region-panel-formats.h"
#define WID(s) GTK_WIDGET (gtk_builder_get_object (dialog, s))
@@ -120,6 +121,7 @@ cc_region_panel_init (CcRegionPanel * self)
setup_xkb_tabs (priv->builder);
setup_language (priv->builder);
+ setup_formats (priv->builder);
}
void
diff --git a/panels/region/gnome-region-panel-formats.c b/panels/region/gnome-region-panel-formats.c
new file mode 100644
index 0000000..2b59fda
--- /dev/null
+++ b/panels/region/gnome-region-panel-formats.c
@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2011 Rodrigo Moya
+ *
+ * Written by: Rodrigo Moya <rodrigo gnome org>
+ *
+ * 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, 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <locale.h>
+#include "cc-common-language.h"
+#include "gdm-languages.h"
+#include "gnome-region-panel-formats.h"
+
+static void
+selection_changed_cb (GtkComboBox *combo, gpointer user_data)
+{
+ const gchar *active_id, *locale;
+ GDateTime *dt;
+ gchar *s;
+ struct lconv *num_info;
+ GtkBuilder *builder = GTK_BUILDER (user_data);
+
+ active_id = gtk_combo_box_get_active_id (combo);
+ if (!active_id)
+ return;
+
+ locale = setlocale (LC_ALL, active_id);
+
+ dt = g_date_time_new_now_local ();
+
+ /* Display dates */
+ s = g_date_time_format (dt, "%x");
+ gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "shortest_day_format")), s);
+ g_free (s);
+
+ /* Display times */
+ s = g_date_time_format (dt, "%r");
+ gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "full_time_format")), s);
+ g_free (s);
+
+ s = g_date_time_format (dt, "%R");
+ gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "short_time_format")), s);
+ g_free (s);
+
+ /* Display numbers */
+ s = g_strdup_printf ("%'.2f", 123456789.00);
+ gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "numbers_format")), s);
+ g_free (s);
+
+ /* Display currency and measurement */
+ num_info = localeconv ();
+ if (num_info != NULL) {
+ gtk_label_set_text (GTK_LABEL (gtk_builder_get_object (builder, "currency_format")), num_info->currency_symbol);
+ }
+
+ setlocale (LC_ALL, locale);
+}
+
+void
+setup_formats (GtkBuilder *builder)
+{
+ GtkWidget *combo;
+ gchar **langs, *language, *current_lang;
+ gint i;
+
+ /* Setup formats selector */
+ combo = GTK_WIDGET (gtk_builder_get_object (builder, "region_selector"));
+ gtk_combo_box_set_id_column (GTK_COMBO_BOX (combo), 1);
+
+ langs = gdm_get_all_language_names ();
+ for (i = 0; langs[i] != NULL; i++) {
+ language = gdm_get_language_from_name (langs[i], NULL);
+ /* FIXME: sort while adding */
+ gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (combo), langs[i], language);
+
+ g_free (language);
+
+ }
+
+ g_signal_connect (G_OBJECT (combo), "changed",
+ G_CALLBACK (selection_changed_cb), builder);
+
+ current_lang = cc_common_language_get_current_language ();
+ gtk_combo_box_set_active_id (GTK_COMBO_BOX (combo), current_lang);
+ g_free (current_lang);
+}
diff --git a/panels/region/gnome-region-panel-formats.h b/panels/region/gnome-region-panel-formats.h
new file mode 100644
index 0000000..91200da
--- /dev/null
+++ b/panels/region/gnome-region-panel-formats.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2011 Rodrigo Moya
+ *
+ * Written by: Rodrigo Moya <rodrigo gnome org>
+ *
+ * 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, 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.
+ */
+
+#ifndef __GNOME_REGION_PANEL_FORMATS_H
+#define __GNOME_REGION_PANEL_FORMATS_H
+
+#include <gtk/gtk.h>
+
+void setup_formats (GtkBuilder *builder);
+
+#endif
diff --git a/panels/region/gnome-region-panel.ui b/panels/region/gnome-region-panel.ui
index 4188367..0431009 100644
--- a/panels/region/gnome-region-panel.ui
+++ b/panels/region/gnome-region-panel.ui
@@ -236,8 +236,6 @@
<property name="can_focus">False</property>
<property name="n_rows">9</property>
<property name="n_columns">2</property>
- <property name="column_spacing">3</property>
- <property name="row_spacing">3</property>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
@@ -265,43 +263,210 @@
<placeholder/>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="full_date_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="full_day_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="short_day_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="shortest_day_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Times</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="full_time_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="short_time_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label9">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Numbers</property>
+ </object>
+ <packing>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="numbers_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Currency</property>
+ </object>
+ <packing>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="currency_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">7</property>
+ <property name="bottom_attach">8</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="label11">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Measurement</property>
+ </object>
+ <packing>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
<child>
- <placeholder/>
+ <object class="GtkLabel" id="measurement_format">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">8</property>
+ <property name="bottom_attach">9</property>
+ <property name="y_options">GTK_FILL</property>
+ <property name="x_padding">3</property>
+ <property name="y_padding">3</property>
+ </packing>
</child>
</object>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]