gimpquerybox.c 20.2 KB
Newer Older
1 2 3 4
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
 *
 * gimpquerybox.c
5
 * Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
Michael Natterer's avatar
Michael Natterer committed
6 7 8 9
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
10
 * version 2 of the License, or (at your option) any later version.
11 12 13
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Michael Natterer's avatar
Michael Natterer committed
15 16 17 18 19 20
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
21
 */
Michael Natterer's avatar
Michael Natterer committed
22

23 24 25
#include "config.h"

#include <gtk/gtk.h>
Michael Natterer's avatar
Michael Natterer committed
26

27
#include "libgimpbase/gimpbase.h"
28 29

#include "gimpwidgetstypes.h"
30

Michael Natterer's avatar
Michael Natterer committed
31
#include "gimpdialog.h"
Sven Neumann's avatar
Sven Neumann committed
32
#include "gimppixmap.h"
33
#include "gimpquerybox.h"
Michael Natterer's avatar
Michael Natterer committed
34 35 36
#include "gimpsizeentry.h"
#include "gimpwidgets.h"

37
#include "libgimp/libgimp-intl.h"
Michael Natterer's avatar
Michael Natterer committed
38

39

Michael Natterer's avatar
Michael Natterer committed
40 41 42 43 44 45 46 47 48 49 50
/*
 *  String, integer, double and size query boxes
 */

typedef struct _QueryBox QueryBox;

struct _QueryBox
{
  GtkWidget     *qbox;
  GtkWidget     *vbox;
  GtkWidget     *entry;
51
  GObject       *object;
52
  GCallback      callback;
53
  gpointer       callback_data;
Michael Natterer's avatar
Michael Natterer committed
54 55
};

56 57

static QueryBox * create_query_box             (const gchar   *title,
Michael Natterer's avatar
Michael Natterer committed
58
						GimpHelpFunc   help_func,
59
						const gchar   *help_data,
60 61
						GCallback      ok_callback,
						GCallback      cancel_callback,
62
                                                const gchar   *stock_id,
63 64 65
						const gchar   *message,
						const gchar   *ok_button,
						const gchar   *cancel_button,
66
						GObject       *object,
67
						const gchar   *signal,
68
						GCallback      callback,
69
						gpointer       callback_data);
Michael Natterer's avatar
Michael Natterer committed
70

71
static QueryBox * query_box_disconnect             (gpointer       data);
Michael Natterer's avatar
Michael Natterer committed
72

73 74 75 76 77 78 79 80
static void       string_query_box_ok_callback     (GtkWidget     *widget,
						    gpointer       data);
static void       int_query_box_ok_callback        (GtkWidget     *widget,
						    gpointer       data);
static void       double_query_box_ok_callback     (GtkWidget     *widget,
						    gpointer       data);
static void       size_query_box_ok_callback       (GtkWidget     *widget,
						    gpointer       data);
Michael Natterer's avatar
Michael Natterer committed
81 82 83 84 85 86

static void       boolean_query_box_true_callback  (GtkWidget     *widget,
						    gpointer       data);
static void       boolean_query_box_false_callback (GtkWidget     *widget,
						    gpointer       data);

87 88 89 90 91 92 93
static void       query_box_cancel_callback        (GtkWidget     *widget,
						    gpointer       data);


/*
 *  create a generic query box without any entry widget
 */
Michael Natterer's avatar
Michael Natterer committed
94
static QueryBox *
95
create_query_box (const gchar   *title,
Michael Natterer's avatar
Michael Natterer committed
96
		  GimpHelpFunc   help_func,
97
		  const gchar   *help_data,
98 99
		  GCallback      ok_callback,
		  GCallback      cancel_callback,
100
                  const gchar   *stock_id,
101 102 103
		  const gchar   *message,
		  const gchar   *ok_button,
		  const gchar   *cancel_button,
104
		  GObject       *object,
105
		  const gchar   *signal,
106
		  GCallback      callback,
107
		  gpointer       callback_data)
