~ubuntu-branches/ubuntu/maverick/gimp/maverick-updates

« back to all changes in this revision

Viewing changes to libgimpwidgets/gimpquerybox.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2005-12-09 19:44:52 UTC
  • Revision ID: james.westby@ubuntu.com-20051209194452-yggpemjlofpjqyf4
Tags: upstream-2.2.9
ImportĀ upstreamĀ versionĀ 2.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* LIBGIMP - The GIMP Library
 
2
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
 
3
 *
 
4
 * gimpquerybox.c
 
5
 * Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This library is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
 * Lesser General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the
 
19
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
 * Boston, MA 02111-1307, USA.
 
21
 */
 
22
 
 
23
#include "config.h"
 
24
 
 
25
#include <gtk/gtk.h>
 
26
 
 
27
#include "libgimpbase/gimpbase.h"
 
28
 
 
29
#include "gimpwidgetstypes.h"
 
30
 
 
31
#include "gimpdialog.h"
 
32
#include "gimppixmap.h"
 
33
#include "gimpquerybox.h"
 
34
#include "gimpsizeentry.h"
 
35
#include "gimpwidgets.h"
 
36
 
 
37
#include "libgimp/libgimp-intl.h"
 
38
 
 
39
 
 
40
/*
 
41
 *  String, integer, double and size query boxes
 
42
 */
 
43
 
 
44
typedef struct _QueryBox QueryBox;
 
45
 
 
46
struct _QueryBox
 
47
{
 
48
  GtkWidget *qbox;
 
49
  GtkWidget *vbox;
 
50
  GtkWidget *entry;
 
51
  GObject   *object;
 
52
  gulong     response_handler;
 
53
  GCallback  callback;
 
54
  gpointer   callback_data;
 
55
};
 
56
 
 
57
 
 
58
static QueryBox * create_query_box             (const gchar   *title,
 
59
                                                GtkWidget     *parent,
 
60
                                                GimpHelpFunc   help_func,
 
61
                                                const gchar   *help_id,
 
62
                                                GCallback      response_callback,
 
63
                                                const gchar   *stock_id,
 
64
                                                const gchar   *message,
 
65
                                                const gchar   *ok_button,
 
66
                                                const gchar   *cancel_button,
 
67
                                                GObject       *object,
 
68
                                                const gchar   *signal,
 
69
                                                GCallback      callback,
 
70
                                                gpointer       callback_data);
 
71
 
 
72
static void       query_box_disconnect         (QueryBox      *query_box);
 
73
 
 
74
static void       string_query_box_response    (GtkWidget     *widget,
 
75
                                                gint           response_id,
 
76
                                                QueryBox      *query_box);
 
77
static void       int_query_box_response       (GtkWidget     *widget,
 
78
                                                gint           response_id,
 
79
                                                QueryBox      *query_box);
 
80
static void       double_query_box_response    (GtkWidget     *widget,
 
81
                                                gint           response_id,
 
82
                                                QueryBox      *query_box);
 
83
static void       size_query_box_response      (GtkWidget     *widget,
 
84
                                                gint           response_id,
 
85
                                                QueryBox      *query_box);
 
86
static void       boolean_query_box_response   (GtkWidget     *widget,
 
87
                                                gint           response_id,
 
88
                                                QueryBox      *query_box);
 
89
 
 
90
static void       query_box_cancel_callback    (QueryBox      *query_box);
 
91
 
 
92
 
 
93
/*
 
94
 *  create a generic query box without any entry widget
 
95
 */
 
96
static QueryBox *
 
97
create_query_box (const gchar   *title,
 
98
                  GtkWidget     *parent,
 
99
                  GimpHelpFunc   help_func,
 
100
                  const gchar   *help_id,
 
101
                  GCallback      response_callback,
 
102
                  const gchar   *stock_id,
 
103
                  const gchar   *message,
 
104
                  const gchar   *ok_button,
 
105
                  const gchar   *cancel_button,
 
106
                  GObject       *object,
 
107
                  const gchar   *signal,
 
108
                  GCallback      callback,
 
109
                  gpointer       callback_data)
 
