mirror of https://github.com/GNOME/gimp.git
renamed gimp_mem_size_entry_new() to gimp_memsize_entry_new() for
2002-05-29 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpwidgets.[ch]: renamed gimp_mem_size_entry_new() to gimp_memsize_entry_new() for consistency. Rewrote using bitshifts. Should work correctly for sizeof (gulong) > 32 now. Added new unit GigaBytes. * app/gui/preferences-dialog.c * app/gui/user-install-dialog.c: changed accordingly. * app/config/gimpconfig-types.[ch]: added new function gimp_memsize_set_from_string() that allows to check if the conversion succeeded. * app/config/gimpconfig-deserialize.c (gimp_config_deserialize_memsize): use gimp_memsize_set_from_string().
This commit is contained in:
parent
bb32c3c267
commit
4c55933dea
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
2002-05-29 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* libgimpwidgets/gimpwidgets.[ch]: renamed gimp_mem_size_entry_new()
|
||||||
|
to gimp_memsize_entry_new() for consistency. Rewrote using bitshifts.
|
||||||
|
Should work correctly for sizeof (gulong) > 32 now. Added new unit
|
||||||
|
GigaBytes.
|
||||||
|
|
||||||
|
* app/gui/preferences-dialog.c
|
||||||
|
* app/gui/user-install-dialog.c: changed accordingly.
|
||||||
|
|
||||||
|
* app/config/gimpconfig-types.[ch]: added new function
|
||||||
|
gimp_memsize_set_from_string() that allows to check if the
|
||||||
|
conversion succeeded.
|
||||||
|
|
||||||
|
* app/config/gimpconfig-deserialize.c
|
||||||
|
(gimp_config_deserialize_memsize): use gimp_memsize_set_from_string().
|
||||||
|
|
||||||
2002-05-28 Sven Neumann <sven@gimp.org>
|
2002-05-28 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/core/gimplayer.c (gimp_layer_new_from_drawable): determine
|
* app/core/gimplayer.c (gimp_layer_new_from_drawable): determine
|
||||||
|
|
|
@ -459,24 +459,24 @@ gimp_config_deserialize_memsize (GValue *value,
|
||||||
GParamSpec *prop_spec,
|
GParamSpec *prop_spec,
|
||||||
GScanner *scanner)
|
GScanner *scanner)
|
||||||
{
|
{
|
||||||
GTokenType token;
|
gchar *orig_cset_first = scanner->config->cset_identifier_first;
|
||||||
gchar *orig_cset_first = NULL;
|
gchar *orig_cset_nth = scanner->config->cset_identifier_nth;
|
||||||
gchar *orig_cset_nth = NULL;
|
|
||||||
|
|
||||||
orig_cset_first = scanner->config->cset_identifier_first;
|
|
||||||
orig_cset_nth = scanner->config->cset_identifier_nth;
|
|
||||||
|
|
||||||
scanner->config->cset_identifier_first = G_CSET_DIGITS;
|
scanner->config->cset_identifier_first = G_CSET_DIGITS;
|
||||||
scanner->config->cset_identifier_nth = G_CSET_DIGITS "gGmMkKbB";
|
scanner->config->cset_identifier_nth = G_CSET_DIGITS "gGmMkKbB";
|
||||||
|
|
||||||
token = gimp_config_deserialize_any (value, prop_spec, scanner);
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
|
||||||
|
return G_TOKEN_IDENTIFIER;
|
||||||
|
|
||||||
|
g_scanner_get_next_token (scanner);
|
||||||
|
|
||||||
if (orig_cset_first)
|
|
||||||
scanner->config->cset_identifier_first = orig_cset_first;
|
scanner->config->cset_identifier_first = orig_cset_first;
|
||||||
if (orig_cset_nth)
|
|
||||||
scanner->config->cset_identifier_nth = orig_cset_nth;
|
scanner->config->cset_identifier_nth = orig_cset_nth;
|
||||||
|
|
||||||
return token;
|
if (gimp_memsize_set_from_string (value, scanner->value.v_identifier))
|
||||||
|
return G_TOKEN_RIGHT_PAREN;
|
||||||
|
else
|
||||||
|
return G_TOKEN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GTokenType
|
static GTokenType
|
||||||
|
|
|
@ -81,6 +81,60 @@ gimp_memsize_get_type (void)
|
||||||
return memsize_type;
|
return memsize_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gimp_memsize_set_from_string (GValue *value,
|
||||||
|
const gchar *string)
|
||||||
|
{
|
||||||
|
gchar *end;
|
||||||
|
gulong size;
|
||||||
|
|
||||||
|
g_return_val_if_fail (GIMP_VALUE_HOLDS_MEMSIZE (value), FALSE);
|
||||||
|
g_return_val_if_fail (string != NULL, FALSE);
|
||||||
|
|
||||||
|
size = strtoul (string, &end, 0);
|
||||||
|
|
||||||
|
if (size == ULONG_MAX && errno == ERANGE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (end && *end)
|
||||||
|
{
|
||||||
|
guint shift;
|
||||||
|
|
||||||
|
switch (g_ascii_tolower (*end))
|
||||||
|
{
|
||||||
|
case 'b':
|
||||||
|
shift = 0;
|
||||||
|
break;
|
||||||
|
case 'k':
|
||||||
|
shift = 10;
|
||||||
|
break;
|
||||||
|
case 'm':
|
||||||
|
shift = 20;
|
||||||
|
break;
|
||||||
|
case 'g':
|
||||||
|
shift = 30;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* protect against overflow */
|
||||||
|
if (shift)
|
||||||
|
{
|
||||||
|
gulong limit = G_MAXULONG >> (shift);
|
||||||
|
|
||||||
|
if (size != (size & limit))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
size <<= shift;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_value_set_ulong (value, size);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gimp_path_get_type (void)
|
gimp_path_get_type (void)
|
||||||
{
|
{
|
||||||
|
@ -157,60 +211,9 @@ static void
|
||||||
string_to_memsize (const GValue *src_value,
|
string_to_memsize (const GValue *src_value,
|
||||||
GValue *dest_value)
|
GValue *dest_value)
|
||||||
{
|
{
|
||||||
const gchar *str;
|
const gchar *str = g_value_get_string (src_value);
|
||||||
gchar *end;
|
|
||||||
gulong size;
|
|
||||||
|
|
||||||
str = g_value_get_string (src_value);
|
if (!str || !gimp_memsize_set_from_string (dest_value, str))
|
||||||
|
|
||||||
if (!str || !*str)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
size = strtoul (str, &end, 0);
|
|
||||||
|
|
||||||
if (size == ULONG_MAX && errno == ERANGE)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (end && *end)
|
|
||||||
{
|
|
||||||
guint shift;
|
|
||||||
|
|
||||||
switch (g_ascii_tolower (*end))
|
|
||||||
{
|
|
||||||
case 'b':
|
|
||||||
shift = 0;
|
|
||||||
break;
|
|
||||||
case 'k':
|
|
||||||
shift = 10;
|
|
||||||
break;
|
|
||||||
case 'm':
|
|
||||||
shift = 20;
|
|
||||||
break;
|
|
||||||
case 'g':
|
|
||||||
shift = 30;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* protect against overflow */
|
|
||||||
if (shift)
|
|
||||||
{
|
|
||||||
gulong limit = G_MAXULONG >> (shift);
|
|
||||||
|
|
||||||
if (size != (size & limit))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
size <<= shift;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_value_set_ulong (dest_value, size);
|
|
||||||
|
|
||||||
return;
|
|
||||||
|
|
||||||
error:
|
|
||||||
g_value_set_ulong (dest_value, 0);
|
|
||||||
g_warning ("Can't convert string to GimpMemsize.");
|
g_warning ("Can't convert string to GimpMemsize.");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -219,9 +222,7 @@ static void
|
||||||
unit_to_string (const GValue *src_value,
|
unit_to_string (const GValue *src_value,
|
||||||
GValue *dest_value)
|
GValue *dest_value)
|
||||||
{
|
{
|
||||||
GimpUnit unit;
|
GimpUnit unit = (GimpUnit) g_value_get_int (src_value);
|
||||||
|
|
||||||
unit = (GimpUnit) g_value_get_int (src_value);
|
|
||||||
|
|
||||||
g_value_set_string (dest_value, gimp_unit_get_identifier (unit));
|
g_value_set_string (dest_value, gimp_unit_get_identifier (unit));
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,6 +33,8 @@ GType gimp_color_get_type (void) G_GNUC_CONST;
|
||||||
#define GIMP_VALUE_HOLDS_MEMSIZE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_MEMSIZE))
|
#define GIMP_VALUE_HOLDS_MEMSIZE(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_MEMSIZE))
|
||||||
|
|
||||||
GType gimp_memsize_get_type (void) G_GNUC_CONST;
|
GType gimp_memsize_get_type (void) G_GNUC_CONST;
|
||||||
|
gboolean gimp_memsize_set_from_string (GValue *value,
|
||||||
|
const gchar *string);
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_PATH (gimp_path_get_type ())
|
#define GIMP_TYPE_PATH (gimp_path_get_type ())
|
||||||
|
@ -42,6 +44,7 @@ GType gimp_path_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_UNIT (gimp_unit_get_type ())
|
#define GIMP_TYPE_UNIT (gimp_unit_get_type ())
|
||||||
|
#define GIMP_VALUE_HOLDS_UNIT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_UNIT))
|
||||||
|
|
||||||
GType gimp_unit_get_type (void) G_GNUC_CONST;
|
GType gimp_unit_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
|
|
@ -1977,7 +1977,7 @@ preferences_dialog_create (Gimp *gimp)
|
||||||
adjustment = gtk_adjustment_new (gimprc.max_new_image_size,
|
adjustment = gtk_adjustment_new (gimprc.max_new_image_size,
|
||||||
0, G_MAXULONG,
|
0, G_MAXULONG,
|
||||||
1.0, 1.0, 0.0);
|
1.0, 1.0, 0.0);
|
||||||
hbox = gimp_mem_size_entry_new (GTK_ADJUSTMENT (adjustment));
|
hbox = gimp_memsize_entry_new (GTK_ADJUSTMENT (adjustment));
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||||
_("Maximum Image Size:"), 1.0, 0.5,
|
_("Maximum Image Size:"), 1.0, 0.5,
|
||||||
hbox, 1, TRUE);
|
hbox, 1, TRUE);
|
||||||
|
@ -2634,7 +2634,7 @@ preferences_dialog_create (Gimp *gimp)
|
||||||
adjustment = gtk_adjustment_new (edit_tile_cache_size,
|
adjustment = gtk_adjustment_new (edit_tile_cache_size,
|
||||||
0, G_MAXULONG,
|
0, G_MAXULONG,
|
||||||
1.0, 1.0, 0.0);
|
1.0, 1.0, 0.0);
|
||||||
hbox = gimp_mem_size_entry_new (GTK_ADJUSTMENT (adjustment));
|
hbox = gimp_memsize_entry_new (GTK_ADJUSTMENT (adjustment));
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||||
_("Tile Cache Size:"), 1.0, 0.5,
|
_("Tile Cache Size:"), 1.0, 0.5,
|
||||||
hbox, 1, TRUE);
|
hbox, 1, TRUE);
|
||||||
|
|
|
@ -1129,7 +1129,7 @@ user_install_tuning (void)
|
||||||
|
|
||||||
tile_cache_adj = gtk_adjustment_new (base_config->tile_cache_size,
|
tile_cache_adj = gtk_adjustment_new (base_config->tile_cache_size,
|
||||||
0, G_MAXULONG, 1.0, 1.0, 0.0);
|
0, G_MAXULONG, 1.0, 1.0, 0.0);
|
||||||
memsize = gimp_mem_size_entry_new (GTK_ADJUSTMENT (tile_cache_adj));
|
memsize = gimp_memsize_entry_new (GTK_ADJUSTMENT (tile_cache_adj));
|
||||||
gtk_box_pack_end (GTK_BOX (hbox), memsize, FALSE, FALSE, 0);
|
gtk_box_pack_end (GTK_BOX (hbox), memsize, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (memsize);
|
gtk_widget_show (memsize);
|
||||||
|
|
||||||
|
|
|
@ -1977,7 +1977,7 @@ preferences_dialog_create (Gimp *gimp)
|
||||||
adjustment = gtk_adjustment_new (gimprc.max_new_image_size,
|
adjustment = gtk_adjustment_new (gimprc.max_new_image_size,
|
||||||
0, G_MAXULONG,
|
0, G_MAXULONG,
|
||||||
1.0, 1.0, 0.0);
|
1.0, 1.0, 0.0);
|
||||||
hbox = gimp_mem_size_entry_new (GTK_ADJUSTMENT (adjustment));
|
hbox = gimp_memsize_entry_new (GTK_ADJUSTMENT (adjustment));
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||||
_("Maximum Image Size:"), 1.0, 0.5,
|
_("Maximum Image Size:"), 1.0, 0.5,
|
||||||
hbox, 1, TRUE);
|
hbox, 1, TRUE);
|
||||||
|
@ -2634,7 +2634,7 @@ preferences_dialog_create (Gimp *gimp)
|
||||||
adjustment = gtk_adjustment_new (edit_tile_cache_size,
|
adjustment = gtk_adjustment_new (edit_tile_cache_size,
|
||||||
0, G_MAXULONG,
|
0, G_MAXULONG,
|
||||||
1.0, 1.0, 0.0);
|
1.0, 1.0, 0.0);
|
||||||
hbox = gimp_mem_size_entry_new (GTK_ADJUSTMENT (adjustment));
|
hbox = gimp_memsize_entry_new (GTK_ADJUSTMENT (adjustment));
|
||||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
||||||
_("Tile Cache Size:"), 1.0, 0.5,
|
_("Tile Cache Size:"), 1.0, 0.5,
|
||||||
hbox, 1, TRUE);
|
hbox, 1, TRUE);
|
||||||
|
|
|
@ -1129,7 +1129,7 @@ user_install_tuning (void)
|
||||||
|
|
||||||
tile_cache_adj = gtk_adjustment_new (base_config->tile_cache_size,
|
tile_cache_adj = gtk_adjustment_new (base_config->tile_cache_size,
|
||||||
0, G_MAXULONG, 1.0, 1.0, 0.0);
|
0, G_MAXULONG, 1.0, 1.0, 0.0);
|
||||||
memsize = gimp_mem_size_entry_new (GTK_ADJUSTMENT (tile_cache_adj));
|
memsize = gimp_memsize_entry_new (GTK_ADJUSTMENT (tile_cache_adj));
|
||||||
gtk_box_pack_end (GTK_BOX (hbox), memsize, FALSE, FALSE, 0);
|
gtk_box_pack_end (GTK_BOX (hbox), memsize, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (memsize);
|
gtk_widget_show (memsize);
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2002-05-29 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* libgimpwidgets/libgimpwidgets-sections.txt
|
||||||
|
* libgimpwidgets/tmpl/gimpstock.sgml
|
||||||
|
* libgimpwidgets/tmpl/gimpwidgets.sgml: updated.
|
||||||
|
|
||||||
2002-05-16 Michael Natterer <mitch@gimp.org>
|
2002-05-16 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* libgimpbase/tmpl/gimpprotocol.sgml
|
* libgimpbase/tmpl/gimpprotocol.sgml
|
||||||
|
|
|
@ -309,6 +309,7 @@ GIMP_STOCK_TOOL_ISCISSORS
|
||||||
GIMP_STOCK_TOOL_LEVELS
|
GIMP_STOCK_TOOL_LEVELS
|
||||||
GIMP_STOCK_TOOL_MEASURE
|
GIMP_STOCK_TOOL_MEASURE
|
||||||
GIMP_STOCK_TOOL_MOVE
|
GIMP_STOCK_TOOL_MOVE
|
||||||
|
GIMP_STOCK_TOOL_OPTIONS
|
||||||
GIMP_STOCK_TOOL_PAINTBRUSH
|
GIMP_STOCK_TOOL_PAINTBRUSH
|
||||||
GIMP_STOCK_TOOL_PATH
|
GIMP_STOCK_TOOL_PATH
|
||||||
GIMP_STOCK_TOOL_PENCIL
|
GIMP_STOCK_TOOL_PENCIL
|
||||||
|
@ -350,10 +351,10 @@ GIMP_RANDOM_SEED_TOGGLEBUTTON
|
||||||
gimp_random_seed_new
|
gimp_random_seed_new
|
||||||
GIMP_COORDINATES_CHAINBUTTON
|
GIMP_COORDINATES_CHAINBUTTON
|
||||||
gimp_coordinates_new
|
gimp_coordinates_new
|
||||||
GIMP_MEM_SIZE_ENTRY_SPINBUTTON
|
GIMP_MEMSIZE_ENTRY_SPINBUTTON
|
||||||
GIMP_MEM_SIZE_ENTRY_SPINBUTTON_ADJ
|
GIMP_MEMSIZE_ENTRY_SPINBUTTON_ADJ
|
||||||
GIMP_MEM_SIZE_ENTRY_OPTIONMENU
|
GIMP_MEMSIZE_ENTRY_OPTIONMENU
|
||||||
gimp_mem_size_entry_new
|
gimp_memsize_entry_new
|
||||||
gimp_pixmap_button_new
|
gimp_pixmap_button_new
|
||||||
gimp_toggle_button_sensitive_update
|
gimp_toggle_button_sensitive_update
|
||||||
gimp_toggle_button_update
|
gimp_toggle_button_update
|
||||||
|
|
|
@ -448,6 +448,13 @@ GimpStock
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- ##### MACRO GIMP_STOCK_TOOL_OPTIONS ##### -->
|
||||||
|
<para>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### MACRO GIMP_STOCK_TOOL_PAINTBRUSH ##### -->
|
<!-- ##### MACRO GIMP_STOCK_TOOL_PAINTBRUSH ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
|
|
|
@ -403,7 +403,7 @@ Returns the #GimpChainButton which is attached to the #GimpSizeEntry.
|
||||||
@spinbutton_usize:
|
@spinbutton_usize:
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### MACRO GIMP_MEM_SIZE_ENTRY_SPINBUTTON ##### -->
|
<!-- ##### MACRO GIMP_MEMSIZE_ENTRY_SPINBUTTON ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
@ -411,7 +411,7 @@ Returns the #GimpChainButton which is attached to the #GimpSizeEntry.
|
||||||
@memsize:
|
@memsize:
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### MACRO GIMP_MEM_SIZE_ENTRY_SPINBUTTON_ADJ ##### -->
|
<!-- ##### MACRO GIMP_MEMSIZE_ENTRY_SPINBUTTON_ADJ ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
@ -419,7 +419,7 @@ Returns the #GimpChainButton which is attached to the #GimpSizeEntry.
|
||||||
@memsize:
|
@memsize:
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### MACRO GIMP_MEM_SIZE_ENTRY_OPTIONMENU ##### -->
|
<!-- ##### MACRO GIMP_MEMSIZE_ENTRY_OPTIONMENU ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
@ -427,7 +427,7 @@ Returns the #GimpChainButton which is attached to the #GimpSizeEntry.
|
||||||
@memsize:
|
@memsize:
|
||||||
|
|
||||||
|
|
||||||
<!-- ##### FUNCTION gimp_mem_size_entry_new ##### -->
|
<!-- ##### FUNCTION gimp_memsize_entry_new ##### -->
|
||||||
<para>
|
<para>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
|
|
|
@ -459,24 +459,24 @@ gimp_config_deserialize_memsize (GValue *value,
|
||||||
GParamSpec *prop_spec,
|
GParamSpec *prop_spec,
|
||||||
GScanner *scanner)
|
GScanner *scanner)
|
||||||
{
|
{
|
||||||
GTokenType token;
|
gchar *orig_cset_first = scanner->config->cset_identifier_first;
|
||||||
gchar *orig_cset_first = NULL;
|
gchar *orig_cset_nth = scanner->config->cset_identifier_nth;
|
||||||
gchar *orig_cset_nth = NULL;
|
|
||||||
|
|
||||||
orig_cset_first = scanner->config->cset_identifier_first;
|
|
||||||
orig_cset_nth = scanner->config->cset_identifier_nth;
|
|
||||||
|
|
||||||
scanner->config->cset_identifier_first = G_CSET_DIGITS;
|
scanner->config->cset_identifier_first = G_CSET_DIGITS;
|
||||||
scanner->config->cset_identifier_nth = G_CSET_DIGITS "gGmMkKbB";
|
scanner->config->cset_identifier_nth = G_CSET_DIGITS "gGmMkKbB";
|
||||||
|
|
||||||
token = gimp_config_deserialize_any (value, prop_spec, scanner);
|
if (g_scanner_peek_next_token (scanner) != G_TOKEN_IDENTIFIER)
|
||||||
|
return G_TOKEN_IDENTIFIER;
|
||||||
|
|
||||||
|
g_scanner_get_next_token (scanner);
|
||||||
|
|
||||||
if (orig_cset_first)
|
|
||||||
scanner->config->cset_identifier_first = orig_cset_first;
|
scanner->config->cset_identifier_first = orig_cset_first;
|
||||||
if (orig_cset_nth)
|
|
||||||
scanner->config->cset_identifier_nth = orig_cset_nth;
|
scanner->config->cset_identifier_nth = orig_cset_nth;
|
||||||
|
|
||||||
return token;
|
if (gimp_memsize_set_from_string (value, scanner->value.v_identifier))
|
||||||
|
return G_TOKEN_RIGHT_PAREN;
|
||||||
|
else
|
||||||
|
return G_TOKEN_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GTokenType
|
static GTokenType
|
||||||
|
|
|
@ -607,7 +607,7 @@ gimp_radio_group_set_active (GtkRadioButton *radio_button,
|
||||||
*
|
*
|
||||||
* This function is a shortcut for gtk_adjustment_new() and a subsequent
|
* This function is a shortcut for gtk_adjustment_new() and a subsequent
|
||||||
* gtk_spin_button_new() and does some more initialisation stuff like
|
* gtk_spin_button_new() and does some more initialisation stuff like
|
||||||
* setting a standard minimun horizontal size.
|
* setting a standard minimum horizontal size.
|
||||||
*
|
*
|
||||||
* Returns: A #GtkSpinbutton and it's #GtkAdjustment.
|
* Returns: A #GtkSpinbutton and it's #GtkAdjustment.
|
||||||
**/
|
**/
|
||||||
|
@ -1086,127 +1086,115 @@ gimp_coordinates_new (GimpUnit unit,
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
GtkAdjustment *adjustment;
|
GtkAdjustment *adjustment;
|
||||||
GtkAdjustment *divided_adj;
|
GtkAdjustment *shifted_adj;
|
||||||
guint mem_size_unit;
|
guint shift;
|
||||||
} GimpMemSizeEntryData;
|
} GimpMemsizeEntryData;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_mem_size_entry_callback (GtkAdjustment *adj,
|
gimp_memsize_entry_callback (GtkAdjustment *adj,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpMemSizeEntryData *gmsed;
|
GimpMemsizeEntryData *gmed = (GimpMemsizeEntryData *) data;
|
||||||
gulong new_value;
|
|
||||||
|
|
||||||
gmsed = (GimpMemSizeEntryData *)data;
|
gtk_adjustment_set_value (gmed->adjustment,
|
||||||
new_value = (gulong) adj->value * gmsed->mem_size_unit;
|
(gulong) adj->value << gmed->shift);
|
||||||
|
|
||||||
gtk_adjustment_set_value (gmsed->adjustment, new_value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_mem_size_unit_callback (GtkWidget *widget,
|
gimp_memsize_unit_callback (GtkWidget *widget,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GimpMemSizeEntryData *gmsed;
|
GimpMemsizeEntryData *gmed = (GimpMemsizeEntryData *) data;
|
||||||
gulong divided_mem_size;
|
guint shift;
|
||||||
guint new_unit;
|
|
||||||
|
|
||||||
gmsed = (GimpMemSizeEntryData *)data;
|
shift = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
|
||||||
|
|
||||||
new_unit = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT (widget),
|
|
||||||
"gimp-item-data"));
|
"gimp-item-data"));
|
||||||
|
|
||||||
if (new_unit && new_unit != gmsed->mem_size_unit)
|
if (shift && shift != gmed->shift)
|
||||||
{
|
{
|
||||||
GtkAdjustment *div_adj = GTK_ADJUSTMENT (gmsed->divided_adj);
|
gulong size = (gulong) gmed->adjustment->value >> shift;
|
||||||
|
|
||||||
divided_mem_size = (gulong) gmsed->adjustment->value / new_unit;
|
gmed->shift = shift;
|
||||||
gmsed->mem_size_unit = new_unit;
|
|
||||||
|
|
||||||
div_adj->lower = gmsed->adjustment->lower / new_unit;
|
gmed->shifted_adj->lower = (gulong) gmed->adjustment->lower >> shift;
|
||||||
div_adj->upper = gmsed->adjustment->upper / new_unit;
|
gmed->shifted_adj->upper = (gulong) gmed->adjustment->upper >> shift;
|
||||||
|
|
||||||
gtk_adjustment_changed (div_adj);
|
gtk_adjustment_changed (gmed->shifted_adj);
|
||||||
|
|
||||||
gtk_adjustment_set_value (GTK_ADJUSTMENT (gmsed->divided_adj),
|
gtk_adjustment_set_value (GTK_ADJUSTMENT (gmed->shifted_adj), size);
|
||||||
divided_mem_size);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_mem_size_entry_new:
|
* gimp_memsize_entry_new:
|
||||||
* @adjustment: The adjustment containing the memsize and it's limits.
|
* @adjustment: The adjustment containing the memsize and it's limits.
|
||||||
*
|
*
|
||||||
* Returns: A #GtkHBox with a #GtkSpinButton and a #GtkOptionMenu.
|
* Returns: A #GtkHBox with a #GtkSpinButton and a #GtkOptionMenu.
|
||||||
**/
|
**/
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
gimp_mem_size_entry_new (GtkAdjustment *adjustment)
|
gimp_memsize_entry_new (GtkAdjustment *adjustment)
|
||||||
{
|
{
|
||||||
|
GimpMemsizeEntryData *gmed;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkObject *divided_adj;
|
|
||||||
GtkWidget *spinbutton;
|
GtkWidget *spinbutton;
|
||||||
GtkWidget *optionmenu;
|
GtkWidget *menu;
|
||||||
|
GtkObject *shifted_adj;
|
||||||
GimpMemSizeEntryData *gmsed;
|
guint shift;
|
||||||
gulong mem_size_unit;
|
|
||||||
gulong divided_mem_size;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
|
g_return_val_if_fail (GTK_IS_ADJUSTMENT (adjustment), NULL);
|
||||||
g_return_val_if_fail (adjustment->lower >= 0, NULL);
|
g_return_val_if_fail (adjustment->lower >= 0, NULL);
|
||||||
g_return_val_if_fail (adjustment->value >= 0, NULL);
|
g_return_val_if_fail (adjustment->upper <= G_MAXULONG, NULL);
|
||||||
|
|
||||||
gmsed = g_new (GimpMemSizeEntryData, 1);
|
gmed = g_new (GimpMemsizeEntryData, 1);
|
||||||
|
|
||||||
for (i = 0, mem_size_unit = 1; i < 2; i++)
|
for (shift = 30; shift > 0; shift -= 10)
|
||||||
{
|
{
|
||||||
if ( (gulong) adjustment->value % (mem_size_unit << 10) != 0 )
|
gulong size = adjustment->value;
|
||||||
|
|
||||||
|
if (size > (1 << shift) && size % (1 << shift) == 0)
|
||||||
break;
|
break;
|
||||||
mem_size_unit <<= 10;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
divided_mem_size = (gulong) adjustment->value / mem_size_unit;
|
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 2);
|
hbox = gtk_hbox_new (FALSE, 2);
|
||||||
spinbutton =
|
|
||||||
gimp_spin_button_new (÷d_adj, divided_mem_size,
|
spinbutton = gimp_spin_button_new (&shifted_adj,
|
||||||
adjustment->lower / mem_size_unit,
|
(gulong) adjustment->value >> shift,
|
||||||
adjustment->upper / mem_size_unit,
|
(gulong) adjustment->lower >> shift,
|
||||||
1.0, 16.0, 0.0, 1.0, 0.0);
|
(gulong) adjustment->upper >> shift,
|
||||||
g_signal_connect (G_OBJECT (divided_adj), "value_changed",
|
1, 8, 0, 1, 0);
|
||||||
G_CALLBACK (gimp_mem_size_entry_callback),
|
|
||||||
gmsed);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (spinbutton);
|
gtk_widget_show (spinbutton);
|
||||||
|
|
||||||
optionmenu =
|
g_signal_connect (G_OBJECT (shifted_adj), "value_changed",
|
||||||
gimp_option_menu_new2 (FALSE, G_CALLBACK (gimp_mem_size_unit_callback),
|
G_CALLBACK (gimp_memsize_entry_callback),
|
||||||
gmsed, (gpointer) mem_size_unit,
|
gmed);
|
||||||
|
|
||||||
_("Bytes"), GINT_TO_POINTER (1 << 0), NULL,
|
|
||||||
_("KiloBytes"), GINT_TO_POINTER (1 << 10), NULL,
|
|
||||||
_("MegaBytes"), GINT_TO_POINTER (1 << 20), NULL,
|
|
||||||
|
|
||||||
|
menu = gimp_option_menu_new2 (FALSE, G_CALLBACK (gimp_memsize_unit_callback),
|
||||||
|
gmed,
|
||||||
|
GUINT_TO_POINTER (shift),
|
||||||
|
_("Bytes"), GUINT_TO_POINTER (0), NULL,
|
||||||
|
_("KiloBytes"), GUINT_TO_POINTER (10), NULL,
|
||||||
|
_("MegaBytes"), GUINT_TO_POINTER (20), NULL,
|
||||||
|
_("GigaBytes"), GUINT_TO_POINTER (30), NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), optionmenu, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), menu, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (optionmenu);
|
gtk_widget_show (menu);
|
||||||
|
|
||||||
g_object_ref (adjustment);
|
g_object_ref (adjustment);
|
||||||
gtk_object_sink (GTK_OBJECT (adjustment));
|
gtk_object_sink (GTK_OBJECT (adjustment));
|
||||||
g_signal_connect_swapped (G_OBJECT (hbox), "destroy",
|
|
||||||
G_CALLBACK (g_object_unref),
|
|
||||||
adjustment);
|
|
||||||
g_signal_connect_swapped (G_OBJECT (hbox), "destroy",
|
|
||||||
G_CALLBACK (g_free),
|
|
||||||
gmsed);
|
|
||||||
|
|
||||||
gmsed->adjustment = adjustment;
|
g_signal_connect_swapped (G_OBJECT (hbox), "destroy",
|
||||||
gmsed->divided_adj = GTK_ADJUSTMENT (divided_adj);
|
G_CALLBACK (g_object_unref), adjustment);
|
||||||
gmsed->mem_size_unit = mem_size_unit;
|
g_signal_connect_swapped (G_OBJECT (hbox), "destroy",
|
||||||
|
G_CALLBACK (g_free), gmed);
|
||||||
|
|
||||||
|
gmed->adjustment = adjustment;
|
||||||
|
gmed->shifted_adj = GTK_ADJUSTMENT (shifted_adj);
|
||||||
|
gmed->shift = shift;
|
||||||
|
|
||||||
g_object_set_data (G_OBJECT (hbox), "spinbutton", spinbutton);
|
g_object_set_data (G_OBJECT (hbox), "spinbutton", spinbutton);
|
||||||
g_object_set_data (G_OBJECT (hbox), "optionmenu", optionmenu);
|
g_object_set_data (G_OBJECT (hbox), "optionmenu", menu);
|
||||||
|
|
||||||
return hbox;
|
return hbox;
|
||||||
}
|
}
|
||||||
|
|
|
@ -208,15 +208,15 @@ GtkWidget * gimp_coordinates_new (GimpUnit unit,
|
||||||
gdouble ysize_0, /* % */
|
gdouble ysize_0, /* % */
|
||||||
gdouble ysize_100 /* % */);
|
gdouble ysize_100 /* % */);
|
||||||
|
|
||||||
#define GIMP_MEM_SIZE_ENTRY_SPINBUTTON(memsize) \
|
#define GIMP_MEMSIZE_ENTRY_SPINBUTTON(memsize) \
|
||||||
(g_object_get_data (G_OBJECT (memsize), "spinbutton"))
|
(g_object_get_data (G_OBJECT (memsize), "spinbutton"))
|
||||||
#define GIMP_MEM_SIZE_ENTRY_SPINBUTTON_ADJ(memsize) \
|
#define GIMP_MEMSIZE_ENTRY_SPINBUTTON_ADJ(memsize) \
|
||||||
gtk_spin_button_get_adjustment \
|
gtk_spin_button_get_adjustment \
|
||||||
(GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (memsize), "spinbutton")))
|
(GTK_SPIN_BUTTON (g_object_get_data (G_OBJECT (memsize), "spinbutton")))
|
||||||
#define GIMP_MEM_SIZE_ENTRY_OPTIONMENU(memsize) \
|
#define GIMP_MEMSIZE_ENTRY_OPTIONMENU(memsize) \
|
||||||
(g_object_get_data (G_OBJECT (memsize), "optionmenu"))
|
(g_object_get_data (G_OBJECT (memsize), "optionmenu"))
|
||||||
|
|
||||||
GtkWidget * gimp_mem_size_entry_new (GtkAdjustment *adjustment);
|
GtkWidget * gimp_memsize_entry_new (GtkAdjustment *adjustment);
|
||||||
|
|
||||||
|
|
||||||
GtkWidget * gimp_pixmap_button_new (gchar **xpm_data,
|
GtkWidget * gimp_pixmap_button_new (gchar **xpm_data,
|
||||||
|
|
Loading…
Reference in New Issue