mirror of https://github.com/GNOME/gimp.git
added an API to allow for sub-pixel sizes in spinbuttons connected to a
2003-10-01 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpunitmenu.[ch]: * libgimpwidgets/gimpwidgets.c: added an API to allow for sub-pixel sizes in spinbuttons connected to a GimpUnitMenu. Make GimpUnitMenu emit "unit-changed" when the unit is changed programmatically. * libgimpwidgets/gimpsizeentry.[ch}: added a similar API here. Make GimpSizeEntry emit "unit-changed" when the unit is changed programmatically. The other signals will need similar changes. * plug-ins/common/gauss_rle.c * plug-ins/common/gauss_iir.c * app/widgets/gimpstrokeeditor.c: use the new API.
This commit is contained in:
parent
1667acd36d
commit
2f855afa6a
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2003-10-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpunitmenu.[ch]:
|
||||
* libgimpwidgets/gimpwidgets.c: added an API to allow for
|
||||
sub-pixel sizes in spinbuttons connected to a GimpUnitMenu.
|
||||
Make GimpUnitMenu emit "unit-changed" when the unit is changed
|
||||
programmatically.
|
||||
|
||||
* libgimpwidgets/gimpsizeentry.[ch}: added a similar API here.
|
||||
Make GimpSizeEntry emit "unit-changed" when the unit is changed
|
||||
programmatically. The other signals will need similar changes.
|
||||
|
||||
* plug-ins/common/gauss_rle.c
|
||||
* plug-ins/common/gauss_iir.c
|
||||
* app/widgets/gimpstrokeeditor.c: use the new API.
|
||||
|
||||
2003-09-30 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/widgets/gimpdockable.c (gimp_dockable_new): accept NULL
|
||||
|
|
|
@ -182,6 +182,7 @@ gimp_stroke_editor_constructor (GType type,
|
|||
|
||||
menu = gimp_prop_unit_menu_new (G_OBJECT (editor->options), "unit", "%a");
|
||||
g_object_set_data (G_OBJECT (menu), "set_digits", spinbutton);
|
||||
gimp_unit_menu_set_pixel_digits (GIMP_UNIT_MENU (menu), 1);
|
||||
gtk_table_attach (GTK_TABLE (table), menu, 2, 3, row, row + 1,
|
||||
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
|
||||
gtk_widget_show (menu);
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
2003-10-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/libgimpwidgets-sections.txt
|
||||
* libgimpwidgets/tmpl/gimpsizeentry.sgml
|
||||
* libgimpwidgets/tmpl/gimpunitmenu.sgml: updated for new functions.
|
||||
|
||||
2003-09-30 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/app-docs.sgml
|
||||
|
|
|
@ -150,6 +150,7 @@ gimp_size_entry_get_refval
|
|||
gimp_size_entry_set_refval
|
||||
gimp_size_entry_get_unit
|
||||
gimp_size_entry_set_unit
|
||||
gimp_size_entry_set_pixel_digits
|
||||
gimp_size_entry_grab_focus
|
||||
<SUBSECTION Standard>
|
||||
GIMP_SIZE_ENTRY
|
||||
|
@ -169,6 +170,8 @@ GimpUnitMenu
|
|||
gimp_unit_menu_new
|
||||
gimp_unit_menu_set_unit
|
||||
gimp_unit_menu_get_unit
|
||||
gimp_unit_menu_get_pixel_digits
|
||||
gimp_unit_menu_set_pixel_digits
|
||||
<SUBSECTION Standard>
|
||||
GIMP_UNIT_MENU
|
||||
GIMP_IS_UNIT_MENU
|
||||
|
|
|
@ -215,6 +215,15 @@ gimp_coordinates_new()
|
|||
@unit:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_size_entry_set_pixel_digits ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@gse:
|
||||
@digits:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_size_entry_grab_focus ##### -->
|
||||
<para>
|
||||
|
||||
|
|
|
@ -110,6 +110,24 @@ gimp_coordinates_new()
|
|||
@gum:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_unit_menu_get_pixel_digits ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@menu:
|
||||
@Returns:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_unit_menu_set_pixel_digits ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@menu:
|
||||
@digits:
|
||||
|
||||
|
||||
<!-- ##### SIGNAL GimpUnitMenu::unit-changed ##### -->
|
||||
<para>
|
||||
This signal is emitted whenever the user selects a #GimpUnit from the
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpsizeentry.c
|
||||
* Copyright (C) 1999-2000 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
* 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
|
||||
*
|
||||
* 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
|
||||
|
@ -121,7 +121,7 @@ gimp_size_entry_get_type (void)
|
|||
"GimpSizeEntry",
|
||||
&gse_info, 0);
|
||||
}
|
||||
|
||||
|
||||
return gse_type;
|
||||
}
|
||||
|
||||
|
@ -308,7 +308,7 @@ gimp_size_entry_new (gint number_of_fields,
|
|||
gsef->refval = 0;
|
||||
gsef->min_refval = 0;
|
||||
gsef->max_refval = SIZE_MAX_VALUE;
|
||||
gsef->refval_digits =
|
||||
gsef->refval_digits =
|
||||
(update_policy == GIMP_SIZE_ENTRY_UPDATE_SIZE) ? 0 : 3;
|
||||
gsef->stop_recursion = 0;
|
||||
|
||||
|
@ -361,7 +361,7 @@ gimp_size_entry_new (gint number_of_fields,
|
|||
gsef);
|
||||
|
||||
gtk_widget_show (gsef->refval_spinbutton);
|
||||
}
|
||||
}
|
||||
|
||||
if (gse->menu_show_pixels && (unit == GIMP_UNIT_PIXEL) &&
|
||||
! gse->show_refval)
|
||||
|
@ -380,7 +380,7 @@ gimp_size_entry_new (gint number_of_fields,
|
|||
G_CALLBACK (gimp_size_entry_unit_callback),
|
||||
gse);
|
||||
gtk_widget_show (gse->unitmenu);
|
||||
|
||||
|
||||
return GTK_WIDGET (gse);
|
||||
}
|
||||
|
||||
|
@ -404,6 +404,7 @@ gimp_size_entry_add_field (GimpSizeEntry *gse,
|
|||
GtkSpinButton *refval_spinbutton)
|
||||
{
|
||||
GimpSizeEntryField *gsef;
|
||||
gint digits;
|
||||
|
||||
g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse));
|
||||
g_return_if_fail (GTK_IS_SPIN_BUTTON (value_spinbutton));
|
||||
|
@ -449,10 +450,11 @@ gimp_size_entry_add_field (GimpSizeEntry *gse,
|
|||
gsef);
|
||||
}
|
||||
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (value_spinbutton),
|
||||
(gse->unit == GIMP_UNIT_PIXEL) ? gsef->refval_digits :
|
||||
(gse->unit == GIMP_UNIT_PERCENT) ? 2 :
|
||||
GIMP_SIZE_ENTRY_DIGITS (gse->unit));
|
||||
digits = ((gse->unit == GIMP_UNIT_PIXEL) ? gsef->refval_digits :
|
||||
(gse->unit == GIMP_UNIT_PERCENT) ? 2 :
|
||||
GIMP_SIZE_ENTRY_DIGITS (gse->unit));
|
||||
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (value_spinbutton), digits);
|
||||
|
||||
if (gse->menu_show_pixels &&
|
||||
!gse->show_refval &&
|
||||
|
@ -504,7 +506,7 @@ gimp_size_entry_attach_label (GimpSizeEntry *gse,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gtk_misc_set_alignment (GTK_MISC (label), alignment, 0.5);
|
||||
|
||||
gtk_table_attach (GTK_TABLE (gse), label, column, column+1, row, row+1,
|
||||
|
@ -755,7 +757,7 @@ gimp_size_entry_update_value (GimpSizeEntryField *gsef,
|
|||
gtk_adjustment_set_value (GTK_ADJUSTMENT (gsef->refval_adjustment),
|
||||
gsef->refval);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -1078,7 +1080,7 @@ gimp_size_entry_refval_callback (GtkWidget *widget,
|
|||
* @gse: The sizeentry you want to know the unit of.
|
||||
*
|
||||
* Returns the #GimpUnit the user has selected in the #GimpSizeEntry's
|
||||
* #GimpUnitMenu.
|
||||
* #GimpUnitMenu.
|
||||
*
|
||||
* Returns: The sizeentry's unit.
|
||||
**/
|
||||
|
@ -1100,6 +1102,8 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
|
|||
|
||||
gse->unit = unit;
|
||||
|
||||
digits = gimp_unit_menu_get_pixel_digits (GIMP_UNIT_MENU (gse->unitmenu));
|
||||
|
||||
for (i = 0; i < gse->number_of_fields; i++)
|
||||
{
|
||||
gsef = (GimpSizeEntryField *) g_slist_nth_data (gse->fields, i);
|
||||
|
@ -1108,18 +1112,18 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
|
|||
{
|
||||
if (unit == GIMP_UNIT_PIXEL)
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton),
|
||||
gsef->refval_digits);
|
||||
gsef->refval_digits + digits);
|
||||
else if (unit == GIMP_UNIT_PERCENT)
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton),
|
||||
2);
|
||||
2 + digits);
|
||||
else
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton),
|
||||
GIMP_SIZE_ENTRY_DIGITS (unit));
|
||||
GIMP_SIZE_ENTRY_DIGITS (unit) + digits);
|
||||
}
|
||||
else if (gse->update_policy == GIMP_SIZE_ENTRY_UPDATE_RESOLUTION)
|
||||
{
|
||||
digits =
|
||||
-(_gimp_eek.unit_get_digits (unit) - _gimp_eek.unit_get_digits (GIMP_UNIT_INCH));
|
||||
digits = (_gimp_eek.unit_get_digits (GIMP_UNIT_INCH) -
|
||||
_gimp_eek.unit_get_digits (unit));
|
||||
gtk_spin_button_set_digits (GTK_SPIN_BUTTON (gsef->value_spinbutton),
|
||||
MAX (3 + digits, 3));
|
||||
}
|
||||
|
@ -1131,7 +1135,7 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
|
|||
gsef);
|
||||
|
||||
gimp_size_entry_set_refval_boundaries (gse, i,
|
||||
gsef->min_refval,
|
||||
gsef->min_refval,
|
||||
gsef->max_refval);
|
||||
|
||||
g_signal_handlers_unblock_by_func (gsef->value_adjustment,
|
||||
|
@ -1139,9 +1143,10 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
|
|||
gsef);
|
||||
}
|
||||
|
||||
g_signal_emit (gse, gimp_size_entry_signals[VALUE_CHANGED], 0);
|
||||
g_signal_emit (gse, gimp_size_entry_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_size_entry_set_unit:
|
||||
* @gse: The sizeentry you want to change the unit for.
|
||||
|
@ -1153,7 +1158,7 @@ gimp_size_entry_update_unit (GimpSizeEntry *gse,
|
|||
* gimp_size_entry_new().
|
||||
**/
|
||||
void
|
||||
gimp_size_entry_set_unit (GimpSizeEntry *gse,
|
||||
gimp_size_entry_set_unit (GimpSizeEntry *gse,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse));
|
||||
|
@ -1170,10 +1175,32 @@ gimp_size_entry_unit_callback (GtkWidget *widget,
|
|||
{
|
||||
gimp_size_entry_update_unit (GIMP_SIZE_ENTRY (data),
|
||||
gimp_unit_menu_get_unit (GIMP_UNIT_MENU(widget)));
|
||||
|
||||
g_signal_emit (data, gimp_size_entry_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_size_entry_set_pixel_digits:
|
||||
* @gse: a #GimpSizeEntry
|
||||
* @digits: the number of digits to display for a pixel size
|
||||
*
|
||||
* Similar to gimp_unit_menu_set_pixel_digits(), this function allows
|
||||
* you set up a #GimpSizeEntry so that sub-pixel sizes can be entered.
|
||||
**/
|
||||
void
|
||||
gimp_size_entry_set_pixel_digits (GimpSizeEntry *gse,
|
||||
gint digits)
|
||||
{
|
||||
GimpUnitMenu *menu;
|
||||
|
||||
g_return_if_fail (GIMP_IS_SIZE_ENTRY (gse));
|
||||
|
||||
menu = GIMP_UNIT_MENU (gse->unitmenu);
|
||||
|
||||
gimp_unit_menu_set_pixel_digits (menu, digits);
|
||||
gimp_size_entry_update_unit (gse, gimp_unit_menu_get_unit (menu));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_size_entry_grab_focus:
|
||||
* @gse: The sizeentry you want to grab the keyboard focus.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpsizeentry.h
|
||||
* Copyright (C) 1999-2000 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
* 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
|
||||
|
@ -126,9 +126,12 @@ void gimp_size_entry_set_refval (GimpSizeEntry *gse,
|
|||
gdouble refval);
|
||||
|
||||
GimpUnit gimp_size_entry_get_unit (GimpSizeEntry *gse);
|
||||
void gimp_size_entry_set_unit (GimpSizeEntry *gse,
|
||||
void gimp_size_entry_set_unit (GimpSizeEntry *gse,
|
||||
GimpUnit unit);
|
||||
|
||||
void gimp_size_entry_set_pixel_digits (GimpSizeEntry *gse,
|
||||
gint digits);
|
||||
|
||||
void gimp_size_entry_grab_focus (GimpSizeEntry *gse);
|
||||
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
* 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
|
||||
* 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
|
||||
|
@ -31,6 +31,7 @@
|
|||
#include "gimpdialog.h"
|
||||
#include "gimphelpui.h"
|
||||
#include "gimpunitmenu.h"
|
||||
#include "gimpwidgets.h"
|
||||
#include "gimpwidgets-private.h"
|
||||
|
||||
#include "libgimp/libgimp-intl.h"
|
||||
|
@ -91,7 +92,7 @@ gimp_unit_menu_get_type (void)
|
|||
"GimpUnitMenu",
|
||||
&menu_info, 0);
|
||||
}
|
||||
|
||||
|
||||
return menu_type;
|
||||
}
|
||||
|
||||
|
@ -104,7 +105,7 @@ gimp_unit_menu_class_init (GimpUnitMenuClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gimp_unit_menu_signals[UNIT_CHANGED] =
|
||||
gimp_unit_menu_signals[UNIT_CHANGED] =
|
||||
g_signal_new ("unit_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
|
@ -242,12 +243,12 @@ gimp_unit_menu_new (const gchar *format,
|
|||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||
gtk_widget_set_sensitive (menuitem, FALSE);
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
|
||||
menuitem =
|
||||
gtk_menu_item_new_with_label (gimp_unit_menu_build_string (format,
|
||||
unit));
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
|
||||
g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu",
|
||||
g_object_set_data (G_OBJECT (menuitem), "gimp_unit_menu",
|
||||
GINT_TO_POINTER (unit));
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
|
@ -285,7 +286,7 @@ gimp_unit_menu_new (const gchar *format,
|
|||
(((show_pixels || show_percent) ? 2 : 0) +
|
||||
((show_pixels && show_percent) ? 1 : 0) +
|
||||
((unit < GIMP_UNIT_END) ?
|
||||
(unit - 1) : GIMP_UNIT_END))));
|
||||
(unit - 1) : GIMP_UNIT_END))));
|
||||
|
||||
return GTK_WIDGET (unit_menu);
|
||||
}
|
||||
|
@ -336,7 +337,7 @@ gimp_unit_menu_set_unit (GimpUnitMenu *menu,
|
|||
gtk_menu_reorder_child (GTK_MENU (GTK_OPTION_MENU (menu)->menu),
|
||||
menuitem, user_unit - 1);
|
||||
gtk_widget_show (menuitem);
|
||||
|
||||
|
||||
menuitem =
|
||||
gtk_menu_item_new_with_label (gimp_unit_menu_build_string (menu->format,
|
||||
unit));
|
||||
|
@ -364,6 +365,8 @@ gimp_unit_menu_set_unit (GimpUnitMenu *menu,
|
|||
menu->show_percent) ? 1 : 0) +
|
||||
((unit < GIMP_UNIT_END) ?
|
||||
(unit - 1) : GIMP_UNIT_END))));
|
||||
|
||||
g_signal_emit (menu, gimp_unit_menu_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -382,6 +385,53 @@ gimp_unit_menu_get_unit (GimpUnitMenu *menu)
|
|||
return menu->unit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_unit_menu_set_pixel_digits:
|
||||
* @menu: a #GimpUnitMenu
|
||||
* @digits: the number of digits to display for a pixel size
|
||||
*
|
||||
* A GimpUnitMenu can be setup to control the number of digits shown
|
||||
* by attached spinbuttons. Please refer to the documentation of
|
||||
* gimp_unit_menu_update() to see how this is done.
|
||||
*
|
||||
* This function allows to specify the number of digits shown for a
|
||||
* size in pixels. Usually this is 0 (only full pixels). If you want
|
||||
* to allow the user to specify sub-pixel sizes using the attached
|
||||
* spinbuttons, specify the number of digits after the decimal point
|
||||
* here. You should do this after attaching your spinbuttons.
|
||||
**/
|
||||
void
|
||||
gimp_unit_menu_set_pixel_digits (GimpUnitMenu *menu,
|
||||
gint digits)
|
||||
{
|
||||
GimpUnit unit;
|
||||
|
||||
g_return_if_fail (GIMP_IS_UNIT_MENU (menu));
|
||||
|
||||
menu->pixel_digits = digits;
|
||||
|
||||
gimp_unit_menu_update (GTK_WIDGET (menu), &unit);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_unit_menu_get_pixel_digits:
|
||||
* @menu: a #GimpUnitMenu
|
||||
*
|
||||
* Retrieve the number of digits for a pixel size as set by
|
||||
* gimp_unit_set_pixel_digits().
|
||||
*
|
||||
* Return value: the configured number of digits for a pixel size
|
||||
**/
|
||||
gint
|
||||
gimp_unit_menu_get_pixel_digits (GimpUnitMenu *menu)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_UNIT_MENU (menu), 0);
|
||||
|
||||
return menu->pixel_digits;
|
||||
}
|
||||
|
||||
|
||||
/* most of the next two functions is stolen from app/gdisplay.c */
|
||||
static gint
|
||||
print (gchar *buf,
|
||||
|
@ -422,7 +472,7 @@ gimp_unit_menu_build_string (const gchar *format,
|
|||
case 0:
|
||||
g_warning ("unit-menu-format string ended within %%-sequence");
|
||||
break;
|
||||
|
||||
|
||||
case '%':
|
||||
buffer[i++] = '%';
|
||||
break;
|
||||
|
@ -464,7 +514,7 @@ gimp_unit_menu_build_string (const gchar *format,
|
|||
buffer[i++] = *format;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
format++;
|
||||
}
|
||||
|
||||
|
@ -495,7 +545,6 @@ gimp_unit_menu_selection_ok_callback (GtkWidget *widget,
|
|||
g_value_unset (&val);
|
||||
|
||||
gimp_unit_menu_set_unit (menu, unit);
|
||||
g_signal_emit (menu, gimp_unit_menu_signals[UNIT_CHANGED], 0);
|
||||
|
||||
gtk_widget_destroy (menu->selection);
|
||||
}
|
||||
|
@ -634,7 +683,7 @@ gimp_unit_menu_callback (GtkWidget *widget,
|
|||
menu = data;
|
||||
new_unit = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
|
||||
"gimp_unit_menu"));
|
||||
|
||||
|
||||
if (menu->unit == new_unit)
|
||||
return;
|
||||
|
||||
|
@ -661,5 +710,4 @@ gimp_unit_menu_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
gimp_unit_menu_set_unit (menu, new_unit);
|
||||
g_signal_emit (menu, gimp_unit_menu_signals[UNIT_CHANGED], 0);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
*
|
||||
* gimpunitmenu.h
|
||||
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org>
|
||||
|
@ -45,6 +45,7 @@ struct _GimpUnitMenu
|
|||
/* public (read only) */
|
||||
gchar *format;
|
||||
GimpUnit unit;
|
||||
gint pixel_digits;
|
||||
|
||||
gboolean show_pixels;
|
||||
gboolean show_percent;
|
||||
|
@ -62,18 +63,22 @@ struct _GimpUnitMenuClass
|
|||
};
|
||||
|
||||
|
||||
GType gimp_unit_menu_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_unit_menu_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_unit_menu_new (const gchar *format,
|
||||
GimpUnit unit,
|
||||
gboolean show_pixels,
|
||||
gboolean show_percent,
|
||||
gboolean show_custom);
|
||||
GtkWidget * gimp_unit_menu_new (const gchar *format,
|
||||
GimpUnit unit,
|
||||
gboolean show_pixels,
|
||||
gboolean show_percent,
|
||||
gboolean show_custom);
|
||||
|
||||
void gimp_unit_menu_set_unit (GimpUnitMenu *menu,
|
||||
GimpUnit unit);
|
||||
void gimp_unit_menu_set_unit (GimpUnitMenu *menu,
|
||||
GimpUnit unit);
|
||||
|
||||
GimpUnit gimp_unit_menu_get_unit (GimpUnitMenu *menu);
|
||||
GimpUnit gimp_unit_menu_get_unit (GimpUnitMenu *menu);
|
||||
|
||||
void gimp_unit_menu_set_pixel_digits (GimpUnitMenu *menu,
|
||||
gint digits);
|
||||
gint gimp_unit_menu_get_pixel_digits (GimpUnitMenu *menu);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -1452,6 +1452,8 @@ gimp_unit_menu_update (GtkWidget *widget,
|
|||
((*val == GIMP_UNIT_PERCENT) ? 2 :
|
||||
(MIN (6, MAX (3, _gimp_eek.unit_get_digits (*val))))));
|
||||
|
||||
digits += gimp_unit_menu_get_pixel_digits (GIMP_UNIT_MENU (widget));
|
||||
|
||||
spinbutton = g_object_get_data (G_OBJECT (widget), "set_digits");
|
||||
while (spinbutton)
|
||||
{
|
||||
|
|
|
@ -67,7 +67,7 @@ static void gauss_iir (GimpDrawable *drawable,
|
|||
* Gaussian blur interface
|
||||
*/
|
||||
static gint gauss_iir_dialog (void);
|
||||
static gint gauss_iir2_dialog (gint32 image_ID,
|
||||
static gint gauss_iir2_dialog (gint32 image_ID,
|
||||
GimpDrawable *drawable);
|
||||
|
||||
/*
|
||||
|
@ -215,12 +215,12 @@ run (const gchar *name,
|
|||
case GIMP_RUN_INTERACTIVE:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_gauss_iir", &bvals);
|
||||
|
||||
|
||||
/* First acquire information with a dialog */
|
||||
if (! gauss_iir_dialog ())
|
||||
return;
|
||||
break;
|
||||
|
||||
|
||||
case GIMP_RUN_NONINTERACTIVE:
|
||||
/* Make sure all the arguments are there! */
|
||||
if (nparams != 6)
|
||||
|
@ -234,12 +234,12 @@ run (const gchar *name,
|
|||
if (status == GIMP_PDB_SUCCESS && (bvals.radius <= 0.0))
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
break;
|
||||
|
||||
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_gauss_iir", &bvals);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -253,11 +253,11 @@ run (const gchar *name,
|
|||
else if (strcmp (name, "plug_in_gauss_iir2") == 0)
|
||||
{
|
||||
switch (run_mode)
|
||||
{
|
||||
{
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_gauss_iir2", &b2vals);
|
||||
|
||||
|
||||
/* First acquire information with a dialog */
|
||||
if (! gauss_iir2_dialog (image_ID, drawable))
|
||||
return;
|
||||
|
@ -271,15 +271,16 @@ run (const gchar *name,
|
|||
b2vals.horizontal = param[3].data.d_float;
|
||||
b2vals.vertical = param[4].data.d_float;
|
||||
}
|
||||
if (status == GIMP_PDB_SUCCESS && (b2vals.horizontal <= 0.0 && b2vals.vertical <= 0.0))
|
||||
if (status == GIMP_PDB_SUCCESS &&
|
||||
(b2vals.horizontal <= 0.0 && b2vals.vertical <= 0.0))
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
break;
|
||||
|
||||
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_gauss_iir2", &b2vals);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -294,28 +295,31 @@ run (const gchar *name,
|
|||
gimp_drawable_is_gray (drawable->drawable_id))
|
||||
{
|
||||
gimp_progress_init ( _("IIR Gaussian Blur"));
|
||||
|
||||
|
||||
/* set the tile cache size so that the gaussian blur works well */
|
||||
gimp_tile_cache_ntiles (2 * (MAX (drawable->width, drawable->height) /
|
||||
gimp_tile_cache_ntiles (2 *
|
||||
(MAX (drawable->width, drawable->height) /
|
||||
gimp_tile_width () + 1));
|
||||
|
||||
/* run the gaussian blur */
|
||||
if (strcmp (name, "plug_in_gauss_iir") == 0)
|
||||
{
|
||||
gauss_iir (drawable, (bvals.horizontal ? bvals.radius : 0.0),
|
||||
gauss_iir (drawable, (bvals.horizontal ? bvals.radius : 0.0),
|
||||
(bvals.vertical ? bvals.radius : 0.0));
|
||||
|
||||
|
||||
/* Store data */
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_set_data ("plug_in_gauss_iir", &bvals, sizeof (BlurValues));
|
||||
}
|
||||
gimp_set_data ("plug_in_gauss_iir",
|
||||
&bvals, sizeof (BlurValues));
|
||||
}
|
||||
else
|
||||
{
|
||||
gauss_iir (drawable, b2vals.horizontal, b2vals.vertical);
|
||||
|
||||
|
||||
/* Store data */
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_set_data ("plug_in_gauss_iir2", &b2vals, sizeof (Blur2Values));
|
||||
gimp_set_data ("plug_in_gauss_iir2",
|
||||
&b2vals, sizeof (Blur2Values));
|
||||
}
|
||||
|
||||
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||
|
@ -466,6 +470,8 @@ gauss_iir2_dialog (gint32 image_ID,
|
|||
gtk_container_set_border_width (GTK_CONTAINER (size), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), size);
|
||||
|
||||
gimp_size_entry_set_pixel_digits (GIMP_SIZE_ENTRY (size), 1);
|
||||
|
||||
gtk_widget_show (size);
|
||||
gtk_widget_show (frame);
|
||||
gtk_widget_show (dlg);
|
||||
|
@ -592,10 +598,10 @@ gauss_iir (GimpDrawable *drawable,
|
|||
max_progress = (horz <= 0.0 ) ? 0 : width * height * horz;
|
||||
max_progress += (vert <= 0.0 ) ? 0 : width * height * vert;
|
||||
|
||||
|
||||
|
||||
/* First the vertical pass */
|
||||
if (vert > 0.0)
|
||||
{
|
||||
{
|
||||
vert = fabs (vert) + 1.0;
|
||||
std_dev = sqrt (-(vert * vert) / (2 * log (1.0 / 255.0)));
|
||||
|
||||
|
@ -676,7 +682,7 @@ if (horz > 0.0)
|
|||
if (horz != vert)
|
||||
{
|
||||
std_dev = sqrt (-(horz * horz) / (2 * log (1.0 / 255.0)));
|
||||
|
||||
|
||||
/* derive the constants for calculating the gaussian from the std dev */
|
||||
find_constants (n_p, n_m, d_p, d_m, bd_p, bd_m, std_dev);
|
||||
}
|
||||
|
@ -770,7 +776,7 @@ transfer_pixels (gdouble *src1,
|
|||
sum = *src1++ + *src2++;
|
||||
if (sum > 255) sum = 255;
|
||||
else if(sum < 0) sum = 0;
|
||||
|
||||
|
||||
*dest++ = (guchar) sum;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ static void gauss_rle (GimpDrawable *drawable,
|
|||
* Gaussian blur interface
|
||||
*/
|
||||
static gint gauss_rle_dialog (void);
|
||||
static gint gauss_rle2_dialog (gint32 image_ID,
|
||||
static gint gauss_rle2_dialog (gint32 image_ID,
|
||||
GimpDrawable *drawable);
|
||||
|
||||
/*
|
||||
|
@ -205,7 +205,7 @@ run (const gchar *name,
|
|||
if (strcmp (name, "plug_in_gauss_rle") == 0) /* the old-fashioned way of calling it */
|
||||
{
|
||||
switch (run_mode)
|
||||
{
|
||||
{
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_gauss_rle", &bvals);
|
||||
|
@ -227,31 +227,31 @@ run (const gchar *name,
|
|||
if (status == GIMP_PDB_SUCCESS && (bvals.radius <= 0.0))
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
break;
|
||||
|
||||
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_gauss_rle", &bvals);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (!(bvals.horizontal || bvals.vertical))
|
||||
{
|
||||
g_message ( _("You must specify either horizontal or vertical (or both)"));
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (strcmp (name, "plug_in_gauss_rle2") == 0)
|
||||
{
|
||||
switch (run_mode)
|
||||
{
|
||||
{
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_gauss_rle2", &b2vals);
|
||||
|
||||
|
||||
/* First acquire information with a dialog */
|
||||
if (! gauss_rle2_dialog (image_ID, drawable))
|
||||
return;
|
||||
|
@ -265,10 +265,11 @@ run (const gchar *name,
|
|||
b2vals.horizontal = param[3].data.d_float;
|
||||
b2vals.vertical = param[4].data.d_float;
|
||||
}
|
||||
if (status == GIMP_PDB_SUCCESS && (b2vals.horizontal <= 0.0 && b2vals.vertical <= 0.0))
|
||||
if (status == GIMP_PDB_SUCCESS &&
|
||||
(b2vals.horizontal <= 0.0 && b2vals.vertical <= 0.0))
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
break;
|
||||
|
||||
|
||||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
/* Possibly retrieve data */
|
||||
gimp_get_data ("plug_in_gauss_rle2", &b2vals);
|
||||
|
@ -277,7 +278,7 @@ run (const gchar *name,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
status = GIMP_PDB_CALLING_ERROR;
|
||||
|
||||
|
@ -290,26 +291,29 @@ run (const gchar *name,
|
|||
gimp_progress_init ( _("RLE Gaussian Blur"));
|
||||
|
||||
/* set the tile cache size so that the gaussian blur works well */
|
||||
gimp_tile_cache_ntiles (2 * (MAX (drawable->width, drawable->height) /
|
||||
gimp_tile_cache_ntiles (2 *
|
||||
(MAX (drawable->width, drawable->height) /
|
||||
gimp_tile_width () + 1));
|
||||
|
||||
/* run the gaussian blur */
|
||||
if (strcmp (name, "plug_in_gauss_rle") == 0)
|
||||
{
|
||||
gauss_rle (drawable, (bvals.horizontal ? bvals.radius : 0.0),
|
||||
gauss_rle (drawable, (bvals.horizontal ? bvals.radius : 0.0),
|
||||
(bvals.vertical ? bvals.radius : 0.0));
|
||||
|
||||
|
||||
/* Store data */
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_set_data ("plug_in_gauss_rle", &bvals, sizeof (BlurValues));
|
||||
}
|
||||
gimp_set_data ("plug_in_gauss_rle",
|
||||
&bvals, sizeof (BlurValues));
|
||||
}
|
||||
else
|
||||
{
|
||||
gauss_rle (drawable, b2vals.horizontal, b2vals.vertical);
|
||||
|
||||
|
||||
/* Store data */
|
||||
if (run_mode == GIMP_RUN_INTERACTIVE)
|
||||
gimp_set_data ("plug_in_gauss_rle2", &b2vals, sizeof (Blur2Values));
|
||||
gimp_set_data ("plug_in_gauss_rle2",
|
||||
&b2vals, sizeof (Blur2Values));
|
||||
}
|
||||
|
||||
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
||||
|
@ -460,6 +464,8 @@ gauss_rle2_dialog (gint32 image_ID,
|
|||
gtk_container_set_border_width (GTK_CONTAINER (size), 4);
|
||||
gtk_container_add (GTK_CONTAINER (frame), size);
|
||||
|
||||
gimp_size_entry_set_pixel_digits (GIMP_SIZE_ENTRY (size), 1);
|
||||
|
||||
gtk_widget_show (size);
|
||||
gtk_widget_show (frame);
|
||||
gtk_widget_show (dlg);
|
||||
|
@ -585,14 +591,14 @@ gauss_rle (GimpDrawable *drawable,
|
|||
progress = 0.0;
|
||||
max_progress = (horz <= 0.0 ) ? 0 : width * height * horz;
|
||||
max_progress += (vert <= 0.0 ) ? 0 : width * height * vert;
|
||||
|
||||
|
||||
|
||||
/* First the vertical pass */
|
||||
if (vert > 0.0)
|
||||
{
|
||||
vert = fabs (vert) + 1.0;
|
||||
std_dev = sqrt (-(vert * vert) / (2 * log (1.0 / 255.0)));
|
||||
|
||||
|
||||
curve = make_curve (std_dev, &length);
|
||||
sum = g_new (gint, 2 * length + 1);
|
||||
|
||||
|
@ -601,7 +607,7 @@ gauss_rle (GimpDrawable *drawable,
|
|||
for (i = 1; i <= length*2; i++)
|
||||
sum[i] = curve[i-length-1] + sum[i-1];
|
||||
sum += length;
|
||||
|
||||
|
||||
total = sum[length] - sum[-length];
|
||||
|
||||
for (col = 0; col < width; col++)
|
||||
|
@ -624,7 +630,8 @@ gauss_rle (GimpDrawable *drawable,
|
|||
for (row = 0; row < height; row++)
|
||||
{
|
||||
start = (row < length) ? -row : -length;
|
||||
end = (height <= (row + length)) ? (height - row - 1) : length;
|
||||
end = (height <= (row + length) ?
|
||||
(height - row - 1) : length);
|
||||
|
||||
val = 0;
|
||||
i = start;
|
||||
|
@ -673,7 +680,7 @@ gauss_rle (GimpDrawable *drawable,
|
|||
if (horz != vert)
|
||||
{
|
||||
std_dev = sqrt (-(horz * horz) / (2 * log (1.0 / 255.0)));
|
||||
|
||||
|
||||
curve = make_curve (std_dev, &length);
|
||||
sum = g_new (gint, 2 * length + 1);
|
||||
|
||||
|
@ -682,7 +689,7 @@ gauss_rle (GimpDrawable *drawable,
|
|||
for (i = 1; i <= length*2; i++)
|
||||
sum[i] = curve[i-length-1] + sum[i-1];
|
||||
sum += length;
|
||||
|
||||
|
||||
total = sum[length] - sum[-length];
|
||||
}
|
||||
|
||||
|
@ -741,7 +748,7 @@ gauss_rle (GimpDrawable *drawable,
|
|||
gimp_progress_update (progress / max_progress);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* merge the shadow, update the drawable */
|
||||
gimp_drawable_flush (drawable);
|
||||
|
|
|
@ -637,14 +637,40 @@ load_image (const gchar *filename)
|
|||
}
|
||||
if (png_get_valid (pp, info, PNG_INFO_pHYs))
|
||||
{
|
||||
gimp_image_set_resolution (image,
|
||||
((double)
|
||||
png_get_x_pixels_per_meter (pp,
|
||||
info)) * 0.0254,
|
||||
((double)
|
||||
png_get_y_pixels_per_meter (pp,
|
||||
info)) *
|
||||
0.0254);
|
||||
png_uint_32 xres;
|
||||
png_uint_32 yres;
|
||||
gint unit_type;
|
||||
|
||||
if (png_get_pHYs (pp, info, &xres, &yres, &unit_type))
|
||||
{
|
||||
switch (unit_type)
|
||||
{
|
||||
case PNG_RESOLUTION_UNKNOWN:
|
||||
{
|
||||
gdouble image_xres, image_yres;
|
||||
|
||||
gimp_image_get_resolution (image, &image_xres, &image_yres);
|
||||
|
||||
if (xres > yres)
|
||||
image_xres = image_yres * (gdouble) xres / (gdouble) yres;
|
||||
else
|
||||
image_yres = image_xres * (gdouble) yres / (gdouble) xres;
|
||||
|
||||
gimp_image_set_resolution (image, image_xres, image_yres);
|
||||
}
|
||||
break;
|
||||
|
||||
case PNG_RESOLUTION_METER:
|
||||
gimp_image_set_resolution (image,
|
||||
(gdouble) xres * 0.254,
|
||||
(gdouble) yres * 0.254);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif /* PNG_LIBPNG_VER > 99 */
|
||||
|
||||
|
|
Loading…
Reference in New Issue