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.
This commit is contained in:
Michael Natterer 2010-12-09 22:56:58 +01:00
parent 9c98b0b804
commit bb91ba9d01

View file

@ -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);
}
@ -369,6 +384,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,