[gnome-control-center] [display] Remove libglade dependency from display-properties capplet



commit 622a730e5ce54cde609e75ff5ca33c5e24eb239c
Author: Felix Riemann <friemann gnome org>
Date:   Thu Jul 9 14:54:25 2009 +0200

    [display] Remove libglade dependency from display-properties capplet

 capplets/display/Makefile.am           |    6 +-
 capplets/display/build.sh              |    2 +-
 capplets/display/display-capplet.glade |  541 --------------------------------
 capplets/display/xrandr-capplet.c      |   64 +++--
 po/POTFILES.in                         |    2 +-
 5 files changed, 44 insertions(+), 571 deletions(-)
---
diff --git a/capplets/display/Makefile.am b/capplets/display/Makefile.am
index d8f7d10..ff0bcdf 100644
--- a/capplets/display/Makefile.am
+++ b/capplets/display/Makefile.am
@@ -1,8 +1,8 @@
 # This is used in GNOMECC_CAPPLETS_CFLAGS
 cappletname = display
 
-gladedir = $(pkgdatadir)/glade
-dist_glade_DATA = display-capplet.glade
+uidir = $(pkgdatadir)/ui
+dist_ui_DATA = display-capplet.ui
 
 bin_PROGRAMS = gnome-display-properties
 
@@ -37,7 +37,7 @@ desktop_DATA = $(Desktop_in_files:.desktop.in=.desktop)
 
 INCLUDES   = $(DISPLAY_CAPPLET_CFLAGS) \
              $(GNOMECC_CAPPLETS_CFLAGS) \
-	     -DGLADEDIR="\"$(gladedir)\"" \
+	     -DUIDIR="\"$(uidir)\"" \
 	     -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
 	     -DGNOMECC_DATA_DIR="\"$(pkgdatadir)\""
 
diff --git a/capplets/display/build.sh b/capplets/display/build.sh
index 4268ab7..6d0fc44 100644
--- a/capplets/display/build.sh
+++ b/capplets/display/build.sh
@@ -1 +1 @@
-gcc -g -Wall `pkg-config --cflags --libs gtk+-2.0 libglade-2.0` -I../ ../randrwrap.c ../monitor-db.c xrandr-capplet.c ../edid-parse.c ../display-name.c scrollarea.c foo-marshal.c -o capplet 
+gcc -g -Wall `pkg-config --cflags --libs gtk+-2.0` -I../ ../randrwrap.c ../monitor-db.c xrandr-capplet.c ../edid-parse.c ../display-name.c scrollarea.c foo-marshal.c -o capplet
diff --git a/capplets/display/xrandr-capplet.c b/capplets/display/xrandr-capplet.c
index 9399732..dca6d49 100644
--- a/capplets/display/xrandr-capplet.c
+++ b/capplets/display/xrandr-capplet.c
@@ -21,7 +21,6 @@
 
 #include <config.h>
 #include <gtk/gtk.h>
-#include <glade/glade.h>
 #include <string.h>
 #include <stdlib.h>
 #include "scrollarea.h"
@@ -2110,38 +2109,47 @@ apply_button_clicked_cb (GtkButton *button, gpointer data)
     app->apply_button_clicked_timestamp = gtk_get_current_event_time ();
 }
 
