[Xfce4-commits] [xfce/xfce4-settings] 01/01: display: Drop duplicate code

noreply at xfce.org noreply at xfce.org
Fri Mar 22 01:11:13 CET 2019


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 182fccf3dcb0c6c06d7ff8b1f3235140b43a10ab
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Fri Mar 22 01:11:01 2019 +0100

    display: Drop duplicate code
---
 dialogs/display-settings/main.c | 79 ++---------------------------------------
 1 file changed, 3 insertions(+), 76 deletions(-)

diff --git a/dialogs/display-settings/main.c b/dialogs/display-settings/main.c
index 214d4bc..85495ed 100644
--- a/dialogs/display-settings/main.c
+++ b/dialogs/display-settings/main.c
@@ -45,6 +45,7 @@
 #include <X11/extensions/Xrandr.h>
 
 #include <common/xfce-randr.h>
+#include "common/display-profiles.h"
 #include "display-dialog_ui.h"
 #include "confirmation-dialog_ui.h"
 #include "minimal-display-dialog_ui.h"
@@ -1235,80 +1236,6 @@ display_settings_combobox_selection_changed (GtkComboBox *combobox,
     }
 }
 
-static GList*
-display_settings_get_profiles (void)
-{
-    GHashTable *properties;
-    GList *channel_contents, *profiles = NULL, *current;
-    guint                     m;
-    gchar                    *edid, *output_info_name, **display_infos;
-
-    properties = xfconf_channel_get_properties (display_channel, NULL);
-    channel_contents = g_hash_table_get_keys (properties);
-    display_infos = g_new0 (gchar *, xfce_randr->noutput);
-    /* get all display connectors in combination with their respective edids */
-    for (m = 0; m < xfce_randr->noutput; ++m)
-    {
-        edid = xfce_randr_get_edid (xfce_randr, m);
-        output_info_name = xfce_randr_get_output_info_name (xfce_randr, m);
-        display_infos[m] = g_strdup_printf ("%s/%s", output_info_name, edid);
-    }
-
-    /* get all profiles */
-    current = g_list_first (channel_contents);
-    while (current)
-    {
-        gchar* buf = strtok (current->data, "/");
-        gboolean profile_match = TRUE;
-
-        /* walk all connected displays and filter for edids matching the current profile */
-        for (m = 0; m < xfce_randr->noutput; ++m)
-        {
-            gchar *property;
-            gchar *current_edid, *output_edid;
-            gchar **display_infos_tokens;
-
-            display_infos_tokens = g_strsplit (display_infos[m], "/", 2);
-            property = g_strdup_printf ("/%s/%s/EDID", buf, display_infos_tokens[0]);
-            current_edid = xfconf_channel_get_string (display_channel, property, NULL);
-            output_edid = g_strdup_printf ("%s/%s", display_infos_tokens[0], current_edid);
-            if (current_edid)
-            {
-                if (g_strcmp0 (display_infos[m], output_edid) != 0)
-                    profile_match = FALSE;
-            }
-            else
-            {
-                profile_match = FALSE;
-            }
-            g_free (property);
-            g_free (current_edid);
-            g_free (output_edid);
-            g_strfreev (display_infos_tokens);
-        }
-        /* filter the content of the combobox to only matching profiles and exclude "Notify", "Default" and "Schemes" */
-        if (!g_list_find_custom (profiles, (char*) buf, (GCompareFunc) strcmp) &&
-            strcmp (buf, "Notify") &&
-            strcmp (buf, "Default") &&
-            strcmp (buf, "Schemes") &&
-            profile_match)
-        {
-            profiles = g_list_prepend (profiles, buf);
-        }
-        /* else don't add the profile to the list */
-        current = g_list_next (current);
-    }
-
-    for (m = 0; m < xfce_randr->noutput; ++m)
-    {
-        g_free (display_infos[m]);
-    }
-    g_free (display_infos);
-    g_list_free (channel_contents);
-
-    return profiles;
-}
-
 static void
 display_settings_minimal_profile_populate (GtkBuilder *builder)
 {
@@ -1319,7 +1246,7 @@ display_settings_minimal_profile_populate (GtkBuilder *builder)
     profile_box  = gtk_builder_get_object (builder, "profile-box");
     profile_display1  = gtk_builder_get_object (builder, "display1");
 
-    profiles = display_settings_get_profiles ();
+    profiles = display_settings_get_profiles (xfce_randr, display_channel);
 
     current = g_list_first (profiles);
     while (current)
@@ -1408,7 +1335,7 @@ display_settings_profile_list_populate (GtkBuilder *builder)
     treeview = gtk_builder_get_object (builder, "randr-profile");
     gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
 
-    profiles = display_settings_get_profiles ();
+    profiles = display_settings_get_profiles (xfce_randr, display_channel);
 
     /* Populate treeview */
     current = g_list_first (profiles);

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


More information about the Xfce4-commits mailing list