[Xfce4-commits] [xfce/xfce4-settings] 15/57: color: More state machine simplifications

noreply at xfce.org noreply at xfce.org
Thu Mar 21 22:14:03 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 29ef3c8f2ba3363e609c161bf3ffae83ba4c1e2f
Author: Simon Steinbeiss <simon.steinbeiss at elfenbeinturm.at>
Date:   Wed Feb 6 23:00:43 2019 +0100

    color: More state machine simplifications
---
 dialogs/color-settings/color-dialog.glade |  13 ++--
 dialogs/color-settings/main.c             | 109 ++----------------------------
 2 files changed, 11 insertions(+), 111 deletions(-)

diff --git a/dialogs/color-settings/color-dialog.glade b/dialogs/color-settings/color-dialog.glade
index 0a3e656..d7bfbf6 100644
--- a/dialogs/color-settings/color-dialog.glade
+++ b/dialogs/color-settings/color-dialog.glade
@@ -44,8 +44,8 @@
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="button2">
-                <property name="label">gtk-close</property>
+              <object class="GtkButton" id="button1">
+                <property name="label">gtk-help</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -55,11 +55,12 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="position">0</property>
+                <property name="secondary">True</property>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="button1">
-                <property name="label">gtk-help</property>
+              <object class="GtkButton" id="button2">
+                <property name="label">gtk-close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
@@ -69,7 +70,6 @@
                 <property name="expand">False</property>
                 <property name="fill">False</property>
                 <property name="position">0</property>
-                <property name="secondary">True</property>
               </packing>
             </child>
           </object>
@@ -201,6 +201,7 @@
                   <object class="GtkBox">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="vexpand">True</property>
                     <property name="orientation">vertical</property>
                     <child>
                       <object class="GtkBox" id="box-profiles">
@@ -334,8 +335,8 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">button2</action-widget>
       <action-widget response="-11">button1</action-widget>
+      <action-widget response="0">button2</action-widget>
     </action-widgets>
   </object>
   <object class="GtkAdjustment" id="mouse-emulation-curve">
diff --git a/dialogs/color-settings/main.c b/dialogs/color-settings/main.c
index 897dff3..cd65013 100644
--- a/dialogs/color-settings/main.c
+++ b/dialogs/color-settings/main.c
@@ -216,61 +216,6 @@ color_settings_add_device_profiles (ColorSettings *settings, CdDevice *device)
 
 
 
-/* find the profile in the array -- for flicker-free changes */
-static gboolean
-color_settings_find_profile_by_object_path (GPtrArray *profiles,
-                                       const gchar *object_path)
-{
-  CdProfile *profile_tmp;
-  guint i;
-
-  for (i = 0; i < profiles->len; i++)
-    {
-      profile_tmp = g_ptr_array_index (profiles, i);
-      if (g_strcmp0 (cd_profile_get_object_path (profile_tmp), object_path) == 0)
-        return TRUE;
-    }
-  return FALSE;
-}
-
-
-
-/* find the profile in the list view -- for flicker-free changes */
-static gboolean
-color_settings_find_widget_by_object_path (GList *list,
-                                      const gchar *object_path_device,
-                                      const gchar *object_path_profile)
-{
-  GList *l;
-  CdDevice *device_tmp;
-  CdProfile *profile_tmp;
-
-  for (l = list; l != NULL; l = l->next)
-    {
-      if (!SETTINGS_IS_COLOR_PROFILE (l->data))
-        continue;
-
-      /* correct device ? */
-      device_tmp = color_profile_get_device (SETTINGS_COLOR_PROFILE (l->data));
-      if (g_strcmp0 (object_path_device,
-                     cd_device_get_object_path (device_tmp)) != 0)
-        {
-          continue;
-        }
-
-      /* this profile */
-      profile_tmp = color_profile_get_profile (SETTINGS_COLOR_PROFILE (l->data));
-      if (g_strcmp0 (object_path_profile,
-                     cd_profile_get_object_path (profile_tmp)) == 0)
-        {
-          return TRUE;
-        }
-    }
-  return FALSE;
-}
-
-
-
 static void
 color_settings_update_device_list_extra_entry (ColorSettings *settings)
 {
@@ -319,7 +264,6 @@ color_settings_list_box_row_activated_cb (GtkListBox *list_box,
         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));
 }
 
 
