[Xfce4-commits] [xfce/xfce4-settings] 13/37: color: Try to fix race condition

noreply at xfce.org noreply at xfce.org
Fri Feb 15 00:27:42 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       o   c   h   o   s   i   /   c   o   l   o   r   d   
   in repository xfce/xfce4-settings.

commit 3c57d3809466dd5b65068f9eb97eddb32cb2b325
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Wed Feb 6 00:06:44 2019 +0100

    color: Try to fix race condition
    
    The callbacks for the colord signal "device-changed" and the "enabled"
    signal we emit by hand for the device GtkSwitch competed and sometimes
    produced inconsistent results in the profile list.
---
 dialogs/color-settings/main.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/dialogs/color-settings/main.c b/dialogs/color-settings/main.c
index 924bb99..897dff3 100644
--- a/dialogs/color-settings/main.c
+++ b/dialogs/color-settings/main.c
@@ -87,6 +87,15 @@ struct _ColorSettings
 
 
 static void
+listbox_remove_all (GtkWidget *widget, gpointer user_data)
+{
+    GtkWidget *container = user_data;
+    gtk_container_remove (GTK_CONTAINER (container), widget);
+}
+
+
+
+static void
 color_settings_make_profile_default_cb (GObject *object,
                                         GAsyncResult *res,
                                         ColorSettings *settings)
@@ -185,10 +194,13 @@ color_settings_add_device_profile (ColorSettings *settings,
 static void
 color_settings_add_device_profiles (ColorSettings *settings, CdDevice *device)
 {
+  GtkCallback func = listbox_remove_all;
   CdProfile *profile_tmp;
   g_autoptr(GPtrArray) profiles = NULL;
   guint i;
 
+  /* remove all profiles from the list */
+  gtk_container_foreach (GTK_CONTAINER (settings->profiles_list_box), func, settings->profiles_list_box);
   /* add profiles */
   profiles = cd_device_get_profiles (device);
   if (profiles == NULL)
@@ -291,31 +303,23 @@ color_settings_update_profile_list_extra_entry (ColorSettings *settings)
 
 
 static void
-listbox_remove_all (GtkWidget *widget, gpointer user_data)
-{
-    GtkWidget *container = user_data;
-    gtk_container_remove (GTK_CONTAINER (container), widget);
-}
-
-
-
-static void
 color_settings_list_box_row_activated_cb (GtkListBox *list_box,
                                           GtkListBoxRow *row,
                                           ColorSettings *settings)
 {
-    GtkCallback func = listbox_remove_all;
 
-    gtk_container_foreach (GTK_CONTAINER (settings->profiles_list_box), func, settings->profiles_list_box);
     g_object_get (row, "device", &settings->current_device, NULL);
     if (cd_device_get_enabled (settings->current_device))
     {
         color_settings_add_device_profiles (settings, settings->current_device);
         color_settings_update_profile_list_extra_entry (settings);
-        gtk_widget_queue_draw (GTK_WIDGET (settings->grid));
     }
     else
-        color_settings_update_profile_list_extra_entry (settings);
+    {
+        gtk_widget_show (GTK_WIDGET (settings->label_no_profiles));
+        gtk_widget_hide (GTK_WIDGET (settings->box_profiles));
+    }
+    gtk_widget_queue_draw (GTK_WIDGET (settings->grid));
 }
 
 
@@ -327,8 +331,7 @@ color_settings_device_enabled_changed_cb (ColorDevice *widget,
                                           ColorSettings *settings)
 {
     gtk_list_box_select_row (settings->list_box, GTK_LIST_BOX_ROW (widget));
-    gtk_widget_set_visible (GTK_WIDGET (settings->label_no_profiles), !is_enabled);
-    gtk_widget_set_visible (GTK_WIDGET (settings->box_profiles), is_enabled);
+    color_settings_list_box_row_activated_cb (settings->list_box, GTK_LIST_BOX_ROW (widget), settings);
 }
 
 

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


More information about the Xfce4-commits mailing list