[gnome-initial-setup] driver: Add a locale-changed signal and push it to pages



commit 64c4fd76b3fd5c8723b8190b1447f6e677d829d3
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Feb 13 16:54:56 2013 -0500

    driver: Add a locale-changed signal and push it to pages

 gnome-initial-setup/gis-assistant.c |    5 +++++
 gnome-initial-setup/gis-driver.c    |   20 ++++++++++++++++++--
 gnome-initial-setup/gis-driver.h    |    1 +
 gnome-initial-setup/gis-page.c      |    7 +++++++
 gnome-initial-setup/gis-page.h      |    2 ++
 5 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index edadcf1..3c1cf1b 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -279,8 +279,13 @@ void
 gis_assistant_locale_changed (GisAssistant *assistant)
 {
   GisAssistantPrivate *priv = assistant->priv;
+  GList *l;
+
   gtk_button_set_label (GTK_BUTTON (priv->forward), _("_Next"));
   gtk_button_set_label (GTK_BUTTON (priv->back), _("_Back"));
+
+  for (l = priv->pages; l != NULL; l = l->next)
+    gis_page_locale_changed (l->data);
 }
 
 static void
diff --git a/gnome-initial-setup/gis-driver.c b/gnome-initial-setup/gis-driver.c
index 190950d..01365fa 100644
--- a/gnome-initial-setup/gis-driver.c
+++ b/gnome-initial-setup/gis-driver.c
@@ -58,6 +58,7 @@ G_DEFINE_TYPE(GisDriver, gis_driver, GTK_TYPE_APPLICATION)
 
 enum {
   REBUILD_PAGES,
+  LOCALE_CHANGED,
   LAST_SIGNAL,
 };
 
@@ -151,14 +152,20 @@ gis_driver_add_page (GisDriver *driver,
   gis_assistant_add_page (priv->assistant, page);
 }
 
-void
-gis_driver_locale_changed (GisDriver *driver)
+static void
+gis_driver_real_locale_changed (GisDriver *driver)
 {
   GisDriverPrivate *priv = driver->priv;
   g_idle_add ((GSourceFunc) rebuild_pages, driver);
   gis_assistant_locale_changed (priv->assistant);
 }
 
+void
+gis_driver_locale_changed (GisDriver *driver)
+{
+  g_signal_emit (G_OBJECT (driver), signals[LOCALE_CHANGED], 0);
+}
+
 GisDriverMode
 gis_driver_get_mode (GisDriver *driver)
 {
@@ -274,6 +281,7 @@ gis_driver_class_init (GisDriverClass *klass)
   gobject_class->set_property = gis_driver_set_property;
   application_class->startup = gis_driver_startup;
   application_class->activate = gis_driver_activate;
+  klass->locale_changed = gis_driver_real_locale_changed;
 
   signals[REBUILD_PAGES] =
     g_signal_new ("rebuild-pages",
@@ -283,6 +291,14 @@ gis_driver_class_init (GisDriverClass *klass)
                   NULL, NULL, NULL,
                   G_TYPE_NONE, 0);
 
+  signals[LOCALE_CHANGED] =
+    g_signal_new ("locale-changed",
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GisDriverClass, locale_changed),
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 0);
+
   obj_props[PROP_MODE] =
     g_param_spec_enum ("mode", "", "",
                        GIS_TYPE_DRIVER_MODE,
diff --git a/gnome-initial-setup/gis-driver.h b/gnome-initial-setup/gis-driver.h
index 2e74f73..1ca43b8 100644
--- a/gnome-initial-setup/gis-driver.h
+++ b/gnome-initial-setup/gis-driver.h
@@ -53,6 +53,7 @@ struct _GisDriverClass
   GtkApplicationClass parent_class;
 
   void (* rebuild_pages) (GisDriver *driver);
+  void (* locale_changed) (GisDriver *driver);
 };
 
 typedef enum {
diff --git a/gnome-initial-setup/gis-page.c b/gnome-initial-setup/gis-page.c
index 9b85982..05c6995 100644
--- a/gnome-initial-setup/gis-page.c
+++ b/gnome-initial-setup/gis-page.c
@@ -233,3 +233,10 @@ gis_page_get_action_widget (GisPage *page)
     return GIS_PAGE_GET_CLASS (page)->get_action_widget (page);
   return NULL;
 }
+
+void
+gis_page_locale_changed (GisPage *page)
+{
+  if (GIS_PAGE_GET_CLASS (page)->locale_changed)
+    return GIS_PAGE_GET_CLASS (page)->locale_changed (page);
+}
diff --git a/gnome-initial-setup/gis-page.h b/gnome-initial-setup/gis-page.h
index ec0387c..2b28b69 100644
--- a/gnome-initial-setup/gis-page.h
+++ b/gnome-initial-setup/gis-page.h
@@ -58,6 +58,7 @@ struct _GisPageClass
 
   GtkBuilder * (*get_builder) (GisPage *page);
   GtkWidget  * (*get_action_widget) (GisPage *page);
+  void         (*locale_changed) (GisPage *page);
 };
 
 GType gis_page_get_type (void);
@@ -67,6 +68,7 @@ void         gis_page_set_title (GisPage *page, char *title);
 gboolean     gis_page_get_complete (GisPage *page);
 void         gis_page_set_complete (GisPage *page, gboolean complete);
 GtkWidget *  gis_page_get_action_widget (GisPage *page);
+void         gis_page_locale_changed (GisPage *page);
 
 G_END_DECLS
 


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