110
{
 
111
  QueryBox  *query_box;
 
112
  GtkWidget *hbox = NULL;
 
113
  GtkWidget *label;
 
114
 
 
115
  /*  make sure the object / signal passed are valid
 
116
   */
 
117
  g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
 
118
  g_return_val_if_fail (object == NULL || G_IS_OBJECT (object), NULL);
 
119
  g_return_val_if_fail (object == NULL || signal != NULL, NULL);
 
120
 
 
121
  query_box = g_new0 (QueryBox, 1);
 
122
 
 
123
  query_box->qbox = gimp_dialog_new (title, "gimp-query-box",
 
124
                                     parent, 0,
 
125
                                     help_func, help_id,
 
126
 
 
127
                                     cancel_button, GTK_RESPONSE_CANCEL,
 
128
                                     ok_button,     GTK_RESPONSE_OK,
 
129
 
 
130
                                     NULL);
 
131
 
 
132
  query_box->response_handler =
 
133
    g_signal_connect (query_box->qbox, "response",
 
134
                      G_CALLBACK (response_callback),
 
135
                      query_box);
 
136
 
 
137
  g_signal_connect (query_box->qbox, "destroy",
 
138
                    G_CALLBACK (gtk_widget_destroyed),
 
139
                    &query_box->qbox);
 
140
 
 
141
  /*  if we are associated with an object, connect to the provided signal
 
142
   */
 
143
  if (object)
 
144
    {
 
145
      GClosure *closure;
 
146
 
 
147
      closure = g_cclosure_new_swap (G_CALLBACK (query_box_cancel_callback),
 
148
                                     query_box, NULL);
 
149
      g_object_watch_closure (G_OBJECT (query_box->qbox), closure);
 
150
 
 
151
      g_signal_connect_closure (object, signal, closure, FALSE);
 
152
    }
 
153
 
 
154
  if (stock_id)
 
155
    {
 
156
      GtkWidget *image;
 
157
 
 
158
      hbox = gtk_hbox_new (FALSE, 12);
 
159
      gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
 
160
      gtk_container_add (GTK_CONTAINER (GTK_DIALOG (query_box->qbox)->vbox),
 
161
                         hbox);
 
162
      gtk_widget_show (hbox);
 
163
 
 
164
      image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_DIALOG);
 
165
      gtk_misc_set_alignment (GTK_MISC (image), 0.5, 0.0);
 
166
      gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
 
167
      gtk_widget_show (image);
 
168
    }
 
169
 
 
170
  query_box->vbox = gtk_vbox_new (FALSE, 12);
 
171
 
 
172
  g_object_set_data (G_OBJECT (query_box->qbox), "gimp-query-box-vbox",
 
173
                     query_box->vbox);
 
174
 
 
175
  if (hbox)
 
176
    {
 
177
      gtk_box_pack_start (GTK_BOX (hbox), query_box->vbox, FALSE, FALSE, 0);
 
178
    }
 
179
  else
 
180
    {
 
181
      gtk_container_set_border_width (GTK_CONTAINER (query_box->vbox), 12);
 
182
      gtk_container_add (GTK_CONTAINER (GTK_DIALOG (query_box->qbox)->vbox),
 
183
                         query_box->vbox);
 
184
    }
 
185
 
 
186
  gtk_widget_show (query_box->vbox);
 
187
 
 
188
  if (message)
 
189
    {
 
190
      label = gtk_label_new (message);
 
191
      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
 
192
      gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
 
193
      gtk_box_pack_start (GTK_BOX (query_box->vbox), label, FALSE, FALSE, 0);
 
194
      gtk_widget_show (label);
 
195
    }
 
196
 
 
197
  query_box->entry         = NULL;
 
198
  query_box->object        = object;
 
199
  query_box->callback      = callback;
 
