app/config/test-config.c use g_error_free() so we crash if our GimpConfig

2002-05-28  Sven Neumann  <sven@gimp.org>

	* app/config/test-config.c
	* app/gui/test-commands.c: use g_error_free() so we crash if our
	GimpConfig functions return FALSE and don't set an error.

	* app/widgets/gimpdevices.c: don't warn if devicerc was not found.

	* app/gui/preferences-dialog.c: use G_MAXULONG as upper limit for
	the mem_size entries.

	* libgimpwidgets/gimpwidgets.c (gimp_mem_size_entry): use gulong
	and set the range of the spinbutton's adjustment properly.
This commit is contained in:
Sven Neumann 2002-05-28 18:49:45 +00:00 committed by Sven Neumann
parent 17c02510ef
commit 89585b4c14
9 changed files with 60 additions and 36 deletions

View File

@ -1,3 +1,17 @@
2002-05-28 Sven Neumann <sven@gimp.org>
* app/config/test-config.c
* app/gui/test-commands.c: use g_error_free() so we crash if our
GimpConfig functions return FALSE and don't set an error.
* app/widgets/gimpdevices.c: don't warn if devicerc was not found.
* app/gui/preferences-dialog.c: use G_MAXULONG as upper limit for
the mem_size entries.
* libgimpwidgets/gimpwidgets.c (gimp_mem_size_entry): use gulong
and set the range of the spinbutton's adjustment properly.
2002-05-28 Sven Neumann <sven@gimp.org> 2002-05-28 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-types.c: derive GIMP_TYPE_MEMSIZE from * app/config/gimpconfig-types.c: derive GIMP_TYPE_MEMSIZE from

View File

@ -416,7 +416,7 @@ gimp_config_scanner_message (GScanner *scanner,
g_set_error (error, g_set_error (error,
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
_("Error while parsing '%s' in line %d:\n %s"), _("Error while parsing '%s' in line %d:\n%s"),
scanner->input_name, scanner->line, message); scanner->input_name, scanner->line, message);
} }

View File

