[gnome-control-center] display: Add a slider to select a monitor's scale when available
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] display: Add a slider to select a monitor's scale when available
- Date: Thu, 18 May 2017 17:00:47 +0000 (UTC)
commit 4b30ecb7585b82f899c24080b79d04a23a18b7e8
Author: Rui Matos <tiagomatos gmail com>
Date: Tue Apr 11 14:17:27 2017 +0200
display: Add a slider to select a monitor's scale when available
Mutter's new display configuration API allows configurable per-monitor
scales within a finite set determined by mutter. We expose the
available values in a simple slider widget for each monitor.
https://bugzilla.gnome.org/show_bug.cgi?id=782785
panels/display/cc-display-panel.c | 48 +++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/panels/display/cc-display-panel.c b/panels/display/cc-display-panel.c
index 2d8434b..57a2c85 100644
--- a/panels/display/cc-display-panel.c
+++ b/panels/display/cc-display-panel.c
@@ -2011,6 +2011,27 @@ underscan_switch_toggled (CcDisplayPanel *panel)
update_apply_button (panel);
}
+static guint
+n_supported_scales (CcDisplayConfig *config)
+{
+ const double *scales = cc_display_config_get_supported_scales (config);
+ guint n = 0;
+
+ while (scales[n] != 0.0)
+ n++;
+
+ return n;
+}
+
+static void
+scale_slider_changed (GtkRange *slider,
+ CcDisplayPanel *panel)
+{
+ cc_display_monitor_set_scale (panel->priv->current_output,
+ gtk_range_get_value (slider));
+ update_apply_button (panel);
+}
+
static void
show_setup_dialog (CcDisplayPanel *panel)
{
@@ -2246,6 +2267,33 @@ show_setup_dialog (CcDisplayPanel *panel)
label, "visible", G_BINDING_BIDIRECTIONAL);
grid_pos++;
+ /* scale */
+ if (n_supported_scales (priv->current_config) > 1)
+ {
+ GtkWidget *slider;
+ const double *scales = cc_display_config_get_supported_scales (priv->current_config);
+ guint n = n_supported_scales (priv->current_config);
+ guint i = 0;
+
+ slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
+ scales[0], scales[n - 1],
+ scales[1] - scales[0]);
+ gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
+ gtk_scale_set_has_origin (GTK_SCALE (slider), FALSE);
+ for (i = 0; i < n; i++)
+ {
+ gchar *s = g_strdup_printf ("%.1lgĂ—", scales[i]);
+ gtk_scale_add_mark (GTK_SCALE (slider), scales[i], GTK_POS_TOP, s);
+ g_free (s);
+ }
+ gtk_range_set_value (GTK_RANGE (slider), cc_display_monitor_get_scale (priv->current_output));
+ g_signal_connect (slider, "value-changed", G_CALLBACK (scale_slider_changed), panel);
+
+ gtk_grid_attach (GTK_GRID (priv->config_grid), slider, 1, grid_pos, 1, 1);
+ gtk_widget_set_halign (priv->freq_combo, GTK_ALIGN_CENTER);
+ grid_pos++;
+ }
+
was_clone = clone = cc_display_config_is_cloning (priv->current_config);
primary = cc_display_monitor_is_primary (priv->current_output);
active = cc_display_monitor_is_active (priv->current_output);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]