2000-02-26 11:41:06 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpquerybox.c
|
2003-09-05 09:40:29 +08:00
|
|
|
* Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
|
2000-02-11 05:54:12 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2000-02-11 05:54:12 +08:00
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
2009-01-18 06:28:01 +08:00
|
|
|
* version 3 of the License, or (at your option) any later version.
|
2003-09-05 09:40:29 +08:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2000-02-26 11:41:06 +08:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-02-11 05:54:12 +08:00
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2009-01-18 06:28:01 +08:00
|
|
|
* License along with this library. If not, see
|
2018-07-12 05:27:07 +08:00
|
|
|
* <https://www.gnu.org/licenses/>.
|
2000-02-26 11:41:06 +08:00
|
|
|
*/
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2013-11-02 05:32:06 +08:00
|
|
|
#include <gegl.h>
|
2000-05-31 07:38:46 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-25 06:36:18 +08:00
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
#include "gimpwidgets.h"
|
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
|
2010-07-06 00:01:28 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpquerybox
|
|
|
|
* @title: GimpQueryBox
|
|
|
|
* @short_description: Some simple dialogs to enter a single int,
|
|
|
|
* double, string or boolean value.
|
|
|
|
* @see_also: #GimpSizeEntry, #GimpUnitMenu
|
|
|
|
*
|
|
|
|
* These functions provide simple dialogs for entering a single
|
|
|
|
* string, integer, double, boolean or pixel size value.
|
|
|
|
*
|
|
|
|
* They return a pointer to a #GtkDialog which has to be shown with
|
|
|
|
* gtk_widget_show() by the caller.
|
|
|
|
*
|
|
|
|
* The dialogs contain an entry widget for the kind of value they ask
|
|
|
|
* for and "OK" and "Cancel" buttons. On "Cancel", all query boxes
|
|
|
|
* except the boolean one silently destroy themselves. On "OK" the
|
|
|
|
* user defined callback function is called and returns the entered
|
|
|
|
* value.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
/*
|
|
|
|
* String, integer, double and size query boxes
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _QueryBox QueryBox;
|
|
|
|
|
|
|
|
struct _QueryBox
|
|
|
|
{
|
2019-08-08 04:48:06 +08:00
|
|
|
GtkWidget *qbox;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GObject *object;
|
|
|
|
gulong response_handler;
|
|
|
|
GCallback callback;
|
|
|
|
gpointer callback_data;
|
|
|
|
GDestroyNotify callback_data_destroy;
|
2000-02-11 05:54:12 +08:00
|
|
|
};
|
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
|
|
|
|
static QueryBox * create_query_box (const gchar *title,
|
2003-11-08 23:32:38 +08:00
|
|
|
GtkWidget *parent,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
GCallback response_callback,
|
2014-05-08 03:27:57 +08:00
|
|
|
const gchar *icon_name,
|
2006-04-12 18:53:28 +08:00
|
|
|
const gchar *message,
|
|
|
|
const gchar *ok_button,
|
|
|
|
const gchar *cancel_button,
|
|
|
|
GObject *object,
|
|
|
|
const gchar *signal,
|
|
|
|
GCallback callback,
|
2019-08-08 04:48:06 +08:00
|
|
|
gpointer callback_data,
|
|
|
|
GDestroyNotify callback_data_destroy);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-08 01:13:45 +08:00
|
|
|
static void query_box_disconnect (QueryBox *query_box);
|
2007-05-22 19:49:24 +08:00
|
|
|
static void query_box_destroy (QueryBox *query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
static void string_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box);
|
2003-11-06 23:27:05 +08:00
|
|
|
static void int_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box);
|
2003-11-06 23:27:05 +08:00
|
|
|
static void double_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box);
|
2003-11-06 23:27:05 +08:00
|
|
|
static void size_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box);
|
2003-11-06 23:27:05 +08:00
|
|
|
static void boolean_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-08 01:13:45 +08:00
|
|
|
static void query_box_cancel_callback (QueryBox *query_box);
|
2000-11-18 08:25:42 +08:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* create a generic query box without any entry widget
|
|
|
|
*/
|
2000-02-11 05:54:12 +08:00
|
|
|
static QueryBox *
|
2000-11-18 08:25:42 +08:00
|
|
|
create_query_box (const gchar *title,
|
2003-11-08 23:32:38 +08:00
|
|
|
GtkWidget *parent,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
GCallback response_callback,
|
2014-05-08 03:27:57 +08:00
|
|
|
const gchar *icon_name,
|
2006-04-12 18:53:28 +08:00
|
|
|
const gchar *message,
|
|
|
|
const gchar *ok_button,
|
|
|
|
const gchar *cancel_button,
|
|
|
|
GObject *object,
|
|
|
|
const gchar *signal,
|
|
|
|
GCallback callback,
|
2019-08-08 04:48:06 +08:00
|
|
|
gpointer callback_data,
|
|
|
|
GDestroyNotify callback_data_destroy)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
|
|
|
QueryBox *query_box;
|
2002-01-14 04:59:56 +08:00
|
|
|
GtkWidget *hbox = NULL;
|
2000-02-11 05:54:12 +08:00
|
|
|
GtkWidget *label;
|
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
/* make sure the object / signal passed are valid
|
|
|
|
*/
|
2003-11-08 23:32:38 +08:00
|
|
|
g_return_val_if_fail (parent == NULL || GTK_IS_WIDGET (parent), NULL);
|
2001-07-31 01:17:36 +08:00
|
|
|
g_return_val_if_fail (object == NULL || G_IS_OBJECT (object), NULL);
|
2000-11-18 08:25:42 +08:00
|
|
|
g_return_val_if_fail (object == NULL || signal != NULL, NULL);
|
|
|
|
|
2007-05-22 19:49:24 +08:00
|
|
|
query_box = g_slice_new0 (QueryBox);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-08 01:29:02 +08:00
|
|
|
query_box->qbox = gimp_dialog_new (title, "gimp-query-box",
|
2003-11-08 23:32:38 +08:00
|
|
|
parent, 0,
|
2006-04-12 18:53:28 +08:00
|
|
|
help_func, help_id,
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2006-04-12 18:53:28 +08:00
|
|
|
cancel_button, GTK_RESPONSE_CANCEL,
|
|
|
|
ok_button, GTK_RESPONSE_OK,
|
2001-11-24 07:04:49 +08:00
|
|
|
|
2006-04-12 18:53:28 +08:00
|
|
|
NULL);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2018-05-10 23:04:37 +08:00
|
|
|
gimp_dialog_set_alternative_button_order (GTK_DIALOG (query_box->qbox),
|
2005-02-10 19:00:46 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2004-03-07 01:42:56 +08:00
|
|
|
query_box->response_handler =
|
|
|
|
g_signal_connect (query_box->qbox, "response",
|
|
|
|
G_CALLBACK (response_callback),
|
|
|
|
query_box);
|
2003-11-06 23:27:05 +08:00
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (query_box->qbox, "destroy",
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (gtk_widget_destroyed),
|
|
|
|
&query_box->qbox);
|
2000-11-18 08:25:42 +08:00
|
|
|
|
|
|
|
/* if we are associated with an object, connect to the provided signal
|
|
|
|
*/
|
|
|
|
if (object)
|
|
|
|
{
|
2001-07-31 01:17:36 +08:00
|
|
|
GClosure *closure;
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2003-11-08 01:13:45 +08:00
|
|
|
closure = g_cclosure_new_swap (G_CALLBACK (query_box_cancel_callback),
|
|
|
|
query_box, NULL);
|
2001-07-31 01:17:36 +08:00
|
|
|
g_object_watch_closure (G_OBJECT (query_box->qbox), closure);
|
|
|
|
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect_closure (object, signal, closure, FALSE);
|
2000-11-18 08:25:42 +08:00
|
|
|
}
|
2002-01-14 04:59:56 +08:00
|
|
|
|
2014-05-08 03:27:57 +08:00
|
|
|
if (icon_name)
|
2000-11-18 08:25:42 +08:00
|
|
|
{
|
2009-03-23 03:32:58 +08:00
|
|
|
GtkWidget *content_area;
|
2002-01-14 04:59:56 +08:00
|
|
|
GtkWidget *image;
|
|
|
|
|
2009-03-23 03:32:58 +08:00
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (query_box->qbox));
|
|
|
|
|
2011-09-30 16:50:50 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
|
2004-05-04 22:21:13 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (hbox), 12);
|
2010-10-30 20:56:00 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
|
2003-11-13 00:04:26 +08:00
|
|
|
gtk_widget_show (hbox);
|
2002-01-14 04:59:56 +08:00
|
|
|
|
2014-05-08 03:27:57 +08:00
|
|
|
image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
|
2018-04-29 07:51:36 +08:00
|
|
|
gtk_widget_set_valign (image, GTK_ALIGN_START);
|
2003-11-13 00:04:26 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (image);
|
2000-11-18 08:25:42 +08:00
|
|
|
}
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2011-09-30 16:50:50 +08:00
|
|
|
query_box->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
|
2002-01-14 04:59:56 +08:00
|
|
|
|
|
|
|
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
|
2000-02-11 07:47:56 +08:00
|
|
|
{
|
2009-03-23 03:32:58 +08:00
|
|
|
GtkWidget *content_area;
|
|
|
|
|
|
|
|
content_area = gtk_dialog_get_content_area (GTK_DIALOG (query_box->qbox));
|
|
|
|
|
2004-05-04 22:21:13 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (query_box->vbox), 12);
|
2010-10-30 20:56:00 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (content_area), query_box->vbox,
|
|
|
|
TRUE, TRUE, 0);
|
2002-01-14 04:59:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show (query_box->vbox);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2002-01-14 04:59:56 +08:00
|
|
|
if (message)
|
|
|
|
{
|
2000-02-11 07:47:56 +08:00
|
|
|
label = gtk_label_new (message);
|
2016-09-09 01:11:20 +08:00
|
|
|
gtk_label_set_xalign (GTK_LABEL (label), 0.0);
|
2003-11-14 23:33:40 +08:00
|
|
|
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
|
2001-08-04 22:10:58 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (query_box->vbox), label, FALSE, FALSE, 0);
|
2000-02-11 07:47:56 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
}
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2019-08-08 04:48:06 +08:00
|
|
|
query_box->entry = NULL;
|
|
|
|
query_box->object = object;
|
|
|
|
query_box->callback = callback;
|
|
|
|
query_box->callback_data = callback_data;
|
|
|
|
query_box->callback_data_destroy = callback_data_destroy;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
return query_box;
|
|
|
|
}
|
|
|
|
|
2000-02-12 21:07:59 +08:00
|
|
|
/**
|
|
|
|
* gimp_query_string_box:
|
2019-08-08 04:48:06 +08:00
|
|
|
* @title: The query box dialog's title.
|
|
|
|
* @parent: The dialog's parent widget.
|
|
|
|
* @help_func: (scope async): The help function to show this dialog's help page.
|
|
|
|
* @help_id: A string identifying this dialog's help page.
|
|
|
|
* @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.
|
|
|
|
* @data_destroy: Destroy function for @data.
|
2000-02-12 21:07:59 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Creates a new #GtkDialog that queries the user for a string value.
|
|
|
|
*
|
2019-08-08 04:48:06 +08:00
|
|
|
* Returns: (transfer full): A pointer to the new #GtkDialog.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-02-11 05:54:12 +08:00
|
|
|
GtkWidget *
|
2000-11-18 08:25:42 +08:00
|
|
|
gimp_query_string_box (const gchar *title,
|
2003-11-08 23:32:38 +08:00
|
|
|
GtkWidget *parent,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
const gchar *message,
|
|
|
|
const gchar *initial,
|
|
|
|
GObject *object,
|
|
|
|
const gchar *signal,
|
|
|
|
GimpQueryStringCallback callback,
|
2019-08-08 04:48:06 +08:00
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify data_destroy)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
|
|
|
QueryBox *query_box;
|
|
|
|
GtkWidget *entry;
|
|
|
|
|
2003-11-19 07:44:35 +08:00
|
|
|
query_box = create_query_box (title, parent, help_func, help_id,
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (string_query_box_response),
|
2014-05-12 04:49:22 +08:00
|
|
|
"dialog-question",
|
2006-04-12 18:53:28 +08:00
|
|
|
message,
|
2017-02-12 23:10:50 +08:00
|
|
|
_("_OK"), _("_Cancel"),
|
2006-04-12 18:53:28 +08:00
|
|
|
object, signal,
|
2019-08-08 04:48:06 +08:00
|
|
|
G_CALLBACK (callback),
|
|
|
|
data, data_destroy);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
if (! query_box)
|
|
|
|
return NULL;
|
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
entry = gtk_entry_new ();
|
2004-09-14 20:37:03 +08:00
|
|
|
gtk_entry_set_text (GTK_ENTRY (entry), initial ? initial : "");
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
2000-02-11 05:54:12 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (query_box->vbox), entry, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_grab_focus (entry);
|
|
|
|
gtk_widget_show (entry);
|
|
|
|
|
|
|
|
query_box->entry = entry;
|
|
|
|
|
|
|
|
return query_box->qbox;
|
|
|
|
}
|
|
|
|
|
2000-02-12 21:07:59 +08:00
|
|
|
/**
|
|
|
|
* gimp_query_int_box:
|
2019-08-08 04:48:06 +08:00
|
|
|
* @title: The query box dialog's title.
|
|
|
|
* @parent: The dialog's parent widget.
|
|
|
|
* @help_func: (scope async): The help function to show this dialog's help page.
|
|
|
|
* @help_id: A string identifying this dialog's 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.
|
|
|
|
* @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.
|
|
|
|
* @data_destroy: Destroy function for @data.
|
2000-02-12 21:07:59 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Creates a new #GtkDialog that queries the user for an integer value.
|
|
|
|
*
|
2019-08-08 04:48:06 +08:00
|
|
|
* Returns: (transfer full): A pointer to the new #GtkDialog.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-02-11 05:54:12 +08:00
|
|
|
GtkWidget *
|
2000-11-18 08:25:42 +08:00
|
|
|
gimp_query_int_box (const gchar *title,
|
2003-11-08 23:32:38 +08:00
|
|
|
GtkWidget *parent,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
const gchar *message,
|
|
|
|
gint initial,
|
|
|
|
gint lower,
|
|
|
|
gint upper,
|
|
|
|
GObject *object,
|
|
|
|
const gchar *signal,
|
|
|
|
GimpQueryIntCallback callback,
|
2019-08-08 04:48:06 +08:00
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify data_destroy)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
2014-06-22 04:35:39 +08:00
|
|
|
QueryBox *query_box;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkAdjustment *adjustment;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-19 07:44:35 +08:00
|
|
|
query_box = create_query_box (title, parent, help_func, help_id,
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (int_query_box_response),
|
2014-05-12 04:49:22 +08:00
|
|
|
"dialog-question",
|
2006-04-12 18:53:28 +08:00
|
|
|
message,
|
2017-02-12 23:10:50 +08:00
|
|
|
_("_OK"), _("_Cancel"),
|
2006-04-12 18:53:28 +08:00
|
|
|
object, signal,
|
2019-08-08 04:48:06 +08:00
|
|
|
G_CALLBACK (callback),
|
|
|
|
data, data_destroy);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
if (! query_box)
|
|
|
|
return NULL;
|
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adjustment = gtk_adjustment_new (initial, lower, upper, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adjustment, 1.0, 0);
|
2014-06-22 04:35:39 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2004-09-14 20:37:03 +08:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
|
2000-02-11 05:54:12 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-02-12 21:07:59 +08:00
|
|
|
/**
|
|
|
|
* gimp_query_double_box:
|
2019-08-08 04:48:06 +08:00
|
|
|
* @title: The query box dialog's title.
|
|
|
|
* @parent: The dialog's parent widget.
|
|
|
|
* @help_func: (scope async): The help function to show this dialog's help page.
|
|
|
|
* @help_id: A string identifying this dialog's 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 #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.
|
|
|
|
* @data_destroy: Destroy function for @data.
|
2000-02-12 21:07:59 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Creates a new #GtkDialog that queries the user for a double value.
|
|
|
|
*
|
2019-08-08 04:48:06 +08:00
|
|
|
* Returns: (transfer full): A pointer to the new #GtkDialog.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-02-11 05:54:12 +08:00
|
|
|
GtkWidget *
|
2000-11-18 08:25:42 +08:00
|
|
|
gimp_query_double_box (const gchar *title,
|
2003-11-08 23:32:38 +08:00
|
|
|
GtkWidget *parent,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
const gchar *message,
|
|
|
|
gdouble initial,
|
|
|
|
gdouble lower,
|
|
|
|
gdouble upper,
|
|
|
|
gint digits,
|
|
|
|
GObject *object,
|
|
|
|
const gchar *signal,
|
|
|
|
GimpQueryDoubleCallback callback,
|
2019-08-08 04:48:06 +08:00
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify data_destroy)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
2014-06-22 04:35:39 +08:00
|
|
|
QueryBox *query_box;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkAdjustment *adjustment;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-19 07:44:35 +08:00
|
|
|
query_box = create_query_box (title, parent, help_func, help_id,
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (double_query_box_response),
|
2014-05-12 04:49:22 +08:00
|
|
|
"dialog-question",
|
2006-04-12 18:53:28 +08:00
|
|
|
message,
|
2017-02-12 23:10:50 +08:00
|
|
|
_("_OK"), _("_Cancel"),
|
2006-04-12 18:53:28 +08:00
|
|
|
object, signal,
|
2019-08-08 04:48:06 +08:00
|
|
|
G_CALLBACK (callback),
|
|
|
|
data, data_destroy);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
if (! query_box)
|
|
|
|
return NULL;
|
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adjustment = gtk_adjustment_new (initial, lower, upper, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adjustment, 1.0, 0);
|
2014-06-22 04:35:39 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2004-09-14 20:37:03 +08:00
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
|
2000-02-11 05:54:12 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-02-12 21:07:59 +08:00
|
|
|
/**
|
|
|
|
* gimp_query_size_box:
|
2019-08-08 04:48:06 +08:00
|
|
|
* @title: The query box dialog's title.
|
|
|
|
* @parent: The dialog's parent widget.
|
|
|
|
* @help_func: (scope async): The help function to show this dialog's help page.
|
|
|
|
* @help_id: A string identifying this dialog's 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.
|
|
|
|
* @dot_for_dot: %TRUE if the #GimpUnitMenu's initial unit should be "pixels".
|
|
|
|
* @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.
|
|
|
|
* @data_destroy: Destroy function for @data.
|
2000-02-12 21:07:59 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Creates a new #GtkDialog that queries the user for a size using a
|
|
|
|
* #GimpSizeEntry.
|
|
|
|
*
|
2019-08-08 04:48:06 +08:00
|
|
|
* Returns: (transfer full): A pointer to the new #GtkDialog.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-02-11 05:54:12 +08:00
|
|
|
GtkWidget *
|
2000-11-18 08:25:42 +08:00
|
|
|
gimp_query_size_box (const gchar *title,
|
2003-11-08 23:32:38 +08:00
|
|
|
GtkWidget *parent,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
|
|
|
const gchar *message,
|
|
|
|
gdouble initial,
|
|
|
|
gdouble lower,
|
|
|
|
gdouble upper,
|
|
|
|
gint digits,
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
GimpUnit *unit,
|
2006-04-12 18:53:28 +08:00
|
|
|
gdouble resolution,
|
|
|
|
gboolean dot_for_dot,
|
|
|
|
GObject *object,
|
|
|
|
const gchar *signal,
|
|
|
|
GimpQuerySizeCallback callback,
|
2019-08-08 04:48:06 +08:00
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify data_destroy)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
|
|
|
QueryBox *query_box;
|
|
|
|
GtkWidget *sizeentry;
|
2004-09-14 20:37:03 +08:00
|
|
|
GtkWidget *spinbutton;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-19 07:44:35 +08:00
|
|
|
query_box = create_query_box (title, parent, help_func, help_id,
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (size_query_box_response),
|
2014-05-12 04:49:22 +08:00
|
|
|
"dialog-question",
|
2006-04-12 18:53:28 +08:00
|
|
|
message,
|
2017-02-12 23:10:50 +08:00
|
|
|
_("_OK"), _("_Cancel"),
|
2006-04-12 18:53:28 +08:00
|
|
|
object, signal,
|
2019-08-08 04:48:06 +08:00
|
|
|
G_CALLBACK (callback),
|
|
|
|
data, data_destroy);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
if (! query_box)
|
|
|
|
return NULL;
|
|
|
|
|
Issue #434: remove broken plural support for GimpUnit.
Rather than trying to implement full i18n plural support, we just remove
this failed attempt from the past. The fact is that to get proper
support, we'd basically need to reimplement a Gettext-like plural
definition syntax within our API, then ask people to write down this
plural definition for their language, then to write every plural form…
all this for custom units which only them will ever see!
Moreover code investigation shows that the singular form was simply
never used, and the plural form was always used (whatever the actual
unit value displayed).
As for the "identifier", this was a text which was never shown anywhere
(except in the unit editor) and for all built-in units, as well as
default unitrc units, it was equivalent to the English plural value.
So we now just have a unique name which is the "long label" to be used
everywhere in the GUI, and abbreviation will be basically the "short
label". That's it. No useless (or worse, not actually usable because it
was not generic internationalization) values anymore!
2024-08-05 22:02:47 +08:00
|
|
|
sizeentry = gimp_size_entry_new (1, unit, "%n", TRUE, FALSE, FALSE, 12,
|
2006-04-12 18:53:28 +08:00
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
2000-02-11 05:54:12 +08:00
|
|
|
if (dot_for_dot)
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), gimp_unit_pixel ());
|
2000-02-11 05:54:12 +08:00
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0,
|
2006-04-12 18:53:28 +08:00
|
|
|
resolution, FALSE);
|
2000-02-11 05:54:12 +08:00
|
|
|
gimp_size_entry_set_refval_digits (GIMP_SIZE_ENTRY (sizeentry), 0, digits);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
2006-04-12 18:53:28 +08:00
|
|
|
lower, upper);
|
2000-02-11 05:54:12 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, initial);
|
|
|
|
|
2004-09-14 20:37:03 +08:00
|
|
|
spinbutton = gimp_size_entry_get_help_widget (GIMP_SIZE_ENTRY (sizeentry), 0);
|
|
|
|
gtk_entry_set_activates_default (GTK_ENTRY (spinbutton), TRUE);
|
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-02-12 21:07:59 +08:00
|
|
|
/**
|
|
|
|
* gimp_query_boolean_box:
|
2001-07-31 01:17:36 +08:00
|
|
|
* @title: The query box dialog's title.
|
2003-11-08 23:32:38 +08:00
|
|
|
* @parent: The dialog's parent widget.
|
2019-08-08 04:48:06 +08:00
|
|
|
* @help_func: (scope async): The help function to show this dialog's help page.
|
2003-11-19 07:44:35 +08:00
|
|
|
* @help_id: A string identifying this dialog's help page.
|
2014-05-08 03:27:57 +08:00
|
|
|
* @icon_name: An icon name to specify an icon to appear on the left
|
2002-01-10 04:39:49 +08:00
|
|
|
* on the dialog's message.
|
2001-07-31 01:17:36 +08:00
|
|
|
* @message: A string which will be shown in the query box.
|
|
|
|
* @true_button: The string to be shown in the dialog's left button.
|
2000-02-12 21:07:59 +08:00
|
|
|
* @false_button: The string to be shown in the dialog's right button.
|
2001-07-31 01:17:36 +08:00
|
|
|
* @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.
|
2019-08-08 04:48:06 +08:00
|
|
|
* @data_destroy: Destroy function for @data.
|
2000-02-12 21:07:59 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Creates a new #GtkDialog that asks the user to do a boolean decision.
|
|
|
|
*
|
2019-08-08 04:48:06 +08:00
|
|
|
* Returns: (transfer full): A pointer to the new #GtkDialog.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-02-11 05:54:12 +08:00
|
|
|
GtkWidget *
|
2000-11-18 08:25:42 +08:00
|
|
|
gimp_query_boolean_box (const gchar *title,
|
2003-11-08 23:32:38 +08:00
|
|
|
GtkWidget *parent,
|
2006-04-12 18:53:28 +08:00
|
|
|
GimpHelpFunc help_func,
|
|
|
|
const gchar *help_id,
|
2014-05-08 03:27:57 +08:00
|
|
|
const gchar *icon_name,
|
2006-04-12 18:53:28 +08:00
|
|
|
const gchar *message,
|
|
|
|
const gchar *true_button,
|
|
|
|
const gchar *false_button,
|
|
|
|
GObject *object,
|
|
|
|
const gchar *signal,
|
|
|
|
GimpQueryBooleanCallback callback,
|
2019-08-08 04:48:06 +08:00
|
|
|
gpointer data,
|
|
|
|
GDestroyNotify data_destroy)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
|
|
|
QueryBox *query_box;
|
2002-01-10 04:39:49 +08:00
|
|
|
|
2003-11-19 07:44:35 +08:00
|
|
|
query_box = create_query_box (title, parent, help_func, help_id,
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (boolean_query_box_response),
|
2014-05-08 03:27:57 +08:00
|
|
|
icon_name,
|
2006-04-12 18:53:28 +08:00
|
|
|
message,
|
|
|
|
true_button, false_button,
|
|
|
|
object, signal,
|
2019-08-08 04:48:06 +08:00
|
|
|
G_CALLBACK (callback),
|
|
|
|
data, data_destroy);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
if (! query_box)
|
|
|
|
return NULL;
|
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
return query_box->qbox;
|
|
|
|
}
|
|
|
|
|
2000-11-18 08:25:42 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* private functions
|
|
|
|
*/
|
|
|
|
|
2003-11-08 01:13:45 +08:00
|
|
|
static void
|
|
|
|
query_box_disconnect (QueryBox *query_box)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive (query_box->qbox, FALSE);
|
|
|
|
|
2004-03-07 01:42:56 +08:00
|
|
|
/* disconnect the response callback to avoid that it may be run twice */
|
|
|
|
if (query_box->response_handler)
|
|
|
|
{
|
|
|
|
g_signal_handler_disconnect (query_box->qbox,
|
|
|
|
query_box->response_handler);
|
|
|
|
|
|
|
|
query_box->response_handler = 0;
|
|
|
|
}
|
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
/* disconnect, if we are connected to some signal */
|
|
|
|
if (query_box->object)
|
2003-11-08 01:13:45 +08:00
|
|
|
g_signal_handlers_disconnect_by_func (query_box->object,
|
|
|
|
query_box_cancel_callback,
|
|
|
|
query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
}
|
|
|
|
|
2007-05-22 19:49:24 +08:00
|
|
|
static void
|
|
|
|
query_box_destroy (QueryBox *query_box)
|
|
|
|
{
|
|
|
|
/* Destroy the box */
|
|
|
|
if (query_box->qbox)
|
|
|
|
gtk_widget_destroy (query_box->qbox);
|
|
|
|
|
2019-08-08 04:48:06 +08:00
|
|
|
if (query_box->callback_data_destroy)
|
|
|
|
query_box->callback_data_destroy (query_box->callback_data);
|
|
|
|
|
2007-05-22 19:49:24 +08:00
|
|
|
g_slice_free (QueryBox, query_box);
|
|
|
|
}
|
|
|
|
|
2000-02-11 05:54:12 +08:00
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
string_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
2003-09-05 09:40:29 +08:00
|
|
|
const gchar *string;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-08 01:13:45 +08:00
|
|
|
query_box_disconnect (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
/* Get the entry data */
|
2003-09-05 09:40:29 +08:00
|
|
|
string = gtk_entry_get_text (GTK_ENTRY (query_box->entry));
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
/* Call the user defined callback */
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
(* (GimpQueryStringCallback) query_box->callback) (query_box->qbox,
|
|
|
|
string,
|
|
|
|
query_box->callback_data);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2007-05-22 19:49:24 +08:00
|
|
|
query_box_destroy (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
int_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
2003-11-08 01:13:45 +08:00
|
|
|
gint value;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-08 01:13:45 +08:00
|
|
|
query_box_disconnect (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
/* Get the spinbutton data */
|
2001-07-31 01:17:36 +08:00
|
|
|
value = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (query_box->entry));
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
/* Call the user defined callback */
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
(* (GimpQueryIntCallback) query_box->callback) (query_box->qbox,
|
|
|
|
value,
|
|
|
|
query_box->callback_data);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2007-05-22 19:49:24 +08:00
|
|
|
query_box_destroy (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
double_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
2003-11-08 01:13:45 +08:00
|
|
|
gdouble value;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-08 01:13:45 +08:00
|
|
|
query_box_disconnect (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
/* Get the spinbutton data */
|
2001-12-29 21:26:29 +08:00
|
|
|
value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (query_box->entry));
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
/* Call the user defined callback */
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
(* (GimpQueryDoubleCallback) query_box->callback) (query_box->qbox,
|
|
|
|
value,
|
|
|
|
query_box->callback_data);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2007-05-22 19:49:24 +08:00
|
|
|
query_box_destroy (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
size_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-26 02:55:21 +08:00
|
|
|
gdouble size;
|
|
|
|
GimpUnit *unit;
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2003-11-08 01:13:45 +08:00
|
|
|
query_box_disconnect (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
/* 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 */
|
2003-11-06 23:27:05 +08:00
|
|
|
if (response_id == GTK_RESPONSE_OK)
|
|
|
|
(* (GimpQuerySizeCallback) query_box->callback) (query_box->qbox,
|
|
|
|
size,
|
|
|
|
unit,
|
|
|
|
query_box->callback_data);
|
2000-11-18 08:25:42 +08:00
|
|
|
|
2007-05-22 19:49:24 +08:00
|
|
|
query_box_destroy (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-06 23:27:05 +08:00
|
|
|
boolean_query_box_response (GtkWidget *widget,
|
|
|
|
gint response_id,
|
2003-11-08 01:13:45 +08:00
|
|
|
QueryBox *query_box)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
2003-11-08 01:13:45 +08:00
|
|
|
query_box_disconnect (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
|
|
|
/* Call the user defined callback */
|
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
2001-07-24 Michael Natterer <mitch@gimp.org>
Port to glib/gtk+ 2.0 episode I (every segfault has it's beginning)
* configure.in: require glib/gtk+ >= 1.3.7, commented out the
gtkxmhtml stuff.
From now on, you will need glib, pango, atk and gtk+ HEAD from CVS
to hack or use GIMP HEAD.
Beware, it crashes randomly :)
* app/core/Makefile.am
* app/core/gimpmarshal.list: new file plus rules to generate
gimpmarshal.[ch] from it.
* app/core/*
* app/tools/*
* app/widgets/*
* libgimpwidgets/*: started to use the glib object system. All
core/ objects are still gtk objects however. All signals are
created using g_signal_new(). There are many gtk+ artefacts left.
Finally, we will _not_ use the gtk_signal_foo() wrappers and
friends any more.
* app/colormaps.c
* app/devices.[ch]
* app/disp_callbacks.c
* app/errorconsole.c
* app/file-save.[ch]
* app/interface.c
* app/module_db.c
* app/nav_window.c
* app/ops_buttons.c
* app/scroll.c
* app/user_install.c
* app/gui/about-dialog.c
* app/gui/brush-editor.c
* app/gui/brushes-commands.c
* app/gui/color-notebook.c
* app/gui/colormap-dialog.c
* app/gui/dialogs-commands.c
* app/gui/dialogs-constructors.c
* app/gui/file-commands.c
* app/gui/file-dialog-utils.c
* app/gui/file-new-dialog.c
* app/gui/file-open-dialog.[ch]
* app/gui/file-save-dialog.c
* app/gui/gradient-editor.c
* app/gui/gradients-commands.c
* app/gui/image-commands.c
* app/gui/info-dialog.[ch]
* app/gui/layer-select.c
* app/gui/layers-commands.c
* app/gui/menus.c
* app/gui/offset-dialog.c
* app/gui/palette-editor.c
* app/gui/palettes-commands.c
* app/gui/patterns-commands.c
* app/gui/preferences-dialog.c
* app/gui/resize-dialog.[ch]
* app/gui/splash.c
* app/gui/tips-dialog.c
* app/gui/tool-options-dialog.c
* app/gui/toolbox.c
* app/gui/tools-commands.c
* libgimp/gimpbrushmenu.c
* libgimp/gimpmenu.c
* libgimp/gimppatternmenu.c
* libgimp/gimpui.c
* libgimpbase/gimpenv.c: tons and tons of changes like "const
gchar*", switch from GdkDeviceInfo to GdkDevice (very incomplete
and currently disables), lots of s/gtk_signal/g_signal/,
removal/replacement of deprecated stuff,
s/GtkSignalFunc/GCallback/ and lots of small changes and fixes
while I was on it, zillions of warnings left...
* modules/Makefile.am: disabled the water color selector
temporarily (XInput issues).
* plug-ins/Makefile.am
* plug-ins/common/.cvsignore
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl: simply excluded all plug-ins
which did not build (including Script-Fu). They are trivial to
fix.
2001-07-25 05:27:11 +08:00
|
|
|
(* (GimpQueryBooleanCallback) query_box->callback) (query_box->qbox,
|
2006-04-12 18:53:28 +08:00
|
|
|
(response_id ==
|
2003-11-06 23:27:05 +08:00
|
|
|
GTK_RESPONSE_OK),
|
2006-04-12 18:53:28 +08:00
|
|
|
query_box->callback_data);
|
2000-02-11 05:54:12 +08:00
|
|
|
|
2007-05-22 19:49:24 +08:00
|
|
|
query_box_destroy (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-11-08 01:13:45 +08:00
|
|
|
query_box_cancel_callback (QueryBox *query_box)
|
2000-02-11 05:54:12 +08:00
|
|
|
{
|
2003-11-08 01:13:45 +08:00
|
|
|
query_box_disconnect (query_box);
|
2007-05-22 19:49:24 +08:00
|
|
|
query_box_destroy (query_box);
|
2000-02-11 05:54:12 +08:00
|
|
|
}
|