200
  query_box->callback_data = callback_data;
 
201
 
 
202
  return query_box;
 
203
}
 
204
 
 
205
/**
 
206
 * gimp_query_string_box:
 
207
 * @title:     The query box dialog's title.
 
208
 * @parent:    The dialog's parent widget.
 
209
 * @help_func: The help function to show this dialog's help page.
 
210
 * @help_id:   A string identifying this dialog's help page.
 
211
 * @message:   A string which will be shown above the dialog's entry widget.
 
212
 * @initial:   The initial value.
 
213
 * @object:    The object this query box is associated with.
 
214
 * @signal:    The object's signal which will cause the query box to be closed.
 
215
 * @callback:  The function which will be called when the user selects "OK".
 
216
 * @data:      The callback's user data.
 
217
 *
 
218
 * Creates a new #GtkDialog that queries the user for a string value.
 
219
 *
 
220
 * Returns: A pointer to the new #GtkDialog.
 
221
 **/
 
222
GtkWidget *
 
223
gimp_query_string_box (const gchar             *title,
 
224
                       GtkWidget               *parent,
 
225
                       GimpHelpFunc             help_func,
 
226
                       const gchar             *help_id,
 
227
                       const gchar             *message,
 
228
                       const gchar             *initial,
 
229
                       GObject                 *object,
 
230
                       const gchar             *signal,
 
231
                       GimpQueryStringCallback  callback,
 
232
                       gpointer                 data)
 
233
{
 
234
  QueryBox  *query_box;
 
235
  GtkWidget *entry;
 
236
 
 
237
  query_box = create_query_box (title, parent, help_func, help_id,
 
238
                                G_CALLBACK (string_query_box_response),
 
239
                                GTK_STOCK_DIALOG_QUESTION,
 
240
                                message,
 
241
                                GTK_STOCK_OK, GTK_STOCK_CANCEL,
 
242
                                object, signal,
 
243
                                G_CALLBACK (callback), data);
 
244
 
 
245
  if (! query_box)
 
246
    return NULL;
 
247
 
 
248
  entry = gtk_entry_new ();
 
249
  gtk_entry_set_text (GTK_ENTRY (entry), initial ? initial : "");
 
250
  gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
 
251
  gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0);
 
252
  gtk_widget_grab_focus (entry);
 
253
  gtk_widget_show (entry);
 
254
 
 
255
  query_box->entry = entry;
 
256
 
 
257
  return query_box->qbox;
 
258
}
 
259
 
 
260
/**
 
261
 * gimp_query_int_box:
 
262
 * @title:     The query box dialog's title.
 
263
 * @parent:    The dialog's parent widget.
 
264
 * @help_func: The help function to show this dialog's help page.
 
265
 * @help_id:   A string identifying this dialog's help page.
 
266
 * @message:   A string which will be shown above the dialog's entry widget.
 
267
 * @initial:   The initial value.
 
268
 * @lower:     The lower boundary of the range of possible values.
 
269
 * @upper:     The upper boundray of the range of possible values.
 
270
 * @object:    The object this query box is associated with.
 
271
 * @signal:    The object's signal which will cause the query box to be closed.
 
272
 * @callback:  The function which will be called when the user selects "OK".
 
273
 * @data:      The callback's user data.
 
274
 *
 
275
 * Creates a new #GtkDialog that queries the user for an integer value.
 
276
 *
 
277
 * Returns: A pointer to the new #GtkDialog.
 
278
 **/
 
279
GtkWidget *
 
280
gimp_query_int_box (const gchar          *title,
 
281
                    GtkWidget            *parent,
 
282
                    GimpHelpFunc          help_func,
 
283
                    const gchar          *help_id,
 
284
                    const gchar          *message,
 
285
                    gint                  initial,
 
286
                    gint                  lower,
 
287
                    gint                  upper,
 
288
                    GObject              *object,
 
289
                    const gchar          *signal,
 
290
                    GimpQueryIntCallback  callback,
 
291
                    gpointer              data)
 
