2000-01-13 23:39:26 +08:00
|
|
|
/* LIBGIMP - The GIMP Library
|
|
|
|
* Copyright (C) 1995-1999 Peter Mattis and Spencer Kimball
|
|
|
|
*
|
|
|
|
* gimpwidgets.c
|
|
|
|
* Copyright (C) 2000 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Library 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.
|
|
|
|
*/
|
|
|
|
|
2000-01-27 09:54:52 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
#include "gimpchainbutton.h"
|
2000-01-13 23:39:26 +08:00
|
|
|
#include "gimphelpui.h"
|
2000-01-14 20:41:00 +08:00
|
|
|
#include "gimpunitmenu.h"
|
2000-01-13 23:39:26 +08:00
|
|
|
#include "gimpwidgets.h"
|
2000-01-26 01:46:56 +08:00
|
|
|
#include "gimpmath.h"
|
|
|
|
|
2000-01-27 09:54:52 +08:00
|
|
|
#include "libgimp-intl.h"
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Forward declarations
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void gimp_toggle_button_sensitive_update (GtkToggleButton *toggle_button);
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
|
|
|
|
/*
|
2000-01-27 09:22:27 +08:00
|
|
|
* Widget Constructors
|
2000-01-13 23:39:26 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
GtkWidget *
|
2000-01-27 09:22:27 +08:00
|
|
|
gimp_option_menu_new (gboolean menu_only,
|
2000-01-13 23:39:26 +08:00
|
|
|
|
|
|
|
/* specify menu items as va_list:
|
2000-01-27 09:22:27 +08:00
|
|
|
* gchar *label,
|
|
|
|
* GtkSignalFunc callback,
|
|
|
|
* gpointer data,
|
|
|
|
* gpointer user_data,
|
|
|
|
* GtkWidget **widget_ptr,
|
|
|
|
* gboolean active
|
2000-01-13 23:39:26 +08:00
|
|
|
*/
|
|
|
|
|
2000-01-27 09:22:27 +08:00
|
|
|
...)
|
|
|
|
{
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
|
|
|
|
|
|
|
/* menu item variables */
|
|
|
|
gchar *label;
|
|
|
|
GtkSignalFunc callback;
|
|
|
|
gpointer data;
|
|
|
|
gpointer user_data;
|
|
|
|
GtkWidget **widget_ptr;
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
gint i;
|
|
|
|
gint initial_index;
|
|
|
|
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
|
|
|
|
/* create the menu items */
|
|
|
|
initial_index = 0;
|
|
|
|
va_start (args, menu_only);
|
|
|
|
label = va_arg (args, gchar*);
|
|
|
|
for (i = 0; label; i++)
|
|
|
|
{
|
|
|
|
callback = va_arg (args, GtkSignalFunc);
|
|
|
|
data = va_arg (args, gpointer);
|
|
|
|
user_data = va_arg (args, gpointer);
|
|
|
|
widget_ptr = va_arg (args, GtkWidget **);
|
|
|
|
active = va_arg (args, gboolean);
|
|
|
|
|
2000-02-14 06:26:41 +08:00
|
|
|
if (strcmp (label, "---"))
|
|
|
|
{
|
|
|
|
menuitem = gtk_menu_item_new_with_label (label);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
|
|
|
callback,
|
|
|
|
data);
|
|
|
|
|
|
|
|
if (user_data)
|
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menuitem), user_data);
|
|
|
|
}
|
2000-01-27 09:22:27 +08:00
|
|
|
else
|
2000-02-14 06:26:41 +08:00
|
|
|
{
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
}
|
2000-01-27 09:22:27 +08:00
|
|
|
|
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
|
|
|
|
if (widget_ptr)
|
|
|
|
*widget_ptr = menuitem;
|
|
|
|
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
/* remember the initial menu item */
|
|
|
|
if (active)
|
|
|
|
initial_index = i;
|
|
|
|
|
|
|
|
label = va_arg (args, gchar*);
|
|
|
|
}
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
if (! menu_only)
|
|
|
|
{
|
|
|
|
GtkWidget *optionmenu;
|
|
|
|
|
|
|
|
optionmenu = gtk_option_menu_new ();
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
|
|
|
|
|
|
|
|
/* select the initial menu item */
|
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), initial_index);
|
|
|
|
|
|
|
|
return optionmenu;
|
|
|
|
}
|
|
|
|
|
|
|
|
return menu;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_option_menu_new2 (gboolean menu_only,
|
|
|
|
GtkSignalFunc menu_item_callback,
|
|
|
|
gpointer data,
|
|
|
|
gpointer initial, /* user_data */
|
|
|
|
|
|
|
|
/* specify menu items as va_list:
|
|
|
|
* gchar *label,
|
|
|
|
* gpointer user_data,
|
|
|
|
* GtkWidget **widget_ptr,
|
|
|
|
*/
|
|
|
|
|
|
|
|
...)
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
|
|
|
GtkWidget *menu;
|
|
|
|
GtkWidget *menuitem;
|
|
|
|
|
|
|
|
/* menu item variables */
|
|
|
|
gchar *label;
|
|
|
|
gpointer user_data;
|
|
|
|
GtkWidget **widget_ptr;
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
gint i;
|
|
|
|
gint initial_index;
|
|
|
|
|
|
|
|
menu = gtk_menu_new ();
|
|
|
|
|
|
|
|
/* create the menu items */
|
|
|
|
initial_index = 0;
|
|
|
|
va_start (args, initial);
|
|
|
|
label = va_arg (args, gchar*);
|
|
|
|
for (i = 0; label; i++)
|
|
|
|
{
|
|
|
|
user_data = va_arg (args, gpointer);
|
2000-01-27 09:22:27 +08:00
|
|
|
widget_ptr = va_arg (args, GtkWidget **);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-02-14 06:26:41 +08:00
|
|
|
if (strcmp (label, "---"))
|
|
|
|
{
|
|
|
|
menuitem = gtk_menu_item_new_with_label (label);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
|
|
|
|
menu_item_callback,
|
|
|
|
data);
|
|
|
|
|
|
|
|
if (user_data)
|
|
|
|
gtk_object_set_user_data (GTK_OBJECT (menuitem), user_data);
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
else
|
2000-02-14 06:26:41 +08:00
|
|
|
{
|
|
|
|
menuitem = gtk_menu_item_new ();
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
gtk_menu_append (GTK_MENU (menu), menuitem);
|
|
|
|
|
|
|
|
if (widget_ptr)
|
|
|
|
*widget_ptr = menuitem;
|
|
|
|
|
|
|
|
gtk_widget_show (menuitem);
|
|
|
|
|
|
|
|
/* remember the initial menu item */
|
|
|
|
if (user_data == initial)
|
|
|
|
initial_index = i;
|
|
|
|
|
|
|
|
label = va_arg (args, gchar*);
|
|
|
|
}
|
|
|
|
va_end (args);
|
|
|
|
|
2000-01-27 09:22:27 +08:00
|
|
|
if (! menu_only)
|
|
|
|
{
|
|
|
|
GtkWidget *optionmenu;
|
|
|
|
|
|
|
|
optionmenu = gtk_option_menu_new ();
|
|
|
|
gtk_option_menu_set_menu (GTK_OPTION_MENU (optionmenu), menu);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-01-27 09:22:27 +08:00
|
|
|
/* select the initial menu item */
|
|
|
|
gtk_option_menu_set_history (GTK_OPTION_MENU (optionmenu), initial_index);
|
|
|
|
|
|
|
|
return optionmenu;
|
|
|
|
}
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-01-27 09:22:27 +08:00
|
|
|
return menu;
|
2000-01-13 23:39:26 +08:00
|
|
|
}
|
|
|
|
|
2000-02-14 06:26:41 +08:00
|
|
|
void
|
|
|
|
gimp_option_menu_set_history (GtkOptionMenu *option_menu,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkWidget *menu_item;
|
|
|
|
GList *list;
|
|
|
|
gint history = 0;
|
|
|
|
|
|
|
|
g_return_if_fail (option_menu);
|
|
|
|
g_return_if_fail (GTK_IS_OPTION_MENU (option_menu));
|
|
|
|
|
|
|
|
for (list = GTK_MENU_SHELL (option_menu->menu)->children;
|
|
|
|
list;
|
|
|
|
list = g_list_next (list))
|
|
|
|
{
|
|
|
|
menu_item = GTK_WIDGET (list->data);
|
|
|
|
|
|
|
|
if (GTK_IS_LABEL (GTK_BIN (menu_item)->child) &&
|
|
|
|
gtk_object_get_user_data (GTK_OBJECT (menu_item)) == user_data)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
history++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
gtk_option_menu_set_history (option_menu, history);
|
|
|
|
}
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
GtkWidget *
|
|
|
|
gimp_radio_group_new (gboolean in_frame,
|
|
|
|
gchar *frame_title,
|
|
|
|
|
|
|
|
/* specify radio buttons as va_list:
|
|
|
|
* gchar *label,
|
|
|
|
* GtkSignalFunc callback,
|
|
|
|
* gpointer data,
|
|
|
|
* gpointer user_data,
|
|
|
|
* GtkWidget **widget_ptr,
|
|
|
|
* gboolean active,
|
|
|
|
*/
|
|
|
|
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GSList *group;
|
|
|
|
|
|
|
|
/* radio button variables */
|
|
|
|
gchar *label;
|
|
|
|
GtkSignalFunc callback;
|
|
|
|
gpointer data;
|
|
|
|
gpointer user_data;
|
|
|
|
GtkWidget **widget_ptr;
|
|
|
|
gboolean active;
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 1);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
|
|
|
|
|
|
|
group = NULL;
|
|
|
|
|
|
|
|
/* create the radio buttons */
|
|
|
|
va_start (args, frame_title);
|
|
|
|
label = va_arg (args, gchar*);
|
|
|
|
while (label)
|
|
|
|
{
|
|
|
|
callback = va_arg (args, GtkSignalFunc);
|
|
|
|
data = va_arg (args, gpointer);
|
|
|
|
user_data = va_arg (args, gpointer);
|
2000-01-27 09:22:27 +08:00
|
|
|
widget_ptr = va_arg (args, GtkWidget **);
|
2000-01-13 23:39:26 +08:00
|
|
|
active = va_arg (args, gboolean);
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
if (label != (gpointer) 1)
|
|
|
|
button = gtk_radio_button_new_with_label (group, label);
|
|
|
|
else
|
|
|
|
button = gtk_radio_button_new (group);
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
if (user_data)
|
|
|
|
gtk_object_set_user_data (GTK_OBJECT (button), user_data);
|
|
|
|
|
|
|
|
if (widget_ptr)
|
|
|
|
*widget_ptr = button;
|
|
|
|
|
|
|
|
if (active)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
|
|
|
2000-01-15 23:32:28 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
2000-01-27 09:22:27 +08:00
|
|
|
callback,
|
2000-01-15 23:32:28 +08:00
|
|
|
data);
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
label = va_arg (args, gchar*);
|
|
|
|
}
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
if (in_frame)
|
2000-02-14 06:26:41 +08:00
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
|
|
|
frame = gtk_frame_new (frame_title);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
2000-01-13 23:39:26 +08:00
|
|
|
|
|
|
|
return vbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_radio_group_new2 (gboolean in_frame,
|
|
|
|
gchar *frame_title,
|
2000-01-27 09:22:27 +08:00
|
|
|
GtkSignalFunc radio_button_callback,
|
2000-01-13 23:39:26 +08:00
|
|
|
gpointer data,
|
|
|
|
gpointer initial, /* user_data */
|
|
|
|
|
|
|
|
/* specify radio buttons as va_list:
|
|
|
|
* gchar *label,
|
|
|
|
* gpointer user_data,
|
|
|
|
* GtkWidget **widget_ptr,
|
|
|
|
*/
|
|
|
|
|
|
|
|
...)
|
|
|
|
{
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
GSList *group;
|
|
|
|
|
|
|
|
/* radio button variables */
|
|
|
|
gchar *label;
|
|
|
|
gpointer user_data;
|
|
|
|
GtkWidget **widget_ptr;
|
|
|
|
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
vbox = gtk_vbox_new (FALSE, 1);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
|
|
|
|
|
|
|
group = NULL;
|
|
|
|
|
|
|
|
/* create the radio buttons */
|
|
|
|
va_start (args, initial);
|
|
|
|
label = va_arg (args, gchar*);
|
|
|
|
while (label)
|
|
|
|
{
|
|
|
|
user_data = va_arg (args, gpointer);
|
2000-01-27 09:22:27 +08:00
|
|
|
widget_ptr = va_arg (args, GtkWidget **);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
if (label != (gpointer) 1)
|
|
|
|
button = gtk_radio_button_new_with_label (group, label);
|
|
|
|
else
|
|
|
|
button = gtk_radio_button_new (group);
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
if (user_data)
|
|
|
|
gtk_object_set_user_data (GTK_OBJECT (button), user_data);
|
|
|
|
|
|
|
|
if (widget_ptr)
|
|
|
|
*widget_ptr = button;
|
|
|
|
|
|
|
|
if (initial == user_data)
|
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
|
|
|
|
|
2000-01-15 23:32:28 +08:00
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
2000-01-27 09:22:27 +08:00
|
|
|
radio_button_callback,
|
2000-01-15 23:32:28 +08:00
|
|
|
data);
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
label = va_arg (args, gchar*);
|
|
|
|
}
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
if (in_frame)
|
2000-02-14 06:26:41 +08:00
|
|
|
{
|
|
|
|
GtkWidget *frame;
|
|
|
|
|
|
|
|
frame = gtk_frame_new (frame_title);
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), vbox);
|
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
|
|
|
return frame;
|
|
|
|
}
|
2000-01-13 23:39:26 +08:00
|
|
|
|
|
|
|
return vbox;
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_spin_button_new (GtkObject **adjustment, /* return value */
|
|
|
|
gfloat value,
|
|
|
|
gfloat lower,
|
|
|
|
gfloat upper,
|
|
|
|
gfloat step_increment,
|
|
|
|
gfloat page_increment,
|
|
|
|
gfloat page_size,
|
|
|
|
gfloat climb_rate,
|
|
|
|
guint digits)
|
|
|
|
{
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
|
|
|
|
*adjustment = gtk_adjustment_new (value, lower, upper,
|
|
|
|
step_increment, page_increment, page_size);
|
|
|
|
|
|
|
|
spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (*adjustment),
|
|
|
|
climb_rate, digits);
|
|
|
|
gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
|
|
|
|
GTK_SHADOW_NONE);
|
|
|
|
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
|
|
|
gtk_widget_set_usize (spinbutton, 75, -1);
|
|
|
|
|
|
|
|
return spinbutton;
|
|
|
|
}
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
static void
|
|
|
|
gimp_scale_entry_unconstrained_adjustment_callback (GtkAdjustment *adjustment,
|
|
|
|
GtkAdjustment *other_adj)
|
|
|
|
{
|
|
|
|
gtk_signal_handler_block_by_data (GTK_OBJECT (other_adj), adjustment);
|
|
|
|
|
|
|
|
gtk_adjustment_set_value (other_adj, adjustment->value);
|
|
|
|
|
|
|
|
gtk_signal_handler_unblock_by_data (GTK_OBJECT (other_adj), adjustment);
|
|
|
|
}
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
GtkObject *
|
|
|
|
gimp_scale_entry_new (GtkTable *table,
|
|
|
|
gint column,
|
|
|
|
gint row,
|
|
|
|
gchar *text,
|
|
|
|
gint scale_usize,
|
|
|
|
gint spinbutton_usize,
|
|
|
|
gfloat value,
|
|
|
|
gfloat lower,
|
|
|
|
gfloat upper,
|
|
|
|
gfloat step_increment,
|
|
|
|
gfloat page_increment,
|
|
|
|
guint digits,
|
2000-02-04 23:12:17 +08:00
|
|
|
gboolean constrain,
|
|
|
|
gfloat unconstrained_lower,
|
|
|
|
gfloat unconstrained_upper,
|
2000-01-13 23:39:26 +08:00
|
|
|
gchar *tooltip,
|
|
|
|
gchar *private_tip)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scale;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkObject *adjustment;
|
2000-02-04 23:12:17 +08:00
|
|
|
GtkObject *return_adj;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
|
|
|
label = gtk_label_new (text);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), label,
|
|
|
|
column, column + 1, row, row + 1,
|
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
if (! constrain &&
|
|
|
|
unconstrained_lower <= lower &&
|
|
|
|
unconstrained_upper >= upper)
|
|
|
|
{
|
|
|
|
GtkObject *constrained_adj;
|
|
|
|
|
|
|
|
constrained_adj = gtk_adjustment_new (value, lower, upper,
|
|
|
|
step_increment, page_increment,
|
|
|
|
0.0);
|
|
|
|
|
|
|
|
spinbutton = gimp_spin_button_new (&adjustment, value,
|
|
|
|
unconstrained_lower,
|
|
|
|
unconstrained_upper,
|
|
|
|
step_increment, page_increment, 0.0,
|
|
|
|
1.0, digits);
|
|
|
|
|
|
|
|
gtk_signal_connect
|
|
|
|
(GTK_OBJECT (constrained_adj), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_scale_entry_unconstrained_adjustment_callback),
|
|
|
|
adjustment);
|
|
|
|
|
|
|
|
gtk_signal_connect
|
|
|
|
(GTK_OBJECT (adjustment), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_scale_entry_unconstrained_adjustment_callback),
|
|
|
|
constrained_adj);
|
|
|
|
|
|
|
|
return_adj = adjustment;
|
|
|
|
|
|
|
|
adjustment = constrained_adj;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
spinbutton = gimp_spin_button_new (&adjustment, value, lower, upper,
|
|
|
|
step_increment, page_increment, 0.0,
|
|
|
|
1.0, digits);
|
|
|
|
|
|
|
|
return_adj = adjustment;
|
|
|
|
}
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
if (spinbutton_usize > 0)
|
|
|
|
gtk_widget_set_usize (spinbutton, spinbutton_usize, -1);
|
|
|
|
|
|
|
|
scale = gtk_hscale_new (GTK_ADJUSTMENT (adjustment));
|
|
|
|
if (scale_usize > 0)
|
|
|
|
gtk_widget_set_usize (scale, scale_usize, -1);
|
|
|
|
gtk_scale_set_digits (GTK_SCALE (scale), digits);
|
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), scale,
|
|
|
|
column + 1, column + 2, row, row + 1,
|
2000-02-04 23:12:17 +08:00
|
|
|
GTK_FILL | GTK_EXPAND, GTK_FILL, 0, 0);
|
2000-01-13 23:39:26 +08:00
|
|
|
gtk_widget_show (scale);
|
|
|
|
|
|
|
|
gtk_table_attach (GTK_TABLE (table), spinbutton,
|
|
|
|
column + 2, column + 3, row, row + 1,
|
2000-02-04 23:12:17 +08:00
|
|
|
GTK_SHRINK, GTK_SHRINK, 0, 0);
|
2000-01-13 23:39:26 +08:00
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
|
|
|
if (tooltip || private_tip)
|
|
|
|
{
|
|
|
|
gimp_help_set_help_data (scale, tooltip, private_tip);
|
|
|
|
gimp_help_set_help_data (spinbutton, tooltip, private_tip);
|
|
|
|
}
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
return return_adj;
|
2000-01-13 23:39:26 +08:00
|
|
|
}
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
static void
|
|
|
|
gimp_random_seed_toggle_update (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gint *toggle_val;
|
|
|
|
|
|
|
|
toggle_val = (gint *) data;
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
|
|
|
*toggle_val = (gint) gtk_object_get_data (GTK_OBJECT (widget),
|
|
|
|
"time_true");
|
|
|
|
else
|
|
|
|
*toggle_val = (gint) gtk_object_get_data (GTK_OBJECT (widget),
|
|
|
|
"time_false");
|
|
|
|
|
|
|
|
gimp_toggle_button_sensitive_update (GTK_TOGGLE_BUTTON (widget));
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2000-02-04 23:12:17 +08:00
|
|
|
gimp_random_seed_new (gint *seed,
|
|
|
|
GtkWidget **seed_spinbutton,
|
|
|
|
gint *use_time,
|
|
|
|
GtkWidget **time_button,
|
|
|
|
gint time_true,
|
|
|
|
gint time_false)
|
2000-01-26 01:46:56 +08:00
|
|
|
{
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkObject *adj;
|
2000-02-04 23:12:17 +08:00
|
|
|
GtkWidget *button;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 4);
|
|
|
|
|
|
|
|
spinbutton = gimp_spin_button_new (&adj, *seed,
|
|
|
|
0, G_MAXRAND, 1, 10, 0, 1, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (adj), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_int_adjustment_update),
|
|
|
|
seed);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
if (seed_spinbutton)
|
|
|
|
*seed_spinbutton = spinbutton;
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
gimp_help_set_help_data (spinbutton,
|
|
|
|
_("If the \"Time\" button is not pressed, "
|
|
|
|
"use this value for random number generator "
|
|
|
|
"seed - this allows you to repeat a "
|
|
|
|
"given \"random\" operation"), NULL);
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
button = gtk_toggle_button_new_with_label (_("Time"));
|
|
|
|
gtk_misc_set_padding (GTK_MISC (GTK_BIN (button)->child), 2, 0);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "toggled",
|
2000-01-26 01:46:56 +08:00
|
|
|
GTK_SIGNAL_FUNC (gimp_random_seed_toggle_update),
|
|
|
|
use_time);
|
2000-02-04 23:12:17 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
|
|
|
if (time_button)
|
|
|
|
*time_button = button;
|
2000-01-26 01:46:56 +08:00
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
gimp_help_set_help_data (button,
|
2000-01-26 01:46:56 +08:00
|
|
|
_("Seed random number generator from the current "
|
|
|
|
"time - this guarantees a reasonable "
|
|
|
|
"randomization"), NULL);
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
gtk_object_set_data (GTK_OBJECT (button), "time_true",
|
2000-01-26 01:46:56 +08:00
|
|
|
(gpointer) time_true);
|
2000-02-04 23:12:17 +08:00
|
|
|
gtk_object_set_data (GTK_OBJECT (button), "time_false",
|
2000-01-26 01:46:56 +08:00
|
|
|
(gpointer) time_false);
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
gtk_object_set_data (GTK_OBJECT (button), "inverse_sensitive",
|
2000-01-26 01:46:56 +08:00
|
|
|
spinbutton);
|
|
|
|
|
2000-02-04 23:12:17 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
|
2000-01-26 01:46:56 +08:00
|
|
|
*use_time == time_true);
|
|
|
|
|
|
|
|
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
|
2000-02-03 01:59:44 +08:00
|
|
|
gimp_coordinates_callback (GtkWidget *widget,
|
2000-02-01 04:47:44 +08:00
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
GimpCoordinatesData *gcd;
|
|
|
|
gdouble new_x;
|
|
|
|
gdouble new_y;
|
|
|
|
|
|
|
|
gcd = (GimpCoordinatesData *) data;
|
|
|
|
|
|
|
|
new_x = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
|
|
|
|
new_y = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
|
|
|
|
|
|
|
|
if (gimp_chain_button_get_active (gcd->chainbutton))
|
|
|
|
{
|
|
|
|
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "value_changed");
|
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
if (gcd->chain_constrains_ratio)
|
|
|
|
{
|
|
|
|
if ((gcd->orig_x != 0) && (gcd->orig_y != 0))
|
|
|
|
{
|
|
|
|
if (new_x != gcd->last_x)
|
|
|
|
{
|
|
|
|
gcd->last_x = new_x;
|
|
|
|
gcd->last_y = new_y = (new_x * gcd->orig_y) / gcd->orig_x;
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1,
|
|
|
|
new_y);
|
|
|
|
}
|
|
|
|
else if (new_y != gcd->last_y)
|
|
|
|
{
|
|
|
|
gcd->last_y = new_y;
|
|
|
|
gcd->last_x = new_x = (new_y * gcd->orig_x) / gcd->orig_y;
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0,
|
|
|
|
new_x);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (new_x != gcd->last_x)
|
|
|
|
{
|
|
|
|
gcd->last_y = new_y = gcd->last_x = new_x;
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, new_x);
|
|
|
|
}
|
|
|
|
else if (new_y != gcd->last_y)
|
|
|
|
{
|
|
|
|
gcd->last_x = new_x = gcd->last_y = new_y;
|
|
|
|
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, new_y);
|
|
|
|
}
|
|
|
|
}
|
2000-02-01 04:47:44 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (new_x != gcd->last_x)
|
|
|
|
gcd->last_x = new_x;
|
|
|
|
if (new_y != gcd->last_y)
|
|
|
|
gcd->last_y = new_y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_coordinates_new (GimpUnit unit,
|
2000-02-01 04:47:44 +08:00
|
|
|
gchar *unit_format,
|
|
|
|
gboolean menu_show_pixels,
|
|
|
|
gboolean menu_show_percent,
|
|
|
|
gint spinbutton_usize,
|
2000-02-08 04:35:13 +08:00
|
|
|
GimpSizeEntryUpdatePolicy update_policy,
|
2000-02-01 04:47:44 +08:00
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
gboolean chainbutton_active,
|
|
|
|
gboolean chain_constrains_ratio,
|
|
|
|
/* return value: */
|
|
|
|
GtkWidget **chainbutton,
|
|
|
|
|
2000-02-01 04:47:44 +08:00
|
|
|
gchar *xlabel,
|
|
|
|
gdouble x,
|
|
|
|
gdouble xres,
|
2000-02-03 01:59:44 +08:00
|
|
|
gdouble lower_boundary_x,
|
|
|
|
gdouble upper_boundary_x,
|
|
|
|
gdouble xsize_0, /* % */
|
|
|
|
gdouble xsize_100, /* % */
|
2000-02-01 04:47:44 +08:00
|
|
|
|
|
|
|
gchar *ylabel,
|
|
|
|
gdouble y,
|
|
|
|
gdouble yres,
|
2000-02-03 01:59:44 +08:00
|
|
|
gdouble lower_boundary_y,
|
|
|
|
gdouble upper_boundary_y,
|
|
|
|
gdouble ysize_0, /* % */
|
|
|
|
gdouble ysize_100 /* % */)
|
2000-02-01 04:47:44 +08:00
|
|
|
{
|
|
|
|
GimpCoordinatesData *gcd;
|
|
|
|
GtkObject *adjustment;
|
|
|
|
GtkWidget *spinbutton;
|
|
|
|
GtkWidget *sizeentry;
|
2000-02-03 01:59:44 +08:00
|
|
|
GtkWidget *chainb;
|
2000-02-01 04:47:44 +08:00
|
|
|
|
|
|
|
spinbutton = gimp_spin_button_new (&adjustment, 1, 0, 1, 1, 10, 1, 1, 2);
|
|
|
|
sizeentry = gimp_size_entry_new (1, unit, unit_format,
|
|
|
|
menu_show_pixels,
|
|
|
|
menu_show_percent,
|
|
|
|
FALSE,
|
|
|
|
spinbutton_usize,
|
|
|
|
update_policy);
|
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (sizeentry), 0, 4);
|
2000-02-03 01:59:44 +08:00
|
|
|
gtk_table_set_col_spacing (GTK_TABLE (sizeentry), 2, 4);
|
2000-02-01 04:47:44 +08:00
|
|
|
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (sizeentry),
|
|
|
|
GTK_SPIN_BUTTON (spinbutton), NULL);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (sizeentry), spinbutton, 1, 2, 0, 1);
|
|
|
|
gtk_widget_show (spinbutton);
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (sizeentry), 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,
|
|
|
|
lower_boundary_x, upper_boundary_x);
|
|
|
|
gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
lower_boundary_y, upper_boundary_y);
|
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
if (menu_show_percent)
|
|
|
|
{
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 0,
|
|
|
|
xsize_0, xsize_100);
|
|
|
|
gimp_size_entry_set_size (GIMP_SIZE_ENTRY (sizeentry), 1,
|
|
|
|
ysize_0, ysize_100);
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), xlabel, 0, 0, 1.0);
|
|
|
|
gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (sizeentry), ylabel, 1, 0, 1.0);
|
|
|
|
|
2000-02-03 01:59:44 +08:00
|
|
|
chainb = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
|
|
|
|
if (chainbutton_active)
|
|
|
|
gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (chainb), TRUE);
|
|
|
|
gtk_table_attach (GTK_TABLE (sizeentry), chainb, 2, 3, 0, 2,
|
2000-02-01 04:47:44 +08:00
|
|
|
GTK_SHRINK | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
2000-02-03 01:59:44 +08:00
|
|
|
gtk_widget_show (chainb);
|
|
|
|
|
|
|
|
if (chainbutton)
|
|
|
|
*chainbutton = chainb;
|
2000-02-01 04:47:44 +08:00
|
|
|
|
|
|
|
gcd = g_new (GimpCoordinatesData, 1);
|
2000-02-03 01:59:44 +08:00
|
|
|
gcd->chainbutton = GIMP_CHAIN_BUTTON (chainb);
|
|
|
|
gcd->chain_constrains_ratio = chain_constrains_ratio;
|
|
|
|
gcd->orig_x = x;
|
|
|
|
gcd->orig_y = y;
|
|
|
|
gcd->last_x = x;
|
|
|
|
gcd->last_y = y;
|
2000-02-01 04:47:44 +08:00
|
|
|
|
|
|
|
gtk_signal_connect_object (GTK_OBJECT (sizeentry), "destroy",
|
|
|
|
GTK_SIGNAL_FUNC (g_free),
|
|
|
|
(GtkObject *) gcd);
|
|
|
|
|
|
|
|
gtk_signal_connect (GTK_OBJECT (sizeentry), "value_changed",
|
|
|
|
GTK_SIGNAL_FUNC (gimp_coordinates_callback),
|
|
|
|
gcd);
|
|
|
|
|
|
|
|
return sizeentry;
|
|
|
|
}
|
|
|
|
|
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-01-26 01:46:56 +08:00
|
|
|
static void
|
|
|
|
gimp_toggle_button_sensitive_update (GtkToggleButton *toggle_button)
|
2000-01-13 23:39:26 +08:00
|
|
|
{
|
|
|
|
GtkWidget *set_sensitive;
|
2000-01-26 01:46:56 +08:00
|
|
|
gboolean active;
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
active = gtk_toggle_button_get_active (toggle_button);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
|
|
|
set_sensitive =
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_object_get_data (GTK_OBJECT (toggle_button), "set_sensitive");
|
2000-01-13 23:39:26 +08:00
|
|
|
while (set_sensitive)
|
|
|
|
{
|
2000-02-01 04:47:44 +08:00
|
|
|
gtk_widget_set_sensitive (set_sensitive, active);
|
2000-01-13 23:39:26 +08:00
|
|
|
set_sensitive =
|
|
|
|
gtk_object_get_data (GTK_OBJECT (set_sensitive), "set_sensitive");
|
|
|
|
}
|
|
|
|
|
|
|
|
set_sensitive =
|
2000-01-26 01:46:56 +08:00
|
|
|
gtk_object_get_data (GTK_OBJECT (toggle_button), "inverse_sensitive");
|
2000-01-13 23:39:26 +08:00
|
|
|
while (set_sensitive)
|
|
|
|
{
|
2000-02-01 04:47:44 +08:00
|
|
|
gtk_widget_set_sensitive (set_sensitive, ! active);
|
2000-01-13 23:39:26 +08:00
|
|
|
set_sensitive =
|
|
|
|
gtk_object_get_data (GTK_OBJECT (set_sensitive), "inverse_sensitive");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-26 01:46:56 +08:00
|
|
|
void
|
|
|
|
gimp_toggle_button_update (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gint *toggle_val;
|
|
|
|
|
|
|
|
toggle_val = (gint *) data;
|
|
|
|
|
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
|
|
|
*toggle_val = TRUE;
|
|
|
|
else
|
|
|
|
*toggle_val = FALSE;
|
|
|
|
|
|
|
|
gimp_toggle_button_sensitive_update (GTK_TOGGLE_BUTTON (widget));
|
|
|
|
}
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
void
|
|
|
|
gimp_menu_item_update (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gint *item_val;
|
|
|
|
|
|
|
|
item_val = (gint *) data;
|
|
|
|
|
|
|
|
*item_val = (gint) gtk_object_get_user_data (GTK_OBJECT (widget));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_radio_button_update (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gint *toggle_val;
|
|
|
|
|
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
|
|
|
{
|
|
|
|
toggle_val = (gint *) data;
|
|
|
|
|
|
|
|
*toggle_val = (gint) gtk_object_get_user_data (GTK_OBJECT (widget));
|
|
|
|
}
|
2000-01-26 01:46:56 +08:00
|
|
|
|
|
|
|
gimp_toggle_button_sensitive_update (GTK_TOGGLE_BUTTON (widget));
|
2000-01-13 23:39:26 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_int_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gint *val;
|
|
|
|
|
|
|
|
val = (gint *) data;
|
|
|
|
*val = (gint) (adjustment->value + 0.5);
|
|
|
|
}
|
|
|
|
|
2000-01-15 23:32:28 +08:00
|
|
|
void
|
|
|
|
gimp_float_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gfloat *val;
|
|
|
|
|
|
|
|
val = (gfloat *) data;
|
|
|
|
*val = adjustment->value;
|
|
|
|
}
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
void
|
|
|
|
gimp_double_adjustment_update (GtkAdjustment *adjustment,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gdouble *val;
|
|
|
|
|
|
|
|
val = (gdouble *) data;
|
|
|
|
*val = adjustment->value;
|
|
|
|
}
|
|
|
|
|
2000-01-14 20:41:00 +08:00
|
|
|
void
|
|
|
|
gimp_unit_menu_update (GtkWidget *widget,
|
|
|
|
gpointer data)
|
|
|
|
{
|
2000-02-08 04:35:13 +08:00
|
|
|
GimpUnit *val;
|
2000-01-14 20:41:00 +08:00
|
|
|
GtkWidget *spinbutton;
|
|
|
|
gint digits;
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
val = (GimpUnit *) data;
|
2000-01-14 20:41:00 +08:00
|
|
|
*val = gimp_unit_menu_get_unit (GIMP_UNIT_MENU (widget));
|
|
|
|
|
2000-02-08 04:35:13 +08:00
|
|
|
digits = ((*val == GIMP_UNIT_PIXEL) ? 0 :
|
|
|
|
((*val == GIMP_UNIT_PERCENT) ? 2 :
|
2000-01-14 20:41:00 +08:00
|
|
|
(MIN (6, MAX (3, gimp_unit_get_digits (*val))))));
|
|
|
|
|
|
|
|
spinbutton =
|
|
|
|
gtk_object_get_data (GTK_OBJECT (widget), "set_digits");
|
|
|
|
while (spinbutton)
|
|
|
|
{
|
|
|
|
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (spinbutton), digits);
|
|
|
|
spinbutton = gtk_object_get_data (GTK_OBJECT (spinbutton), "set_digits");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
/*
|
2000-01-27 09:22:27 +08:00
|
|
|
* Helper Functions
|
2000-01-13 23:39:26 +08:00
|
|
|
*/
|
|
|
|
|
2000-01-31 11:13:02 +08:00
|
|
|
/* add aligned label & widget to a table */
|
2000-01-13 23:39:26 +08:00
|
|
|
void
|
|
|
|
gimp_table_attach_aligned (GtkTable *table,
|
2000-01-31 11:13:02 +08:00
|
|
|
gint column,
|
2000-01-13 23:39:26 +08:00
|
|
|
gint row,
|
2000-01-27 09:22:27 +08:00
|
|
|
gchar *label_text,
|
2000-01-13 23:39:26 +08:00
|
|
|
gfloat xalign,
|
|
|
|
gfloat yalign,
|
|
|
|
GtkWidget *widget,
|
2000-01-31 11:13:02 +08:00
|
|
|
gint colspan,
|
|
|
|
gboolean left_align)
|
2000-01-28 03:26:00 +08:00
|
|
|
{
|
|
|
|
if (label_text)
|
|
|
|
{
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
label = gtk_label_new (label_text);
|
|
|
|
gtk_misc_set_alignment (GTK_MISC (label), xalign, yalign);
|
|
|
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_RIGHT);
|
2000-01-31 11:13:02 +08:00
|
|
|
gtk_table_attach (table, label,
|
|
|
|
column, column + 1,
|
2000-01-28 03:26:00 +08:00
|
|
|
row, row + 1,
|
2000-02-04 23:12:17 +08:00
|
|
|
GTK_FILL, GTK_FILL, 0, 0);
|
2000-01-28 03:26:00 +08:00
|
|
|
gtk_widget_show (label);
|
|
|
|
}
|
|
|
|
|
2000-01-31 11:13:02 +08:00
|
|
|
if (left_align)
|
2000-01-28 03:26:00 +08:00
|
|
|
{
|
|
|
|
GtkWidget *alignment;
|
|
|
|
|
|
|
|
alignment = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (alignment), widget);
|
2000-02-04 23:12:17 +08:00
|
|
|
gtk_widget_show (widget);
|
|
|
|
|
|
|
|
widget = alignment;
|
2000-01-28 03:26:00 +08:00
|
|
|
}
|
2000-02-04 23:12:17 +08:00
|
|
|
|
|
|
|
gtk_table_attach (table, widget,
|
|
|
|
column + 1, column + 1 + colspan,
|
|
|
|
row, row + 1,
|
|
|
|
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
|
|
|
gtk_widget_show (widget);
|
|
|
|
}
|