Michael Natterer's avatar
Michael Natterer committed
108 109
{
  QueryBox  *query_box;
110
  GtkWidget *hbox = NULL;
Michael Natterer's avatar
Michael Natterer committed
111 112
  GtkWidget *label;

113 114
  /*  make sure the object / signal passed are valid
   */
115
  g_return_val_if_fail (object == NULL || G_IS_OBJECT (object), NULL);
116 117
  g_return_val_if_fail (object == NULL || signal != NULL, NULL);

Michael Natterer's avatar
Michael Natterer committed
118 119
  query_box = g_new (QueryBox, 1);

120 121 122 123
  query_box->qbox = gimp_dialog_new (title, "query_box",
				     help_func, help_data,
				     GTK_WIN_POS_MOUSE,
				     FALSE, TRUE, FALSE,
Michael Natterer's avatar
Michael Natterer committed
124

125 126
				     cancel_button, cancel_callback,
				     query_box, NULL, NULL, FALSE, TRUE,
Michael Natterer's avatar
Michael Natterer committed
127

128 129 130
				     ok_button, ok_callback,
				     query_box, NULL, NULL, TRUE, FALSE,

131
				     NULL);
Michael Natterer's avatar
Michael Natterer committed
132

133
  g_signal_connect (query_box->qbox, "destroy",
134 135
		    G_CALLBACK (gtk_widget_destroyed),
		    &query_box->qbox);
136 137 138 139 140

  /*  if we are associated with an object, connect to the provided signal
   */
  if (object)
    {
141
      GClosure *closure;
142

143 144 145 146
      closure = g_cclosure_new (G_CALLBACK (query_box_cancel_callback),
				query_box, NULL);
      g_object_watch_closure (G_OBJECT (query_box->qbox), closure);

147
      g_signal_connect_closure (object, signal, closure, FALSE);
148
    }
149 150

  if (stock_id)
151
    {
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
      GtkWidget *image;

      image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_DIALOG);

      if (image)
        {
          hbox = gtk_hbox_new (FALSE, 10);
          gtk_container_set_border_width (GTK_CONTAINER (hbox), 10);
          gtk_container_add (GTK_CONTAINER (GTK_DIALOG (query_box->qbox)->vbox),
                             hbox);
          gtk_widget_show (hbox);

          gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
          gtk_widget_show (image);
        }
167
    }
Michael Natterer's avatar
Michael Natterer committed
168

169 170 171 172 173 174 175 176 177 178
  query_box->vbox = gtk_vbox_new (FALSE, 4);

  g_object_set_data (G_OBJECT (query_box->qbox), "gimp-query-box-vbox",
                     query_box->vbox);

  if (hbox)
    {
      gtk_box_pack_start (GTK_BOX (hbox), query_box->vbox, FALSE, FALSE, 0);
    }
  else
179
    {
180
      gtk_container_set_border_width (GTK_CONTAINER (query_box->vbox), 10);
181
      gtk_container_add (GTK_CONTAINER (GTK_DIALOG (query_box->qbox)->vbox),
182 183 184 185
                         query_box->vbox);
    }

  gtk_widget_show (query_box->vbox);
Michael Natterer's avatar
Michael Natterer committed
186

187 188
  if (message)
    {
189
      label = gtk_label_new (message);
190
      gtk_box_pack_start (GTK_BOX (query_box->vbox), label, FALSE, FALSE, 0);
191 192
      gtk_widget_show (label);
    }
Michael Natterer's avatar
Michael Natterer committed
193

194 195 196 197
  query_box->entry         = NULL;
  query_box->object        = object;
  query_box->callback      = callback;
  query_box->callback_data = callback_data;
Michael Natterer's avatar
Michael Natterer committed
198 199 200 201

  return query_box;
}