292
{
 
293
  QueryBox  *query_box;
 
294
  GtkWidget *spinbutton;
 
295
  GtkObject *adjustment;
 
296
 
 
297
  query_box = create_query_box (title, parent, help_func, help_id,
 
298
                                G_CALLBACK (int_query_box_response),
 
299
                                GTK_STOCK_DIALOG_QUESTION,
 
300
                                message,
 
301
                                GTK_STOCK_OK, GTK_STOCK_CANCEL,
 
302
                                object, signal,
 
303
                                G_CALLBACK (callback), data);
 
304
 
 
305
  if (! query_box)
 
306
    return NULL;
 
307
 
 
308
  spinbutton = gimp_spin_button_new (&adjustment,
 
309
                                     initial, lower, upper, 1, 10, 0,
 
310
                                     1, 0);
 
311
  gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
 
312
  gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0);
 
313
  gtk_widget_grab_focus (spinbutton);
 
314
  gtk_widget_show (spinbutton);
 
315
 
 
316
  query_box->entry = spinbutton;
 
317
 
 
318
  return query_box->qbox;
 
319
}
 
320
 
 
321
/**
 
322
 * gimp_query_double_box:
 
323
 * @title:     The query box dialog's title.
 
324
 * @parent:    The dialog's parent widget.
 
325
 * @help_func: The help function to show this dialog's help page.
 
326
 * @help_id:   A string identifying this dialog's help page.
 
327
 * @message:   A string which will be shown above the dialog's entry widget.
 
328
 * @initial:   The initial value.
 
329
 * @lower:     The lower boundary of the range of possible values.
 
330
 * @upper:     The upper boundray of the range of possible values.
 
331
 * @digits:    The number of decimal digits the #GtkSpinButton will provide.
 
332
 * @object:    The object this query box is associated with.
 
333
 * @signal:    The object's signal which will cause the query box to be closed.
 
334
 * @callback:  The function which will be called when the user selects "OK".
 
335
 * @data:      The callback's user data.
 
336
 *
 
337
 * Creates a new #GtkDialog that queries the user for a double value.
 
338
 *
 
339
 * Returns: A pointer to the new #GtkDialog.
 
340
 **/
 
341
GtkWidget *
 
342
gimp_query_double_box (const gchar             *title,
 
343
                       GtkWidget               *parent,
 
344
                       GimpHelpFunc             help_func,
 
345
                       const gchar             *help_id,
 
346
                       const gchar             *message,
 
347
                       gdouble                  initial,
 
348
                       gdouble                  lower,
 
349
                       gdouble                  upper,
 
350
                       gint                     digits,
 
351
                       GObject                 *object,
 
352
                       const gchar             *signal,
 
353
                       GimpQueryDoubleCallback  callback,
 
354
                       gpointer                 data)
 
355
{
 
356
  QueryBox  *query_box;
 
357
  GtkWidget *spinbutton;
 
358
  GtkObject *adjustment;
 
359
 
 
360
  query_box = create_query_box (title, parent, help_func, help_id,
 
361
                                G_CALLBACK (double_query_box_response),
 
362
                                GTK_STOCK_DIALOG_QUESTION,
 
363
                                message,
 
364
                                GTK_STOCK_OK, GTK_STOCK_CANCEL,
 
365
                                object, signal,
 
366
                                G_CALLBACK (callback), data);
 
367
 
 
368
  if (! query_box)
 
369
    return NULL;
 
370
 
 
371
  spinbutton = gimp_spin_button_new (&adjustment,
 
372
                                     initial, lower, upper, 1, 10, 0,
 
373
                                     1, digits);
 
374
  gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
 
375
  gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0);
 
376
  gtk_widget_grab_focus (spinbutton);
 
377
  gtk_widget_show (spinbutton);
 
378
 
 
379
  query_box->entry = spinbutton;
 
380
 
 
381
  return query_box->qbox;
 
382
}
 
