[gnome-initial-setup] eula: Move eulas to a GtkBuilder
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-initial-setup] eula: Move eulas to a GtkBuilder
- Date: Thu, 24 Jan 2013 21:32:21 +0000 (UTC)
commit f3b6400f684cdeb64b4573feb1c260430687824d
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Thu Jan 24 15:56:33 2013 -0500
eula: Move eulas to a GtkBuilder
gnome-initial-setup/Makefile.am | 1 +
gnome-initial-setup/pages/eulas/gis-eula-page.ui | 43 +++++++++++++++
gnome-initial-setup/pages/eulas/gis-eula-pages.c | 63 ++++++----------------
gnome-initial-setup/setup.gresource.xml | 1 +
4 files changed, 61 insertions(+), 47 deletions(-)
---
diff --git a/gnome-initial-setup/Makefile.am b/gnome-initial-setup/Makefile.am
index 17a25bf..a90fcd8 100644
--- a/gnome-initial-setup/Makefile.am
+++ b/gnome-initial-setup/Makefile.am
@@ -15,6 +15,7 @@ BUILT_SOURCES =
UI_FILES = \
pages/language/gis-language-page.ui \
+ pages/eulas/gis-eula-page.ui \
pages/network/gis-network-page.ui \
pages/account/gis-account-page.ui \
pages/location/gis-location-page.ui \
diff --git a/gnome-initial-setup/pages/eulas/gis-eula-page.ui b/gnome-initial-setup/pages/eulas/gis-eula-page.ui
new file mode 100644
index 0000000..e860f82
--- /dev/null
+++ b/gnome-initial-setup/pages/eulas/gis-eula-page.ui
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.0 -->
+ <object class="GtkGrid" id="eula-page">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">fill</property>
+ <property name="margin_left">80</property>
+ <property name="margin_right">80</property>
+ <child>
+ <object class="GtkBox" id="vbox">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="shadow_type">etched-in</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="vexpand">True</property>
+ <property name="hexpand">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkCheckButton" id="checkbox">
+ <property name="visible">False</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="True">I have _agreed to the terms and conditions in this end user license agreement.</property>
+ <property name="use_underline">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/gnome-initial-setup/pages/eulas/gis-eula-pages.c b/gnome-initial-setup/pages/eulas/gis-eula-pages.c
index 79ec007..a285652 100644
--- a/gnome-initial-setup/pages/eulas/gis-eula-pages.c
+++ b/gnome-initial-setup/pages/eulas/gis-eula-pages.c
@@ -23,6 +23,8 @@
/* EULA pages {{{1 */
+#define PAGE_ID "eula"
+
#include "config.h"
#include "gis-eula-pages.h"
#include "utils.h"
@@ -39,7 +41,6 @@ struct _GisEulaPagePrivate
{
GFile *eula;
- GtkWidget *text_view;
GtkWidget *checkbox;
GtkWidget *scrolled_window;
@@ -47,6 +48,9 @@ struct _GisEulaPagePrivate
gboolean require_scroll;
};
+#define OBJ(type,name) ((type)gtk_builder_get_object(GIS_PAGE(page)->builder,(name)))
+#define WID(name) OBJ(GtkWidget*,name)
+
enum
{
PROP_0,
@@ -214,21 +218,12 @@ get_config (GFile *eula,
g_key_file_unref (config);
}
-static GtkBuilder *
-gis_eula_page_get_builder (GisPage *page)
-{
- /* Prevent warnings because of NULL page IDs */
- return NULL;
-}
-
static void
gis_eula_page_constructed (GObject *object)
{
GisEulaPage *page = GIS_EULA_PAGE (object);
GisEulaPagePrivate *priv = page->priv;
GtkWidget *text_view;
- GtkWidget *vbox;
- GtkWidget *scrolled_window;
gboolean require_checkbox = FALSE;
gboolean require_scroll = FALSE;
@@ -241,49 +236,22 @@ gis_eula_page_constructed (GObject *object)
if (text_view == NULL)
return;
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8);
- gtk_widget_set_margin_left (vbox, 80);
- gtk_widget_set_margin_right (vbox, 80);
-
- scrolled_window = gtk_scrolled_window_new (NULL, NULL);
- gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_SHADOW_ETCHED_IN);
- gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
- GTK_POLICY_NEVER,
- GTK_POLICY_AUTOMATIC);
- gtk_widget_set_vexpand (scrolled_window, TRUE);
- gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
- gtk_container_add (GTK_CONTAINER (vbox), scrolled_window);
- gtk_container_add (GTK_CONTAINER (page), vbox);
+ priv->scrolled_window = WID ("scrolledwindow");
+ gtk_container_add (GTK_CONTAINER (priv->scrolled_window), text_view);
- priv->text_view = text_view;
- priv->scrolled_window = scrolled_window;
+ gtk_widget_show (text_view);
get_config (eula, &require_checkbox, &require_scroll);
priv->require_checkbox = require_checkbox;
priv->require_scroll = require_scroll;
- if (require_checkbox) {
- GtkWidget *checkbox;
-
- checkbox = gtk_check_button_new_with_mnemonic (_("I have _agreed to the "
- "terms and conditions in "
- "this end user license "
- "agreement."));
-
- gtk_container_add (GTK_CONTAINER (vbox), checkbox);
-
- g_signal_connect_swapped (checkbox, "toggled",
- G_CALLBACK (sync_page_complete),
- page);
-
- priv->checkbox = checkbox;
- }
+ priv->checkbox = WID ("checkbox");
+ gtk_widget_set_visible (priv->checkbox, require_checkbox);
if (require_scroll) {
GtkAdjustment *vadjust;
- vadjust = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolled_window));
+ vadjust = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scrolled_window));
g_signal_connect_swapped (vadjust, "changed",
G_CALLBACK (sync_page_complete),
page);
@@ -295,9 +263,10 @@ gis_eula_page_constructed (GObject *object)
gis_page_set_title (GIS_PAGE (page), _("License Agreements"));
sync_page_complete (page);
- gtk_widget_show_all (GTK_WIDGET (page));
-}
+ gtk_container_add (GTK_CONTAINER (page), WID ("eula-page"));
+ gtk_widget_show (GTK_WIDGET (page));
+}
static void
gis_eula_page_get_property (GObject *object,
@@ -351,10 +320,10 @@ gis_eula_page_dispose (GObject *object)
static void
gis_eula_page_class_init (GisEulaPageClass *klass)
{
- GisPageClass *page_klass = GIS_PAGE_CLASS (klass);
+ GisPageClass *page_class = GIS_PAGE_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- page_klass->get_builder = gis_eula_page_get_builder;
+ page_class->page_id = PAGE_ID;
object_class->get_property = gis_eula_page_get_property;
object_class->set_property = gis_eula_page_set_property;
object_class->constructed = gis_eula_page_constructed;
diff --git a/gnome-initial-setup/setup.gresource.xml b/gnome-initial-setup/setup.gresource.xml
index fba5715..e008853 100644
--- a/gnome-initial-setup/setup.gresource.xml
+++ b/gnome-initial-setup/setup.gresource.xml
@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/ui">
<file preprocess="xml-stripblanks" alias="gis-language-page.ui">pages/language/gis-language-page.ui</file>
+ <file preprocess="xml-stripblanks" alias="gis-eula-page.ui">pages/eulas/gis-eula-page.ui</file>
<file preprocess="xml-stripblanks" alias="gis-account-page.ui">pages/account/gis-account-page.ui</file>
<file preprocess="xml-stripblanks" alias="gis-location-page.ui">pages/location/gis-location-page.ui</file>
<file preprocess="xml-stripblanks" alias="gis-network-page.ui">pages/network/gis-network-page.ui</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]