@@ -331,7 +275,9 @@ color_settings_device_enabled_changed_cb (ColorDevice *widget,
                                           ColorSettings *settings)
 {
     gtk_list_box_select_row (settings->list_box, GTK_LIST_BOX_ROW (widget));
-    color_settings_list_box_row_activated_cb (settings->list_box, GTK_LIST_BOX_ROW (widget), settings);
+    gtk_widget_set_visible (GTK_WIDGET (settings->label_no_profiles), !is_enabled);
+    gtk_widget_set_visible (GTK_WIDGET (settings->box_profiles), is_enabled);
+    gtk_widget_set_sensitive (GTK_WIDGET (settings->profiles_remove), is_enabled);
 }
 
 
@@ -373,50 +319,7 @@ color_settings_dialog_response (GtkWidget *dialog,
 static void
 color_settings_device_changed_cb (CdDevice *device, ColorSettings *settings)
 {
-  CdDevice *device_tmp;
-  CdProfile *profile_tmp;
-  gboolean ret;
-  GList *l;
-  g_autoptr(GList) list = NULL;
-  GPtrArray *profiles;
-  guint i;
-
-  /* remove anything in the list view that's not in Device.Profiles */
-  profiles = cd_device_get_profiles (device);
-  list = gtk_container_get_children (GTK_CONTAINER (settings->profiles_list_box));
-  for (l = list; l != NULL; l = l->next)
-    {
-      if (!SETTINGS_IS_COLOR_PROFILE (l->data))
-        continue;
-
-      /* correct device ? */
-      device_tmp = color_profile_get_device (SETTINGS_COLOR_PROFILE (l->data));
-      if (g_strcmp0 (cd_device_get_id (device),
-                     cd_device_get_id (device_tmp)) != 0)
-        continue;
-
-      /* if profile is not in Device.Profiles then remove */
-      profile_tmp = color_profile_get_profile (SETTINGS_COLOR_PROFILE (l->data));
-      ret = color_settings_find_profile_by_object_path (profiles,
-                                                   cd_profile_get_object_path (profile_tmp));
-      if (!ret) {
-        gtk_widget_destroy (GTK_WIDGET (l->data));
-        /* Don't look at the destroyed widget below */
-        l->data = NULL;
-      }
-    }
-
-  /* add anything in Device.Profiles that's not in the list view */
-  for (i = 0; i < profiles->len; i++)
-    {
-      profile_tmp = g_ptr_array_index (profiles, i);
-      ret = color_settings_find_widget_by_object_path (list,
-                                                  cd_device_get_object_path (device),
-                                                  cd_profile_get_object_path (profile_tmp));
-      if (!ret)
-        color_settings_add_device_profile (settings, device, profile_tmp, i == 0);
-    }
-
+  color_settings_add_device_profiles (settings, device);
   color_settings_update_profile_list_extra_entry (settings);
 }
 
@@ -634,10 +537,6 @@ color_settings_dialog_init (GtkBuilder *builder)
         g_signal_connect (settings->list_box, "row-selected",
                           G_CALLBACK (color_settings_list_box_row_activated_cb),
                           settings);
-    settings->list_box_activated_id =
-    g_signal_connect (settings->list_box, "row-activated",
-                      G_CALLBACK (color_settings_list_box_row_activated_cb),
-                      settings);
     settings->list_box_size = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL);
 
     gtk_container_add (GTK_CONTAINER (settings->frame_devices), GTK_WIDGET (settings->list_box));

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


More information about the Xfce4-commits mailing list