383
 
 
384
/**
 
385
 * gimp_query_size_box:
 
386
 * @title:       The query box dialog's title.
 
387
 * @parent:      The dialog's parent widget.
 
388
 * @help_func:   The help function to show this dialog's help page.
 
389
 * @help_id:     A string identifying this dialog's help page.
 
390
 * @message:     A string which will be shown above the dialog's entry widget.
 
391
 * @initial:     The initial value.
 
392
 * @lower:       The lower boundary of the range of possible values.
 
393
 * @upper:       The upper boundray of the range of possible values.
 
394
 * @digits:      The number of decimal digits the #GimpSizeEntry provide in
 
395
 *               "pixel" mode.
 
396
 * @unit:        The unit initially shown by the #GimpUnitMenu.
 
397
 * @resolution:  The resolution (in dpi) which will be used for pixel/unit
 
398
 *               calculations.
 
399
 * @dot_for_dot: %TRUE if the #GimpUnitMenu's initial unit should be "pixels".
 
400
 * @object:      The object this query box is associated with.
 
401
 * @signal:      The object's signal which will cause the query box
 
402
 *               to be closed.
 
403
 * @callback:    The function which will be called when the user selects "OK".
 
404
 * @data:        The callback's user data.
 
405
 *
 
406
 * Creates a new #GtkDialog that queries the user for a size using a
 
407
 * #GimpSizeEntry.
 
408
 *
 
409
 * Returns: A pointer to the new #GtkDialog.
 
410
 **/
 
411
GtkWidget *
 
412
gimp_query_size_box (const gchar           *title,
 
413
                     GtkWidget             *parent,
 
414
                     GimpHelpFunc           help_func,
 
415
                     const gchar           *help_id,
 
416
                     const gchar           *message,
 
417
                     gdouble                initial,
 
418
                     gdouble                lower,
 
419
                     gdouble                upper,
 
420
                     gint                   digits,
 
421
                     GimpUnit               unit,
 
422
                     gdouble                resolution,
 
423
                     gboolean               dot_for_dot,
 
424
                     GObject               *object,
 
425
                     const gchar           *signal,
 
426
                     GimpQuerySizeCallback  callback,
 
427
                     gpointer               data)
 
428
{
 
429
  QueryBox  *query_box;
 
430
  GtkWidget *sizeentry;
 
431
  GtkWidget *spinbutton;
 
432
 
 
433
  query_box = create_query_box (title, parent, help_func, help_id,
 
434
                                G_CALLBACK (size_query_box_response),
 
435
                                GTK_STOCK_DIALOG_QUESTION,
 
436
                                message,
 
437
                                GTK_STOCK_OK, GTK_STOCK_CANCEL,
 
438
                                object, signal,
 
439
                                G_CALLBACK (callback), data);
 
440
 
 
441
  if (! query_box)
 
442
    return NULL;
 
443
 
 
444
  sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 12,
 
445
                                   GIMP_SIZE_ENTRY_UPDATE_SIZE);
 
446
  if (dot_for_dot)
 
447
    gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL);
 
448
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
 
449
                                  resolution, FALSE);
 
450
  gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits);
 
451
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
 
452
                                         lower, upper);
 
453
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, initial);
 
454
 
 
455
  spinbutton = gimp_size_entry_get_help_widget (GIMP_SIZE_ENTRY (sizeentry), 0);
 
456
  gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
 
457
 
 
458
  gtk_box_pack_start (GTK_BOX (query_box->vbox), sizeentry, FALSE, FALSE, 0);
 
459
  gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (sizeentry));
 
460
  gtk_widget_show (sizeentry);
 
461
 
 
462
  query_box->entry = sizeentry;
 
463
 
 
464
  return query_box->qbox;
 
465
}
 
