region: Move preview of format to a widget
This commit is contained in:
parent
0dce812e18
commit
ddfd582b72
8 changed files with 467 additions and 275 deletions
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "list-box-helper.h"
|
||||
#include "cc-common-language.h"
|
||||
#include "cc-format-preview.h"
|
||||
#include "cc-util.h"
|
||||
|
||||
#define GNOME_DESKTOP_USE_UNSTABLE_API
|
||||
|
@ -53,12 +54,7 @@ struct _CcFormatChooser {
|
|||
GtkWidget *common_region_listbox;
|
||||
GtkWidget *region_title;
|
||||
GtkWidget *region_listbox;
|
||||
GtkWidget *date_format_label;
|
||||
GtkWidget *time_format_label;
|
||||
GtkWidget *date_time_format_label;
|
||||
GtkWidget *number_format_label;
|
||||
GtkWidget *measurement_format_label;
|
||||
GtkWidget *paper_format_label;
|
||||
CcFormatPreview *format_preview;
|
||||
gboolean adding;
|
||||
gboolean showing_extra;
|
||||
gboolean no_results;
|
||||
|
@ -69,110 +65,6 @@ struct _CcFormatChooser {
|
|||
|
||||
G_DEFINE_TYPE (CcFormatChooser, cc_format_chooser, GTK_TYPE_DIALOG)
|
||||
|
||||
static void
|
||||
display_date (GtkWidget *label, GDateTime *dt, const gchar *format)
|
||||
{
|
||||
g_autofree gchar *s = g_date_time_format (dt, format);
|
||||
gtk_label_set_text (GTK_LABEL (label), g_strstrip (s));
|
||||
}
|
||||
|
||||
static void
|
||||
update_format_examples (CcFormatChooser *chooser,
|
||||
const gchar *region)
|
||||
{
|
||||
locale_t locale;
|
||||
locale_t old_locale;
|
||||
g_autoptr(GDateTime) dt = NULL;
|
||||
g_autofree gchar *s = NULL;
|
||||
const gchar *fmt;
|
||||
g_autoptr(GtkPaperSize) paper = NULL;
|
||||
|
||||
if (!region || !*region)
|
||||
return;
|
||||
|
||||
locale = newlocale (LC_TIME_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
dt = g_date_time_new_now_local ();
|
||||
display_date (chooser->date_format_label, dt, "%x");
|
||||
display_date (chooser->time_format_label, dt, "%X");
|
||||
display_date (chooser->date_time_format_label, dt, "%c");
|
||||
|
||||
if (locale != (locale_t) 0) {
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
|
||||
locale = newlocale (LC_NUMERIC_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
s = g_strdup_printf ("%'.2f", 123456789.00);
|
||||
gtk_label_set_text (GTK_LABEL (chooser->number_format_label), s);
|
||||
|
||||
if (locale != (locale_t) 0) {
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
|
||||
#if 0
|
||||
locale = newlocale (LC_MONETARY_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
num_info = localeconv ();
|
||||
if (num_info != NULL)
|
||||
gtk_label_set_text (GTK_LABEL (chooser->currency_format_label), num_info->currency_symbol);
|
||||
|
||||
if (locale != (locale_t) 0) {
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LC_MEASUREMENT
|
||||
locale = newlocale (LC_MEASUREMENT_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
fmt = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
|
||||
if (fmt && *fmt == 2)
|
||||
gtk_label_set_text (GTK_LABEL (chooser->measurement_format_label), C_("measurement format", "Imperial"));
|
||||
else
|
||||
gtk_label_set_text (GTK_LABEL (chooser->measurement_format_label), C_("measurement format", "Metric"));
|
||||
|
||||
if (locale != (locale_t) 0) {
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LC_PAPER
|
||||
locale = newlocale (LC_PAPER_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
paper = gtk_paper_size_new (gtk_paper_size_get_default ());
|
||||
gtk_label_set_text (GTK_LABEL (chooser->paper_format_label), gtk_paper_size_get_display_name (paper));
|
||||
|
||||
if (locale != (locale_t) 0) {
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
update_check_button_for_list (GtkWidget *list_box,
|
||||
const gchar *locale_id)
|
||||
|
@ -207,7 +99,7 @@ set_locale_id (CcFormatChooser *chooser,
|
|||
|
||||
update_check_button_for_list (chooser->region_listbox, locale_id);
|
||||
update_check_button_for_list (chooser->common_region_listbox, locale_id);
|
||||
update_format_examples (chooser, locale_id);
|
||||
cc_format_preview_set_region (chooser->format_preview, locale_id);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -293,7 +185,7 @@ format_chooser_leaflet_fold_changed_cb (CcFormatChooser *self)
|
|||
|
||||
if (!folded)
|
||||
{
|
||||
update_format_examples (self, self->region);
|
||||
cc_format_preview_set_region (self->format_preview, self->region);
|
||||
gtk_header_bar_set_title (GTK_HEADER_BAR (self->title_bar), _("Formats"));
|
||||
hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "region-list");
|
||||
gtk_stack_set_visible_child (GTK_STACK (self->title_buttons), self->cancel_button);
|
||||
|
@ -316,7 +208,7 @@ preview_button_clicked_cb (CcFormatChooser *self,
|
|||
|
||||
region = g_object_get_data (G_OBJECT (row), "locale-id");
|
||||
locale_name = g_object_get_data (G_OBJECT (row), "locale-name");
|
||||
update_format_examples (self, region);
|
||||
cc_format_preview_set_region (self->format_preview, region);
|
||||
|
||||
hdy_leaflet_set_visible_child_name (HDY_LEAFLET (self->main_leaflet), "preview");
|
||||
gtk_stack_set_visible_child (GTK_STACK (self->title_buttons), self->back_button);
|
||||
|
@ -568,6 +460,8 @@ cc_format_chooser_class_init (CcFormatChooserClass *klass)
|
|||
|
||||
object_class->dispose = cc_format_chooser_dispose;
|
||||
|
||||
g_type_ensure (CC_TYPE_FORMAT_PREVIEW);
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/region/cc-format-chooser.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, title_bar);
|
||||
|
@ -581,15 +475,10 @@ cc_format_chooser_class_init (CcFormatChooserClass *klass)
|
|||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, common_region_listbox);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_title);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_listbox);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, date_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, time_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, date_time_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, number_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, measurement_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, paper_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_list);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, region_list_stack);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, empty_results_view);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatChooser, format_preview);
|
||||
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_chooser_back_button_clicked_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, format_chooser_leaflet_fold_changed_cb);
|
||||
|
|
|
@ -284,22 +284,15 @@
|
|||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">1</property>
|
||||
<property name="width-request">300</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<style>
|
||||
<class name="view" />
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin">24</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="spacing">4</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin_top">24</property>
|
||||
<property name="margin_bottom">6</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="hexpand">True</property>
|
||||
|
@ -311,145 +304,14 @@
|
|||
</attributes>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Dates -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Dates</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="date_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">23 January 2013</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Times -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Times</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="time_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">11:31 AM</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Date & Times -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Dates & Times</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="date_time_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">Sun Wed 2 11:31:00 KST 2013</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Numbers -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Numbers</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="number_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">123,456,789.00</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Measurement -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Measurement</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="measurement_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">Metric</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Paper -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Paper</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="paper_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">A4</property>
|
||||
<object class="CcFormatPreview" id="format_preview">
|
||||
<property name="visible">1</property>
|
||||
<property name="width-request">300</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">preview</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
|
255
panels/region/cc-format-preview.c
Normal file
255
panels/region/cc-format-preview.c
Normal file
|
@ -0,0 +1,255 @@
|
|||
/* cc-format-preview.c
|
||||
*
|
||||
* Copyright (C) 2013 Red Hat, Inc.
|
||||
* Copyright (C) 2020 System76, 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Written by:
|
||||
* Matthias Clasen
|
||||
* Ian Douglas Scott <idscott@system76.com>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#include "cc-format-preview.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <locale.h>
|
||||
#include <langinfo.h>
|
||||
#include <string.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
struct _CcFormatPreview {
|
||||
GtkDialog parent_instance;
|
||||
|
||||
GtkWidget *date_format_label;
|
||||
GtkWidget *date_time_format_label;
|
||||
GtkWidget *measurement_format_label;
|
||||
GtkWidget *number_format_label;
|
||||
GtkWidget *paper_format_label;
|
||||
GtkWidget *time_format_label;
|
||||
|
||||
gchar *region;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_REGION
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (CcFormatPreview, cc_format_preview, GTK_TYPE_BOX)
|
||||
|
||||
static void
|
||||
display_date (GtkWidget *label, GDateTime *dt, const gchar *format)
|
||||
{
|
||||
g_autofree gchar *s = g_date_time_format (dt, format);
|
||||
gtk_label_set_text (GTK_LABEL (label), g_strstrip (s));
|
||||
}
|
||||
|
||||
static void
|
||||
update_format_examples (CcFormatPreview *self)
|
||||
{
|
||||
const gchar *region = self->region;
|
||||
locale_t locale;
|
||||
locale_t old_locale;
|
||||
g_autoptr(GDateTime) dt = NULL;
|
||||
g_autofree gchar *s = NULL;
|
||||
const gchar *fmt;
|
||||
g_autoptr(GtkPaperSize) paper = NULL;
|
||||
|
||||
if (region == NULL || region[0] == '\0')
|
||||
return;
|
||||
|
||||
locale = newlocale (LC_TIME_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
dt = g_date_time_new_now_local ();
|
||||
display_date (self->date_format_label, dt, "%x");
|
||||
display_date (self->time_format_label, dt, "%X");
|
||||
display_date (self->date_time_format_label, dt, "%c");
|
||||
|
||||
if (locale != (locale_t) 0)
|
||||
{
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
|
||||
locale = newlocale (LC_NUMERIC_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
s = g_strdup_printf ("%'.2f", 123456789.00);
|
||||
gtk_label_set_text (GTK_LABEL (self->number_format_label), s);
|
||||
|
||||
if (locale != (locale_t) 0)
|
||||
{
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
|
||||
#if 0
|
||||
locale = newlocale (LC_MONETARY_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
num_info = localeconv ();
|
||||
if (num_info != NULL)
|
||||
gtk_label_set_text (GTK_LABEL (self->currency_format_label), num_info->currency_symbol);
|
||||
|
||||
if (locale != (locale_t) 0)
|
||||
{
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LC_MEASUREMENT
|
||||
locale = newlocale (LC_MEASUREMENT_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
fmt = nl_langinfo (_NL_MEASUREMENT_MEASUREMENT);
|
||||
if (fmt && *fmt == 2)
|
||||
gtk_label_set_text (GTK_LABEL (self->measurement_format_label), C_("measurement format", "Imperial"));
|
||||
else
|
||||
gtk_label_set_text (GTK_LABEL (self->measurement_format_label), C_("measurement format", "Metric"));
|
||||
|
||||
if (locale != (locale_t) 0)
|
||||
{
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LC_PAPER
|
||||
locale = newlocale (LC_PAPER_MASK, region, (locale_t) 0);
|
||||
if (locale == (locale_t) 0)
|
||||
g_warning ("Failed to create locale %s: %s", region, g_strerror (errno));
|
||||
else
|
||||
old_locale = uselocale (locale);
|
||||
|
||||
paper = gtk_paper_size_new (gtk_paper_size_get_default ());
|
||||
gtk_label_set_text (GTK_LABEL (self->paper_format_label), gtk_paper_size_get_display_name (paper));
|
||||
|
||||
if (locale != (locale_t) 0)
|
||||
{
|
||||
uselocale (old_locale);
|
||||
freelocale (locale);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
cc_format_preview_set_property (GObject *object,
|
||||
guint prop_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CcFormatPreview *self;
|
||||
|
||||
self = CC_FORMAT_PREVIEW (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_REGION:
|
||||
cc_format_preview_set_region (self, g_value_get_string (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cc_format_preview_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CcFormatPreview *self;
|
||||
|
||||
self = CC_FORMAT_PREVIEW (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_REGION:
|
||||
g_value_set_string (value, self->region);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cc_format_preview_finalize (GObject *object)
|
||||
{
|
||||
CcFormatPreview *self = CC_FORMAT_PREVIEW (object);
|
||||
|
||||
g_clear_pointer (&self->region, g_free);
|
||||
|
||||
G_OBJECT_CLASS (cc_format_preview_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
void
|
||||
cc_format_preview_class_init (CcFormatPreviewClass *klass)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->get_property = cc_format_preview_get_property;
|
||||
object_class->set_property = cc_format_preview_set_property;
|
||||
object_class->finalize = cc_format_preview_finalize;
|
||||
|
||||
g_object_class_install_property (object_class,
|
||||
PROP_REGION,
|
||||
g_param_spec_string ("region",
|
||||
"region",
|
||||
"region",
|
||||
NULL,
|
||||
G_PARAM_READWRITE));
|
||||
|
||||
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/region/cc-format-preview.ui");
|
||||
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatPreview, date_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatPreview, date_time_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatPreview, measurement_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatPreview, number_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatPreview, paper_format_label);
|
||||
gtk_widget_class_bind_template_child (widget_class, CcFormatPreview, time_format_label);
|
||||
}
|
||||
|
||||
void
|
||||
cc_format_preview_init (CcFormatPreview *self)
|
||||
{
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
void
|
||||
cc_format_preview_set_region (CcFormatPreview *preview,
|
||||
const gchar *region)
|
||||
{
|
||||
g_free (preview->region);
|
||||
preview->region = g_strdup (region);
|
||||
update_format_examples (preview);
|
||||
}
|
38
panels/region/cc-format-preview.h
Normal file
38
panels/region/cc-format-preview.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* cc-format-preview.c
|
||||
*
|
||||
* Copyright (C) 2013 Red Hat, Inc.
|
||||
* Copyright (C) 2020 System76, 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Written by:
|
||||
* Matthias Clasen
|
||||
* Ian Douglas Scott <idscott@system76.com>
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define CC_TYPE_FORMAT_PREVIEW (cc_format_preview_get_type())
|
||||
G_DECLARE_FINAL_TYPE (CcFormatPreview, cc_format_preview, CC, FORMAT_PREVIEW, GtkBox)
|
||||
|
||||
void cc_format_preview_set_region (CcFormatPreview *preview,
|
||||
const gchar *region);
|
||||
|
||||
G_END_DECLS
|
143
panels/region/cc-format-preview.ui
Normal file
143
panels/region/cc-format-preview.ui
Normal file
|
@ -0,0 +1,143 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<!-- interface-requires gtk+ 3.0 -->
|
||||
<template class="CcFormatPreview" parent="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="margin">24</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="spacing">4</property>
|
||||
<property name="orientation">vertical</property>
|
||||
|
||||
<!-- Dates -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label" translatable="yes">Dates</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="date_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">23 January 2013</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Times -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Times</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="time_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">11:31 AM</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Date & Times -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Dates & Times</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="date_time_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">Sun Wed 2 11:31:00 KST 2013</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Numbers -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Numbers</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="number_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">123,456,789.00</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Measurement -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Measurement</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="measurement_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">Metric</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
<!-- Paper -->
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="margin-top">18</property>
|
||||
<property name="label" translatable="yes">Paper</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="paper_format_label">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">A4</property>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
|
@ -20,6 +20,7 @@ i18n.merge_file(
|
|||
sources = files(
|
||||
'cc-region-panel.c',
|
||||
'cc-format-chooser.c',
|
||||
'cc-format-preview.c',
|
||||
'cc-ibus-utils.c',
|
||||
'cc-input-chooser.c',
|
||||
'cc-input-row.c',
|
||||
|
@ -31,6 +32,7 @@ sources = files(
|
|||
|
||||
resource_data = files(
|
||||
'cc-format-chooser.ui',
|
||||
'cc-format-preview.ui',
|
||||
'cc-input-chooser.ui',
|
||||
'cc-region-panel.ui',
|
||||
'view-layout-symbolic.svg',
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
<file preprocess="xml-stripblanks">cc-input-row.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-input-list-box.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-region-panel.ui</file>
|
||||
<file preprocess="xml-stripblanks">cc-format-preview.ui</file>
|
||||
</gresource>
|
||||
<gresource prefix="/org/gnome/ControlCenter/icons/scalable/actions">
|
||||
<file>view-layout-symbolic.svg</file>
|
||||
|
|
|
@ -175,6 +175,8 @@ panels/printers/printer-entry.ui
|
|||
panels/printers/printers.ui
|
||||
panels/region/cc-format-chooser.c
|
||||
panels/region/cc-format-chooser.ui
|
||||
panels/region/cc-format-preview.c
|
||||
panels/region/cc-format-preview.ui
|
||||
panels/region/cc-input-chooser.c
|
||||
panels/region/cc-input-chooser.ui
|
||||
panels/region/cc-region-panel.c
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue