[gnome-control-center/wip/region-panel: 1/7] Wip region



commit df84eb6f5d1faf0251341e7ef16309978f868247
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jan 26 14:53:40 2013 -0500

    Wip region

 panels/region/cc-region-panel.c    |  295 +++++++++++++++++++++++++++---------
 panels/region/region.gresource.xml |    1 +
 panels/region/region.ui            |   19 +++
 3 files changed, 244 insertions(+), 71 deletions(-)
---
diff --git a/panels/region/cc-region-panel.c b/panels/region/cc-region-panel.c
index 6e59e7f..f271208 100644
--- a/panels/region/cc-region-panel.c
+++ b/panels/region/cc-region-panel.c
@@ -19,6 +19,9 @@
  *
  */
 
+#include <config.h>
+#include <glib/gi18n.h>
+
 #include "cc-region-panel.h"
 #include "cc-region-resources.h"
 
@@ -29,84 +32,47 @@
 #include "gnome-region-panel-formats.h"
 #include "gnome-region-panel-system.h"
 
+#include "egg-list-box/egg-list-box.h"
+
 CC_PANEL_REGISTER (CcRegionPanel, cc_region_panel)
 
 #define REGION_PANEL_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), CC_TYPE_REGION_PANEL, CcRegionPanelPrivate))
 
 struct _CcRegionPanelPrivate {
 	GtkBuilder *builder;
-};
 
-enum {
-	PROP_0,
-	PROP_ARGV
+        GtkWidget *login_button;
+        GtkWidget *language_row;
+        GtkWidget *formats_row;
+        GtkWidget *options_button;
+        GtkWidget *input_source_list;
 };
 
-enum {
-	LANGUAGE_PAGE,
-	FORMATS_PAGE,
-	LAYOUTS_PAGE,
-	SYSTEM_PAGE
-};
-
-static void
-cc_region_panel_set_page (CcRegionPanel *panel,
-			  const char    *page)
-{
-	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);
-}
-
 static void
-cc_region_panel_set_property (GObject * object,
-			      guint property_id,
-			      const GValue * value,
-			      GParamSpec * pspec)
+cc_region_panel_finalize (GObject * object)
 {
-	CcRegionPanel *self;
-
-	self = CC_REGION_PANEL (object);
+	CcRegionPanel *panel;
 
-	switch (property_id) {
-        case PROP_ARGV: {
-                gchar **args;
+	panel = CC_REGION_PANEL (object);
 
-                args = g_value_get_boxed (value);
+	if (panel->priv && panel->priv->builder)
+		g_object_unref (panel->priv->builder);
 
-                if (args && args[0]) {
-                        cc_region_panel_set_page (self, args[0]);
-                }
-                break;
-        }
-	default:
-		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id,
-						   pspec);
-	}
+	G_OBJECT_CLASS (cc_region_panel_parent_class)->finalize (object);
 }
 
 static void
-cc_region_panel_finalize (GObject * object)
+cc_region_panel_constructed (GObject *object)
 {
-	CcRegionPanel *panel;
+        CcRegionPanel *self = CC_REGION_PANEL (object);
 
-	panel = CC_REGION_PANEL (object);
+        G_OBJECT_CLASS (cc_region_panel_parent_class)->constructed (object);
 
-	if (panel->priv && panel->priv->builder)
-		g_object_unref (panel->priv->builder);
+        self->priv->login_button = gtk_button_new_with_label (_("Login Screen"));
 
-	G_OBJECT_CLASS (cc_region_panel_parent_class)->finalize (object);
+        cc_shell_embed_widget_in_header (cc_panel_get_shell (CC_PANEL (object)),
+                                         self->priv->login_button);
+        gtk_widget_show_all (self->priv->login_button);
 }
 
 static const char *
@@ -125,17 +91,209 @@ cc_region_panel_class_init (CcRegionPanelClass * klass)
 
 	panel_class->get_help_uri = cc_region_panel_get_help_uri;
 
-	object_class->set_property = cc_region_panel_set_property;
+        object_class->constructed = cc_region_panel_constructed;
 	object_class->finalize = cc_region_panel_finalize;
+}
 
-	g_object_class_override_property (object_class, PROP_ARGV, "argv");
+static void
+update_separator_func (GtkWidget **separator,
+                       GtkWidget  *child,
+                       GtkWidget  *before,
+                       gpointer    user_data)
+{
+  if (before == NULL)
+    return;
+
+  if (*separator == NULL)
+    {
+      *separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+      g_object_ref_sink (*separator);
+      gtk_widget_show (*separator);
+    }
+}
+
+static void
+activate_input_child (CcRegionPanel *self, GtkWidget child)
+{
 }
 
 static void
