~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/widgets/gimpdevicestatus.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimpdevicestatus.c
30
30
 
31
31
#include "core/gimp.h"
32
32
#include "core/gimpbrush.h"
33
 
#include "core/gimpcontainer.h"
34
33
#include "core/gimpdatafactory.h"
35
34
#include "core/gimpgradient.h"
 
35
#include "core/gimplist.h"
36
36
#include "core/gimppattern.h"
37
37
#include "core/gimptoolinfo.h"
38
38
 
41
41
#include "gimpdevices.h"
42
42
#include "gimpdevicestatus.h"
43
43
#include "gimpdialogfactory.h"
 
44
#include "gimppropwidgets.h"
44
45
#include "gimpview.h"
45
 
#include "gimppropwidgets.h"
46
46
 
47
47
#include "gimp-intl.h"
48
48
 
50
50
#define CELL_SIZE 20 /* The size of the view cells */
51
51
 
52
52
 
 
53
enum
 
54
{
 
55
  PROP_0,
 
56
  PROP_GIMP
 
57
};
 
58
 
 
59
 
53
60
struct _GimpDeviceStatusEntry
54
61
{
55
 
  GdkDevice *device;
 
62
  GimpDeviceInfo *device_info;
56
63
 
57
 
  GtkWidget *separator;
58
 
  GtkWidget *label;
59
 
  GtkWidget *arrow;
60
 
  GtkWidget *tool;
61
 
  GtkWidget *foreground;
62
 
  GtkWidget *background;
63
 
  GtkWidget *brush;
64
 
  GtkWidget *pattern;
65
 
  GtkWidget *gradient;
 
64
  GtkWidget      *table;
 
65
  GtkWidget      *label;
 
66
  GtkWidget      *arrow;
 
67
  GtkWidget      *tool;
 
68
  GtkWidget      *foreground;
 
69
  GtkWidget      *background;
 
70
  GtkWidget      *brush;
 
71
  GtkWidget      *pattern;
 
72
  GtkWidget      *gradient;
66
73
};
67
74
 
68
75
 
69
 
static void gimp_device_status_class_init      (GimpDeviceStatusClass *klass);
70
 
static void gimp_device_status_init            (GimpDeviceStatus      *editor);
 
76
static GObject *gimp_device_status_constructor (GType                  type,
 
77
                                                guint                  n_params,
 
78
                                                GObjectConstructParam *params);
 
79
static void gimp_device_status_set_property    (GObject               *object,
 
80
                                                guint                  property_id,
 
81
                                                const GValue          *value,
 
82
                                                GParamSpec            *pspec);
71
83
 
72
84
static void gimp_device_status_destroy         (GtkObject             *object);
73
85
 
 
86
static void gimp_device_status_device_add      (GimpContainer         *devices,
 
87
                                                GimpDeviceInfo        *device_info,
 
88
                                                GimpDeviceStatus      *status);
 
89
static void gimp_device_status_device_remove   (GimpContainer         *devices,
 
90
                                                GimpDeviceInfo        *device_info,
 
91
                                                GimpDeviceStatus      *status);
 
92
 
74
93
static void gimp_device_status_update_entry    (GimpDeviceInfo        *device_info,
75
94
                                                GimpDeviceStatusEntry *entry);
76
95
static void gimp_device_status_save_clicked    (GtkWidget             *button,
77
96
                                                GimpDeviceStatus      *status);
78
 