@ -159,7 +159,7 @@ main (int argc,
"gimpconfig.c", NULL, &error)) "gimpconfig.c", NULL, &error))
{ {
g_print (" OK, failed. The error was:\n %s\n", error->message); g_print (" OK, failed. The error was:\n %s\n", error->message);
g_clear_error (&error); g_error_free (error);
} }
else else
{ {

View File

@ -1975,7 +1975,7 @@ preferences_dialog_create (Gimp *gimp)
/* The maximum size of a new image */ /* The maximum size of a new image */
adjustment = gtk_adjustment_new (gimprc.max_new_image_size, adjustment = gtk_adjustment_new (gimprc.max_new_image_size,
0, (4069.0 * 1024 * 1024 - 1), 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_mem_size_entry_new (GTK_ADJUSTMENT (adjustment));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
@ -2632,7 +2632,7 @@ preferences_dialog_create (Gimp *gimp)
/* The tile cache size */ /* The tile cache size */
adjustment = gtk_adjustment_new (edit_tile_cache_size, adjustment = gtk_adjustment_new (edit_tile_cache_size,
0, (4069.0 * 1024 * 1024 - 1), 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_mem_size_entry_new (GTK_ADJUSTMENT (adjustment));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,

View File

@ -1975,7 +1975,7 @@ preferences_dialog_create (Gimp *gimp)
/* The maximum size of a new image */ /* The maximum size of a new image */
adjustment = gtk_adjustment_new (gimprc.max_new_image_size, adjustment = gtk_adjustment_new (gimprc.max_new_image_size,
0, (4069.0 * 1024 * 1024 - 1), 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_mem_size_entry_new (GTK_ADJUSTMENT (adjustment));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
@ -2632,7 +2632,7 @@ preferences_dialog_create (Gimp *gimp)
/* The tile cache size */ /* The tile cache size */
adjustment = gtk_adjustment_new (edit_tile_cache_size, adjustment = gtk_adjustment_new (edit_tile_cache_size,
0, (4069.0 * 1024 * 1024 - 1), 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_mem_size_entry_new (GTK_ADJUSTMENT (adjustment));
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1, gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,

View File

@ -311,7 +311,7 @@ test_serialize_context_cmd_callback (GtkWidget *widget,
&error)) &error))
{ {
g_message ("Serializing Context failed:\n%s", error->message); g_message ("Serializing Context failed:\n%s", error->message);
g_clear_error (&error); g_error_free (error);
} }
g_free (filename); g_free (filename);
@ -335,7 +335,7 @@ test_deserialize_context_cmd_callback (GtkWidget *widget,
&error)) &error))
{ {
g_message ("Deserializing Context failed:\n%s", error->message); g_message ("Deserializing Context failed:\n%s", error->message);
g_clear_error (&error); g_error_free (error);
} }
g_free (filename); g_free (filename);

View File

@ -18,10 +18,6 @@
#include "config.h" #include "config.h"
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h" #include "libgimpcolor/gimpcolor.h"
@ -92,10 +88,9 @@ gimp_devices_init (Gimp *gimp,
{ {
device = (GdkDevice *) list->data; device = (GdkDevice *) list->data;
g_print ("############# adding %s\n", device->name);
device_info = gimp_device_info_new (gimp, device->name); device_info = gimp_device_info_new (gimp, device->name);
gimp_container_add (manager->device_info_list, GIMP_OBJECT (device_info)); gimp_container_add (manager->device_info_list,
GIMP_OBJECT (device_info));
g_object_unref (G_OBJECT (device_info)); g_object_unref (G_OBJECT (device_info));
gimp_device_info_set_from_device (device_info, device); gimp_device_info_set_from_device (device_info, device);
@ -139,9 +134,10 @@ gimp_devices_restore (Gimp *gimp)
gimp, gimp,
&error)) &error))
{ {
g_message ("Could not read devicerc: %s", error->message); if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
g_clear_error (&error); g_message (error->message);
g_error_free (error);
/* don't bail out here */ /* don't bail out here */
} }
@ -183,8 +179,8 @@ gimp_devices_save (Gimp *gimp)
NULL, NULL,
&error)) &error))
{ {
g_message ("Could not write devicerc: %s", error->message); g_message (error->message);
g_clear_error (&error); g_error_free (error);
} }
g_free (filename); g_free (filename);

View File

@ -416,7 +416,7 @@ gimp_config_scanner_message (GScanner *scanner,
g_set_error (error, g_set_error (error,
GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE, GIMP_CONFIG_ERROR, GIMP_CONFIG_ERROR_PARSE,
_("Error while parsing '%s' in line %d:\n %s"), _("Error while parsing '%s' in line %d:\n%s"),
scanner->input_name, scanner->line, message); scanner->input_name, scanner->line, message);
} }

View File