+static GtkWidget*
+_gtk_builder_get_widget (GtkBuilder *builder, const gchar *name)
+{
+    return GTK_WIDGET (gtk_builder_get_object (builder, name));
+}
+
 static void
 run_application (App *app)
 {
-#ifndef GLADEDIR
-#define GLADEDIR "."
+#ifndef UIDIR
+#define UIDIR "."
 #endif
-#define GLADE_FILE GLADEDIR "/display-capplet.glade"
-    GladeXML *xml;
+#define UI_FILE UIDIR "/display-capplet.ui"
+    GtkBuilder *builder;
     GtkWidget *align;
     GError *error;
 
-    xml = glade_xml_new (GLADE_FILE, NULL, NULL);
-    if (!xml)
+    error = NULL;
+    builder = gtk_builder_new ();
+
+    if (gtk_builder_add_from_file (builder, UI_FILE, &error) == 0)
     {
-	g_warning ("Could not open " GLADE_FILE);
+	g_warning ("Could not parse UI definition: %s", error->message);
+	g_error_free (error);
+	g_object_unref (builder);
 	return;
     }
 
-    error = NULL;
     app->screen = gnome_rr_screen_new (gdk_screen_get_default (),
 				       on_screen_changed, app, &error);
     if (!app->screen)
     {
 	error_message (NULL, _("Could not get screen information"), error->message);
 	g_error_free (error);
-	g_object_unref (xml);
+	g_object_unref (builder);
 	return;
     }
 
     app->client = gconf_client_get_default ();
 
-    app->dialog = glade_xml_get_widget (xml, "dialog");
+    app->dialog = _gtk_builder_get_widget (builder, "dialog");
     g_signal_connect_after (app->dialog, "map-event",
 			    G_CALLBACK (dialog_map_event_cb), app);
 
@@ -2149,43 +2157,49 @@ run_application (App *app)
     gtk_window_set_icon_name (GTK_WINDOW (app->dialog),
 			      "gnome-display-properties");
 
-    app->current_monitor_event_box = glade_xml_get_widget (xml, "current_monitor_event_box");
-    app->current_monitor_label = glade_xml_get_widget (xml, "current_monitor_label");
+    app->current_monitor_event_box = _gtk_builder_get_widget (builder,
+    						   "current_monitor_event_box");
+    app->current_monitor_label = _gtk_builder_get_widget (builder,
+    						       "current_monitor_label");
 
-    app->monitor_on_radio = glade_xml_get_widget (xml, "monitor_on_radio");
-    app->monitor_off_radio = glade_xml_get_widget (xml, "monitor_off_radio");
+    app->monitor_on_radio = _gtk_builder_get_widget (builder,
+    						     "monitor_on_radio");
+    app->monitor_off_radio = _gtk_builder_get_widget (builder,
+    						      "monitor_off_radio");
     g_signal_connect (app->monitor_on_radio, "toggled",
 		      G_CALLBACK (monitor_on_off_toggled_cb), app);
     g_signal_connect (app->monitor_off_radio, "toggled",
 		      G_CALLBACK (monitor_on_off_toggled_cb), app);
 
-    app->resolution_combo = glade_xml_get_widget (xml, "resolution_combo");
+    app->resolution_combo = _gtk_builder_get_widget (builder,
+    						     "resolution_combo");
     g_signal_connect (app->resolution_combo, "changed",
 		      G_CALLBACK (on_resolution_changed), app);
 
-    app->refresh_combo = glade_xml_get_widget (xml, "refresh_combo");
+    app->refresh_combo = _gtk_builder_get_widget (builder, "refresh_combo");
     g_signal_connect (app->refresh_combo, "changed",
 		      G_CALLBACK (on_rate_changed), app);
 
-    app->rotation_combo = glade_xml_get_widget (xml, "rotation_combo");
+    app->rotation_combo = _gtk_builder_get_widget (builder, "rotation_combo");
     g_signal_connect (app->rotation_combo, "changed",
 		      G_CALLBACK (on_rotation_changed), app);
 
-    app->clone_checkbox = glade_xml_get_widget (xml, "clone_checkbox");
+    app->clone_checkbox = _gtk_builder_get_widget (builder, "clone_checkbox");
     g_signal_connect (app->clone_checkbox, "toggled",
 		      G_CALLBACK (on_clone_changed), app);
 
-    g_signal_connect (glade_xml_get_widget (xml, "detect_displays_button"),
+    g_signal_connect (_gtk_builder_get_widget (builder, "detect_displays_button"),
 		      "clicked", G_CALLBACK (on_detect_displays), app);
 
-    app->show_icon_checkbox = glade_xml_get_widget (xml, "show_notification_icon");
+    app->show_icon_checkbox = _gtk_builder_get_widget (builder,
+						      "show_notification_icon");
 
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (app->show_icon_checkbox),
 				  gconf_client_get_bool (app->client, SHOW_ICON_KEY, NULL));
 
     g_signal_connect (app->show_icon_checkbox, "toggled", G_CALLBACK (on_show_icon_toggled), app);
 
-    app->panel_checkbox = glade_xml_get_widget (xml, "panel_checkbox");
+    app->panel_checkbox = _gtk_builder_get_widget (builder, "panel_checkbox");
 
     make_text_combo (app->resolution_combo, 4);
     make_text_combo (app->refresh_combo, 3);
@@ -2206,20 +2220,20 @@ run_application (App *app)
     g_signal_connect (app->area, "viewport_changed",
 		      G_CALLBACK (on_viewport_changed), app);
 
-    align = glade_xml_get_widget (xml, "align");
+    align = _gtk_builder_get_widget (builder, "align");
 
     gtk_container_add (GTK_CONTAINER (align), app->area);
 
     /* Until we have help to show, we'll just hide the Help button */
     hide_help_button (app);
 
-    app->apply_button = glade_xml_get_widget (xml, "apply_button");
+    app->apply_button = _gtk_builder_get_widget (builder, "apply_button");
     g_signal_connect (app->apply_button, "clicked",
 		      G_CALLBACK (apply_button_clicked_cb), app);
 
     on_screen_changed (app->screen, app);
 
-    g_object_unref (xml);
+    g_object_unref (builder);
 
 restart:
     switch (gtk_dialog_run (GTK_DIALOG (app->dialog)))
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 7b1ad06..21528f8 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -38,7 +38,7 @@ capplets/default-applications/gnome-at-session.desktop.in.in
 capplets/default-applications/gnome-da-capplet.c
 capplets/default-applications/gnome-default-applications-properties.glade
 capplets/default-applications/gnome-default-applications.xml.in
-capplets/display/display-capplet.glade
+[type: gettext/glade]capplets/display/display-capplet.ui
 capplets/display/display-properties.desktop.in.in
 capplets/display/xrandr-capplet.c
 capplets/keybindings/00-multimedia-key.xml.in



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