[Xfce4-commits] r30269 - xfce4-settings/branches/migration-to-4ui/dialogs/display-settings

Nick Schermer nick at xfce.org
Sat Jul 11 10:52:34 CEST 2009


Author: nick
Date: 2009-07-11 08:52:34 +0000 (Sat, 11 Jul 2009)
New Revision: 30269

Modified:
   xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/Makefile.am
   xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/display-dialog.glade
   xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/main.c
Log:
Port display settings to Gtkbuilder and 4ui.


Modified: xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/Makefile.am
===================================================================
--- xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/Makefile.am	2009-07-11 08:36:01 UTC (rev 30268)
+++ xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/Makefile.am	2009-07-11 08:52:34 UTC (rev 30269)
@@ -21,10 +21,7 @@
 
 xfce4_display_settings_CFLAGS = \
 	$(GTK_CFLAGS) \
-	$(GLIB_CFLAGS) \
-	$(GLADE_CFLAGS) \
-	$(DBUS_GLIB_CFLAGS) \
-	$(LIBXFCEGUI4_CFLAGS) \
+	$(LIBXFCE4UI_CFLAGS) \
 	$(XFCONF_CFLAGS) \
 	$(XRANDR_CFLAGS)
 
@@ -34,10 +31,7 @@
 
 xfce4_display_settings_LDADD = \
 	$(GTK_LIBS) \
-	$(GLIB_LIBS) \
-	$(GLADE_LIBS) \
-	$(DBUS_GLIB_LIBS) \
-	$(LIBXFCEGUI4_LIBS) \
+	$(LIBXFCE4UI_LIBS) \
 	$(XFCONF_LIBS) \
 	$(XRANDR_LIBS)
 

Modified: xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/display-dialog.glade
===================================================================
--- xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/display-dialog.glade	2009-07-11 08:36:01 UTC (rev 30268)
+++ xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/display-dialog.glade	2009-07-11 08:52:34 UTC (rev 30269)
@@ -1,60 +1,64 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Fri Oct 31 00:42:04 2008 -->
-<glade-interface>
-  <requires lib="xfce4"/>
-  <widget class="XfceTitledDialog" id="display-dialog">
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 2.12 -->
+  <!-- interface-requires libxfce4ui 4.5 -->
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="XfceTitledDialog" id="display-dialog">
     <property name="title" translatable="yes">Display</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="window_position">center-on-parent</property>
     <property name="default_width">400</property>
     <property name="default_height">350</property>
     <property name="icon_name">video-display</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="type_hint">dialog</property>
     <property name="has_separator">False</property>
     <property name="subtitle" translatable="yes">Configure screen settings and layout</property>
     <child internal-child="vbox">
-      <widget class="GtkVBox" id="dialog-vbox1">
+      <object class="GtkVBox" id="dialog-vbox1">
         <property name="visible">True</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <child>
-          <widget class="GtkHBox" id="hbox1">
+          <object class="GtkHBox" id="hbox1">
             <property name="visible">True</property>
             <property name="border_width">12</property>
             <property name="spacing">12</property>
             <child>
-              <widget class="GtkScrolledWindow" id="scrolledwindow1">
+              <object class="GtkScrolledWindow" id="scrolledwindow1">
                 <property name="width_request">200</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
-                <property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
+                <property name="hscrollbar_policy">automatic</property>
+                <property name="vscrollbar_policy">automatic</property>
+                <property name="shadow_type">etched-in</property>
                 <child>
-                  <widget class="GtkTreeView" id="randr-outputs">
+                  <object class="GtkTreeView" id="randr-outputs">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="headers_visible">False</property>
                     <property name="enable_search">False</property>
                     <property name="show_expanders">False</property>
-                  </widget>
+                  </object>
                 </child>
-              </widget>
+              </object>
+              <packing>
+                <property name="position">0</property>
+              </packing>
             </child>
             <child>
