[gnome-control-center] thunderbolt: device entry can show device warnings



commit d2ae2d464fae704de004d98aa795f27b75760709
Author: Christian Kellner <christian kellner me>
Date:   Fri Feb 1 17:51:43 2019 +0100

    thunderbolt: device entry can show device warnings
    
    The CcBoltDeviceEntry can now optionally show a warning indicator
    if the device is in the pending state.
    Since we *don't* want to show this in the main list, remove calls
    to gtk_widget_show_all and replace them with gtk_widget_show.

 panels/thunderbolt/cc-bolt-device-entry.c  | 11 ++++++++++-
 panels/thunderbolt/cc-bolt-device-entry.h  |  3 ++-
 panels/thunderbolt/cc-bolt-device-entry.ui | 28 +++++++++++++++++++++++-----
 panels/thunderbolt/cc-bolt-panel.c         | 16 ++++++++--------
 4 files changed, 43 insertions(+), 15 deletions(-)
---
diff --git a/panels/thunderbolt/cc-bolt-device-entry.c b/panels/thunderbolt/cc-bolt-device-entry.c
index 27beaddea..cba7ac056 100644
--- a/panels/thunderbolt/cc-bolt-device-entry.c
+++ b/panels/thunderbolt/cc-bolt-device-entry.c
@@ -38,6 +38,8 @@ struct _CcBoltDeviceEntry
   /* main ui */
   GtkLabel *name_label;
   GtkLabel *status_label;
+  GtkLabel *status_warning;
+  gboolean  show_warnings;
 };
 
 static const char *   device_status_to_brief_for_ui (BoltDevice *dev);
@@ -70,6 +72,7 @@ entry_update_status (CcBoltDeviceEntry *entry)
 {
   const char *brief;
   BoltStatus status;
+  gboolean warn;
 
   status = bolt_device_get_status (entry->device);
   brief = device_status_to_brief_for_ui (entry->device);
@@ -80,6 +83,9 @@ entry_update_status (CcBoltDeviceEntry *entry)
                  signals[SIGNAL_STATUS_CHANGED],
                  0,
                  status);
+
+  warn = entry->show_warnings && bolt_status_is_pending (status);
+  gtk_widget_set_visible (GTK_WIDGET (entry->status_warning), warn);
 }
 
 static void
@@ -167,6 +173,7 @@ cc_bolt_device_entry_class_init (CcBoltDeviceEntryClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, RESOURCE_UI);
   gtk_widget_class_bind_template_child (widget_class, CcBoltDeviceEntry, name_label);
   gtk_widget_class_bind_template_child (widget_class, CcBoltDeviceEntry, status_label);
