[gnome-control-center] [at-properties] Remove libglade depency from at-properties capplet



commit 0b65af5fad4533311d4148ec102b044583120168
Author: Felix Riemann <friemann gnome org>
Date:   Fri Jul 10 13:47:45 2009 +0200

    [at-properties] Remove libglade depency from at-properties capplet
    
    The image widgets used by the buttons are now created and assigned
    through GtkBuilder directly as well.

 capplets/accessibility/at-properties/Makefile.am   |    8 +-
 .../at-properties/at-enable-dialog.glade           |  394 --------------------
 .../at-properties/at-enable-dialog.ui              |  347 +++++++++++++++++
 capplets/accessibility/at-properties/main.c        |  108 +++---
 po/POTFILES.in                                     |    2 +-
 5 files changed, 407 insertions(+), 452 deletions(-)
---
diff --git a/capplets/accessibility/at-properties/Makefile.am b/capplets/accessibility/at-properties/Makefile.am
index 4249d3c..3f3ee4a 100644
--- a/capplets/accessibility/at-properties/Makefile.am
+++ b/capplets/accessibility/at-properties/Makefile.am
@@ -16,14 +16,14 @@ pixmap_DATA =					\
 	at-startup.png				\
 	at-support.png
 
-gladedir = $(pkgdatadir)/glade
-glade_DATA = at-enable-dialog.glade
+uidir = $(pkgdatadir)/ui
+ui_DATA = at-enable-dialog.ui
 
 INCLUDES   = $(AT_CAPPLET_CFLAGS)     \
              $(GNOMECC_CAPPLETS_CFLAGS) \
-	     -DGLADEDIR=\""$(gladedir)"\" \
+	     -DUIDIR=\""$(uidir)"\" \
 	     -DPIXMAPDIR=\""$(pixmapdir)"\" \
 	     -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\"" \
 	     -DGNOMELOCALEDIR="\"$(datadir)/locale\""
 CLEANFILES = $(GNOMECC_CAPPLETS_CLEANFILES) $(Desktop_in_files) $(desktop_DATA)