-              <widget class="GtkTable" id="table1">
+              <object class="GtkTable" id="table1">
                 <property name="visible">True</property>
                 <property name="n_rows">3</property>
                 <property name="n_columns">2</property>
                 <property name="column_spacing">12</property>
                 <property name="row_spacing">6</property>
                 <child>
-                  <widget class="GtkLabel" id="label5">
+                  <object class="GtkLabel" id="label5">
                     <property name="visible">True</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">Ro_tation:</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">randr-rotation</property>
-                  </widget>
+                  </object>
                   <packing>
                     <property name="top_attach">2</property>
                     <property name="bottom_attach">3</property>
@@ -63,13 +67,13 @@
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label4">
+                  <object class="GtkLabel" id="label4">
                     <property name="visible">True</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">Refresh _rate:</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">randr-refresh-rate</property>
-                  </widget>
+                  </object>
                   <packing>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
@@ -78,22 +82,22 @@
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkLabel" id="label3">
+                  <object class="GtkLabel" id="label3">
                     <property name="visible">True</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">R_esolution:</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">randr-resolution</property>
-                  </widget>
+                  </object>
                   <packing>
                     <property name="x_options">GTK_FILL</property>
                     <property name="y_options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBox" id="randr-rotation">
+                  <object class="GtkComboBox" id="randr-rotation">
                     <property name="visible">True</property>
-                  </widget>
+                  </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
@@ -103,9 +107,9 @@
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBox" id="randr-refresh-rate">
+                  <object class="GtkComboBox" id="randr-refresh-rate">
                     <property name="visible">True</property>
-                  </widget>
+                  </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
@@ -115,60 +119,70 @@
                   </packing>
                 </child>
                 <child>
-                  <widget class="GtkComboBox" id="randr-resolution">
+                  <object class="GtkComboBox" id="randr-resolution">
                     <property name="visible">True</property>
-                  </widget>
+                  </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
                     <property name="y_options">GTK_FILL</property>
                   </packing>
                 </child>
-              </widget>
+              </object>
               <packing>
                 <property name="position">1</property>
               </packing>
             </child>
-          </widget>
+          </object>
           <packing>
             <property name="position">1</property>
           </packing>
         </child>
         <child internal-child="action_area">
-          <widget class="GtkHButtonBox" id="dialog-action_area1">
+          <object class="GtkHButtonBox" id="dialog-action_area1">
             <property name="visible">True</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <property name="layout_style">end</property>
             <child>
-              <widget class="GtkButton" id="button-apply">
+              <object class="GtkButton" id="button-apply">
+                <property name="label">gtk-apply</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="tooltip" translatable="yes">Apply any changes and test the new display settings</property>
-                <property name="label">gtk-apply</property>
+                <property name="tooltip_text" translatable="yes">Apply any changes and test the new display settings</property>
                 <property name="use_stock">True</property>
-                <property name="response_id">1</property>
-              </widget>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
             </child>
             <child>
-              <widget class="GtkButton" id="button-close">
+              <object class="GtkButton" id="button-close">
+                <property name="label">gtk-close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="label">gtk-close</property>
                 <property name="use_stock">True</property>
-                <property name="response_id">0</property>
-              </widget>
+              </object>
               <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
                 <property name="position">1</property>
               </packing>
             </child>
-          </widget>
+          </object>
           <packing>
             <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
+            <property name="pack_type">end</property>
+            <property name="position">0</property>
           </packing>
         </child>
-      </widget>
+      </object>
     </child>
-  </widget>
-</glade-interface>
+    <action-widgets>
+      <action-widget response="1">button-apply</action-widget>
+      <action-widget response="0">button-close</action-widget>
+    </action-widgets>
+  </object>
+</interface>

Modified: xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/main.c
===================================================================
--- xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/main.c	2009-07-11 08:36:01 UTC (rev 30268)
+++ xfce4-settings/branches/migration-to-4ui/dialogs/display-settings/main.c	2009-07-11 08:52:34 UTC (rev 30269)
@@ -31,10 +31,9 @@
 #include <glib.h>
 #include <gtk/gtk.h>
 #include <gdk/gdkx.h>
