[Xfce4-commits] [xfce/xfce4-settings] 01/01: display: Mark preferred mode with an asterisk

noreply at xfce.org noreply at xfce.org
Wed Jan 8 23:20:07 CET 2020


This is an automated email from the git hooks/post-receive script.

o   c   h   o   s   i       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/xfce4-settings.

commit 4930c124e0ad1ff53bedf8a6bf1fff96440f17e5
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Fri Dec 27 01:32:09 2019 +0100

    display: Mark preferred mode with an asterisk
    
    While the xrandr cli utility uses a '+' for the preferred mode and an
    asterisk '*' for the currently active mode it feels more appropriate and
    understandable to use the asterisk over the plus sign in the combobox.
---
 dialogs/display-settings/main.c | 32 +++++++++++++++++++++++---------
 1 file changed, 23 insertions(+), 9 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index c2fb52b..41f83a3 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -228,6 +228,9 @@ static void display_settings_profile_apply                   (GtkWidget       *w
 static void display_settings_minimal_profile_apply           (GtkToggleButton *widget,
                                                               GtkBuilder      *builder);
 
+static GList *list_connected_outputs                         (gint            *total_w,
+                                                              gint            *total_h);
+
 static void
 display_settings_changed (void)
 {
@@ -235,13 +238,15 @@ display_settings_changed (void)
 }
 
 static XfceOutputInfo*
-get_nth_xfce_output_info(gint id)
+get_nth_xfce_output_info (gint id)
 {
     XfceOutputInfo *output = NULL;
     GList * entry = NULL;
 
-    if (current_outputs)
-        entry = g_list_nth (current_outputs, id);
+    if (!current_outputs)
+        current_outputs = list_connected_outputs (NULL, NULL);
+
+    entry = g_list_nth (current_outputs, id);
 
     if (entry)
         output = entry->data;
@@ -697,6 +702,7 @@ display_setting_resolutions_populate (GtkBuilder *builder)
     gchar            *rratio;
     GtkTreeIter       iter;
     const XfceRRMode *modes;
+    XfceOutputInfo   *output;
 
     /* Get the combo box store and clear it */
     combobox = gtk_builder_get_object (builder, "randr-resolution");
@@ -705,6 +711,8 @@ display_setting_resolutions_populate (GtkBuilder *builder)
 
     label = gtk_builder_get_object (builder, "label-resolution");
 
+    output = get_nth_xfce_output_info (active_output);
+
     /* Disable it if no mode is selected */
     if (xfce_randr->mode[active_output] == None)
     {
@@ -734,6 +742,15 @@ display_setting_resolutions_populate (GtkBuilder *builder)
             gchar     *ratio_text = NULL;
             XfceRatio *ratio_info = g_hash_table_lookup (display_ratio, &ratio);
 
+            /* Highlight the preferred mode with an asterisk */
+            if (output->pref_width == modes[n].width
+                && output->pref_height == modes[n].height)
+                name = g_strdup_printf ("%dx%d*", modes[n].width,
+                                        modes[n].height);
+            else
+                name = g_strdup_printf ("%dx%d", modes[n].width,
+                                        modes[n].height);
+
             if (ratio_info)
                 ratio_text = g_strdup (ratio_info->desc);
 
@@ -771,14 +788,10 @@ display_setting_resolutions_populate (GtkBuilder *builder)
                 guint gcd_tmp = gcd (modes[n].width, modes[n].height);
                 guint format_x = modes[n].width / gcd_tmp;
                 guint format_y = modes[n].height / gcd_tmp;
-                name = g_strdup_printf ("%dx%d", modes[n].width,
-                                        modes[n].height);
                 rratio = g_strdup_printf ("<span fgalpha='50%%'>%d:%d</span>", format_x, format_y);
             }
             else
             {
-                name = g_strdup_printf ("%dx%d", modes[n].width,
-                                        modes[n].height);
                 rratio = g_strdup_printf ("<span fgalpha='50%%'>%s</span>", ratio_text);
             }
             g_free (ratio_text);
@@ -2459,7 +2472,8 @@ get_mirrored_configuration (void)
         return cloned;
 }
 
-static XfceOutputInfo *convert_xfce_output_info (gint output_id)
+static XfceOutputInfo *
+convert_xfce_output_info (gint output_id)
 {
     XfceOutputInfo *output;
     const XfceRRMode *mode, *preferred;
@@ -2468,7 +2482,7 @@ static XfceOutputInfo *convert_xfce_output_info (gint output_id)
 
     xfce_randr_get_positions(xfce_randr, output_id, &x, &y);
     mode = xfce_randr_find_mode_by_id (xfce_randr, output_id, xfce_randr->mode[output_id]);
-    preferred_mode = xfce_randr_preferred_mode(xfce_randr, output_id);
+    preferred_mode = xfce_randr_preferred_mode (xfce_randr, output_id);
     preferred = xfce_randr_find_mode_by_id (xfce_randr, output_id, preferred_mode);
     output = g_new0 (XfceOutputInfo, 1);
     output->id = output_id;

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list