-EXTRA_DIST = $(glade_DATA) $(pixmap_DATA)
+EXTRA_DIST = $(ui_DATA) $(pixmap_DATA)
diff --git a/capplets/accessibility/at-properties/at-enable-dialog.ui b/capplets/accessibility/at-properties/at-enable-dialog.ui
new file mode 100644
index 0000000..8abfd6c
--- /dev/null
+++ b/capplets/accessibility/at-properties/at-enable-dialog.ui
@@ -0,0 +1,347 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.14"/>
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="GtkDialog" id="at_properties_dialog">
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Assistive Technologies Preferences</property>
+    <property name="resizable">False</property>
+    <property name="type_hint">dialog</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <object class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkVBox" id="vbox1">
+            <property name="visible">True</property>
+            <property name="border_width">5</property>
+            <property name="spacing">18</property>
+            <child>
+              <object class="GtkVBox" id="at_support_frame">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkVBox" id="vbox2">
+                    <property name="visible">True</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="label4">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Assistive Technologies&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hbox2">
+                        <property name="visible">True</property>
+                        <property name="spacing">12</property>
+                        <child>
+                          <object class="GtkImage" id="at_enable_image">
+                            <property name="visible">True</property>
+                            <property name="yalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkVBox" id="vbox3">
+                            <property name="visible">True</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkButton" id="at_pref_button">
+                                <property name="label" translatable="yes">_Preferred Applications</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="image">pref_button_img</property>
+                                <property name="use_underline">True</property>
+                                <child internal-child="accessible">
+                                  <object class="AtkObject" id="at_pref_button-atkobject">
+                                    <property name="AtkObject::accessible-description" translatable="yes">Jump to Preferred Applications dialog</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="at_enable_toggle">
+                                <property name="label" translatable="yes">_Enable assistive technologies</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_underline">True</property>
+                                <property name="draw_indicator">True</property>
+                                <child internal-child="accessible">
+                                  <object class="AtkObject" id="at_enable_toggle-atkobject">
+                                    <property name="AtkObject::accessible-description" translatable="yes">Changes to enable assistive technologies will not take effect until your next log in.</property>
+                                  </object>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="at_applications_frame">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkVBox" id="vbox7">
+                    <property name="visible">True</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkLabel" id="pref_label">
+                        <property name="visible">True</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Preferences&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hbox3">
+                        <property name="visible">True</property>
+                        <property name="spacing">12</property>
+                        <child>
+                          <object class="GtkImage" id="at_applications_image">
+                            <property name="visible">True</property>
+                            <property name="yalign">0</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkVBox" id="vbox5">
+                            <property name="visible">True</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkVBox" id="vbox8">
+                                <property name="visible">True</property>
+                                <child>
+                                  <object class="GtkButton" id="keyboard_button">
+                                    <property name="label" translatable="yes">_Keyboard Accessibility</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="image">keyboard_button_img</property>
+                                    <property name="use_underline">True</property>
+                                    <child internal-child="accessible">
+                                      <object class="AtkObject" id="keyboard_button-atkobject">
+                                        <property name="AtkObject::accessible-description" translatable="yes">Jump to the Keyboard Accessibility dialog</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="padding">5</property>
+                                    <property name="position">0</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="mouse_button">
+                                    <property name="label" translatable="yes">_Mouse Accessibility</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="image">mouse_button_img</property>
+                                    <property name="use_underline">True</property>
+                                    <child internal-child="accessible">
+                                      <object class="AtkObject" id="mouse_button-atkobject">
+                                        <property name="AtkObject::accessible-description" translatable="yes">Jump to the Mouse Accessibility dialog</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="padding">5</property>
+                                    <property name="position">1</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkButton" id="login_button">
+                                    <property name="label" translatable="yes">Accessible Lo_gin</property>
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="receives_default">False</property>
+                                    <property name="image">login_button_img</property>
+                                    <property name="use_underline">True</property>
+                                    <child internal-child="accessible">
+                                      <object class="AtkObject" id="login_button-atkobject">
+                                        <property name="AtkObject::accessible-description" translatable="yes">Jump to the Accessible Login dialog</property>
+                                      </object>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">False</property>
+                                    <property name="fill">False</property>
+                                    <property name="padding">5</property>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="expand">False</property>
+                                <property name="fill">False</property>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">end</property>
+            <child>
+              <object class="GtkButton" id="at_help_button">
+                <property name="label">gtk-help</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="at_close_logout_button">
+                <property name="label" translatable="yes">Close and _Log Out</property>
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="image">close_logout_button_img</property>
+                <property name="use_underline">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkButton" id="at_close_button">
+                <property name="label">gtk-close</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_stock">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <action-widgets>
+      <action-widget response="-11">at_help_button</action-widget>
+      <action-widget response="0">at_close_logout_button</action-widget>
+      <action-widget response="-7">at_close_button</action-widget>
+    </action-widgets>
+  </object>
+  <object class="GtkImage" id="close_logout_button_img">
+    <property name="visible">True</property>
+    <property name="stock">gtk-quit</property>
+  </object>
+  <object class="GtkImage" id="pref_button_img">
+    <property name="visible">True</property>
+    <property name="stock">gtk-jump-to</property>
+  </object>
+  <object class="GtkImage" id="keyboard_button_img">
+    <property name="visible">True</property>
+    <property name="stock">gtk-jump-to</property>
+  </object>
+  <object class="GtkImage" id="mouse_button_img">
+    <property name="visible">True</property>
+    <property name="stock">gtk-jump-to</property>
+  </object>
+  <object class="GtkImage" id="login_button_img">
+    <property name="visible">True</property>
+    <property name="stock">gtk-jump-to</property>
+  </object>
+</interface>
diff --git a/capplets/accessibility/at-properties/main.c b/capplets/accessibility/at-properties/main.c
index e613adb..84065f2 100644
--- a/capplets/accessibility/at-properties/main.c
+++ b/capplets/accessibility/at-properties/main.c
@@ -1,7 +1,6 @@
 #include <config.h>
 #include <gtk/gtk.h>
 #include <gconf/gconf-client.h>
-#include <glade/glade.h>
 
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
@@ -25,46 +24,44 @@ enum {
 
 static gboolean initial_state;
 
-static GladeXML *
-create_dialog (void)
+static GtkBuilder *
+create_builder (void)
 {
-	GladeXML *dialog;
+	GtkBuilder *builder;
+	GError *error = NULL;
+	static const gchar *uifile = UIDIR "/at-enable-dialog.ui";
 
-	dialog = glade_xml_new (GLADEDIR "/at-enable-dialog.glade", "at_properties_dialog", NULL);
+	builder = gtk_builder_new ();
 
-	if (dialog) {
-		GtkWidget *image;
+	if (gtk_builder_add_from_file (builder, uifile, &error)) {
+		GObject *object;
 		gchar *prog;
 
-		image = gtk_image_new_from_stock (GTK_STOCK_QUIT, GTK_ICON_SIZE_BUTTON);
-		gtk_button_set_image (GTK_BUTTON (WID ("at_close_logout_button")), image);
-
-		image = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
-		gtk_button_set_image (GTK_BUTTON (WID ("at_pref_button")), image);
-
-		image = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
-		gtk_button_set_image (GTK_BUTTON (WID ("keyboard_button")), image);
-
-		image = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
-		gtk_button_set_image (GTK_BUTTON (WID ("mouse_button")), image);
-
-		image = gtk_image_new_from_stock (GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_BUTTON);
-		gtk_button_set_image (GTK_BUTTON (WID ("login_button")), image);
-
-		gtk_image_set_from_file (GTK_IMAGE (WID ("at_enable_image")),
+		object = gtk_builder_get_object (builder, "at_enable_image");
+		gtk_image_set_from_file (GTK_IMAGE (object),
 					 PIXMAPDIR "/at-startup.png");
 
-		gtk_image_set_from_file (GTK_IMAGE (WID ("at_applications_image")),
+		object = gtk_builder_get_object (builder,
+						 "at_applications_image");
+		gtk_image_set_from_file (GTK_IMAGE (object),
 					 PIXMAPDIR "/at-support.png");
 
 		prog = g_find_program_in_path ("gdmsetup");
-		if (prog == NULL)
-			gtk_widget_hide (WID ("login_button"));
+		if (prog == NULL) {
+			object = gtk_builder_get_object (builder,
+							 "login_button");
+			gtk_widget_hide (GTK_WIDGET (object));
+		}
 
 		g_free (prog);
+	} else {
+		g_warning ("Could not load UI: %s", error->message);
+		g_error_free (error);
+		g_object_unref (builder);
+		builder = NULL;
 	}
 
-	return dialog;
+	return builder;
 }
 
 static void
@@ -168,18 +165,20 @@ cb_dialog_response (GtkDialog *dialog, gint response_id)
 }
 
 static void
-close_logout_update (GladeXML *dialog)
+close_logout_update (GtkBuilder *builder)
 {
 	GConfClient *client = gconf_client_get_default ();
 	gboolean curr_state = gconf_client_get_bool (client, ACCESSIBILITY_KEY, NULL);
+	GObject *btn = gtk_builder_get_object (builder,
+					       "at_close_logout_button");
 
-	gtk_widget_set_sensitive (WID ("at_close_logout_button"), initial_state != curr_state);
+	gtk_widget_set_sensitive (GTK_WIDGET (btn), initial_state != curr_state);
 	g_object_unref (client);
 }
 
 static void
 at_enable_toggled (GtkToggleButton *toggle_button,
-		   GladeXML        *dialog)
+		   GtkBuilder      *builder)
 {
 	GConfClient *client = gconf_client_get_default ();
 	gboolean is_enabled = gtk_toggle_button_get_active (toggle_button);
@@ -192,11 +191,12 @@ at_enable_toggled (GtkToggleButton *toggle_button,
 
 static void
 at_enable_update (GConfClient *client,
-		  GladeXML    *dialog)
+		  GtkBuilder  *builder)
 {
 	gboolean is_enabled = gconf_client_get_bool (client, ACCESSIBILITY_KEY, NULL);
+	GObject *btn = gtk_builder_get_object (builder, "at_enable_toggle");
 
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (WID ("at_enable_toggle")),
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (btn),
 				      is_enabled);
 }
 
@@ -211,10 +211,11 @@ at_enable_changed (GConfClient *client,
 }
 
 static void
-setup_dialog (GladeXML *dialog)
+setup_dialog (GtkBuilder *builder)
 {
 	GConfClient *client;
 	GtkWidget *widget;
+	GObject *object;
 	GObject *peditor;
 
 	client = gconf_client_get_default ();
@@ -222,40 +223,41 @@ setup_dialog (GladeXML *dialog)
 	gconf_client_add_dir (client, ACCESSIBILITY_KEY_DIR,
 			      GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
 
-	widget = WID ("at_enable_toggle");
-	g_signal_connect (widget, "toggled",
+	object = gtk_builder_get_object (builder, "at_enable_toggle");
+	g_signal_connect (object, "toggled",
 			  G_CALLBACK (at_enable_toggled),
-			  dialog);
+			  builder);
 
 	peditor = gconf_peditor_new_boolean (NULL, ACCESSIBILITY_KEY,
-					     widget,
+					     GTK_WIDGET (object),
 					     NULL);
 
 	initial_state = gconf_client_get_bool (client, ACCESSIBILITY_KEY, NULL);
 
-	at_enable_update (client, dialog);
+	at_enable_update (client, builder);
 
 	gconf_client_notify_add (client, ACCESSIBILITY_KEY_DIR,
 				 at_enable_changed,
-				 dialog, NULL, NULL);
+				 builder, NULL, NULL);
 
-	g_signal_connect (G_OBJECT (WID("at_pref_button")),
-			  "clicked",
+	object = gtk_builder_get_object (builder, "at_pref_button");
+	g_signal_connect (object, "clicked",
 			  G_CALLBACK (cb_at_preferences), NULL);
 
-	g_signal_connect (G_OBJECT (WID("keyboard_button")),
-			  "clicked",
+	object = gtk_builder_get_object (builder, "keyboard_button");
+	g_signal_connect (object, "clicked",
 			  G_CALLBACK (cb_keyboard_preferences), NULL);
 
-	g_signal_connect (G_OBJECT (WID("mouse_button")),
-			  "clicked",
+	object = gtk_builder_get_object (builder, "mouse_button");
+	g_signal_connect (object, "clicked",
 			  G_CALLBACK (cb_mouse_preferences), NULL);
 
-	g_signal_connect (G_OBJECT (WID("login_button")),
-			  "clicked",
+	object = gtk_builder_get_object (builder, "login_button");
+	g_signal_connect (object, "clicked",
 			  G_CALLBACK (cb_login_preferences), NULL);
 
-	widget = WID ("at_properties_dialog");
+	widget = GTK_WIDGET (gtk_builder_get_object (builder,
+						     "at_properties_dialog"));
 	capplet_set_icon (widget, "preferences-desktop-accessibility");
 
 	g_signal_connect (G_OBJECT (widget),
@@ -270,21 +272,21 @@ setup_dialog (GladeXML *dialog)
 int
 main (int argc, char *argv[])
 {
-	GladeXML *dialog;
+	GtkBuilder *builder;
 
 	capplet_init (NULL, &argc, &argv);
 
 	activate_settings_daemon ();
 
-	dialog = create_dialog ();
+	builder = create_builder ();
 
-	if (dialog) {
+	if (builder) {
 
-		setup_dialog (dialog);
+		setup_dialog (builder);
 
 		gtk_main ();
 
-		g_object_unref (dialog);
+		g_object_unref (builder);
 	}
 
 	return 0;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 2e3b91e..9a8aa52 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,7 +10,7 @@ capplets/about-me/gnome-about-me-fingerprint.c
 capplets/about-me/gnome-about-me-fingerprint.glade
 capplets/about-me/gnome-about-me.glade
 capplets/about-me/gnome-about-me-password.c
-capplets/accessibility/at-properties/at-enable-dialog.glade
+[type: gettext/glade]capplets/accessibility/at-properties/at-enable-dialog.ui
 capplets/accessibility/at-properties/at-properties.desktop.in.in
 capplets/accessibility/at-properties/main.c
 capplets/appearance/appearance-desktop.c



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