Commit 68763a92 authored by Rodrigo Moya's avatar Rodrigo Moya
Browse files

region: Add code to manage the new Formats tab

parent 298a9555
......@@ -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 \
......
......@@ -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
......
/*
* 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);
}
/*
* 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
......@@ -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>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment