[gimp] app: use a treeview for selecting which device to edit
- From: Michael Natterer <mitch src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gimp] app: use a treeview for selecting which device to edit
- Date: Sat, 13 Feb 2010 14:56:32 +0000 (UTC)
commit 472597bba090c4c7f04ac7139dd39dee4e9ab0c3
Author: Michael Natterer <mitch gimp org>
Date: Sat Feb 13 15:54:55 2010 +0100
app: use a treeview for selecting which device to edit
and change the dialog from a editor of the display's devices to an
editor of all devices of all displays known to GIMP, regardless
whether currently plugged or just remembered in devicerc. will need to
distinguish them in the next step...
app/widgets/gimpdeviceeditor.c | 180 +++++++++++++++++++++++++++++++---------
1 files changed, 140 insertions(+), 40 deletions(-)
---
diff --git a/app/widgets/gimpdeviceeditor.c b/app/widgets/gimpdeviceeditor.c
index 02606f6..5f16e6d 100644
--- a/app/widgets/gimpdeviceeditor.c
+++ b/app/widgets/gimpdeviceeditor.c
@@ -24,8 +24,11 @@
#include "widgets-types.h"
#include "core/gimp.h"
+#include "core/gimplist.h"
#include "core/gimpmarshal.h"
+#include "gimpcontainerview.h"
+#include "gimpcontainertreeview.h"
#include "gimpdeviceeditor.h"
#include "gimpdeviceinfo.h"
#include "gimpdeviceinfoeditor.h"
@@ -47,6 +50,7 @@ struct _GimpDeviceEditorPrivate
{
Gimp *gimp;
+ GtkWidget *treeview;
GtkWidget *notebook;
};
@@ -69,8 +73,17 @@ static void gimp_device_editor_get_property (GObject *objec
GValue *value,
GParamSpec *pspec);
-static void gimp_device_editor_screen_changed (GtkWidget *widget,
- GdkScreen *previous_screen);
+static void gimp_device_editor_add_device (GimpContainer *container,
+ GimpDeviceInfo *info,
+ GimpDeviceEditor *editor);
+static void gimp_device_editor_remove_device (GimpContainer *container,
+ GimpDeviceInfo *info,
+ GimpDeviceEditor *editor);
+
+static void gimp_device_editor_select_device (GimpContainerView *view,
+ GimpViewable *viewable,
+ gpointer insert_data,
+ GimpDeviceEditor *editor);
G_DEFINE_TYPE (GimpDeviceEditor, gimp_device_editor, GTK_TYPE_HBOX)
@@ -81,14 +94,11 @@ G_DEFINE_TYPE (GimpDeviceEditor, gimp_device_editor, GTK_TYPE_HBOX)
static void
gimp_device_editor_class_init (GimpDeviceEditorClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- object_class->constructor = gimp_device_editor_constructor;
- object_class->set_property = gimp_device_editor_set_property;
- object_class->get_property = gimp_device_editor_get_property;
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
- widget_class->screen_changed = gimp_device_editor_screen_changed;
+ object_class->constructor = gimp_device_editor_constructor;
+ object_class->set_property = gimp_device_editor_set_property;
+ object_class->get_property = gimp_device_editor_get_property;
g_object_class_install_property (object_class, PROP_GIMP,
g_param_spec_object ("gimp",
@@ -104,11 +114,58 @@ static void
gimp_device_editor_init (GimpDeviceEditor *editor)
{
GimpDeviceEditorPrivate *private = GIMP_DEVICE_EDITOR_GET_PRIVATE (editor);
+ gint icon_width;
+ gint icon_height;
gtk_box_set_spacing (GTK_BOX (editor), 12);
+ gtk_icon_size_lookup_for_settings (gtk_widget_get_settings (GTK_WIDGET (editor)),
+ GTK_ICON_SIZE_BUTTON,
+ &icon_width, &icon_height);
+
+ private->treeview = gimp_container_tree_view_new (NULL, NULL, icon_height, 0);
+ gtk_widget_set_size_request (private->treeview, 250, -1);
+ gtk_box_pack_start (GTK_BOX (editor), private->treeview, FALSE, FALSE, 0);
+ gtk_widget_show (private->treeview);
+
+ g_signal_connect_object (private->treeview, "select-item",
+ G_CALLBACK (gimp_device_editor_select_device),
+ G_OBJECT (editor), 0);
+
+#if 0
+ list->edit_button =
+ gimp_editor_add_button (GIMP_EDITOR (list->dest),
+ GTK_STOCK_PROPERTIES,
+ _("Configure the selected controller"),
+ NULL,
+ G_CALLBACK (gimp_controller_list_edit_clicked),
+ NULL,
+ list);
+ list->up_button =
+ gimp_editor_add_button (GIMP_EDITOR (list->dest),
+ GTK_STOCK_GO_UP,
+ _("Move the selected controller up"),
+ NULL,
+ G_CALLBACK (gimp_controller_list_up_clicked),
+ NULL,
+ list);
+ list->down_button =
+ gimp_editor_add_button (GIMP_EDITOR (list->dest),
+ GTK_STOCK_GO_DOWN,
+ _("Move the selected controller down"),
+ NULL,
+ G_CALLBACK (gimp_controller_list_down_clicked),
+ NULL,
+ list);
+
+ gtk_widget_set_sensitive (list->edit_button, FALSE);
+ gtk_widget_set_sensitive (list->up_button, FALSE);
+ gtk_widget_set_sensitive (list->down_button, FALSE);
+#endif
+
private->notebook = gtk_notebook_new ();
- gtk_notebook_set_tab_pos (GTK_NOTEBOOK (private->notebook), GTK_POS_LEFT);
+ gtk_notebook_set_show_border (GTK_NOTEBOOK (private->notebook), FALSE);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (private->notebook), FALSE);
gtk_box_pack_start (GTK_BOX (editor), private->notebook, TRUE, TRUE, 0);
gtk_widget_show (private->notebook);
}
@@ -121,6 +178,8 @@ gimp_device_editor_constructor (GType type,
GObject *object;
GimpDeviceEditor *editor;
GimpDeviceEditorPrivate *private;
+ GimpContainer *devices;
+ GList *list;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
@@ -129,6 +188,28 @@ gimp_device_editor_constructor (GType type,
g_assert (GIMP_IS_GIMP (private->gimp));
+ devices = gimp_devices_get_list (private->gimp);
+
+ gimp_container_view_set_container (GIMP_CONTAINER_VIEW (private->treeview),
+ devices);
+
+ gimp_container_view_set_context (GIMP_CONTAINER_VIEW (private->treeview),
+ gimp_get_user_context (private->gimp));
+
+ g_signal_connect (devices, "add",
+ G_CALLBACK (gimp_device_editor_add_device),
+ editor);
+ g_signal_connect (devices, "remove",
+ G_CALLBACK (gimp_device_editor_remove_device),
+ editor);
+
+ for (list = GIMP_LIST (devices)->list;
+ list;
+ list = g_list_next (list))
+ {
+ gimp_device_editor_add_device (devices, list->data, editor);
+ }
+
return object;
}
@@ -173,50 +254,69 @@ gimp_device_editor_get_property (GObject *object,
}
static void
-gimp_device_editor_screen_changed (GtkWidget *widget,
- GdkScreen *previous_screen)
+gimp_device_editor_add_device (GimpContainer *container,
+ GimpDeviceInfo *info,
+ GimpDeviceEditor *editor)
{
- GimpDeviceEditor *editor = GIMP_DEVICE_EDITOR (widget);
- GimpDeviceEditorPrivate *private = GIMP_DEVICE_EDITOR_GET_PRIVATE (editor);
- GdkDevice *core_pointer = NULL;
- GList *devices = NULL;
- GList *list;
+ GimpDeviceEditorPrivate *private = GIMP_DEVICE_EDITOR_GET_PRIVATE (editor);
+ GtkWidget *widget;
+ GtkTreeIter *iter;
+
+ widget = gimp_device_info_editor_new (info);
+ gtk_notebook_append_page (GTK_NOTEBOOK (private->notebook), widget, NULL);
+ gtk_widget_show (widget);
- if (gtk_widget_has_screen (widget))
+ iter = gimp_container_view_lookup (GIMP_CONTAINER_VIEW (private->treeview),
+ GIMP_VIEWABLE (info));
+
+ if (iter)
{
- GdkDisplay *display = gtk_widget_get_display (widget);
+ GimpContainerTreeView *treeview;
+
+ treeview = GIMP_CONTAINER_TREE_VIEW (private->treeview);
- devices = gdk_display_list_devices (display);
- core_pointer = gdk_display_get_core_pointer (display);
+ gtk_tree_store_set (GTK_TREE_STORE (treeview->model), iter,
+ GIMP_CONTAINER_TREE_VIEW_COLUMN_USER_DATA, widget,
+ -1);
}
+}
- gtk_container_foreach (GTK_CONTAINER (private->notebook),
- (GtkCallback) gtk_widget_destroy,
- NULL);
+static void
+gimp_device_editor_remove_device (GimpContainer *container,
+ GimpDeviceInfo *info,
+ GimpDeviceEditor *editor)
+{
+}
- if (g_list_length (devices) <= 1)
- return;
+static void
+gimp_device_editor_select_device (GimpContainerView *view,
+ GimpViewable *viewable,
+ gpointer insert_data,
+ GimpDeviceEditor *editor)
+{
+ GimpDeviceEditorPrivate *private = GIMP_DEVICE_EDITOR_GET_PRIVATE (editor);
+ GimpContainerTreeView *treeview;
+ GtkWidget *widget;
- for (list = devices; list; list = g_list_next (list))
- {
- GdkDevice *device = list->data;
+ treeview = GIMP_CONTAINER_TREE_VIEW (private->treeview);
- if (device != core_pointer)
- {
- GimpDeviceInfo *info = gimp_device_info_get_by_device (device);
- GtkWidget *widget;
+ gtk_tree_model_get (treeview->model, insert_data,
+ GIMP_CONTAINER_TREE_VIEW_COLUMN_USER_DATA, &widget,
+ -1);
- widget = gimp_device_info_editor_new (info);
- gtk_container_set_border_width (GTK_CONTAINER (widget), 12);
+ if (widget)
+ {
+ gint page_num = gtk_notebook_page_num (GTK_NOTEBOOK (private->notebook),
+ widget);
- gtk_notebook_append_page (GTK_NOTEBOOK (private->notebook),
- widget,
- gtk_label_new (gimp_object_get_name (info)));
- gtk_widget_show (widget);
- }
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (private->notebook),
+ page_num);
}
}
+
+/* public functions */
+
GtkWidget *
gimp_device_editor_new (Gimp *gimp)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]