202 203
/**
 * gimp_query_string_box:
204
 * @title:     The query box dialog's title.
205 206
 * @help_func: The help function to show this dialog's help page.
 * @help_data: A string pointing to this dialog's html help page.
207 208 209 210 211 212
 * @message:   A string which will be shown above the dialog's entry widget.
 * @initial:   The initial value.
 * @object:    The object this query box is associated with.
 * @signal:    The object's signal which will cause the query box to be closed.
 * @callback:  The function which will be called when the user selects "OK".
 * @data:      The callback's user data.
213
 *
214 215
 * Creates a new #GtkDialog that queries the user for a string value.
 *
216
 * Returns: A pointer to the new #GtkDialog.
217
 **/
Michael Natterer's avatar
Michael Natterer committed
218
GtkWidget *
219
gimp_query_string_box (const gchar             *title,
Michael Natterer's avatar
Michael Natterer committed
220
		       GimpHelpFunc             help_func,
221 222 223
		       const gchar             *help_data,
		       const gchar             *message,
		       const gchar             *initial,
224
		       GObject                 *object,
225
		       const gchar             *signal,
Michael Natterer's avatar
Michael Natterer committed
226 227 228 229 230 231 232
		       GimpQueryStringCallback  callback,
		       gpointer                 data)
{
  QueryBox  *query_box;
  GtkWidget *entry;

  query_box = create_query_box (title, help_func, help_data,
233 234
				G_CALLBACK (string_query_box_ok_callback),
				G_CALLBACK (query_box_cancel_callback),
235
                                GTK_STOCK_DIALOG_QUESTION,
Michael Natterer's avatar
Michael Natterer committed
236
				message,
237
				GTK_STOCK_OK, GTK_STOCK_CANCEL,
Michael Natterer's avatar
Michael Natterer committed
238
				object, signal,
239
				G_CALLBACK (callback), data);
Michael Natterer's avatar
Michael Natterer committed
240

241 242 243
  if (! query_box)
    return NULL;

Michael Natterer's avatar
Michael Natterer committed
244 245 246 247 248 249 250 251 252 253 254 255
  entry = gtk_entry_new ();
  gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0);
  if (initial)
    gtk_entry_set_text (GTK_ENTRY (entry), initial);
  gtk_widget_grab_focus (entry);
  gtk_widget_show (entry);

  query_box->entry = entry;

  return query_box->qbox;
}

256 257
/**
 * gimp_query_int_box:
258
 * @title:     The query box dialog's title.
259 260
 * @help_func: The help function to show this dialog's help page.
 * @help_data: A string pointing to this dialog's html help page.
261 262 263 264 265 266 267 268
 * @message:   A string which will be shown above the dialog's entry widget.
 * @initial:   The initial value.
 * @lower:     The lower boundary of the range of possible values.
 * @upper:     The upper boundray of the range of possible values.
 * @object:    The object this query box is associated with.
 * @signal:    The object's signal which will cause the query box to be closed.
 * @callback:  The function which will be called when the user selects "OK".
 * @data:      The callback's user data.
269
 *
270 271
 * Creates a new #GtkDialog that queries the user for an integer value.
 *
272
 * Returns: A pointer to the new #GtkDialog.
273
 **/
