[Xfce4-commits] <xfce4-settings:xrandr-display-settings> Do less work when an output is disabled
Jérôme Guelfucci
noreply at xfce.org
Sun Jun 27 23:04:02 CEST 2010
Updating branch refs/heads/xrandr-display-settings
to c3e08946f4d74d6530fc97dc40ae61ded82e7af8 (commit)
from 16607b4cf5e1e102a86037fcda3e41bda7159877 (commit)
commit c3e08946f4d74d6530fc97dc40ae61ded82e7af8
Author: Lionel Le Folgoc <mrpouit at gmail.com>
Date: Sun Jun 27 19:08:03 2010 +0200
Do less work when an output is disabled
When an output is disabled, simply clear the comboboxes, mark them as
insensitive, and return. Fill them only if the output is enabled.
dialogs/display-settings/main.c | 121 ++++++++++++++++++++++++--------------
1 files changed, 76 insertions(+), 45 deletions(-)
diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 2a52cc2..e5a9dd2 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -274,7 +274,21 @@ display_setting_reflections_populate (GtkBuilder *builder)
guint n;
GtkTreeIter iter;
+ if (!xfce_randr)
+ return;
+
+ /* get the combo box store and clear it */
combobox = gtk_builder_get_object (builder, "randr-reflection");
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
+ gtk_list_store_clear (GTK_LIST_STORE (model));
+
+ /* disable it if no mode is selected */
+ if (XFCE_RANDR_MODE (xfce_randr) == None)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), FALSE);
+ return;
+ }
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), TRUE);
/* Disconnect the "changed" signal to avoid triggering the confirmation
* dialog */
@@ -282,37 +296,26 @@ display_setting_reflections_populate (GtkBuilder *builder)
display_setting_reflections_changed,
builder, NULL);
- /* get the combo box store and clear it */
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
- gtk_list_store_clear (GTK_LIST_STORE (model));
+ /* load only supported reflections */
+ reflections = XFCE_RANDR_ROTATIONS (xfce_randr) & XFCE_RANDR_REFLECTIONS_MASK;
+ active_reflection = XFCE_RANDR_ROTATION (xfce_randr) & XFCE_RANDR_REFLECTIONS_MASK;
-
- if (xfce_randr)
+ /* try to insert the reflections */
+ for (n = 0; n < G_N_ELEMENTS (reflection_names); n++)
{
- /* disable it if no mode is selected */
- gtk_widget_set_sensitive (GTK_WIDGET (combobox), XFCE_RANDR_MODE (xfce_randr) != None);
-
- /* load only supported reflections */
- reflections = XFCE_RANDR_ROTATIONS (xfce_randr) & XFCE_RANDR_REFLECTIONS_MASK;
- active_reflection = XFCE_RANDR_ROTATION (xfce_randr) & XFCE_RANDR_REFLECTIONS_MASK;
-
- /* try to insert the reflections */
- for (n = 0; n < G_N_ELEMENTS (reflection_names); n++)
+ if ((reflections & reflection_names[n].rotation) == reflection_names[n].rotation)
{
- if ((reflections & reflection_names[n].rotation) == reflection_names[n].rotation)
- {
- /* insert */
- gtk_list_store_append (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COLUMN_COMBO_NAME, _(reflection_names[n].name),
- COLUMN_COMBO_VALUE, reflection_names[n].rotation, -1);
+ /* insert */
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COLUMN_COMBO_NAME, _(reflection_names[n].name),
+ COLUMN_COMBO_VALUE, reflection_names[n].rotation, -1);
- /* select active reflection */
- if (xfce_randr && XFCE_RANDR_MODE (xfce_randr) != None)
- {
- if ((reflection_names[n].rotation & active_reflection) == reflection_names[n].rotation)
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
- }
+ /* select active reflection */
+ if (xfce_randr && XFCE_RANDR_MODE (xfce_randr) != None)
+ {
+ if ((reflection_names[n].rotation & active_reflection) == reflection_names[n].rotation)
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combobox), &iter);
}
}
}
@@ -390,6 +393,21 @@ display_setting_rotations_populate (GtkBuilder *builder)
/* get the combo box store and clear it */
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));
+
+#ifdef HAS_RANDR_ONE_POINT_TWO
+ if (xfce_randr)
+ {
+ /* disable it if no mode is selected */
+ if (XFCE_RANDR_MODE (xfce_randr) == None)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), FALSE);
+ return;
+ }
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), TRUE);
+ }
+#endif
/* Disconnect the "changed" signal to avoid triggering the confirmation
* dialog */
@@ -397,15 +415,9 @@ display_setting_rotations_populate (GtkBuilder *builder)
display_setting_rotations_changed,
builder, NULL);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
- gtk_list_store_clear (GTK_LIST_STORE (model));
-
#ifdef HAS_RANDR_ONE_POINT_TWO
if (xfce_randr)
{
- /* disable it if no mode is selected */
- gtk_widget_set_sensitive (GTK_WIDGET (combobox), XFCE_RANDR_MODE (xfce_randr) != None);
-
/* load only supported rotations */
rotations = XFCE_RANDR_ROTATIONS (xfce_randr) & XFCE_RANDR_ROTATIONS_MASK;
active_rotation = XFCE_RANDR_ROTATION (xfce_randr) & XFCE_RANDR_ROTATIONS_MASK;
@@ -519,6 +531,21 @@ display_setting_refresh_rates_populate (GtkBuilder *builder)
/* get the combo box store and clear it */
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
+ if (xfce_randr)
+ {
+ /* disable it if no mode is selected */
+ if (XFCE_RANDR_MODE (xfce_randr) == None)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), FALSE);
+ return;
+ }
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), TRUE);
+ }
+#endif
/* Disconnect the "changed" signal to avoid triggering the confirmation
* dialog */
@@ -526,15 +553,9 @@ display_setting_refresh_rates_populate (GtkBuilder *builder)
display_setting_refresh_rates_changed,
builder, NULL);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
- gtk_list_store_clear (GTK_LIST_STORE (model));
-
#ifdef HAS_RANDR_ONE_POINT_TWO
if (xfce_randr)
{
- /* disable it if no mode is selected */
- gtk_widget_set_sensitive (GTK_WIDGET (combobox), XFCE_RANDR_MODE (xfce_randr) != None);
-
/* fetch the selected resolution */
res_combobox = gtk_builder_get_object (builder, "randr-resolution");
if (!display_setting_combo_box_get_value (GTK_COMBO_BOX (res_combobox), &n))
@@ -682,6 +703,22 @@ display_setting_resolutions_populate (GtkBuilder *builder)
/* get the combo box store and clear it */
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));
+
+#ifdef HAS_RANDR_ONE_POINT_TWO
+ if (xfce_randr)
+ {
+ /* disable it if no mode is selected */
+ if (XFCE_RANDR_MODE (xfce_randr) == None)
+ {
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), FALSE);
+ display_setting_refresh_rates_populate (builder);
+ return;
+ }
+ gtk_widget_set_sensitive (GTK_WIDGET (combobox), TRUE);
+ }
+#endif
/* Disconnect the "changed" signal to avoid triggering the confirmation
* dialog */
@@ -689,15 +726,9 @@ display_setting_resolutions_populate (GtkBuilder *builder)
display_setting_resolutions_changed,
builder, NULL);
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (combobox));
- gtk_list_store_clear (GTK_LIST_STORE (model));
-
#ifdef HAS_RANDR_ONE_POINT_TWO
if (xfce_randr)
{
- /* disable it if no mode is selected */
- gtk_widget_set_sensitive (GTK_WIDGET (combobox), XFCE_RANDR_MODE (xfce_randr) != None);
-
/* walk all supported modes */
modes = XFCE_RANDR_SUPPORTED_MODES (xfce_randr);
for (n = 0; n < XFCE_RANDR_OUTPUT_INFO (xfce_randr)->nmode; ++n)
More information about the Xfce4-commits
mailing list