466
 
 
467
/**
 
468
 * gimp_query_boolean_box:
 
469
 * @title:        The query box dialog's title.
 
470
 * @parent:       The dialog's parent widget.
 
471
 * @help_func:    The help function to show this dialog's help page.
 
472
 * @help_id:      A string identifying this dialog's help page.
 
473
 * @stock_id:     A stock_id to specify an icon to appear on the left
 
474
 *                on the dialog's message.
 
475
 * @message:      A string which will be shown in the query box.
 
476
 * @true_button:  The string to be shown in the dialog's left button.
 
477
 * @false_button: The string to be shown in the dialog's right button.
 
478
 * @object:       The object this query box is associated with.
 
479
 * @signal:       The object's signal which will cause the query box
 
480
 *                to be closed.
 
481
 * @callback:     The function which will be called when the user clicks one
 
482
 *                of the buttons.
 
483
 * @data:         The callback's user data.
 
484
 *
 
485
 * Creates a new #GtkDialog that asks the user to do a boolean decision.
 
486
 *
 
487
 * Returns: A pointer to the new #GtkDialog.
 
488
 **/
 
489
GtkWidget *
 
490
gimp_query_boolean_box (const gchar              *title,
 
491
                        GtkWidget                *parent,
 
492
                        GimpHelpFunc              help_func,
 
493
                        const gchar              *help_id,
 
494
                        const gchar              *stock_id,
 
495
                        const gchar              *message,
 
496
                        const gchar              *true_button,
 
497
                        const gchar              *false_button,
 
498
                        GObject                  *object,
 
499
                        const gchar              *signal,
 
500
                        GimpQueryBooleanCallback  callback,
 
501
                        gpointer                  data)
 
502
{
 
503
  QueryBox  *query_box;
 
504
 
 
505
  query_box = create_query_box (title, parent, help_func, help_id,
 
506
                                G_CALLBACK (boolean_query_box_response),
 
507
                                stock_id,
 
508
                                message,
 
509
                                true_button, false_button,
 
510
                                object, signal,
 
511
                                G_CALLBACK (callback), data);
 
512
 
 
513
  if (! query_box)
 
514
    return NULL;
 
515
 
 
516
  return query_box->qbox;
 
517
}
 
518
 
 
519
 
 
520
/*
 
521
 *  private functions
 
522
 */
 
523
 
 
524
static void
 
525
query_box_disconnect (QueryBox *query_box)
 
526
{
 
527
  gtk_widget_set_sensitive (query_box->qbox, FALSE);
 
528
 
 
529
  /*  disconnect the response callback to avoid that it may be run twice  */
 
530
  if (query_box->response_handler)
 
531
    {
 
532
      g_signal_handler_disconnect (query_box->qbox,
 
533
                                   query_box->response_handler);
 
534
 
 
535
      query_box->response_handler = 0;
 
536
    }
 
537
 
 
538
  /*  disconnect, if we are connected to some signal  */
 
539
  if (query_box->object)
 
540
    g_signal_handlers_disconnect_by_func (query_box->object,
 
541
                                          query_box_cancel_callback,
 
542
                                          query_box);
 
543
}
 
544
 
 
545
static void
 
546
string_query_box_response (GtkWidget *widget,
 
547
                           gint       response_id,
 
548
                           QueryBox  *query_box)
 
549
{
 
550
  const gchar *string;
 
551
 
 
552
  query_box_disconnect (query_box);
 
553
 
 
554
  /*  Get the entry data  */
 
555
  string = gtk_entry_get_text (GTK_ENTRY (query_box->entry));
 
556
 
 
557
  /*  Call the user defined callback  */
 
558
  if (response_id == GTK_RESPONSE_OK)
 
559
    (* (GimpQueryStringCallback) query_box->callback) (query_box->qbox,
 
560
                                                       string,
 
561
                                                       query_box->callback_data);
 
562
 
 
563
  /*  Destroy the box  */
 
564
  if (query_box->qbox)
 
565
    gtk_widget_destroy (query_box->qbox);
 
566
 
 
567
  g_free (query_box);
 
568
}
 
569
 
 
570
static void
 