Michael Natterer's avatar
Michael Natterer committed
274
GtkWidget *
275
gimp_query_int_box (const gchar          *title,
Michael Natterer's avatar
Michael Natterer committed
276
		    GimpHelpFunc          help_func,
277 278
		    const gchar          *help_data,
		    const gchar          *message,
Michael Natterer's avatar
Michael Natterer committed
279 280 281
		    gint                  initial,
		    gint                  lower,
		    gint                  upper,
282
		    GObject              *object,
283
		    const gchar          *signal,
Michael Natterer's avatar
Michael Natterer committed
284 285 286 287 288 289 290 291
		    GimpQueryIntCallback  callback,
		    gpointer              data)
{
  QueryBox  *query_box;
  GtkWidget *spinbutton;
  GtkObject *adjustment;

  query_box = create_query_box (title, help_func, help_data,
292 293
				G_CALLBACK (int_query_box_ok_callback),
				G_CALLBACK (query_box_cancel_callback),
294
                                GTK_STOCK_DIALOG_QUESTION,
Michael Natterer's avatar
Michael Natterer committed
295
				message,
296
				GTK_STOCK_OK, GTK_STOCK_CANCEL,
Michael Natterer's avatar
Michael Natterer committed
297
				object, signal,
298
				G_CALLBACK (callback), data);
Michael Natterer's avatar
Michael Natterer committed
299

300 301 302
  if (! query_box)
    return NULL;

Michael Natterer's avatar
Michael Natterer committed
303 304 305 306 307 308 309 310 311 312 313 314
  spinbutton = gimp_spin_button_new (&adjustment,
				     initial, lower, upper, 1, 10, 0,
				     1, 0);
  gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0);
  gtk_widget_grab_focus (spinbutton);
  gtk_widget_show (spinbutton);

  query_box->entry = spinbutton;

  return query_box->qbox;
}

315 316
/**
 * gimp_query_double_box:
317
 * @title:     The query box dialog's title.
318 319
 * @help_func: The help function to show this dialog's help page.
 * @help_data: A string pointing to this dialog's html help page.
320 321 322 323 324 325 326 327 328
 * @message:   A string which will be shown above the dialog's entry widget.
 * @initial:   The initial value.
 * @lower:     The lower boundary of the range of possible values.
 * @upper:     The upper boundray of the range of possible values.
 * @digits:    The number of decimal digits the #GtkSpinButton will provide.
 * @object:    The object this query box is associated with.
 * @signal:    The object's signal which will cause the query box to be closed.
 * @callback:  The function which will be called when the user selects "OK".
 * @data:      The callback's user data.
329
 *
330 331
 * Creates a new #GtkDialog that queries the user for a double value.
 *
332
 * Returns: A pointer to the new #GtkDialog.
333
 **/
Michael Natterer's avatar
Michael Natterer committed
334
GtkWidget *
335
gimp_query_double_box (const gchar             *title,
Michael Natterer's avatar
Michael Natterer committed
336
		       GimpHelpFunc             help_func,
337 338
		       const gchar             *help_data,
		       const gchar             *message,
Michael Natterer's avatar
Michael Natterer committed
339 340 341 342
		       gdouble                  initial,
		       gdouble                  lower,
		       gdouble                  upper,
		       gint                     digits,
343
		       GObject                 *object,
344
		       const gchar             *signal,
Michael Natterer's avatar
Michael Natterer committed
345 346 347 348 349 350 351 352
		       GimpQueryDoubleCallback  callback,
		       gpointer                 data)
{
  QueryBox  *query_box;
  GtkWidget *spinbutton;
  GtkObject *adjustment;

  query_box = create_query_box (title, help_func, help_data,
353 354
				G_CALLBACK (double_query_box_ok_callback),
				G_CALLBACK (query_box_cancel_callback),
355
                                GTK_STOCK_DIALOG_QUESTION,
Michael Natterer's avatar
Michael Natterer committed
356
				message,
357
				GTK_STOCK_OK, GTK_STOCK_CANCEL,
Michael Natterer's avatar
Michael Natterer committed
358
				object, signal,
359
				G_CALLBACK (callback), data);
Michael Natterer's avatar
Michael Natterer committed
360

361 362 363
  if (! query_box)
    return NULL;

Michael Natterer's avatar
Michael Natterer committed
364 365 366 367 368 369 370 371 372 373 374 375
  spinbutton = gimp_spin_button_new (&adjustment,
				     initial, lower, upper, 1, 10, 0,
				     1, digits);
  gtk_box_pack_start (GTK_BOX (query_box->vbox), spinbutton, FALSE, FALSE, 0);
  gtk_widget_grab_focus (spinbutton);
  gtk_widget_show (spinbutton);

  query_box->entry = spinbutton;

  return query_box->qbox;
}

