2000-02-26 11:41:06 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
2000-11-18 08:25:42 +08:00
|
|
|
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
2000-01-13 23:39:26 +08:00
|
|
|
*
|
|
|
|
* gimpwidgets.c
|
|
|
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This library is free software: you can redistribute it and/or
|
2000-01-13 23:39:26 +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.
|
2000-02-26 11:41:06 +08:00
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-01-13 23:39:26 +08:00
|
|
|
* Library 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-01-13 23:39:26 +08:00
|
|
|
*/
|
|
|
|
|
2000-01-27 09:54:52 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2012-05-03 09:36:22 +08:00
|
|
|
#include <gegl.h>
|
2000-05-31 07:38:46 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2002-10-31 00:10:18 +08:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
#include "gimpwidgets.h"
|
2001-11-28 09:14:06 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimp/libgimp-intl.h"
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-05-31 07:38:46 +08:00
|
|
|
|
2010-07-06 00:01:28 +08:00
|
|
|
/**
|
|
|
|
* SECTION: gimpwidgets
|
|
|
|
* @title: GimpWidgets
|
|
|
|
* @short_description: A collection of convenient widget constructors,
|
|
|
|
* standard callbacks and helper functions.
|
|
|
|
*
|
|
|
|
* A collection of convenient widget constructors, standard callbacks
|
|
|
|
* and helper functions.
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
2003-11-15 02:05:39 +08:00
|
|
|
/**
|
2020-05-21 19:43:47 +08:00
|
|
|
* gimp_int_radio_group_new: (skip)
|
2003-11-15 02:05:39 +08:00
|
|
|
* @in_frame: %TRUE if you want a #GtkFrame around the
|
|
|
|
* radio button group.
|
2020-05-08 21:23:56 +08:00
|
|
|
* @frame_title: (nullable):
|
|
|
|
* The title of the Frame or %NULL if you don't want a
|
|
|
|
* title.
|
2020-01-15 20:51:55 +08:00
|
|
|
* @radio_button_callback: (scope notified): The callback each button's
|
|
|
|
* "toggled" signal will be connected with.
|
|
|
|
* @radio_button_callback_data: (closure radio_button_callback):
|
2003-11-15 02:05:39 +08:00
|
|
|
* The data which will be passed to g_signal_connect().
|
2020-01-15 20:51:55 +08:00
|
|
|
* @radio_button_callback_destroy: (destroy radio_button_callback_data):
|
2003-11-15 02:05:39 +08:00
|
|
|
* @initial: The @item_data of the initially pressed radio button.
|
|
|
|
* @...: A %NULL-terminated @va_list describing
|
|
|
|
* the radio buttons.
|
|
|
|
*
|
|
|
|
* Convenience function to create a group of radio buttons embedded into
|
2020-05-08 21:23:56 +08:00
|
|
|
* a #GtkFrame or #GtkBox. This function does the same thing as
|
2003-11-15 02:05:39 +08:00
|
|
|
* gimp_radio_group_new2(), but it takes integers as @item_data instead of
|
|
|
|
* pointers, since that is a very common case (mapping an enum to a radio
|
|
|
|
* group).
|
|
|
|
*
|
2020-05-08 21:23:56 +08:00
|
|
|
* Returns: (transfer full): A #GtkFrame or #GtkBox (depending on @in_frame).
|
2003-11-15 02:05:39 +08:00
|
|
|
**/
|
|
|
|
GtkWidget *
|
|
|
|
gimp_int_radio_group_new (gboolean in_frame,
|
2006-04-12 18:53:28 +08:00
|
|
|
const gchar *frame_title,
|
|
|
|
GCallback radio_button_callback,
|
2020-01-15 20:51:55 +08:00
|
|
|
gpointer radio_button_callback_data,
|
|
|
|
GDestroyNotify radio_button_callback_destroy,
|
2006-04-12 18:53:28 +08:00
|
|
|
gint initial, /* item_data */
|
|
|
|
|
|
|
|
/* specify radio buttons as va_list:
|
|
|
|
* const gchar *label,
|
|
|
|
* gint item_data,
|
|
|
|
* GtkWidget **widget_ptr,
|
|
|
|
*/
|
|
|
|
|
|
|
|
...)
|
2003-11-15 02:05:39 +08:00
|
|
|
{
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GSList *group;
|
|
|
|
|
|
|
|
/* radio button variables */
|
|
|
|
const gchar *label;
|
|
|
|
gint item_data;
|
|
|
|
gpointer item_ptr;
|
|
|
|
GtkWidget **widget_ptr;
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
|
2011-09-30 16:50:50 +08:00
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
|
|
|
group = NULL;
|
|
|
|
|
2020-01-15 20:51:55 +08:00
|
|
|
if (radio_button_callback_destroy)
|
|
|
|
g_object_weak_ref (G_OBJECT (vbox),
|
|
|
|
(GWeakNotify) radio_button_callback_destroy,
|
|
|
|
radio_button_callback_data);
|
|
|
|
|
2003-11-15 02:05:39 +08:00
|
|
|
/* create the radio buttons */
|
|
|
|
va_start (args, initial);
|
|
|
|
label = va_arg (args, const gchar *);
|
|
|
|
|
|
|
|
while (label)
|
|
|
|
{
|
|
|
|
item_data = va_arg (args, gint);
|
|
|
|
widget_ptr = va_arg (args, GtkWidget **);
|
|
|
|
|
|
|
|
item_ptr = GINT_TO_POINTER (item_data);
|
|
|
|
|
|
|
|
if (label != GINT_TO_POINTER (1))
|
2006-04-12 18:53:28 +08:00
|
|
|
button = gtk_radio_button_new_with_mnemonic (group, label);
|
2003-11-15 02:05:39 +08:00
|
|
|
else
|
2006-04-12 18:53:28 +08:00
|
|
|
button = gtk_radio_button_new (group);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
|
|
|
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
if (item_data)
|
|
|
|
{
|
|
|
|
g_object_set_data (G_OBJECT (button), "gimp-item-data", item_ptr);
|
|
|
|
|
|
|
|
/* backward compatibility */
|
|
|
|
g_object_set_data (G_OBJECT (button), "user_data", item_ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (widget_ptr)
|
2006-04-12 18:53:28 +08:00
|
|
|
*widget_ptr = button;
|
2003-11-15 02:05:39 +08:00
|
|
|
|
|
|
|
if (initial == item_data)
|
2006-04-12 18:53:28 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
|
|
|
g_signal_connect (button, "toggled",
|
2006-04-12 18:53:28 +08:00
|
|
|
radio_button_callback,
|
2020-01-15 20:51:55 +08:00
|
|
|
radio_button_callback_data);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
label = va_arg (args, const gchar *);
|
|
|
|
}
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
if (in_frame)
|
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
2004-05-03 08:10:24 +08:00
|
|
|
frame = gimp_frame_new (frame_title);
|
2003-11-15 02:05:39 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
|
|
|
|
return vbox;
|
|
|
|
}
|
|
|
|
|
2003-01-05 23:41:23 +08:00
|
|
|
/**
|
2019-09-26 05:37:03 +08:00
|
|
|
* gimp_int_radio_group_set_active:
|
2003-01-05 23:41:23 +08:00
|
|
|
* @radio_button: Pointer to a #GtkRadioButton.
|
|
|
|
* @item_data: The @item_data of the radio button you want to select.
|
|
|
|
*
|
2019-09-26 05:37:03 +08:00
|
|
|
* Calls gtk_toggle_button_set_active() with the radio button that was created
|
|
|
|
* with a matching @item_data. This function does the same thing as
|
|
|
|
* gimp_radio_group_set_active(), but takes integers as @item_data instead
|
|
|
|
* of pointers.
|
2003-01-05 23:41:23 +08:00
|
|
|
**/
|
2001-11-22 21:01:26 +08:00
|
|
|
void
|
2019-09-26 05:37:03 +08:00
|
|
|
gimp_int_radio_group_set_active (GtkRadioButton *radio_button,
|
|
|
|
gint item_data)
|
2001-11-22 21:01:26 +08:00
|
|
|
{
|
|
|
|
GtkWidget *button;
|
|
|
|
GSList *group;
|
|
|
|
|
|
|
|
g_return_if_fail (GTK_IS_RADIO_BUTTON (radio_button));
|
|
|
|
|
|
|
|
for (group = gtk_radio_button_get_group (radio_button);
|
|
|
|
group;
|
|
|
|
group = g_slist_next (group))
|
|
|
|
{
|
|
|
|
button = GTK_WIDGET (group->data);
|
|
|
|
|
2019-09-26 05:37:03 +08:00
|
|
|
if (g_object_get_data (G_OBJECT (button), "gimp-item-data") ==
|
|
|
|
GINT_TO_POINTER (item_data))
|
2001-11-22 21:01:26 +08:00
|
|
|
{
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-11-15 07:17:38 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
static void
|
2002-11-25 03:26:58 +08:00
|
|
|
gimp_random_seed_update (GtkWidget *widget,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2004-02-01 21:22:09 +08:00
|
|
|
GtkWidget *spinbutton = data;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2004-02-01 21:22:09 +08:00
|
|
|
/* Generate a new seed if the "New Seed" button was clicked or
|
|
|
|
* of the "Randomize" toggle is activated
|
|
|
|
*/
|
|
|
|
if (! GTK_IS_TOGGLE_BUTTON (widget) ||
|
|
|
|
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
|
|
|
{
|
|
|
|
gtk_spin_button_set_value (GTK_SPIN_BUTTON (spinbutton),
|
|
|
|
(guint) g_random_int ());
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
}
|
|
|
|
|
2000-02-19 03:59:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_random_seed_new:
|
2003-12-17 22:39:38 +08:00
|
|
|
* @seed: A pointer to the variable which stores the random seed.
|
2004-02-01 21:22:09 +08:00
|
|
|
* @random_seed: A pointer to a boolean indicating whether seed should be
|
2003-12-17 22:49:56 +08:00
|
|
|
* initialised randomly or not.
|
2000-02-19 03:59:02 +08:00
|
|
|
*
|
2003-03-06 04:21:50 +08:00
|
|
|
* Creates a widget that allows the user to control how the random number
|
|
|
|
* generator is initialized.
|
2000-02-23 23:52:33 +08:00
|
|
|
*
|
2020-05-08 20:17:18 +08:00
|
|
|
* Returns: (transfer full): A #GtkBox containing a #GtkSpinButton for
|
2019-08-01 19:06:35 +08:00
|
|
|
* the seed and a #GtkButton for setting a random seed.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-26 01:46:56 +08:00
|
|
|
GtkWidget *
|
2004-02-01 21:22:09 +08:00
|
|
|
gimp_random_seed_new (guint *seed,
|
|
|
|
gboolean *random_seed)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2014-06-22 04:35:39 +08:00
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *toggle;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkAdjustment *adj;
|
|
|
|
GtkWidget *button;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2004-02-01 21:22:09 +08:00
|
|
|
g_return_val_if_fail (seed != NULL, NULL);
|
|
|
|
g_return_val_if_fail (random_seed != NULL, NULL);
|
|
|
|
|
2011-09-30 16:50:50 +08:00
|
|
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2004-02-01 07:34:56 +08:00
|
|
|
/* If we're being asked to generate a random seed, generate one. */
|
2003-12-17 22:49:56 +08:00
|
|
|
if (*random_seed)
|
2004-02-01 21:22:09 +08:00
|
|
|
*seed = g_random_int ();
|
2003-12-17 22:49:56 +08:00
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adj = gtk_adjustment_new (*seed, 0, (guint32) -1, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adj, 1.0, 0);
|
2014-06-22 04:35:39 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
2004-02-01 21:22:09 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (adj, "value-changed",
|
2002-11-25 03:26:58 +08:00
|
|
|
G_CALLBACK (gimp_uint_adjustment_update),
|
2001-07-31 19:33:13 +08:00
|
|
|
seed);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
gimp_help_set_help_data (spinbutton,
|
2002-11-25 03:26:58 +08:00
|
|
|
_("Use this value for random number generator "
|
2000-01-26 01:46:56 +08:00
|
|
|
"seed - this allows you to repeat a "
|
|
|
|
"given \"random\" operation"), NULL);
|
|
|
|
|
2004-02-01 21:22:09 +08:00
|
|
|
button = gtk_button_new_with_mnemonic (_("_New Seed"));
|
2018-04-29 07:51:36 +08:00
|
|
|
g_object_set (gtk_bin_get_child (GTK_BIN (button)),
|
|
|
|
"margin-start", 2,
|
|
|
|
"margin-end", 2,
|
|
|
|
NULL);
|
2004-02-01 21:22:09 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2003-08-17 03:46:59 +08:00
|
|
|
/* Send spinbutton as data so that we can change the value in
|
2004-02-01 21:22:09 +08:00
|
|
|
* gimp_random_seed_update()
|
|
|
|
*/
|
2003-01-06 06:07:10 +08:00
|
|
|
g_signal_connect (button, "clicked",
|
2002-11-25 03:26:58 +08:00
|
|
|
G_CALLBACK (gimp_random_seed_update),
|
|
|
|
spinbutton);
|
2000-02-04 23:12:17 +08:00
|
|
|
|
|
|
|
gimp_help_set_help_data (button,
|
2004-02-01 21:22:09 +08:00
|
|
|
_("Seed random number generator with a generated "
|
|
|
|
"random number"),
|
2002-11-25 03:26:58 +08:00
|
|
|
NULL);
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2004-03-05 21:27:26 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic (_("_Randomize"));
|
2004-02-01 07:34:56 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), *random_seed);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (toggle);
|
2004-02-01 21:22:09 +08:00
|
|
|
|
2004-02-01 07:34:56 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
random_seed);
|
|
|
|
|
2004-02-01 21:22:09 +08:00
|
|
|
/* Need to create a new seed when the "Randomize" toggle is activated */
|
|
|
|
g_signal_connect (toggle, "toggled",
|
|
|
|
G_CALLBACK (gimp_random_seed_update),
|
|
|
|
spinbutton);
|
|
|
|
|
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
|
|
|
g_object_set_data (G_OBJECT (hbox), "spinbutton", spinbutton);
|
2002-11-25 03:26:58 +08:00
|
|
|
g_object_set_data (G_OBJECT (hbox), "button", button);
|
2004-02-01 07:34:56 +08:00
|
|
|
g_object_set_data (G_OBJECT (hbox), "toggle", toggle);
|
|
|
|
|
2011-05-12 04:12:26 +08:00
|
|
|
g_object_bind_property (toggle, "active",
|
|
|
|
spinbutton, "sensitive",
|
|
|
|
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
|
|
|
|
g_object_bind_property (toggle, "active",
|
|
|
|
button, "sensitive",
|
|
|
|
G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN);
|
2000-02-23 23:52:33 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
return hbox;
|
|
|
|
}
|
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
GimpChainButton *chainbutton;
|
2000-02-03 01:59:44 +08:00
|
|
|
gboolean chain_constrains_ratio;
|
|
|
|
gdouble orig_x;
|
|
|
|
gdouble orig_y;
|
2000-02-01 04:47:44 +08:00
|
|
|
gdouble last_x;
|
|
|
|
gdouble last_y;
|
|
|
|
} GimpCoordinatesData;
|
|
|
|
|
|
|
|
static void
|
2003-08-17 03:46:59 +08:00
|
|
|
gimp_coordinates_callback (GtkWidget *widget,
|
2007-05-23 01:58:02 +08:00
|
|
|
GimpCoordinatesData *data)
|
2000-02-01 04:47:44 +08:00
|
|
|
{
|
|
|
|
gdouble new_x;
|
|
|
|
gdouble new_y;
|
|
|
|
|
|
|
|
new_x = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
|
|
|
new_y = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
|
|
|
|
2007-05-23 01:58:02 +08:00
|
|
|
if (gimp_chain_button_get_active (data->chainbutton))
|
2000-02-01 04:47:44 +08:00
|
|
|
{
|
2007-05-23 01:58:02 +08:00
|
|
|
if (data->chain_constrains_ratio)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
2007-05-23 01:58:02 +08:00
|
|
|
if ((data->orig_x != 0) && (data->orig_y != 0))
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
2013-02-24 23:48:33 +08:00
|
|
|
g_signal_handlers_block_by_func (widget,
|
|
|
|
gimp_coordinates_callback,
|
|
|
|
data);
|
|
|
|
|
2007-05-23 01:58:02 +08:00
|
|
|
if (ROUND (new_x) != ROUND (data->last_x))
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
2007-05-23 01:58:02 +08:00
|
|
|
data->last_x = new_x;
|
|
|
|
new_y = (new_x * data->orig_y) / data->orig_x;
|
2003-08-17 03:46:59 +08:00
|
|
|
|
2006-04-12 18:53:28 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1,
|
2005-01-19 02:09:19 +08:00
|
|
|
new_y);
|
2007-05-23 01:58:02 +08:00
|
|
|
data->last_y
|
2005-01-19 02:09:19 +08:00
|
|
|
= gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
2006-04-12 18:53:28 +08:00
|
|
|
}
|
2007-05-23 01:58:02 +08:00
|
|
|
else if (ROUND (new_y) != ROUND (data->last_y))
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
2007-05-23 01:58:02 +08:00
|
|
|
data->last_y = new_y;
|
|
|
|
new_x = (new_y * data->orig_x) / data->orig_y;
|
2003-08-17 03:46:59 +08:00
|
|
|
|
2006-04-12 18:53:28 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0,
|
2005-01-19 02:09:19 +08:00
|
|
|
new_x);
|
2007-05-23 01:58:02 +08:00
|
|
|
data->last_x
|
2005-01-19 02:09:19 +08:00
|
|
|
= gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
2006-04-12 18:53:28 +08:00
|
|
|
}
|
2013-02-24 23:48:33 +08:00
|
|
|
|
|
|
|
g_signal_handlers_unblock_by_func (widget,
|
|
|
|
gimp_coordinates_callback,
|
|
|
|
data);
|
2006-04-12 18:53:28 +08:00
|
|
|
}
|
|
|
|
}
|
2000-02-03 01:59:44 +08:00
|
|
|
else
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
2007-05-23 01:58:02 +08:00
|
|
|
if (new_x != data->last_x)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, new_x);
|
2007-05-23 01:58:02 +08:00
|
|
|
data->last_y = data->last_x
|
2005-01-19 02:09:19 +08:00
|
|
|
= gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
2006-04-12 18:53:28 +08:00
|
|
|
}
|
2007-05-23 01:58:02 +08:00
|
|
|
else if (new_y != data->last_y)
|
2006-04-12 18:53:28 +08:00
|
|
|
{
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, new_y);
|
2007-05-23 01:58:02 +08:00
|
|
|
data->last_x = data->last_y
|
2005-01-19 02:09:19 +08:00
|
|
|
= gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
2006-04-12 18:53:28 +08:00
|
|
|
}
|
|
|
|
}
|
2000-02-01 04:47:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-05-23 01:58:02 +08:00
|
|
|
if (new_x != data->last_x)
|
|
|
|
data->last_x = new_x;
|
|
|
|
if (new_y != data->last_y)
|
|
|
|
data->last_y = new_y;
|
2003-08-17 03:46:59 +08:00
|
|
|
}
|
2000-02-01 04:47:44 +08:00
|
|
|
}
|
|
|
|
|
2007-05-27 04:32:56 +08:00
|
|
|
static void
|
|
|
|
gimp_coordinates_data_free (GimpCoordinatesData *data)
|
|
|
|
{
|
|
|
|
g_slice_free (GimpCoordinatesData, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_coordinates_chainbutton_toggled (GimpChainButton *button,
|
|
|
|
GimpSizeEntry *entry)
|
|
|
|
{
|
|
|
|
if (gimp_chain_button_get_active (button))
|
|
|
|
{
|
|
|
|
GimpCoordinatesData *data;
|
|
|
|
|
|
|
|
data = g_object_get_data (G_OBJECT (entry), "coordinates-data");
|
|
|
|
|
|
|
|
data->orig_x = gimp_size_entry_get_refval (entry, 0);
|
|
|
|
data->orig_y = gimp_size_entry_get_refval (entry, 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-19 03:59:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_coordinates_new:
|
2000-11-28 01:09:53 +08:00
|
|
|
* @unit: The initial unit of the #GimpUnitMenu.
|
2003-02-07 05:17:12 +08:00
|
|
|
* @unit_format: A printf-like unit-format string as is used with
|
|
|
|
* gimp_unit_menu_new().
|
|
|
|
* @menu_show_pixels: %TRUE if the #GimpUnitMenu should contain an item
|
|
|
|
* for GIMP_UNIT_PIXEL.
|
2003-08-17 03:46:59 +08:00
|
|
|
* @menu_show_percent: %TRUE if the #GimpUnitMenu should contain an item
|
2003-02-07 05:17:12 +08:00
|
|
|
* for GIMP_UNIT_PERCENT.
|
2001-11-12 02:35:25 +08:00
|
|
|
* @spinbutton_width: The horizontal size of the #GimpSizeEntry's
|
2000-11-28 01:09:53 +08:00
|
|
|
* #GtkSpinButton's.
|
|
|
|
* @update_policy: The update policy for the #GimpSizeEntry.
|
2003-02-07 05:17:12 +08:00
|
|
|
* @chainbutton_active: %TRUE if the attached #GimpChainButton should be
|
2000-11-28 01:09:53 +08:00
|
|
|
* active.
|
2003-02-07 05:17:12 +08:00
|
|
|
* @chain_constrains_ratio: %TRUE if the chainbutton should constrain the
|
|
|
|
* fields' aspect ratio. If %FALSE, the values will
|
2000-02-23 23:52:33 +08:00
|
|
|
* be constrained.
|
2000-11-28 01:09:53 +08:00
|
|
|
* @xlabel: The label for the X coordinate.
|
|
|
|
* @x: The initial value of the X coordinate.
|
|
|
|
* @xres: The horizontal resolution in DPI.
|
|
|
|
* @lower_boundary_x: The lower boundary of the X coordinate.
|
|
|
|
* @upper_boundary_x: The upper boundary of the X coordinate.
|
|
|
|
* @xsize_0: The X value which will be treated as 0%.
|
|
|
|
* @xsize_100: The X value which will be treated as 100%.
|
|
|
|
* @ylabel: The label for the Y coordinate.
|
|
|
|
* @y: The initial value of the Y coordinate.
|
|
|
|
* @yres: The vertical resolution in DPI.
|
|
|
|
* @lower_boundary_y: The lower boundary of the Y coordinate.
|
|
|
|
* @upper_boundary_y: The upper boundary of the Y coordinate.
|
|
|
|
* @ysize_0: The Y value which will be treated as 0%.
|
|
|
|
* @ysize_100: The Y value which will be treated as 100%.
|
2000-02-19 03:59:02 +08:00
|
|
|
*
|
2003-01-05 23:41:23 +08:00
|
|
|
* Convenience function that creates a #GimpSizeEntry with two fields for x/y
|
|
|
|
* coordinates/sizes with a #GimpChainButton attached to constrain either the
|
|
|
|
* two fields' values or the ratio between them.
|
|
|
|
*
|
2019-08-01 19:06:35 +08:00
|
|
|
* Returns: (transfer full): The new #GimpSizeEntry.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-02-01 04:47:44 +08:00
|
|
|
GtkWidget *
|
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_coordinates_new (GimpUnit *unit,
|
2006-04-12 18:53:28 +08:00
|
|
|
const gchar *unit_format,
|
|
|
|
gboolean menu_show_pixels,
|
|
|
|
gboolean menu_show_percent,
|
|
|
|
gint spinbutton_width,
|
|
|
|
GimpSizeEntryUpdatePolicy update_policy,
|
|
|
|
|
|
|
|
gboolean chainbutton_active,
|
|
|
|
gboolean chain_constrains_ratio,
|
|
|
|
|
|
|
|
const gchar *xlabel,
|
|
|
|
gdouble x,
|
|
|
|
gdouble xres,
|
|
|
|
gdouble lower_boundary_x,
|
|
|
|
gdouble upper_boundary_x,
|
|
|
|
gdouble xsize_0, /* % */
|
|
|
|
gdouble xsize_100, /* % */
|
|
|
|
|
|
|
|
const gchar *ylabel,
|
|
|
|
gdouble y,
|
|
|
|
gdouble yres,
|
|
|
|
gdouble lower_boundary_y,
|
|
|
|
gdouble upper_boundary_y,
|
|
|
|
gdouble ysize_0, /* % */
|
|
|
|
gdouble ysize_100 /* % */)
|
2000-02-01 04:47:44 +08:00
|
|
|
{
|
2007-05-23 01:58:02 +08:00
|
|
|
GimpCoordinatesData *data;
|
2014-06-22 04:35:39 +08:00
|
|
|
GtkAdjustment *adjustment;
|
2007-05-23 01:58:02 +08:00
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *sizeentry;
|
|
|
|
GtkWidget *chainbutton;
|
2000-02-01 04:47:44 +08:00
|
|
|
|
2018-06-25 00:15:16 +08:00
|
|
|
adjustment = gtk_adjustment_new (1, 0, 1, 1, 10, 0);
|
2019-03-09 20:25:19 +08:00
|
|
|
spinbutton = gimp_spin_button_new (adjustment, 1.0, 2);
|
2014-06-22 04:35:39 +08:00
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
2002-09-07 04:44:47 +08:00
|
|
|
|
|
|
|
if (spinbutton_width > 0)
|
|
|
|
{
|
|
|
|
if (spinbutton_width < 17)
|
|
|
|
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), spinbutton_width);
|
|
|
|
else
|
|
|
|
gtk_widget_set_size_request (spinbutton, spinbutton_width, -1);
|
|
|
|
}
|
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
sizeentry = gimp_size_entry_new (1, unit, unit_format,
|
2006-04-12 18:53:28 +08:00
|
|
|
menu_show_pixels,
|
|
|
|
menu_show_percent,
|
|
|
|
FALSE,
|
|
|
|
spinbutton_width,
|
|
|
|
update_policy);
|
2000-02-01 04:47:44 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
2018-05-03 02:23:05 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (sizeentry), spinbutton, 1, 0, 1, 1);
|
2000-02-01 04:47:44 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry),
|
2006-04-12 18:53:28 +08:00
|
|
|
(update_policy == GIMP_SIZE_ENTRY_UPDATE_RESOLUTION) ||
|
2003-08-17 03:46:59 +08:00
|
|
|
(menu_show_pixels == FALSE) ?
|
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_unit_inch () : gimp_unit_pixel ());
|
2000-02-01 04:47:44 +08:00
|
|
|
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 0, xres, TRUE);
|
|
|
|
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (sizeentry), 1, yres, TRUE);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 0,
|
2006-04-12 18:53:28 +08:00
|
|
|
lower_boundary_x, upper_boundary_x);
|
2000-02-01 04:47:44 +08:00
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
|
2006-04-12 18:53:28 +08:00
|
|
|
lower_boundary_y, upper_boundary_y);
|
2000-02-01 04:47:44 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
if (menu_show_percent)
|
|
|
|
{
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
|
2006-04-12 18:53:28 +08:00
|
|
|
xsize_0, xsize_100);
|
2000-02-03 01:59:44 +08:00
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
|
2006-04-12 18:53:28 +08:00
|
|
|
ysize_0, ysize_100);
|
2000-02-03 01:59:44 +08:00
|
|
|
}
|
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 0, x);
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (sizeentry), 1, y);
|
|
|
|
|
2004-05-12 19:37:21 +08:00
|
|
|
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
|
|
|
|
xlabel, 0, 0, 0.0);
|
|
|
|
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry),
|
|
|
|
ylabel, 1, 0, 0.0);
|
2000-02-01 04:47:44 +08:00
|
|
|
|
2000-02-23 23:52:33 +08:00
|
|
|
chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
2007-05-27 04:32:56 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
if (chainbutton_active)
|
2000-02-23 23:52:33 +08:00
|
|
|
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chainbutton), TRUE);
|
2007-05-27 04:32:56 +08:00
|
|
|
|
2018-05-03 02:23:05 +08:00
|
|
|
gtk_grid_attach (GTK_GRID (sizeentry), chainbutton, 2, 0, 1, 2);
|
2000-02-23 23:52:33 +08:00
|
|
|
gtk_widget_show (chainbutton);
|
2000-02-01 04:47:44 +08:00
|
|
|
|
2007-05-23 01:58:02 +08:00
|
|
|
data = g_slice_new (GimpCoordinatesData);
|
|
|
|
|
|
|
|
data->chainbutton = GIMP_CHAIN_BUTTON (chainbutton);
|
|
|
|
data->chain_constrains_ratio = chain_constrains_ratio;
|
|
|
|
data->orig_x = x;
|
|
|
|
data->orig_y = y;
|
|
|
|
data->last_x = x;
|
|
|
|
data->last_y = y;
|
2000-02-01 04:47:44 +08:00
|
|
|
|
2007-05-27 04:32:56 +08:00
|
|
|
g_object_set_data_full (G_OBJECT (sizeentry), "coordinates-data",
|
|
|
|
data,
|
|
|
|
(GDestroyNotify) gimp_coordinates_data_free);
|
2000-02-01 04:47:44 +08:00
|
|
|
|
2005-05-27 21:05:26 +08:00
|
|
|
g_signal_connect (sizeentry, "value-changed",
|
2006-04-12 18:53:28 +08:00
|
|
|
G_CALLBACK (gimp_coordinates_callback),
|
2007-05-23 01:58:02 +08:00
|
|
|
data);
|
2000-02-01 04:47:44 +08:00
|
|
|
|
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
|
|
|
g_object_set_data (G_OBJECT (sizeentry), "chainbutton", chainbutton);
|
2000-02-23 23:52:33 +08:00
|
|
|
|
2007-05-27 04:32:56 +08:00
|
|
|
g_signal_connect (chainbutton, "toggled",
|
|
|
|
G_CALLBACK (gimp_coordinates_chainbutton_toggled),
|
|
|
|
sizeentry);
|
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
return sizeentry;
|
|
|
|
}
|
|
|
|
|
2000-03-15 07:06:21 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
/*
|
2000-01-27 09:22:27 +08:00
|
|
|
* Standard Callbacks
|
2000-01-13 23:39:26 +08:00
|
|
|
*/
|
|
|
|
|
2000-02-19 03:59:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_toggle_button_update:
|
2000-02-23 23:52:33 +08:00
|
|
|
* @widget: A #GtkToggleButton.
|
2024-05-11 21:30:45 +08:00
|
|
|
* @data: (out) (type gboolean): A return location for the value of
|
2000-11-28 01:09:53 +08:00
|
|
|
* gtk_toggle_button_get_active().
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-26 01:46:56 +08:00
|
|
|
void
|
|
|
|
gimp_toggle_button_update (GtkWidget *widget,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
2024-05-11 21:30:45 +08:00
|
|
|
gboolean *toggle_val = (gboolean *) data;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
|
|
|
*toggle_val = TRUE;
|
|
|
|
else
|
|
|
|
*toggle_val = FALSE;
|
|
|
|
}
|
|
|
|
|
2000-02-19 03:59:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_radio_button_update:
|
2000-02-23 23:52:33 +08:00
|
|
|
* @widget: A #GtkRadioButton.
|
2024-05-11 21:30:45 +08:00
|
|
|
* @data: (out) (type gint): A return location for the value of
|
|
|
|
* `GPOINTER_TO_INT (g_object_get_data (@widget, "gimp-item-data"))`.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-13 23:39:26 +08:00
|
|
|
void
|
|
|
|
gimp_radio_button_update (GtkWidget *widget,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
2000-01-26 01:46:56 +08:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
2006-10-18 18:29:16 +08:00
|
|
|
gint *toggle_val = (gint *) data;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
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
|
|
|
*toggle_val = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
|
2006-04-12 18:53:28 +08:00
|
|
|
"gimp-item-data"));
|
2000-01-13 23:39:26 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-02-19 03:59:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_int_adjustment_update:
|
2024-05-11 21:30:45 +08:00
|
|
|
* @adjustment: A #GtkAdjustment.
|
|
|
|
* @data: (out) (type gint): A return location for the @adjustment's value.
|
2000-02-23 23:52:33 +08:00
|
|
|
*
|
2003-02-26 20:48:48 +08:00
|
|
|
* Note that the #GtkAdjustment's value (which is a #gdouble) will be
|
|
|
|
* rounded with RINT().
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-13 23:39:26 +08:00
|
|
|
void
|
|
|
|
gimp_int_adjustment_update (GtkAdjustment *adjustment,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
2006-10-18 18:29:16 +08:00
|
|
|
gint *val = (gint *) data;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2008-08-29 23:54:10 +08:00
|
|
|
*val = RINT (gtk_adjustment_get_value (adjustment));
|
2000-01-13 23:39:26 +08:00
|
|
|
}
|
|
|
|
|
2000-05-21 02:39:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_uint_adjustment_update:
|
|
|
|
* @adjustment: A #GtkAdjustment.
|
2024-05-11 21:30:45 +08:00
|
|
|
* @data: (out) (type guint): A return location for the @adjustment's value.
|
2000-05-21 02:39:02 +08:00
|
|
|
*
|
2003-02-26 20:48:48 +08:00
|
|
|
* Note that the #GtkAdjustment's value (which is a #gdouble) will be rounded
|
2000-05-21 02:39:02 +08:00
|
|
|
* with (#guint) (value + 0.5).
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-05-21 02:39:02 +08:00
|
|
|
void
|
|
|
|
gimp_uint_adjustment_update (GtkAdjustment *adjustment,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
2000-05-21 02:39:02 +08:00
|
|
|
{
|
2006-10-18 18:29:16 +08:00
|
|
|
guint *val = (guint *) data;
|
2000-05-21 02:39:02 +08:00
|
|
|
|
2008-08-29 23:54:10 +08:00
|
|
|
*val = (guint) (gtk_adjustment_get_value (adjustment) + 0.5);
|
2000-05-21 02:39:02 +08:00
|
|
|
}
|
|
|
|
|
2000-02-19 03:59:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_float_adjustment_update:
|
2000-02-23 23:52:33 +08:00
|
|
|
* @adjustment: A #GtkAdjustment.
|
2024-05-11 21:30:45 +08:00
|
|
|
* @data: (out) (type gfloat): A return location for the @adjustment's value.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-15 23:32:28 +08:00
|
|
|
void
|
|
|
|
gimp_float_adjustment_update (GtkAdjustment *adjustment,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
2000-01-15 23:32:28 +08:00
|
|
|
{
|
2006-10-18 18:29:16 +08:00
|
|
|
gfloat *val = (gfloat *) data;
|
2008-08-29 23:54:10 +08:00
|
|
|
|
|
|
|
*val = gtk_adjustment_get_value (adjustment);
|
2006-10-18 18:29:16 +08:00
|
|
|
|
2000-01-15 23:32:28 +08:00
|
|
|
}
|
|
|
|
|
2000-02-19 03:59:02 +08:00
|
|
|
/**
|
|
|
|
* gimp_double_adjustment_update:
|
2000-02-23 23:52:33 +08:00
|
|
|
* @adjustment: A #GtkAdjustment.
|
2024-05-11 21:30:45 +08:00
|
|
|
* @data: (out) (type gdouble): A return location for the @adjustment's value.
|
2000-11-18 08:25:42 +08:00
|
|
|
**/
|
2000-01-13 23:39:26 +08:00
|
|
|
void
|
|
|
|
gimp_double_adjustment_update (GtkAdjustment *adjustment,
|
2006-04-12 18:53:28 +08:00
|
|
|
gpointer data)
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
2006-10-18 18:29:16 +08:00
|
|
|
gdouble *val = (gdouble *) data;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2008-08-29 23:54:10 +08:00
|
|
|
*val = gtk_adjustment_get_value (adjustment);
|
2000-01-13 23:39:26 +08:00
|
|
|
}
|