571
int_query_box_response (GtkWidget *widget,
 
572
                        gint       response_id,
 
573
                        QueryBox  *query_box)
 
574
{
 
575
  gint value;
 
576
 
 
577
  query_box_disconnect (query_box);
 
578
 
 
579
  /*  Get the spinbutton data  */
 
580
  value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (query_box->entry));
 
581
 
 
582
  /*  Call the user defined callback  */
 
583
  if (response_id == GTK_RESPONSE_OK)
 
584
    (* (GimpQueryIntCallback) query_box->callback) (query_box->qbox,
 
585
                                                    value,
 
586
                                                    query_box->callback_data);
 
587
 
 
588
  /*  Destroy the box  */
 
589
  if (query_box->qbox)
 
590
    gtk_widget_destroy (query_box->qbox);
 
591
 
 
592
  g_free (query_box);
 
593
}
 
594
 
 
595
static void
 
596
double_query_box_response (GtkWidget *widget,
 
597
                           gint       response_id,
 
598
                           QueryBox  *query_box)
 
599
{
 
600
  gdouble value;
 
601
 
 
602
  query_box_disconnect (query_box);
 
603
 
 
604
  /*  Get the spinbutton data  */
 
605
  value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (query_box->entry));
 
606
 
 
607
  /*  Call the user defined callback  */
 
608
  if (response_id == GTK_RESPONSE_OK)
 
609
    (* (GimpQueryDoubleCallback) query_box->callback) (query_box->qbox,
 
610
                                                       value,
 
611
                                                       query_box->callback_data);
 
612
 
 
613
  /*  Destroy the box  */
 
614
  if (query_box->qbox)
 
615
    gtk_widget_destroy (query_box->qbox);
 
616
 
 
617
  g_free (query_box);
 
618
}
 
619
 
 
620
static void
 
621
size_query_box_response (GtkWidget *widget,
 
622
                         gint       response_id,
 
623
                         QueryBox  *query_box)
 
624
{
 
625
  gdouble  size;
 
626
  GimpUnit unit;
 
627
 
 
628
  query_box_disconnect (query_box);
 
629
 
 
630
  /*  Get the sizeentry data  */
 
631
  size = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (query_box->entry), 0);
 
632
  unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (query_box->entry));
 
633
 
 
634
  /*  Call the user defined callback  */
 
635
  if (response_id == GTK_RESPONSE_OK)
 
636
    (* (GimpQuerySizeCallback) query_box->callback) (query_box->qbox,
 
637
                                                     size,
 
638
                                                     unit,
 
639
                                                     query_box->callback_data);
 
640
 
 
641
  /*  Destroy the box  */
 
642
  if (query_box->qbox)
 
643
    gtk_widget_destroy (query_box->qbox);
 
644
 
 
645
  g_free (query_box);
 
646
}
 
647
 
 
648
static void
 
649
boolean_query_box_response (GtkWidget *widget,
 
650
                            gint       response_id,
 
651
                            QueryBox  *query_box)
 
652
{
 
653
  query_box_disconnect (query_box);
 
654
 
 
655
  /*  Call the user defined callback  */
 
656
  (* (GimpQueryBooleanCallback) query_box->callback) (query_box->qbox,
 
657
                                                      (response_id ==
 
658
                                                       GTK_RESPONSE_OK),
 
659
                                                      query_box->callback_data);
 
660
 
 
661
  /*  Destroy the box  */
 
662
  if (query_box->qbox)
 
663
    gtk_widget_destroy (query_box->qbox);
 
664
 
 
665
  g_free (query_box);
 
666
}
 
667
 
 
668
static void
 
669
query_box_cancel_callback (QueryBox *query_box)
 
670
{
 
671
  query_box_disconnect (query_box);
 
672
 
 
673
  /*  Destroy the box  */
 
674
  if (query_box->qbox)
 
675
    gtk_widget_destroy (query_box->qbox);
 
676
 
 
677
  g_free (query_box);
 
678
}