-#include <glade/glade.h>
 
 #include <xfconf/xfconf.h>
-#include <libxfcegui4/libxfcegui4.h>
+#include <libxfce4ui/libxfce4ui.h>
 #include <libxfce4util/libxfce4util.h>
 
 #include <X11/Xlib.h>
@@ -117,7 +116,7 @@
 
 static void
 display_setting_rotations_changed (GtkComboBox *combobox,
-                                   GladeXML    *gxml)
+                                   GtkBuilder  *builder)
 {
     gint value;
 
@@ -136,17 +135,17 @@
 
 
 static void
-display_setting_rotations_populate (GladeXML *gxml)
+display_setting_rotations_populate (GtkBuilder *builder)
 {
     GtkTreeModel *model;
-    GtkWidget    *combobox;
+    GObject      *combobox;
     Rotation      rotations;
     Rotation      active_rotation;
     guint         n;
     GtkTreeIter   iter;
 
     /* get the combo box store and clear it */
-    combobox = glade_xml_get_widget (gxml, "randr-rotation");
+    combobox = gtk_builder_get_object (builder, "randr-rotation");
     model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
     gtk_list_store_clear (GTK_LIST_STORE (model));
 
@@ -185,7 +184,7 @@
 
 static void
 display_setting_refresh_rates_changed (GtkComboBox *combobox,
-                                       GladeXML    *gxml)
+                                       GtkBuilder  *builder)
 {
     gint value;
 
@@ -204,10 +203,10 @@
 
 
 static void
-display_setting_refresh_rates_populate (GladeXML *gxml)
+display_setting_refresh_rates_populate (GtkBuilder *builder)
 {
     GtkTreeModel *model;
-    GtkWidget    *combobox;
+    GObject      *combobox;
     gshort       *rates;
     gint          nrates;
     GtkTreeIter   iter;
@@ -215,7 +214,7 @@
     gint          n, active = -1;
     gshort        diff, active_diff = G_MAXSHORT;
 #ifdef HAS_RANDR_ONE_POINT_TWO
-    GtkWidget    *rescombo;
+    GObject      *rescombo;
     XRRModeInfo  *mode_info;
     gchar        *mode_name;
     gfloat        rate;
@@ -223,16 +222,16 @@
 #endif
 
     /* get the combo box store and clear it */
-    combobox = glade_xml_get_widget (gxml, "randr-refresh-rate");
+    combobox = gtk_builder_get_object (builder, "randr-refresh-rate");
     model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
     gtk_list_store_clear (GTK_LIST_STORE (model));
 
 #ifdef HAS_RANDR_ONE_POINT_TWO
     /* get the selected resolution mode */
-    rescombo = glade_xml_get_widget (gxml, "randr-resolution");
+    rescombo = gtk_builder_get_object (builder, "randr-resolution");
     if (!display_setting_combo_box_get_value (GTK_COMBO_BOX (rescombo), (gint *) &active_mode))
         active_mode = 0;
-    
+
     if (xfce_randr)
     {
         /* find the selected resolution name */
@@ -314,7 +313,7 @@
 
 static void
 display_setting_resolutions_changed (GtkComboBox *combobox,
-                                     GladeXML    *gxml)
+                                     GtkBuilder  *builder)
 {
     gint value;
 
@@ -326,16 +325,16 @@
         XFCE_RANDR_LEGACY_RESOLUTION (xfce_randr_legacy) = value;
 
     /* update refresh rates */
-    display_setting_refresh_rates_populate (gxml);
+    display_setting_refresh_rates_populate (builder);
 }
 
 
 
 static void
-display_setting_resolutions_populate (GladeXML *gxml)
+display_setting_resolutions_populate (GtkBuilder *builder)
 {
     GtkTreeModel  *model;
-    GtkWidget     *combobox;
+    GObject       *combobox;
     XRRScreenSize *screen_sizes;
     gint           n, nsizes;
     gchar         *name;
@@ -346,7 +345,7 @@
 #endif
 
     /* get the combo box store and clear it */
-    combobox = glade_xml_get_widget (gxml, "randr-resolution");
+    combobox = gtk_builder_get_object (builder, "randr-resolution");
     model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
     gtk_list_store_clear (GTK_LIST_STORE (model));
 
@@ -409,7 +408,7 @@
 
 static void
 display_settings_treeview_selection_changed (GtkTreeSelection *selection,
-                                             GladeXML         *gxml)
+                                             GtkBuilder       *builder)
 {
     GtkTreeModel *model;
     GtkTreeIter   iter;
@@ -432,19 +431,19 @@
             xfce_randr_legacy->active_screen = active_id;
 
         /* update the combo boxes */
-        display_setting_resolutions_populate (gxml);
-        display_setting_rotations_populate (gxml);
+        display_setting_resolutions_populate (builder);
+        display_setting_rotations_populate (builder);
     }
 }
 
 
 
 static void
-display_settings_treeview_populate (GladeXML *gxml)
+display_settings_treeview_populate (GtkBuilder *builder)
 {
     gint              n;
     GtkListStore     *store;
-    GtkWidget        *treeview;
+    GObject          *treeview;
     GtkTreeIter       iter;
     gchar            *name;
     GtkTreeSelection *selection;
@@ -454,9 +453,9 @@
                                 G_TYPE_STRING, /* COLUMN_OUTPUT_NAME */
                                 G_TYPE_STRING, /* COLUMN_OUTPUT_ICON_NAME */
                                 G_TYPE_INT);   /* COLUMN_OUTPUT_ID */
-    
+
     /* set the treeview model */
-    treeview = glade_xml_get_widget (gxml, "randr-outputs");
+    treeview = gtk_builder_get_object (builder, "randr-outputs");
     gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
 
@@ -479,7 +478,7 @@
                                 COLUMN_OUTPUT_NAME, name,
                                 COLUMN_OUTPUT_ICON_NAME, "video-display",
                                 COLUMN_OUTPUT_ID, n, -1);
-            
+
             /* select active output */
             if (n == xfce_randr->active_output)
                 gtk_tree_selection_select_iter (selection, &iter);
@@ -503,7 +502,7 @@
 
             /* cleanup */
             g_free (name);
-            
+
             /* select active screen */
             if (n == xfce_randr_legacy->active_screen)
                 gtk_tree_selection_select_iter (selection, &iter);
@@ -537,9 +536,9 @@
 
 
 static void
-display_settings_dialog_response (GtkDialog *dialog,
-                                  gint       response_id,
-                                  GladeXML  *gxml)
+display_settings_dialog_response (GtkDialog  *dialog,
+                                  gint        response_id,
+                                  GtkBuilder *builder)
 {
     if (response_id == 1)
     {
@@ -561,7 +560,7 @@
             xfce_randr_legacy_reload (xfce_randr_legacy);
 
         /* update dialog */
-        display_settings_treeview_populate (gxml);
+        display_settings_treeview_populate (builder);
     }
     else
     {
@@ -573,18 +572,16 @@
 
 
 static GtkWidget *
-display_settings_dialog_new_from_xml (GladeXML *gxml)
+display_settings_dialog_new (GtkBuilder *builder)
 {
-    GtkWidget        *treeview;
+    GObject          *treeview;
     GtkCellRenderer  *renderer;
     GtkTreeSelection *selection;
-    GtkWidget        *combobox;
+    GObject          *combobox;
 
     /* get the treeview */
-    treeview = glade_xml_get_widget (gxml, "randr-outputs");
-#if GTK_CHECK_VERSION (2, 12, 0)
-        gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview), COLUMN_OUTPUT_NAME);
-#endif
+    treeview = gtk_builder_get_object (builder, "randr-outputs");
+    gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (treeview), COLUMN_OUTPUT_NAME);
 
     /* icon renderer */
     renderer = gtk_cell_renderer_pixbuf_new ();
@@ -599,25 +596,25 @@
     /* treeview selection */
     selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
     gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
-    g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (display_settings_treeview_selection_changed), gxml);
+    g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (display_settings_treeview_selection_changed), builder);
 
     /* setup the combo boxes */
