[gnome-initial-setup] gis-assistant: Add an assistant API to get/set a page title
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] gis-assistant: Add an assistant API to get/set a page title
- Date: Thu, 26 Jul 2012 06:40:36 +0000 (UTC)
commit 54d999feea7d3bff9df5f6e591dd122642c52ea8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Mon Jul 23 20:58:10 2012 -0300
gis-assistant: Add an assistant API to get/set a page title
Accompanied by the title of the current page. This will be used
to keep track of potential page title changes in case of a language
change or something else.
gnome-initial-setup/gis-assistant.c | 66 ++++++++++++++++++++
gnome-initial-setup/gis-assistant.h | 7 ++
gnome-initial-setup/gnome-initial-setup.c | 16 ++++-
.../pages/account/gis-account-page.c | 2 +-
gnome-initial-setup/pages/eulas/gis-eula-pages.c | 2 +-
gnome-initial-setup/pages/goa/gis-goa-page.c | 2 +-
.../pages/language/gis-language-page.c | 3 +-
.../pages/location/gis-location-page.c | 2 +-
.../pages/network/gis-network-page.c | 2 +-
.../pages/summary/gis-summary-page.c | 2 +-
10 files changed, 92 insertions(+), 12 deletions(-)
---
diff --git a/gnome-initial-setup/gis-assistant.c b/gnome-initial-setup/gis-assistant.c
index 79efb95..94f06e9 100644
--- a/gnome-initial-setup/gis-assistant.c
+++ b/gnome-initial-setup/gis-assistant.c
@@ -36,6 +36,14 @@ G_DEFINE_TYPE (GisAssistant, gis_assistant, GTK_TYPE_BOX)
#define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GIS_TYPE_ASSISTANT, GisAssistantPrivate))
enum {
+ PROP_0,
+ PROP_TITLE,
+ PROP_LAST,
+};
+
+static GParamSpec *obj_props[PROP_LAST];
+
+enum {
PREPARE,
LAST_SIGNAL,
};
@@ -61,6 +69,7 @@ struct _PageData
GtkWidget *widget;
gboolean page_complete;
GList *link;
+ gchar *title;
};
static PageData *
@@ -185,6 +194,35 @@ gis_assistant_get_page_complete (GisAssistant *assistant,
return page_data->page_complete;
}
+void
+gis_assistant_set_page_title (GisAssistant *assistant,
+ GtkWidget *page,
+ gchar *title)
+{
+ GisAssistantPrivate *priv = assistant->priv;
+ PageData *page_data = get_page_data_for_page (page);
+ g_free (page_data->title);
+ page_data->title = g_strdup (title);
+
+ if (page_data == priv->current_page)
+ g_object_notify_by_pspec (G_OBJECT (assistant), obj_props[PROP_TITLE]);
+}
+
+gchar *
+gis_assistant_get_page_title (GisAssistant *assistant,
+ GtkWidget *page)
+{
+ PageData *page_data = get_page_data_for_page (page);
+ return page_data->title;
+}
+
+gchar *
+gis_assistant_get_title (GisAssistant *assistant)
+{
+ GisAssistantPrivate *priv = assistant->priv;
+ return priv->current_page->title;
+}
+
GtkWidget *
_gis_assistant_get_frame (GisAssistant *assistant)
{
@@ -200,6 +238,7 @@ _gis_assistant_current_page_changed (GisAssistant *assistant,
if (priv->current_page != page_data) {
priv->current_page = page_data;
+ g_object_notify_by_pspec (G_OBJECT (assistant), obj_props[PROP_TITLE]);
g_signal_emit (assistant, signals[PREPARE], 0, page);
}
}
@@ -249,6 +288,26 @@ remove_page_data (PageData *page_data)
}
static void
+gis_assistant_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GisAssistant *assistant = GIS_ASSISTANT (object);
+
+ switch (prop_id)
+ {
+ case PROP_TITLE:
+ g_value_set_string (value, gis_assistant_get_title (assistant));
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
gis_assistant_finalize (GObject *gobject)
{
GisAssistant *assistant = GIS_ASSISTANT (gobject);
@@ -268,10 +327,17 @@ gis_assistant_class_init (GisAssistantClass *klass)
g_type_class_add_private (klass, sizeof (GisAssistantPrivate));
+ gobject_class->get_property = gis_assistant_get_property;
gobject_class->finalize = gis_assistant_finalize;
klass->prepare = gis_assistant_prepare;
+ obj_props[PROP_TITLE] =
+ g_param_spec_string ("title",
+ "", "",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
/**
* GisAssistant::prepare:
* @assistant: the #GisAssistant
diff --git a/gnome-initial-setup/gis-assistant.h b/gnome-initial-setup/gis-assistant.h
index 8920c6e..86f4101 100644
--- a/gnome-initial-setup/gis-assistant.h
+++ b/gnome-initial-setup/gis-assistant.h
@@ -50,6 +50,13 @@ void gis_assistant_set_page_complete (GisAssistant *assistant,
gboolean gis_assistant_get_page_complete (GisAssistant *assistant,
GtkWidget *page);
+void gis_assistant_set_page_title (GisAssistant *assistant,
+ GtkWidget *page,
+ gchar *title);
+gchar * gis_assistant_get_page_title (GisAssistant *assistant,
+ GtkWidget *page);
+gchar * gis_assistant_get_title (GisAssistant *assistant);
+
G_END_DECLS
#endif /* __GIS_ASSISTANT_H__ */
diff --git a/gnome-initial-setup/gnome-initial-setup.c b/gnome-initial-setup/gnome-initial-setup.c
index b9627e1..7971216 100644
--- a/gnome-initial-setup/gnome-initial-setup.c
+++ b/gnome-initial-setup/gnome-initial-setup.c
@@ -56,14 +56,19 @@ run_finals (SetupData *setup)
}
static void
-prepare_cb (GisAssistant *assi, GtkWidget *page, SetupData *setup)
+title_changed_cb (GisAssistant *assistant,
+ GParamSpec *gparam,
+ SetupData *setup)
{
- gchar *page_title;
+ gtk_window_set_title (setup->main_window, gis_assistant_get_title (assistant));
+}
+static void
+prepare_cb (GisAssistant *assi, GtkWidget *page, SetupData *setup)
+{
g_debug ("Preparing page %s", gtk_widget_get_name (page));
- page_title = g_object_get_data (G_OBJECT (page), "gis-page-title");
- gtk_window_set_title (setup->main_window, page_title);
+ title_changed_cb (assi, NULL, setup);
if (g_object_get_data (G_OBJECT (page), "gis-summary"))
run_finals (setup);
@@ -81,6 +86,9 @@ prepare_main_window (SetupData *setup)
g_signal_connect (gtk_widget_get_screen (GTK_WIDGET (setup->main_window)),
"monitors-changed", G_CALLBACK (recenter_window), setup);
+ g_signal_connect (setup->assistant, "notify::title",
+ G_CALLBACK (title_changed_cb), setup);
+
g_signal_connect (setup->assistant, "prepare",
G_CALLBACK (prepare_cb), setup);
diff --git a/gnome-initial-setup/pages/account/gis-account-page.c b/gnome-initial-setup/pages/account/gis-account-page.c
index 3451dd4..9fe0300 100644
--- a/gnome-initial-setup/pages/account/gis-account-page.c
+++ b/gnome-initial-setup/pages/account/gis-account-page.c
@@ -546,8 +546,8 @@ gis_prepare_account_page (SetupData *setup)
data->act_client = act_user_manager_get_default ();
- g_object_set_data (OBJ (GObject *, "account-page"), "gis-page-title", _("Login"));
gis_assistant_add_page (assistant, WID ("account-page"));
+ gis_assistant_set_page_title (assistant, WID ("account-page"), _("Login"));
gis_add_summary_callback (setup, (GFunc)copy_account_data, data);
clear_account_page (data);
diff --git a/gnome-initial-setup/pages/eulas/gis-eula-pages.c b/gnome-initial-setup/pages/eulas/gis-eula-pages.c
index a9996af..f757fc3 100644
--- a/gnome-initial-setup/pages/eulas/gis-eula-pages.c
+++ b/gnome-initial-setup/pages/eulas/gis-eula-pages.c
@@ -270,8 +270,8 @@ build_eula_page (SetupData *setup,
page);
}
- g_object_set_data (G_OBJECT (vbox), "gis-page-title", _("License Agreements"));
gis_assistant_add_page (gis_get_assistant (setup), vbox);
+ gis_assistant_set_page_title (gis_get_assistant (setup), vbox, _("License Agreements"));
sync_page_complete (page);
diff --git a/gnome-initial-setup/pages/goa/gis-goa-page.c b/gnome-initial-setup/pages/goa/gis-goa-page.c
index 1ab34fe..c23e870 100644
--- a/gnome-initial-setup/pages/goa/gis-goa-page.c
+++ b/gnome-initial-setup/pages/goa/gis-goa-page.c
@@ -298,7 +298,7 @@ gis_prepare_online_page (SetupData *setup)
g_signal_connect (data->goa_client, "account-removed",
G_CALLBACK (goa_account_removed), data);
- g_object_set_data (OBJ (GObject *, "goa-page"), "gis-page-title", _("Online Accounts"));
gis_assistant_add_page (assistant, WID ("goa-page"));
gis_assistant_set_page_complete (assistant, WID ("goa-page"), TRUE);
+ gis_assistant_set_page_title (assistant, WID ("goa-page"), _("Online Accounts"));
}
diff --git a/gnome-initial-setup/pages/language/gis-language-page.c b/gnome-initial-setup/pages/language/gis-language-page.c
index 69ba082..e08b31f 100644
--- a/gnome-initial-setup/pages/language/gis-language-page.c
+++ b/gnome-initial-setup/pages/language/gis-language-page.c
@@ -40,8 +40,7 @@ sync_language (LanguageData *data)
{
setlocale (LC_MESSAGES, data->locale_id);
- /* XXX more to do */
- g_object_set_data (G_OBJECT (data->page), "gis-page-title", _("Welcome"));
+ gis_assistant_set_page_title (gis_get_assistant (data->setup), data->page, _("Welcome"));
}
static gint
diff --git a/gnome-initial-setup/pages/location/gis-location-page.c b/gnome-initial-setup/pages/location/gis-location-page.c
index c8e4d18..8b3cada 100644
--- a/gnome-initial-setup/pages/location/gis-location-page.c
+++ b/gnome-initial-setup/pages/location/gis-location-page.c
@@ -308,7 +308,7 @@ gis_prepare_location_page (SetupData *setup)
gtk_widget_hide (WID ("location-auto-button"));
#endif
- g_object_set_data (OBJ (GObject *, "location-page"), "gis-page-title", _("Location"));
gis_assistant_add_page (assistant, WID ("location-page"));
+ gis_assistant_set_page_title (assistant, WID ("location-page"), _("Location"));
gis_assistant_set_page_complete (assistant, WID ("location-page"), TRUE);
}
diff --git a/gnome-initial-setup/pages/network/gis-network-page.c b/gnome-initial-setup/pages/network/gis-network-page.c
index dcde868..4576877 100644
--- a/gnome-initial-setup/pages/network/gis-network-page.c
+++ b/gnome-initial-setup/pages/network/gis-network-page.c
@@ -736,8 +736,8 @@ gis_prepare_network_page (SetupData *setup)
refresh_wireless_list (data);
- g_object_set_data (OBJ (GObject *, "network-page"), "gis-page-title", _("Network"));
gis_assistant_add_page (assistant, WID ("network-page"));
+ gis_assistant_set_page_title (assistant, WID ("network-page"), _("Network"));
gis_assistant_set_page_complete (assistant, WID ("network-page"), TRUE);
out: ;
diff --git a/gnome-initial-setup/pages/summary/gis-summary-page.c b/gnome-initial-setup/pages/summary/gis-summary-page.c
index 34ca7ac..abf7c55 100644
--- a/gnome-initial-setup/pages/summary/gis-summary-page.c
+++ b/gnome-initial-setup/pages/summary/gis-summary-page.c
@@ -140,8 +140,8 @@ gis_prepare_summary_page (SetupData *setup)
g_signal_connect (button, "clicked",
G_CALLBACK (tour_cb), setup);
- g_object_set_data (OBJ (GObject *, "summary-page"), "gis-page-title", _("Thank You"));
g_object_set_data (OBJ (GObject *, "summary-page"), "gis-summary", GUINT_TO_POINTER (TRUE));
gis_assistant_add_page (assistant, WID ("summary-page"));
+ gis_assistant_set_page_title (assistant, WID ("summary-page"), _("Thank You"));
gis_assistant_set_page_complete (assistant, WID ("summary-page"), TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]