[Xfce4-commits] <xfce4-settings:master> Use a different ui depending on the available randr version

Nick Schermer noreply at xfce.org
Sat Aug 28 23:02:10 CEST 2010


Updating branch refs/heads/master
         to 126f1a96fb5e658097665ab3e4ad6cca36cce62d (commit)
       from 878339adbd4b2c0cff336739890efb9b4a114133 (commit)

commit 126f1a96fb5e658097665ab3e4ad6cca36cce62d
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date:   Sat Jun 5 19:45:12 2010 +0200

    Use a different ui depending on the available randr version

 dialogs/display-settings/Makefile.am               |    9 +++-
 ...dialog.glade => display-dialog-xrandr1.2.glade} |    0
 dialogs/display-settings/display-dialog.glade      |   37 ++++++++++++--
 dialogs/display-settings/main.c                    |   52 +++++++++++++------
 po/POTFILES.in                                     |    1 +
 5 files changed, 75 insertions(+), 24 deletions(-)

diff --git a/dialogs/display-settings/Makefile.am b/dialogs/display-settings/Makefile.am
index 2d5f801..4413535 100644
--- a/dialogs/display-settings/Makefile.am
+++ b/dialogs/display-settings/Makefile.am
@@ -17,7 +17,8 @@ xfce4_display_settings_SOURCES = \
 	xfce-randr.h \
 	xfce-randr-legacy.c \
 	xfce-randr-legacy.h \
-	display-dialog_ui.h
+	display-dialog_ui.h \
+	display-dialog-xrandr1.2_ui.h
 
 xfce4_display_settings_CFLAGS = \
 	$(GTK_CFLAGS) \
@@ -44,6 +45,9 @@ BUILT_SOURCES = \
 display-dialog_ui.h: display-dialog.glade
 	exo-csource --static --strip-comments --strip-content --name=display_dialog_ui $< >$@
 
+display-dialog-xrandr1.2_ui.h: display-dialog-xrandr1.2.glade
+	exo-csource --static --strip-comments --strip-content --name=display_dialog_xrandr12_ui $< >$@
+
 endif
 
 desktopdir = $(datadir)/applications
@@ -54,7 +58,8 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
 
 EXTRA_DIST = \
 	$(desktop_in_files) \
-	display-dialog.glade
+	display-dialog.glade \
+	display-dialog-xrandr1.2.glade
 
 DISTCLEANFILES = \
 	$(desktop_DATA)
diff --git a/dialogs/display-settings/display-dialog.glade b/dialogs/display-settings/display-dialog-xrandr1.2.glade
similarity index 100%
copy from dialogs/display-settings/display-dialog.glade
copy to dialogs/display-settings/display-dialog-xrandr1.2.glade
diff --git a/dialogs/display-settings/display-dialog.glade b/dialogs/display-settings/display-dialog.glade
index d7f65c6..a255b81 100644
--- a/dialogs/display-settings/display-dialog.glade
+++ b/dialogs/display-settings/display-dialog.glade
@@ -47,12 +47,12 @@
             <child>
               <object class="GtkTable" id="table1">
                 <property name="visible">True</property>
-                <property name="n_rows">2</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>
-                  <object class="GtkLabel" id="label4">
+                  <object class="GtkLabel" id="label5">
                     <property name="visible">True</property>
                     <property name="xalign">0</property>
                     <property name="label" translatable="yes">Ro_tation:</property>
@@ -60,6 +60,21 @@
                     <property name="mnemonic_widget">randr-rotation</property>
                   </object>
                   <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <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>
+                  </object>
+                  <packing>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                     <property name="x_options">GTK_FILL</property>
@@ -70,9 +85,9 @@
                   <object class="GtkLabel" id="label3">
                     <property name="visible">True</property>
                     <property name="xalign">0</property>
-                    <property name="label" translatable="yes">M_ode:</property>
+                    <property name="label" translatable="yes">R_esolution:</property>
                     <property name="use_underline">True</property>
-                    <property name="mnemonic_widget">randr-mode</property>
+                    <property name="mnemonic_widget">randr-resolution</property>
                   </object>
                   <packing>
                     <property name="x_options">GTK_FILL</property>