376 377
/**
 * gimp_query_size_box:
378 379 380 381 382 383 384 385 386 387 388 389
 * @title:       The query box dialog's title.
 * @help_func:   The help function to show this dialog's help page.
 * @help_data:   A string pointing to this dialog's html help page.
 * @message:     A string which will be shown above the dialog's entry widget.
 * @initial:     The initial value.
 * @lower:       The lower boundary of the range of possible values.
 * @upper:       The upper boundray of the range of possible values.
 * @digits:      The number of decimal digits the #GimpSizeEntry provide in
 *               "pixel" mode.
 * @unit:        The unit initially shown by the #GimpUnitMenu.
 * @resolution:  The resolution (in dpi) which will be used for pixel/unit
 *               calculations.
390
 * @dot_for_dot: %TRUE if the #GimpUnitMenu's initial unit should be "pixels".
391 392 393 394 395
 * @object:      The object this query box is associated with.
 * @signal:      The object's signal which will cause the query box
 *               to be closed.
 * @callback:    The function which will be called when the user selects "OK".
 * @data:        The callback's user data.
396
 *
397 398 399
 * Creates a new #GtkDialog that queries the user for a size using a
 * #GimpSizeEntry.
 *
400
 * Returns: A pointer to the new #GtkDialog.
401
 **/
Michael Natterer's avatar
Michael Natterer committed
402
GtkWidget *
403
gimp_query_size_box (const gchar           *title,
Michael Natterer's avatar
Michael Natterer committed
404
		     GimpHelpFunc           help_func,
405 406
		     const gchar           *help_data,
		     const gchar           *message,
Michael Natterer's avatar
Michael Natterer committed
407 408 409 410 411 412 413
		     gdouble                initial,
		     gdouble                lower,
		     gdouble                upper,
		     gint                   digits,
		     GimpUnit               unit,
		     gdouble                resolution,
		     gboolean               dot_for_dot,
414
		     GObject               *object,
415
		     const gchar           *signal,
Michael Natterer's avatar
Michael Natterer committed
416 417 418 419 420 421 422
		     GimpQuerySizeCallback  callback,
		     gpointer               data)
{
  QueryBox  *query_box;
  GtkWidget *sizeentry;

  query_box = create_query_box (title, help_func, help_data,
423 424
				G_CALLBACK (size_query_box_ok_callback),
				G_CALLBACK (query_box_cancel_callback),
425
                                GTK_STOCK_DIALOG_QUESTION,
Michael Natterer's avatar
Michael Natterer committed
426
				message,
427
				GTK_STOCK_OK, GTK_STOCK_CANCEL,
Michael Natterer's avatar
Michael Natterer committed
428
				object, signal,
429
				G_CALLBACK (callback), data);
Michael Natterer's avatar
Michael Natterer committed
430

431 432 433
  if (! query_box)
    return NULL;

434
  sizeentry = gimp_size_entry_new (1, unit, "%p", TRUE, FALSE, FALSE, 12,
Michael Natterer's avatar
Michael Natterer committed
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
				   GIMP_SIZE_ENTRY_UPDATE_SIZE);
  if (dot_for_dot)
    gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), GIMP_UNIT_PIXEL);
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
				  resolution, FALSE);
  gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits);
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
					 lower, upper);
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, initial);

  gtk_box_pack_start (GTK_BOX (query_box->vbox), sizeentry, FALSE, FALSE, 0);
  gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (sizeentry));
  gtk_widget_show (sizeentry);

  query_box->entry = sizeentry;

  return query_box->qbox;
}