-cc_region_panel_init (CcRegionPanel * self)
+add_language_section (CcRegionPanel *self)
+{
+	CcRegionPanelPrivate *priv = self->priv;
+        GtkWidget *vbox;
+        GtkWidget *frame;
+        GtkWidget *widget;
+        GtkWidget *row;
+        GtkWidget *label;
+
+        vbox = GTK_WIDGET (gtk_builder_get_object (priv->builder, "vbox_region"));
+
+        widget = GTK_WIDGET (egg_list_box_new ());
+        egg_list_box_set_selection_mode (EGG_LIST_BOX (widget),
+                                         GTK_SELECTION_NONE);
+        egg_list_box_set_separator_funcs (EGG_LIST_BOX (widget),
+                                          update_separator_func,
+                                          NULL, NULL);
+        g_signal_connect_swapped (widget, "child-activated",
+                                  G_CALLBACK (activate_input_child), self);
+
+
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+        gtk_widget_set_margin_left (frame, 134);
+        gtk_widget_set_margin_right (frame, 134);
+        gtk_widget_set_margin_bottom (frame, 22);
+
+        gtk_container_add (GTK_CONTAINER (frame), widget);
+        gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, TRUE, 0);
+
+        priv->language_row = row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+        gtk_container_add (GTK_CONTAINER (widget), priv->language_row);
+        label = gtk_label_new (_("Language"));
+        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+        gtk_widget_set_margin_left (label, 20);
+        gtk_widget_set_margin_right (label, 20);
+        gtk_widget_set_margin_top (label, 6);
+        gtk_widget_set_margin_bottom (label, 6);
+        gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
+
+        label = gtk_label_new ("English (United Kingdom)");
+        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
+        gtk_widget_set_margin_left (label, 20);
+        gtk_widget_set_margin_right (label, 20);
+        gtk_widget_set_margin_top (label, 6);
+        gtk_widget_set_margin_bottom (label, 6);
+        gtk_box_pack_start (GTK_BOX (row), label, FALSE, TRUE, 0);
+
+        priv->formats_row = row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+        gtk_container_add (GTK_CONTAINER (widget), priv->formats_row);
+        label = gtk_label_new (_("Formats"));
+        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+        gtk_widget_set_margin_left (label, 20);
+        gtk_widget_set_margin_right (label, 20);
+        gtk_widget_set_margin_top (label, 6);
+        gtk_widget_set_margin_bottom (label, 6);
+        gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
+
+        label = gtk_label_new ("United Kingdom");
+        gtk_misc_set_alignment (GTK_MISC (label), 1, 0.5);
+        gtk_widget_set_margin_left (label, 20);
+        gtk_widget_set_margin_right (label, 20);
+        gtk_widget_set_margin_top (label, 6);
+        gtk_widget_set_margin_bottom (label, 6);
+        gtk_box_pack_start (GTK_BOX (row), label, FALSE, TRUE, 0);
+
+        gtk_widget_show_all (frame);
+}
+
+static void
+add_keyboard_layout_row (CcRegionPanel *self, const gchar *name)
+{
+        GtkWidget *row;
+        GtkWidget *label;
+
+        row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+        label = gtk_label_new (name);
+        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+        gtk_widget_set_margin_left (label, 20);
+        gtk_widget_set_margin_right (label, 20);
+        gtk_widget_set_margin_top (label, 6);
+        gtk_widget_set_margin_bottom (label, 6);
+        gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
+        gtk_widget_show_all (row);
+        gtk_container_add (GTK_CONTAINER (self->priv->input_source_list), row);
+}
+
+static void
+add_input_method_row (CcRegionPanel *self, const gchar *name)
+{
+        GtkWidget *row;
+        GtkWidget *label;
+        GtkWidget *image;
+
+        row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+        label = gtk_label_new (name);
+        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+        gtk_widget_set_margin_left (label, 20);
+        gtk_widget_set_margin_right (label, 20);
+        gtk_widget_set_margin_top (label, 6);
+        gtk_widget_set_margin_bottom (label, 6);
+        gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
+
+        image = gtk_image_new_from_icon_name ("system-run-symbolic", GTK_ICON_SIZE_BUTTON);
+        gtk_widget_set_margin_left (image, 20);
+        gtk_widget_set_margin_right (image, 20);
+        gtk_widget_set_margin_top (image, 6);
+        gtk_widget_set_margin_bottom (image, 6);
+        gtk_box_pack_start (GTK_BOX (row), image, FALSE, TRUE, 0);
+
+        gtk_widget_show_all (row);
+        gtk_container_add (GTK_CONTAINER (self->priv->input_source_list), row);
+}
+
+static void
+add_input_section (CcRegionPanel *self)
+{
+	CcRegionPanelPrivate *priv = self->priv;
+        GtkWidget *vbox;
+        GtkWidget *box;
+        GtkWidget *widget;
+        GtkWidget *row;
+        GtkWidget *label;
+        GtkWidget *frame;
+        gchar *s;
+
+        vbox = GTK_WIDGET (gtk_builder_get_object (priv->builder, "vbox_region"));
+
+        box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+        gtk_widget_set_margin_left (box, 134);
+        gtk_widget_set_margin_right (box, 134);
+        gtk_widget_set_margin_top (box, 0);
+        gtk_widget_set_margin_bottom (box, 22);
+        gtk_box_pack_start (GTK_BOX (vbox), box, TRUE, TRUE, 0);
+
+        s = g_strdup_printf ("<b>%s</b>", _("Input Sources"));
+        label = gtk_label_new (s);
+        g_free (s);
+        gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+        gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+        gtk_widget_set_margin_left (label, 6);
+        gtk_widget_set_margin_right (label, 6);
+        gtk_widget_set_margin_bottom (label, 6);
+        row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+        gtk_box_pack_start (GTK_BOX (row), label, TRUE, TRUE, 0);
+
+        self->priv->options_button = gtk_button_new_with_label (_("Options"));
+        gtk_widget_set_margin_bottom (label, 6);
+        gtk_box_pack_start (GTK_BOX (row), self->priv->options_button, FALSE, TRUE, 0);
+        gtk_box_pack_start (GTK_BOX (box), row, FALSE, TRUE, 0);
+
+        priv->input_source_list = widget = GTK_WIDGET (egg_list_box_new ());
+        egg_list_box_set_selection_mode (EGG_LIST_BOX (widget),
+                                         GTK_SELECTION_SINGLE);
+        egg_list_box_set_separator_funcs (EGG_LIST_BOX (widget),
+                                          update_separator_func,
+                                          NULL, NULL);
+
+        frame = gtk_frame_new (NULL);
+        gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
+
+        gtk_container_add (GTK_CONTAINER (frame), widget);
+        gtk_box_pack_start (GTK_BOX (box), frame, FALSE, TRUE, 0);
+
+        add_keyboard_layout_row (self, _("English (UK)"));
+        add_input_method_row (self, _("Japanese (Anthy)"));
+        add_input_method_row (self, _("Chinese (Pinyin)"));
+
+        gtk_widget_show_all (box);
+}
+
+static void
+cc_region_panel_init (CcRegionPanel *self)
 {
 	CcRegionPanelPrivate *priv;
-	GtkWidget *prefs_widget;
+	GtkWidget *vbox;
 	GError *error = NULL;
 
 	priv = self->priv = REGION_PANEL_PRIVATE (self);
@@ -144,7 +302,7 @@ cc_region_panel_init (CcRegionPanel * self)
 	priv->builder = gtk_builder_new ();
 
 	gtk_builder_add_from_resource (priv->builder,
-                                       "/org/gnome/control-center/region/gnome-region-panel.ui",
+                                       "/org/gnome/control-center/region/region.ui",
                                        &error);
 	if (error != NULL) {
 		g_warning ("Error loading UI file: %s", error->message);
@@ -152,14 +310,9 @@ cc_region_panel_init (CcRegionPanel * self)
 		return;
 	}
 
-	prefs_widget = (GtkWidget *) gtk_builder_get_object (priv->builder,
-							     "region_notebook");
-	gtk_widget_set_size_request (GTK_WIDGET (prefs_widget), -1, 400);
-
-	gtk_widget_reparent (prefs_widget, GTK_WIDGET (self));
+        add_language_section (self);
+        add_input_section (self);
 
-        setup_input_tabs (priv->builder, self);
-	setup_language (priv->builder);
-	setup_formats (priv->builder);
-	setup_system (priv->builder);
+        vbox = GTK_WIDGET (gtk_builder_get_object (priv->builder, "vbox_region"));
+	gtk_widget_reparent (vbox, GTK_WIDGET (self));
 }
diff --git a/panels/region/region.gresource.xml b/panels/region/region.gresource.xml
index 02b8d98..815ed36 100644
--- a/panels/region/region.gresource.xml
+++ b/panels/region/region.gresource.xml
@@ -3,5 +3,6 @@
   <gresource prefix="/org/gnome/control-center/region">
     <file preprocess="xml-stripblanks">gnome-region-panel.ui</file>
     <file preprocess="xml-stripblanks">gnome-region-panel-input-chooser.ui</file>
+    <file preprocess="xml-stripblanks">region.ui</file>
   </gresource>
 </gresources>
diff --git a/panels/region/region.ui b/panels/region/region.ui
new file mode 100644
index 0000000..1c885d7
--- /dev/null
+++ b/panels/region/region.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <object class="GtkWindow" id="window_region">
+    <property name="can_focus">False</property>
+    <property name="resizable">False</property>
+    <child>
+      <object class="GtkVBox" id="vbox_region">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="border_width">12</property>
+        <property name="spacing">3</property>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]