[gimp] app: update the device name's style when devices get added/removed



commit bb91ba9d01fd06ca1c346b8b79100dfd5fdce340
Author: Michael Natterer <mitch gimp org>
Date:   Thu Dec 9 22:56:58 2010 +0100

    app: update the device name's style when devices get added/removed
    
    This can't happen on GTK+ 2.x but why should I keep this generic code
    on a branch.

 app/widgets/gimpdeviceeditor.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/app/widgets/gimpdeviceeditor.c b/app/widgets/gimpdeviceeditor.c
index 32520ce..9c32ec4 100644
--- a/app/widgets/gimpdeviceeditor.c
+++ b/app/widgets/gimpdeviceeditor.c
@@ -56,6 +56,8 @@ struct _GimpDeviceEditorPrivate
 {
   Gimp      *gimp;
 
+  GQuark     name_changed_handler;
+
   GtkWidget *treeview;
   GtkWidget *delete_button;
 
@@ -91,6 +93,8 @@ static void      gimp_device_editor_add_device     (GimpContainer         *conta
 static void      gimp_device_editor_remove_device  (GimpContainer         *container,
                                                     GimpDeviceInfo        *info,
                                                     GimpDeviceEditor      *editor);
+static void      gimp_device_editor_device_changed (GimpDeviceInfo        *info,
+                                                    GimpDeviceEditor      *editor);
 
 static void      gimp_device_editor_select_device  (GimpContainerView     *view,
                                                     GimpViewable          *viewable,
@@ -245,6 +249,11 @@ gimp_device_editor_constructor (GType                   type,
                     G_CALLBACK (gimp_device_editor_add_device),
                     editor);
 
+  private->name_changed_handler =
+    gimp_container_add_handler (devices, "name-changed",
+                                G_CALLBACK (gimp_device_editor_device_changed),
+                                editor);
+
   for (list = GIMP_LIST (devices)->list;
        list;
        list = g_list_next (list))
@@ -269,6 +278,12 @@ gimp_device_editor_dispose (GObject *object)
                                         gimp_device_editor_remove_device,
                                         object);
 
+  if (private->name_changed_handler)
+    {
+      gimp_container_remove_handler (devices, private->name_changed_handler);
+      private->name_changed_handler = 0;
+    }
+
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
@@ -370,6 +385,29 @@ gimp_device_editor_remove_device (GimpContainer    *container,
 }
 
 static void
+gimp_device_editor_device_changed (GimpDeviceInfo   *info,
+                                   GimpDeviceEditor *editor)
+{
+  GimpDeviceEditorPrivate *private = GIMP_DEVICE_EDITOR_GET_PRIVATE (editor);
+  GtkTreeIter             *iter;
+
+  iter = gimp_container_view_lookup (GIMP_CONTAINER_VIEW (private->treeview),
+                                     GIMP_VIEWABLE (info));
+
+  if (iter)
+    {
+      GimpContainerTreeView *treeview;
+
+      treeview = GIMP_CONTAINER_TREE_VIEW (private->treeview);
+
+      gtk_tree_store_set (GTK_TREE_STORE (treeview->model), iter,
+                          GIMP_CONTAINER_TREE_STORE_COLUMN_NAME_SENSITIVE,
+                          gimp_device_info_get_device (info, NULL) != NULL,
+                          -1);
+    }
+}
+
+static void
 gimp_device_editor_select_device (GimpContainerView *view,
                                   GimpViewable      *viewable,
                                   gpointer           insert_data,



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