454 455
/**
 * gimp_query_boolean_box:
456 457 458
 * @title:        The query box dialog's title.
 * @help_func:    The help function to show this dialog's help page.
 * @help_data:    A string pointing to this dialog's html help page.
459 460
 * @stock_id:     A stock_id to specify an icon to appear on the left
 *                on the dialog's message.
461 462
 * @message:      A string which will be shown in the query box.
 * @true_button:  The string to be shown in the dialog's left button.
463
 * @false_button: The string to be shown in the dialog's right button.
464 465 466 467 468 469
 * @object:       The object this query box is associated with.
 * @signal:       The object's signal which will cause the query box
 *                to be closed.
 * @callback:     The function which will be called when the user clicks one
 *                of the buttons.
 * @data:         The callback's user data.
470
 *
471 472
 * Creates a new #GtkDialog that asks the user to do a boolean decision.
 *
473
 * Returns: A pointer to the new #GtkDialog.
474
 **/
Michael Natterer's avatar
Michael Natterer committed
475
GtkWidget *
476
gimp_query_boolean_box (const gchar              *title,
Michael Natterer's avatar
Michael Natterer committed
477
			GimpHelpFunc              help_func,
478
			const gchar              *help_data,
479
			const gchar              *stock_id,
480 481 482
			const gchar              *message,
			const gchar              *true_button,
			const gchar              *false_button,
483
			GObject                  *object,
484
			const gchar              *signal,
Michael Natterer's avatar
Michael Natterer committed
485 486 487 488
			GimpQueryBooleanCallback  callback,
			gpointer                  data)
{
  QueryBox  *query_box;
489

Michael Natterer's avatar
Michael Natterer committed
490
  query_box = create_query_box (title, help_func, help_data,
491 492
				G_CALLBACK (boolean_query_box_true_callback),
				G_CALLBACK (boolean_query_box_false_callback),
493 494
                                stock_id,
				message,
Michael Natterer's avatar
Michael Natterer committed
495 496
				true_button, false_button,
				object, signal,
497
				G_CALLBACK (callback), data);
Michael Natterer's avatar
Michael Natterer committed
498

499 500 501
  if (! query_box)
    return NULL;

Michael Natterer's avatar
Michael Natterer committed
502 503 504
  return query_box->qbox;
}

505 506 507 508 509

/*
 *  private functions
 */

Michael Natterer's avatar
Michael Natterer committed
510 511 512 513 514 515 516 517 518 519 520
static QueryBox *
query_box_disconnect (gpointer  data)
{
  QueryBox *query_box;

  query_box = (QueryBox *) data;

  gtk_widget_set_sensitive (query_box->qbox, FALSE);

  /*  disconnect, if we are connected to some signal  */
  if (query_box->object)
521 522 523 524 525
    {
      g_signal_handlers_disconnect_by_func (query_box->object,
					    query_box_cancel_callback,
					    query_box);
    }
Michael Natterer's avatar
Michael Natterer committed
526 527 528 529 530 531 532 533

  return query_box;
}

static void
string_query_box_ok_callback (GtkWidget *widget,
			      gpointer   data)
{
534 535
  QueryBox    *query_box;
  const gchar *string;
Michael Natterer's avatar
Michael Natterer committed
536 537 538 539

  query_box = query_box_disconnect (data);

  /*  Get the entry data  */
540
  string = gtk_entry_get_text (GTK_ENTRY (query_box->entry));
Michael Natterer's avatar
Michael Natterer committed
541 542

  /*  Call the user defined callback  */
543 544
  (* (GimpQueryStringCallback) query_box->callback) (query_box->qbox,
						     string,
545
						     query_box->callback_data);
Michael Natterer's avatar
Michael Natterer committed
546 547

  /*  Destroy the box  */
548 549
  if (query_box->qbox)
    gtk_widget_destroy (query_box->qbox);
Michael Natterer's avatar
Michael Natterer committed
550 551 552 553 554 555 556 557 558 559 560 561 562 563

  g_free (query_box);
}

static void
int_query_box_ok_callback (GtkWidget *widget,
			   gpointer   data)
{
  QueryBox *query_box;
  gint      value;

  query_box = query_box_disconnect (data);

  /*  Get the spinbutton data  */
564
  value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (query_box->entry));
Michael Natterer's avatar
Michael Natterer committed
565 566

  /*  Call the user defined callback  */