@ -1095,10 +1095,10 @@ gimp_mem_size_entry_callback (GtkAdjustment *adj,
gpointer data) gpointer data)
{ {
GimpMemSizeEntryData *gmsed; GimpMemSizeEntryData *gmsed;
guint new_value; gulong new_value;
gmsed = (GimpMemSizeEntryData *)data; gmsed = (GimpMemSizeEntryData *)data;
new_value = adj->value * gmsed->mem_size_unit; new_value = (gulong) adj->value * gmsed->mem_size_unit;
gtk_adjustment_set_value (gmsed->adjustment, new_value); gtk_adjustment_set_value (gmsed->adjustment, new_value);
} }
@ -1108,7 +1108,7 @@ gimp_mem_size_unit_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
GimpMemSizeEntryData *gmsed; GimpMemSizeEntryData *gmsed;
guint divided_mem_size; gulong divided_mem_size;
guint new_unit; guint new_unit;
gmsed = (GimpMemSizeEntryData *)data; gmsed = (GimpMemSizeEntryData *)data;
@ -1118,9 +1118,16 @@ gimp_mem_size_unit_callback (GtkWidget *widget,
if (new_unit && new_unit != gmsed->mem_size_unit) if (new_unit && new_unit != gmsed->mem_size_unit)
{ {
divided_mem_size = gmsed->adjustment->value / new_unit; GtkAdjustment *div_adj = GTK_ADJUSTMENT (gmsed->divided_adj);
divided_mem_size = (gulong) gmsed->adjustment->value / new_unit;
gmsed->mem_size_unit = new_unit; gmsed->mem_size_unit = new_unit;
div_adj->lower = gmsed->adjustment->lower / new_unit;
div_adj->upper = gmsed->adjustment->upper / new_unit;
gtk_adjustment_changed (div_adj);
gtk_adjustment_set_value (GTK_ADJUSTMENT (gmsed->divided_adj), gtk_adjustment_set_value (GTK_ADJUSTMENT (gmsed->divided_adj),
divided_mem_size); divided_mem_size);
} }
@ -1141,25 +1148,31 @@ gimp_mem_size_entry_new (GtkAdjustment *adjustment)
GtkWidget *optionmenu; GtkWidget *optionmenu;
GimpMemSizeEntryData *gmsed; GimpMemSizeEntryData *gmsed;
guint mem_size_unit = 1; gulong mem_size_unit;
guint divided_mem_size; gulong divided_mem_size;
gint i; gint i;
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->value >= 0, NULL);
gmsed = g_new (GimpMemSizeEntryData, 1); gmsed = g_new (GimpMemSizeEntryData, 1);
for (i = 0; i < 2; i++) for (i = 0, mem_size_unit = 1; i < 2; i++)
{ {
if ( (gint) adjustment->value % (mem_size_unit * 1024) != 0 ) if ( (gulong) adjustment->value % (mem_size_unit << 10) != 0 )
break; break;
mem_size_unit *= 1024; mem_size_unit <<= 10;
} }
divided_mem_size = adjustment->value / mem_size_unit;
divided_mem_size = (gulong) adjustment->value / mem_size_unit;
hbox = gtk_hbox_new (FALSE, 2); hbox = gtk_hbox_new (FALSE, 2);
spinbutton = spinbutton =
gimp_spin_button_new (&divided_adj, divided_mem_size, gimp_spin_button_new (&divided_adj, divided_mem_size,
0.0, (4096.0 * 1024 * 1024 - 1), 1.0, 16.0, 0.0, adjustment->lower / mem_size_unit,
1.0, 0.0); adjustment->upper / mem_size_unit,
1.0, 16.0, 0.0, 1.0, 0.0);
g_signal_connect (G_OBJECT (divided_adj), "value_changed", g_signal_connect (G_OBJECT (divided_adj), "value_changed",
G_CALLBACK (gimp_mem_size_entry_callback), G_CALLBACK (gimp_mem_size_entry_callback),
gmsed); gmsed);
@ -1170,11 +1183,12 @@ gimp_mem_size_entry_new (GtkAdjustment *adjustment)
gimp_option_menu_new2 (FALSE, G_CALLBACK (gimp_mem_size_unit_callback), gimp_option_menu_new2 (FALSE, G_CALLBACK (gimp_mem_size_unit_callback),
gmsed, (gpointer) mem_size_unit, gmsed, (gpointer) mem_size_unit,
_("Bytes"), (gpointer) 1, NULL, _("Bytes"), GINT_TO_POINTER (1 << 0), NULL,
_("KiloBytes"), (gpointer) 1024, NULL, _("KiloBytes"), GINT_TO_POINTER (1 << 10), NULL,
_("MegaBytes"), (gpointer) (1024 * 1024), NULL, _("MegaBytes"), GINT_TO_POINTER (1 << 20), NULL,
NULL); NULL);
gtk_box_pack_start (GTK_BOX (hbox), optionmenu, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), optionmenu, FALSE, FALSE, 0);
gtk_widget_show (optionmenu); gtk_widget_show (optionmenu);