@@ -86,13 +101,25 @@
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBox" id="randr-refresh-rate">
+                    <property name="visible">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                     <property name="y_options">GTK_FILL</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkComboBox" id="randr-mode">
+                  <object class="GtkComboBox" id="randr-resolution">
                     <property name="visible">True</property>
                   </object>
                   <packing>
diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 10c393e..a3083f2 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -42,6 +42,9 @@
 #include "xfce-randr.h"
 #include "xfce-randr-legacy.h"
 #include "display-dialog_ui.h"
+#ifdef HAS_RANDR_ONE_POINT_TWO
+#include "display-dialog-xrandr1.2_ui.h"
+#endif
 
 enum
 {
@@ -186,7 +189,6 @@ display_setting_rotations_populate (GtkBuilder *builder)
 
 
 
-#ifndef HAS_RANDR_ONE_POINT_TWO
 static void
 display_setting_refresh_rates_changed (GtkComboBox *combobox,
                                        GtkBuilder  *builder)
@@ -199,7 +201,6 @@ display_setting_refresh_rates_changed (GtkComboBox *combobox,
     /* set new rate */
         XFCE_RANDR_LEGACY_RATE (xfce_randr_legacy) = value;
 }
-#endif
 
 
 
@@ -252,7 +253,6 @@ display_setting_refresh_rates_populate (GtkBuilder *builder)
 
 
 
-#ifndef HAS_RANDR_ONE_POINT_TWO
 static void
 display_setting_resolutions_changed (GtkComboBox *combobox,
                                      GtkBuilder  *builder)
@@ -270,7 +270,6 @@ display_setting_resolutions_changed (GtkComboBox *combobox,
     display_setting_refresh_rates_populate (builder);
     display_setting_rotations_populate (builder);
 }
-#endif
 
 
 
@@ -607,18 +606,24 @@ display_settings_dialog_new (GtkBuilder *builder)
 
     /* setup the combo boxes */
 #ifdef HAS_RANDR_ONE_POINT_TWO
-    combobox = gtk_builder_get_object (builder, "randr-mode");
-    display_settings_combo_box_create (GTK_COMBO_BOX (combobox));
-    g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_modes_changed), builder);
-#else
-    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), builder);
-
-    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), builder);
+    if (xfce_randr != NULL)
+    {
+        combobox = gtk_builder_get_object (builder, "randr-mode");
+        display_settings_combo_box_create (GTK_COMBO_BOX (combobox));
+        g_signal_connect (G_OBJECT (combobox), "changed", G_CALLBACK (display_setting_modes_changed), builder);
+    }
+    else
 #endif
+    {
+        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), builder);
+
+        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), builder);
+    }
+
     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), builder);
@@ -640,6 +645,7 @@ main (gint argc, gchar **argv)
     GdkDisplay *display;
     gboolean    succeeded = TRUE;
     gint        event_base, error_base;
+    guint       ui_ret;
 
     /* setup translation domain */
     xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
@@ -744,8 +750,20 @@ main (gint argc, gchar **argv)
 
         /* load the Gtk user-interface file */
         builder = gtk_builder_new ();
-        if (gtk_builder_add_from_string (builder, display_dialog_ui,
-                                         display_dialog_ui_length, &error) != 0)
+#ifdef HAS_RANDR_ONE_POINT_TWO
+        if (xfce_randr != NULL)
+        {
+            ui_ret = gtk_builder_add_from_string (builder, display_dialog_xrandr12_ui,
+                                                  display_dialog_xrandr12_ui_length, &error);
+        }
+        else
+#endif
+        {
+            ui_ret = gtk_builder_add_from_string (builder, display_dialog_ui,
+                                                  display_dialog_ui_length, &error);
+        }
+
+        if (ui_ret != 0)
         {
             /* build the dialog */
             dialog = display_settings_dialog_new (builder);
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c695ee7..1161f73 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -7,6 +7,7 @@ dialogs/appearance-settings/main.c
 dialogs/appearance-settings/xfce-ui-settings.desktop.in
 
 dialogs/display-settings/display-dialog.glade
+dialogs/display-settings/display-dialog-xrandr1.2.glade
 dialogs/display-settings/main.c
 dialogs/display-settings/xfce-randr.c
 dialogs/display-settings/xfce-randr-legacy.c



More information about the Xfce4-commits mailing list