567 568
  (* (GimpQueryIntCallback) query_box->callback) (query_box->qbox,
						  value,
569
						  query_box->callback_data);
Michael Natterer's avatar
Michael Natterer committed
570 571

  /*  Destroy the box  */
572 573
  if (query_box->qbox)
    gtk_widget_destroy (query_box->qbox);
Michael Natterer's avatar
Michael Natterer committed
574 575 576 577 578 579 580 581 582 583 584 585 586 587

  g_free (query_box);
}

static void
double_query_box_ok_callback (GtkWidget *widget,
			      gpointer   data)
{
  QueryBox *query_box;
  gdouble   value;

  query_box = query_box_disconnect (data);

  /*  Get the spinbutton data  */
588
  value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (query_box->entry));
Michael Natterer's avatar
Michael Natterer committed
589 590

  /*  Call the user defined callback  */
591 592
  (* (GimpQueryDoubleCallback) query_box->callback) (query_box->qbox,
						     value,
593
						     query_box->callback_data);
Michael Natterer's avatar
Michael Natterer committed
594 595

  /*  Destroy the box  */
596 597
  if (query_box->qbox)
    gtk_widget_destroy (query_box->qbox);
Michael Natterer's avatar
Michael Natterer committed
598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616

  g_free (query_box);
}

static void
size_query_box_ok_callback (GtkWidget *widget,
			    gpointer   data)
{
  QueryBox *query_box;
  gdouble   size;
  GimpUnit  unit;

  query_box = query_box_disconnect (data);

  /*  Get the sizeentry data  */
  size = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (query_box->entry), 0);
  unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (query_box->entry));

  /*  Call the user defined callback  */
617 618 619
  (* (GimpQuerySizeCallback) query_box->callback) (query_box->qbox,
						   size,
						   unit,
620
						   query_box->callback_data);
Michael Natterer's avatar
Michael Natterer committed
621 622

  /*  Destroy the box  */
623 624
  if (query_box->qbox)
    gtk_widget_destroy (query_box->qbox);
Michael Natterer's avatar
Michael Natterer committed
625 626 627 628 629

  g_free (query_box);
}

static void
630 631
boolean_query_box_true_callback (GtkWidget *widget,
				 gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
632 633 634 635 636
{
  QueryBox *query_box;

  query_box = query_box_disconnect (data);

637
  /*  Call the user defined callback  */
638 639
  (* (GimpQueryBooleanCallback) query_box->callback) (query_box->qbox,
						      TRUE,
640
						      query_box->callback_data);
641

Michael Natterer's avatar
Michael Natterer committed
642
  /*  Destroy the box  */
643 644
  if (query_box->qbox)
    gtk_widget_destroy (query_box->qbox);
Michael Natterer's avatar
Michael Natterer committed
645 646 647 648 649

  g_free (query_box);
}

static void
650 651
boolean_query_box_false_callback (GtkWidget *widget,
				  gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
652 653 654 655 656 657
{
  QueryBox *query_box;

  query_box = query_box_disconnect (data);

  /*  Call the user defined callback  */
658 659
  (* (GimpQueryBooleanCallback) query_box->callback) (query_box->qbox,
						      FALSE,
660
						      query_box->callback_data);
Michael Natterer's avatar
Michael Natterer committed
661 662

  /*  Destroy the box  */
663 664
  if (query_box->qbox)
    gtk_widget_destroy (query_box->qbox);
Michael Natterer's avatar
Michael Natterer committed
665 666 667 668 669

  g_free (query_box);
}

static void
670 671
query_box_cancel_callback (GtkWidget *widget,
			   gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
672 673 674 675 676 677
{
  QueryBox *query_box;

  query_box = query_box_disconnect (data);

  /*  Destroy the box  */
678 679
  if (query_box->qbox)
    gtk_widget_destroy (query_box->qbox);
Michael Natterer's avatar
Michael Natterer committed
680 681 682

  g_free (query_box);
}