-    combobox = glade_xml_get_widget (gxml, "randr-resolution");
+    combobox = gtk_builder_get_object (builder, "randr-resolution");
     display_settings_combo_box_create (GTK_COMBO_BOX (combobox));
-    g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_resolutions_changed), gxml);
+    g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_resolutions_changed), builder);
 
-    combobox = glade_xml_get_widget (gxml, "randr-refresh-rate");
+    combobox = gtk_builder_get_object (builder, "randr-refresh-rate");
     display_settings_combo_box_create (GTK_COMBO_BOX (combobox));
-    g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_refresh_rates_changed), gxml);
+    g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_refresh_rates_changed), builder);
 
-    combobox = glade_xml_get_widget (gxml, "randr-rotation");
+    combobox = gtk_builder_get_object (builder, "randr-rotation");
     display_settings_combo_box_create (GTK_COMBO_BOX (combobox));
-    g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_rotations_changed), gxml);
+    g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_rotations_changed), builder);
 
     /* populate the treeview */
-    display_settings_treeview_populate (gxml);
+    display_settings_treeview_populate (builder);
 
-    return glade_xml_get_widget (gxml, "display-dialog");
+    return GTK_WIDGET (gtk_builder_get_object (builder, "display-dialog"));
 }
 
 
@@ -626,7 +623,7 @@
 main (gint argc, gchar **argv)
 {
     GtkWidget  *dialog;
-    GladeXML   *gxml;
+    GtkBuilder *builder;
     GError     *error = NULL;
     GdkDisplay *display;
     gboolean    succeeded = TRUE;
@@ -728,13 +725,18 @@
             }
         }
 