static void gimp_device_status_preview_clicked (GtkWidget             *widget,
 
97
static void gimp_device_status_view_clicked    (GtkWidget             *widget,
79
98
                                                GdkModifierType        state,
80
99
                                                const gchar           *identifier);
81
100
 
82
101
 
83
 
static GimpEditorClass *parent_class = NULL;
84
 
 
85
 
 
86
 
GType
87
 
gimp_device_status_get_type (void)
88
 
{
89
 
  static GType view_type = 0;
90
 
 
91
 
  if (! view_type)
92
 
    {
93
 
      static const GTypeInfo view_info =
94
 
      {
95
 
        sizeof (GimpDeviceStatusClass),
96
 
        NULL,           /* base_init */
97
 
        NULL,           /* base_finalize */
98
 
        (GClassInitFunc) gimp_device_status_class_init,
99
 
        NULL,           /* class_finalize */
100
 
        NULL,           /* class_data */
101
 
        sizeof (GimpDeviceStatus),
102
 
        0,              /* n_preallocs */
103
 
        (GInstanceInitFunc) gimp_device_status_init,
104
 
      };
105
 
 
106
 
      view_type = g_type_register_static (GIMP_TYPE_EDITOR,
107
 
                                          "GimpDeviceStatus",
108
 
                                          &view_info, 0);
109
 
    }
110
 
 
111
 
  return view_type;
112
 
}
 
102
G_DEFINE_TYPE (GimpDeviceStatus, gimp_device_status, GIMP_TYPE_EDITOR)
 
103
 
 
104
#define parent_class gimp_device_status_parent_class
 
105
 
113
106
 
114
107
static void
115
108
gimp_device_status_class_init (GimpDeviceStatusClass *klass)
116
109
{
117
 
  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
118
 
 
119
 
  parent_class = g_type_class_peek_parent (klass);
120
 
 
121
 
  object_class->destroy = gimp_device_status_destroy;
 
110
  GObjectClass   *object_class     = G_OBJECT_CLASS (klass);
 
111
  GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
 
112
 
 
113
  object_class->constructor  = gimp_device_status_constructor;
 
114
  object_class->set_property = gimp_device_status_set_property;
 
115
 
 
116
  gtk_object_class->destroy  = gimp_device_status_destroy;
 
117
 
 
118
  g_object_class_install_property (object_class, PROP_GIMP,
 
119
                                   g_param_spec_object ("gimp", NULL, NULL,
 
120
                                                        GIMP_TYPE_GIMP,
 
121
                                                        GIMP_PARAM_WRITABLE |
 
122
                                                        G_PARAM_CONSTRUCT_ONLY));
122
123
}
123
124
 
124
125
static void
125
126
gimp_device_status_init (GimpDeviceStatus *status)
126
127
{
127
 
  GdkDisplay *display;
128
 
  GList      *list;
129
 
  gint        i;
130
 
 
131
 
  display = gtk_widget_get_display (GTK_WIDGET (status));
132
 
 
133
128
  status->gimp           = NULL;
134
129
  status->current_device = NULL;
135
 
  status->num_devices    = g_list_length (gdk_display_list_devices (display));
136
 
  status->entries        = g_new0 (GimpDeviceStatusEntry,
137
 
                                   status->num_devices);
138
 
 
139
 
  status->table = gtk_table_new (status->num_devices * 3, 7, FALSE);
140
 
  gtk_container_set_border_width (GTK_CONTAINER (status->table), 6);
141
 
  gtk_table_set_col_spacings (GTK_TABLE (status->table), 6);
142
 
  gtk_container_add (GTK_CONTAINER (status), status->table);
143
 
  gtk_widget_show (status->table);
144
 
 
145
 
  for (list = gdk_display_list_devices (display), i = 0;
146
 
       list;
147
 
       list = list->next, i++)
148
 
    {
149
 
      GimpDeviceInfo        *device_info;
150
 
      GimpContext           *context;
151
 
      GimpDeviceStatusEntry *entry = &status->entries[i];
152
 
      gint                   row    = i * 3;
153
 
      gchar                 *markup;
154
 
      GClosure              *closure;
155
 
 
156
 
      entry->device = GDK_DEVICE (list->data);
157
 
 
158
 
      device_info = gimp_device_info_get_by_device (entry->device);
159
 
      context     = GIMP_CONTEXT (device_info);
160
 
 
161
 
      closure = g_cclosure_new (G_CALLBACK (gimp_device_status_update_entry),
162
 
                                entry, NULL);
163
 
      g_object_watch_closure (G_OBJECT (status), closure);
164
 
      g_signal_connect_closure (device_info, "changed", closure, FALSE);
165
 
 
166
 
      /*  the separator  */
167
 
 
168
 
      entry->separator = gtk_hbox_new (FALSE, 0);
169
 
      gtk_table_attach (GTK_TABLE (status->table), entry->separator,
170
 
                        0, 7, row, row + 1,
171
 
                        GTK_FILL, GTK_FILL, 0, 2);
172
 
 
173
 
      row++;
174
 
 
175
 
      /*  the device name  */
176
 
 
177
 
      entry->label = gtk_label_new (NULL);
178
 
 
179
 
      markup = g_strdup_printf ("<b>%s</b>", GIMP_OBJECT (device_info)->name);
180
 
      gtk_label_set_markup (GTK_LABEL (entry->label), markup);
181
 
      g_free (markup);
182
 
 
183
 
      gtk_widget_set_size_request (entry->label, -1, CELL_SIZE);
184
 
      gtk_misc_set_alignment (GTK_MISC (entry->label), 0.0, 0.5);
185
 
      gtk_table_attach (GTK_TABLE (status->table), entry->label,
186
 
                        1, 7, row, row + 1,
187
 
                        GTK_FILL, GTK_FILL, 0, 2);
188
 
 
189
 
      entry->arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
190
 
      gtk_widget_set_size_request (entry->arrow, CELL_SIZE, CELL_SIZE);
191
 
      gtk_table_attach (GTK_TABLE (status->table), entry->arrow,
192
 
                        0, 1, row, row + 1,
193
 
                        GTK_FILL, GTK_FILL, 0, 0);
194
 
 
195
 
      row++;
196
 
 
197
 
      /*  the tool  */
198
 
 
199
 
      entry->tool = gimp_prop_preview_new (G_OBJECT (context),
200
 
                                            "tool", CELL_SIZE);
201
 
      GIMP_VIEW (entry->tool)->clickable = TRUE;
202
 
      gtk_table_attach (GTK_TABLE (status->table), entry->tool,
203
 
                        1, 2, row, row + 1,
204
 
                        0, 0, 0, 0);
205
 
 
206
 
      g_signal_connect (entry->tool, "clicked",
207
 
                        G_CALLBACK (gimp_device_status_preview_clicked),
208
 
                        "gimp-tool-list|gimp-tool-grid");
209
 
 
210
 
      /*  the foreground color  */
211
 
 
212
 
      entry->foreground = gimp_prop_color_area_new (G_OBJECT (context),
213
 
                                                     "foreground",
214
 
                                                     CELL_SIZE, CELL_SIZE,
215
 
                                                     GIMP_COLOR_AREA_FLAT);
216
 
      gtk_widget_add_events (entry->foreground,
217
 
                             GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
218
 
      gtk_table_attach (GTK_TABLE (status->table), entry->foreground,
219
 
                        2, 3, row, row + 1,
220
 
                        0, 0, 0, 0);
221
 
 
222
 
      /*  the background color  */
223
 
 
224
 
      entry->background = gimp_prop_color_area_new (G_OBJECT (context),
225
 
                                                     "background",
226
 
                                                     CELL_SIZE, CELL_SIZE,
227
 
                                                     GIMP_COLOR_AREA_FLAT);
228
 
      gtk_widget_add_events (entry->background,
229
 
                             GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
230
 
      gtk_table_attach (GTK_TABLE (status->table), entry->background,
231
 
                        3, 4, row, row + 1,
232
 
                        0, 0, 0, 0);
233
 
 
234
 
      /*  the brush  */
235
 
 
236
 
      entry->brush = gimp_prop_preview_new (G_OBJECT (context),
237
 
                                             "brush", CELL_SIZE);
238
 
      GIMP_VIEW (entry->brush)->clickable  = TRUE;
239
 
      GIMP_VIEW (entry->brush)->show_popup = TRUE;
240
 
      gtk_table_attach (GTK_TABLE (status->table), entry->brush,
241
 
                        4, 5, row, row + 1,
242
 
                        0, 0, 0, 0);
243
 
 
244
 
      g_signal_connect (entry->brush, "clicked",
245
 
                        G_CALLBACK (gimp_device_status_preview_clicked),
246
 
                        "gimp-brush-grid|gimp-brush-list");
247
 
 
248
 
      /*  the pattern  */
249
 
 
250
 
      entry->pattern = gimp_prop_preview_new (G_OBJECT (context),
251
 
                                               "pattern", CELL_SIZE);
252
 
      GIMP_VIEW (entry->pattern)->clickable  = TRUE;
253
 
      GIMP_VIEW (entry->pattern)->show_popup = TRUE;
254
 
      gtk_table_attach (GTK_TABLE (status->table), entry->pattern,
255
 
                        5, 6, row, row + 1,
256
 
                        0, 0, 0, 0);
257
 
 
258
 
      g_signal_connect (entry->pattern, "clicked",
259
 
                        G_CALLBACK (gimp_device_status_preview_clicked),
260
 
                        "gimp-pattern-grid|gimp-pattern-list");
261
 
 
262
 
      /*  the gradient  */
263
 
 
264
 
      entry->gradient = gimp_prop_preview_new (G_OBJECT (context),
265
 
                                                "gradient", 2 * CELL_SIZE);
266
 
      GIMP_VIEW (entry->gradient)->clickable  = TRUE;
267
 
      GIMP_VIEW (entry->gradient)->show_popup = TRUE;
268
 
      gtk_table_attach (GTK_TABLE (status->table), entry->gradient,
269
 
                        6, 7, row, row + 1,
270
 
                        0, 0, 0, 0);
271
 
 
272
 
      g_signal_connect (entry->gradient, "clicked",
273
 
                        G_CALLBACK (gimp_device_status_preview_clicked),
274
 
                        "gimp-gradient-list|gimp-gradient-grid");
275
 
 
276
 
      gimp_device_status_update_entry (device_info, entry);
277
 
    }
 
130
 
 
131
  status->vbox = gtk_vbox_new (FALSE, 12);
 
132
  gtk_container_set_border_width (GTK_CONTAINER (status->vbox), 6);
 
133
  gtk_container_add (GTK_CONTAINER (status), status->vbox);
 
134
  gtk_widget_show (status->vbox);
278
135
 
279
136
  status->save_button =
280
137
    gimp_editor_add_button (GIMP_EDITOR (status), GTK_STOCK_SAVE,
284
141
                            status);
285
142
}
286
143
 
 
144
static GObject *
 
145
gimp_device_status_constructor (GType                  type,
 
146
                                guint                  n_params,
 
147
                                GObjectConstructParam *params)
 
148
{
 
149
  GObject          *object;
 
150
  GimpDeviceStatus *status;
 
151
  GimpContainer    *devices;
 
152
  GList            *list;
 
153
 
 
154
  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
 
155
 
 
156
  status = GIMP_DEVICE_STATUS (object);
 
157
 
 
158
  g_assert (GIMP_IS_GIMP (status->gimp));
 
159
 
 
160
  devices = gimp_devices_get_list (status->gimp);
 
161
 
 
162
  for (list = GIMP_LIST (devices)->list; list; list = list->next)
 
163
    gimp_device_status_device_add (devices, list->data, status);
 
164
 
 
165
  g_signal_connect_object (devices, "add",
 
166
                           G_CALLBACK (gimp_device_status_device_add),
 
167
                           status, 0);
 
168
  g_signal_connect_object (devices, "remove",
 
169
                           G_CALLBACK (gimp_device_status_device_remove),
 
170
                           status, 0);
 
171
 
 
172
  gimp_device_status_update (status);
 
173
 
 
174
  return object;
 
175
}
 
176
 
 
177
static void
 
178
gimp_device_status_set_property (GObject      *object,
 
179
                                 guint         property_id,
 
180
                                 const GValue *value,
 
181
                                 GParamSpec   *pspec)
 
182
{
 
183
  GimpDeviceStatus *status = GIMP_DEVICE_STATUS (object);
 
184
 
 
185
  switch (property_id)
 
186
    {
 
187
    case PROP_GIMP:
 
188
      status->gimp = g_value_get_object (value);
 
189
      break;
 
190
    default:
 
191
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
192
      break;
 
193
    }
 
194
}
 
195
 
287
196
static void
288
197
gimp_device_status_destroy (GtkObject *object)
289
198
{
290
199
  GimpDeviceStatus *status = GIMP_DEVICE_STATUS (object);
291
200
 
292
 
  if (status->entries)
 
201
  if (status->devices)
293
202
    {
294
 
      gint i;
 
203
      GList *list;
295
204
 
296
 
      for (i = 0; i < status->num_devices; i++)
 
205
      for (list = status->devices; list; list = list->next)
297
206
        {
298
 
          GimpDeviceStatusEntry *entry = &status->entries[i];
 
207
          GimpDeviceStatusEntry *entry = list->data;
299
208
 
300
 
          g_signal_handlers_disconnect_by_func (entry->device,
 
209
          g_signal_handlers_disconnect_by_func (entry->device_info,
301
210
                                                gimp_device_status_update_entry,
302
211
                                                entry);
 
212
          g_free (entry);
303
213
        }
304
214
 
305
 
      g_free (status->entries);
306
 
      status->entries     = NULL;
307
 
      status->num_devices = 0;
 
215
      g_list_free (status->devices);
 
216
      status->devices = NULL;
308
217
    }
309
218
 
310
219
  GTK_OBJECT_CLASS (parent_class)->destroy (object);
311
220
}
312
221
 
 
222
static void
 
223
gimp_device_status_device_add (GimpContainer    *devices,
 
224
                               GimpDeviceInfo   *device_info,
 
225
                               GimpDeviceStatus *status)
 
226
{
 
227
  GimpContext           *context = GIMP_CONTEXT (device_info);
 
228
  GimpDeviceStatusEntry *entry;
 
229
  GtkWidget             *hbox;
 
230
  GClosure              *closure;
 
231
  gchar                 *name;
 
232
 
 
233
  /*  only list present devices  */
 
234
  if (! device_info->device)
 
235
    return;
 
236
 
 
237
  entry = g_new0 (GimpDeviceStatusEntry, 1);
 
238
 
 
239
  status->devices = g_list_prepend (status->devices, entry);
 
240
 
 
241
  entry->device_info = device_info;
 
242
 
 
243
  closure = g_cclosure_new (G_CALLBACK (gimp_device_status_update_entry),
 
244
                            entry, NULL);
 
245
  g_object_watch_closure (G_OBJECT (status), closure);
 
246
  g_signal_connect_closure (device_info, "changed", closure, FALSE);
 
247
 
 
248
  entry->table = gtk_table_new (2, 7, FALSE);
 
249
  gtk_table_set_col_spacings (GTK_TABLE (entry->table), 6);
 
250
  gtk_box_pack_start (GTK_BOX (status->vbox), entry->table,
 
251
                      FALSE, FALSE, 0);
 
252
  gtk_widget_show (entry->table);
 
253
 
 
254
  /*  the device name  */
 
255
 
 
256
  if (device_info->display == gdk_display_get_default ())
 
257
    name = g_strdup (gimp_object_get_name (GIMP_OBJECT (device_info)));
 
258
  else
 
259
    name = g_strdup_printf ("%s (%s)",
 
260
                            gimp_object_get_name (GIMP_OBJECT (device_info)),
 
261
                            gdk_display_get_name (device_info->display));
 
262
 
 
263
  entry->label = gtk_label_new (name);
 
264
  g_free (name);
 
265
 
 
266
  gimp_label_set_attributes (GTK_LABEL (entry->label),
 
267
                             PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
 
268
                             -1);
 
269
  gtk_widget_set_size_request (entry->label, -1, CELL_SIZE);
 
270
  gtk_misc_set_alignment (GTK_MISC (entry->label), 0.0, 0.5);
 
271
  gtk_table_attach (GTK_TABLE (entry->table), entry->label,
 
272
                    1, 7, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
 
273
  gtk_widget_show (entry->label);
 
274
 
 
275
  /*  the arrow  */
 
276
 
 
277
  entry->arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
 
278
  gtk_widget_set_size_request (entry->arrow, CELL_SIZE, CELL_SIZE);
 
279
  gtk_table_attach (GTK_TABLE (entry->table), entry->arrow,
 
280
                    0, 1, 0, 1, GTK_FILL, GTK_FILL, 0, 0);
 
281
 
 
282
  hbox = gtk_hbox_new (FALSE, 0);
 
283
  gtk_widget_set_size_request (hbox, CELL_SIZE, CELL_SIZE);
 
284
  gtk_table_attach (GTK_TABLE (entry->table), hbox,
 
285
                    0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
 
286
  gtk_widget_show (hbox);
 
287
 
 
288
  /*  the tool  */
 
289
 
 
290
  entry->tool = gimp_prop_view_new (G_OBJECT (context), "tool",
 
291
                                    context, CELL_SIZE);
 
292
  GIMP_VIEW (entry->tool)->clickable = TRUE;
 
293
  gtk_table_attach (GTK_TABLE (entry->table), entry->tool,
 
294
                    1, 2, 1, 2, 0, 0, 0, 0);
 
295
  gtk_widget_show (entry->tool);
 
296
 
 
297
  g_signal_connect (entry->tool, "clicked",
 
298
                    G_CALLBACK (gimp_device_status_view_clicked),
 
299
                    "gimp-tool-list|gimp-tool-grid");
 
300
 
 
301
  /*  the foreground color  */
 
302
 
 
303
  entry->foreground = gimp_prop_color_area_new (G_OBJECT (context),
 
304
                                                "foreground",
 
305
                                                CELL_SIZE, CELL_SIZE,
 
306
                                                GIMP_COLOR_AREA_FLAT);
 
307
  gtk_widget_add_events (entry->foreground,
 
308
                         GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
 
309
  gtk_table_attach (GTK_TABLE (entry->table), entry->foreground,
 
310
                    2, 3, 1, 2, 0, 0, 0, 0);
 
311
  gtk_widget_show (entry->foreground);
 
312
 
 
313
  /*  the background color  */
 
314
 
 
315
  entry->background = gimp_prop_color_area_new (G_OBJECT (context),
 
316
                                                "background",
 
317
                                                CELL_SIZE, CELL_SIZE,
 
318
                                                GIMP_COLOR_AREA_FLAT);
 
319
  gtk_widget_add_events (entry->background,
 
320
                         GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK);
 
321
  gtk_table_attach (GTK_TABLE (entry->table), entry->background,
 
322
                    3, 4, 1, 2, 0, 0, 0, 0);
 
323
  gtk_widget_show (entry->background);
 
324
 
 
325
  /*  the brush  */
 
326
 
 
327
  entry->brush = gimp_prop_view_new (G_OBJECT (context), "brush",
 
328
                                     context, CELL_SIZE);
 
329
  GIMP_VIEW (entry->brush)->clickable  = TRUE;
 
330
  GIMP_VIEW (entry->brush)->show_popup = TRUE;
 
331
  gtk_table_attach (GTK_TABLE (entry->table), entry->brush,
 
332
                    4, 5, 1, 2, 0, 0, 0, 0);
 
333
  gtk_widget_show (entry->brush);
 
334
 
 
335
  g_signal_connect (entry->brush, "clicked",
 
336
                    G_CALLBACK (gimp_device_status_view_clicked),
 
337
                    "gimp-brush-grid|gimp-brush-list");
 
338
 
 
339
  /*  the pattern  */
 
340
 
 
341
  entry->pattern = gimp_prop_view_new (G_OBJECT (context), "pattern",
 
342
                                       context, CELL_SIZE);
 
343
  GIMP_VIEW (entry->pattern)->clickable  = TRUE;
 
344
  GIMP_VIEW (entry->pattern)->show_popup = TRUE;
 
345
  gtk_table_attach (GTK_TABLE (entry->table), entry->pattern,
 
346
                    5, 6, 1, 2, 0, 0, 0, 0);
 
347
  gtk_widget_show (entry->pattern);
 
348
 
 
349
  g_signal_connect (entry->pattern, "clicked",
 
350
                    G_CALLBACK (gimp_device_status_view_clicked),
 
351
                    "gimp-pattern-grid|gimp-pattern-list");
 
352
 
 
353
  /*  the gradient  */
 
354
 
 
355
  entry->gradient = gimp_prop_view_new (G_OBJECT (context), "gradient",
 
356
                                        context, 2 * CELL_SIZE);
 
357
  GIMP_VIEW (entry->gradient)->clickable  = TRUE;
 
358
  GIMP_VIEW (entry->gradient)->show_popup = TRUE;
 
359
  gtk_table_attach (GTK_TABLE (entry->table), entry->gradient,
 
360
                    6, 7, 1, 2, 0, 0, 0, 0);
 
361
  gtk_widget_show (entry->gradient);
 
362
 
 
363
  g_signal_connect (entry->gradient, "clicked",
 
364
                    G_CALLBACK (gimp_device_status_view_clicked),
 
365
                    "gimp-gradient-list|gimp-gradient-grid");
 
366
 
 
367
  gimp_device_status_update_entry (device_info, entry);
 
368
}
 
369
 
 
370
static void
 
371
gimp_device_status_device_remove (GimpContainer    *devices,
 
372
                                  GimpDeviceInfo   *device_info,
 
373
                                  GimpDeviceStatus *status)
 
374
{
 
375
  GList *list;
 
376
 
 
377
  for (list = status->devices; list; list = list->next)
 
378
    {
 
379
      GimpDeviceStatusEntry *entry = list->data;
 
380
 
 
381
      if (entry->device_info == device_info)
 
382
        {
 
383
          status->devices = g_list_remove (status->devices, entry);
 
384
 
 
385
          g_signal_handlers_disconnect_by_func (entry->device_info,
 
386
                                                gimp_device_status_update_entry,
 
387
                                                entry);
 
388
          g_free (entry);
 
389
 
 
390
          return;
 
391
        }
 
392
    }
 
393
}
 
394
 
313
395
GtkWidget *
314
396
gimp_device_status_new (Gimp *gimp)
315
397
{
316
 
  GimpDeviceStatus *status;
317
 
 
318
398
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
319
399
 
320
 
  status = g_object_new (GIMP_TYPE_DEVICE_STATUS, NULL);
321
 
 
322
 
  status->gimp = gimp;
323
 
 
324
 
  gimp_device_status_update (status);
325
 
 
326
 
  return GTK_WIDGET (status);
 
400
  return g_object_new (GIMP_TYPE_DEVICE_STATUS,
 
401
                       "gimp", gimp,
 
402
                       NULL);
327
403
}
328
404
 
329
405
void
330
406
gimp_device_status_update (GimpDeviceStatus *status)
331
407
{
332
 
  gint i;
 
408
  GList *list;
333
409
 
334
410
  g_return_if_fail (GIMP_IS_DEVICE_STATUS (status));
335
411
 
336
412
  status->current_device = gimp_devices_get_current (status->gimp);
337
413
 
338
 
  for (i = 0; i < status->num_devices; i++)
 
414
  for (list = status->devices; list; list = list->next)
339
415
    {
340
 
      GimpDeviceStatusEntry *entry = &status->entries[i];
 
416
      GimpDeviceStatusEntry *entry = list->data;
341
417
 
342
 
      if (entry->device == status->current_device)
 
418
      if (entry->device_info->device &&
 
419
          entry->device_info->device == status->current_device)
343
420
        gtk_widget_show (entry->arrow);
344
421
      else
345
422
        gtk_widget_hide (entry->arrow);
353
430
gimp_device_status_update_entry (GimpDeviceInfo        *device_info,
354
431
                                 GimpDeviceStatusEntry *entry)
355
432
{
356
 
  if (device_info->device->mode == GDK_MODE_DISABLED)
 
433
  if (! device_info->device || device_info->device->mode == GDK_MODE_DISABLED)
357
434
    {
358
 
      gtk_widget_hide (entry->separator);
359
 
      gtk_widget_hide (entry->label);
360
 
      gtk_widget_hide (entry->tool);
361
 
      gtk_widget_hide (entry->foreground);
362
 
      gtk_widget_hide (entry->background);
363
 
      gtk_widget_hide (entry->brush);
364
 
      gtk_widget_hide (entry->pattern);
365
 
      gtk_widget_hide (entry->gradient);
 
435
      gtk_widget_hide (entry->table);
366
436
    }
367
437
  else
368
438
    {
371
441
      guchar       r, g, b;
372
442
      gchar        buf[64];
373
443
 
374
 
      gtk_widget_show (entry->separator);
375
 
      gtk_widget_show (entry->label);
376
 
      gtk_widget_show (entry->tool);
377
 
      gtk_widget_show (entry->foreground);
378
 
      gtk_widget_show (entry->background);
379
 
      gtk_widget_show (entry->brush);
380
 
      gtk_widget_show (entry->pattern);
381
 
      gtk_widget_show (entry->gradient);
382
 
 
383
444
      gimp_context_get_foreground (context, &color);
384
445
      gimp_rgb_get_uchar (&color, &r, &g, &b);
385
446
      g_snprintf (buf, sizeof (buf), _("Foreground: %d, %d, %d"), r, g, b);
389
450
      gimp_rgb_get_uchar (&color, &r, &g, &b);
390
451
      g_snprintf (buf, sizeof (buf), _("Background: %d, %d, %d"), r, g, b);
391
452
      gimp_help_set_help_data (entry->background, buf, NULL);
 
453
 
 
454
      gtk_widget_show (entry->table);
392
455
    }
393
456
}
394
457
 
400
463
}
401
464
 
402
465
static void
403
 
gimp_device_status_preview_clicked (GtkWidget       *widget,
404
 
                                    GdkModifierType  state,
405
 
                                    const gchar     *identifier)
 
466
gimp_device_status_view_clicked (GtkWidget       *widget,
 
467
                                 GdkModifierType  state,
 
468
                                 const gchar     *identifier)
406
469
{
407
470
  GimpDialogFactory *dialog_factory;
408
471