+  gtk_widget_class_bind_template_child (widget_class, CcBoltDeviceEntry, status_warning);
 
   signals[SIGNAL_STATUS_CHANGED] =
     g_signal_new ("status-changed",
@@ -189,12 +196,14 @@ cc_bolt_device_entry_init (CcBoltDeviceEntry *entry)
 /* public function */
 
 CcBoltDeviceEntry *
-cc_bolt_device_entry_new (BoltDevice *device)
+cc_bolt_device_entry_new (BoltDevice *device,
+                         gboolean    show_warnings)
 {
   CcBoltDeviceEntry *entry;
 
   entry = g_object_new (CC_TYPE_BOLT_DEVICE_ENTRY, NULL);
   entry->device = g_object_ref (device);
+  entry->show_warnings = show_warnings;
 
   entry_set_name (entry);
   entry_update_status (entry);
diff --git a/panels/thunderbolt/cc-bolt-device-entry.h b/panels/thunderbolt/cc-bolt-device-entry.h
index f93cee5f8..f6fc1f76f 100644
--- a/panels/thunderbolt/cc-bolt-device-entry.h
+++ b/panels/thunderbolt/cc-bolt-device-entry.h
@@ -28,7 +28,8 @@ G_BEGIN_DECLS
 G_DECLARE_FINAL_TYPE (CcBoltDeviceEntry, cc_bolt_device_entry, CC, BOLT_DEVICE_ENTRY, GtkListBoxRow);
 
 
-CcBoltDeviceEntry * cc_bolt_device_entry_new (BoltDevice *device);
+CcBoltDeviceEntry * cc_bolt_device_entry_new (BoltDevice *device,
+                                             gboolean    show_warnings);
 BoltDevice *        cc_bolt_device_entry_get_device (CcBoltDeviceEntry *entry);
 
 G_END_DECLS
diff --git a/panels/thunderbolt/cc-bolt-device-entry.ui b/panels/thunderbolt/cc-bolt-device-entry.ui
index d1ada1856..7668f6a10 100644
--- a/panels/thunderbolt/cc-bolt-device-entry.ui
+++ b/panels/thunderbolt/cc-bolt-device-entry.ui
@@ -30,14 +30,32 @@
           </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="status_label">
+          <object class="GtkBox">
             <property name="visible">True</property>
             <property name="hexpand">False</property>
-            <property name="label">Status</property>
             <property name="halign">end</property>
-            <property name="valign">center</property>
-            <property name="xalign">1.0</property>
-          </object>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkImage" id="status_warning">
+                <property name="visible">False</property>
+                <property name="can_focus">False</property>
+                <property name="icon_name">dialog-warning-symbolic</property>
+                <property name="icon_size">1</property>
+                <property name="margin_left">0</property>
+                <property name="xalign">0.0</property>
+              </object>
+            </child>
+           <child>
+             <object class="GtkLabel" id="status_label">
+               <property name="visible">True</property>
+               <property name="hexpand">False</property>
+               <property name="label">Status</property>
+               <property name="halign">end</property>
+               <property name="valign">center</property>
+               <property name="xalign">1.0</property>
+             </object>
+           </child>
+         </object>
           <packing>
             <property name="left-attach">1</property>
             <property name="top-attach">0</property>
diff --git a/panels/thunderbolt/cc-bolt-panel.c b/panels/thunderbolt/cc-bolt-panel.c
index 8b64f5c86..0515b1614 100644
--- a/panels/thunderbolt/cc-bolt-panel.c
+++ b/panels/thunderbolt/cc-bolt-panel.c
@@ -349,25 +349,25 @@ cc_bolt_panel_add_device (CcBoltPanel *panel,
   if (type != BOLT_DEVICE_PERIPHERAL)
     return FALSE;
 
-  entry = cc_bolt_device_entry_new (dev);
+  entry = cc_bolt_device_entry_new (dev, FALSE);
   path = g_dbus_proxy_get_object_path (G_DBUS_PROXY (dev));
 
   /* add to the list box */
-  gtk_widget_show_all (GTK_WIDGET (entry));
+  gtk_widget_show (GTK_WIDGET (entry));
 
   status = bolt_device_get_status (dev);
 
   if (bolt_status_is_pending (status))
     {
       gtk_container_add (GTK_CONTAINER (panel->pending_list), GTK_WIDGET (entry));
-      gtk_widget_show_all (GTK_WIDGET (panel->pending_list));
-      gtk_widget_show_all (GTK_WIDGET (panel->pending_box));
+      gtk_widget_show (GTK_WIDGET (panel->pending_list));
+      gtk_widget_show (GTK_WIDGET (panel->pending_box));
     }
   else
     {
       gtk_container_add (GTK_CONTAINER (panel->devices_list), GTK_WIDGET (entry));
-      gtk_widget_show_all (GTK_WIDGET (panel->devices_list));
-      gtk_widget_show_all (GTK_WIDGET (panel->devices_box));
+      gtk_widget_show (GTK_WIDGET (panel->devices_list));
+      gtk_widget_show (GTK_WIDGET (panel->devices_box));
     }
 
   g_signal_connect_object (entry,
@@ -395,7 +395,7 @@ cc_bolt_panel_del_device_entry (CcBoltPanel       *panel,
   if (cc_bolt_device_dialog_device_equal (panel->device_dialog, dev))
     {
       gtk_widget_hide (GTK_WIDGET (panel->device_dialog));
-      cc_bolt_device_dialog_set_device (panel->device_dialog, NULL);
+      cc_bolt_device_dialog_set_device (panel->device_dialog, NULL, NULL);
     }
 
   p = gtk_widget_get_parent (GTK_WIDGET (entry));
@@ -448,7 +448,7 @@ cc_panel_list_box_migrate (CcBoltPanel       *panel,
 
   gtk_container_remove (GTK_CONTAINER (from), target);
   gtk_container_add (GTK_CONTAINER (to), target);
-  gtk_widget_show_all (GTK_WIDGET (to));
+  gtk_widget_show (GTK_WIDGET (to));
 
   from_box = cc_bolt_panel_box_for_listbox (panel, from);
   to_box = cc_bolt_panel_box_for_listbox (panel, to);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]