-        /* load the dialog glade xml */
-        gxml = glade_xml_new_from_buffer (display_dialog_glade, display_dialog_glade_length, NULL, NULL);
-        if (G_LIKELY (gxml))
+        /* hook to make sure the libxfce4ui library is linked */
+        if (xfce_titled_dialog_get_type () == 0)
+            return EXIT_FAILURE;
+
+        /* load the glade interface */
+        builder = gtk_builder_new ();
+        if (gtk_builder_add_from_string (builder, display_dialog_glade,
+                                         display_dialog_glade_length, &error) != 0)
         {
             /* build the dialog */
-            dialog = display_settings_dialog_new_from_xml (gxml);
-            g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (display_settings_dialog_response), gxml);
+            dialog = display_settings_dialog_new (builder);
+            g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (display_settings_dialog_response), builder);
 
 #if 0
 #ifdef HAS_RANDR_ONE_POINT_TWO
@@ -742,7 +744,7 @@
 #endif
             {
                 /* destroy the devices box */
-                box = glade_xml_get_widget (gxml, "randr-devices-tab");
+                box = gtk_builder_get_object (builder, "randr-devices-tab");
                 gtk_widget_destroy (box);
             }
 #endif
@@ -752,15 +754,16 @@
 
             /* enter the main loop */
             gtk_main ();
+        }
+        else
+        {
+            g_error ("Failed to load the glade file: %s.", error->message);
+            g_error_free (error);
+        }
 
-            /* destroy the dialog */
-            if (GTK_IS_WIDGET (dialog))
-                gtk_widget_destroy (dialog);
+        /* release the builder */
+        g_object_unref (G_OBJECT (builder));
 
-            /* release the glade xml */
-            g_object_unref (G_OBJECT (gxml));
-        }
-        
         err1:
 
         /* release the channel */
@@ -781,5 +784,5 @@
     xfconf_shutdown ();
 
     return (succeeded ? EXIT_SUCCESS : EXIT_FAILURE);
-    
+
 }




More information about the Xfce4-commits mailing list