Commit 4ce4adf8 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

removed gimp_config_values_equal().

2002-11-23  Michael Natterer  <mitch@gimp.org>

	* app/config/gimpconfig-utils.[ch]: removed
	gimp_config_values_equal().

	* app/config/gimpconfig-serialize.c
	* app/config/gimpconfig.c: use g_param_values_cmp() instead so
	our registered compare methods are used.

	* app/config/gimpdisplayconfig.[ch]: added "canvas_padding_mode"
	and "canvas_padding_color" properties.

	* app/display/display-enums.[ch]: added enum GimpDisplayPaddingMode
	which can be one of { theme, light check, dark check, custom }.

	* app/display/gimpdisplay.h
	* app/display/gimpdisplay-handlers.c: removed cached monitor
	resolution values...

	* app/display/gimpdisplayshell.[ch]: ...and added them here. Added
	padding state as in GimpDisplayConfig. Added utility function
	gimp_display_shell_set_padding() which hides all the details.
	Added the new padding modes to the padding color button's context
	menu.

	* app/display/gimpdisplayshell-callbacks.[ch]: don't fiddle
	with colors manually but use gimp_display_shell_set_padding()
	in realize() and in the color button callbacks.

	* app/display/gimpdisplayshell-handlers.c: connect to
	notify::monitor-[xy]resolution and
	notify::canvas-padding-[mode|color] and update accordingly.

	* app/widgets/gimppropwidgets.[ch]: added
	gimp_prop_color_button_new().

	* app/widgets/gimpdialogfactory.[ch]: added
	gimp_dialog_factories_session_clear() (unimplemented).

	* app/gui/preferences-dialog.c: added widgets for padding mode and
	color. Removed some callbacks by connecting the functions they
	called directly. Cleanup.
parent c6188401
2002-11-23 Michael Natterer <mitch@gimp.org>
* app/config/gimpconfig-utils.[ch]: removed
gimp_config_values_equal().
* app/config/gimpconfig-serialize.c
* app/config/gimpconfig.c: use g_param_values_cmp() instead so
our registered compare methods are used.
* app/config/gimpdisplayconfig.[ch]: added "canvas_padding_mode"
and "canvas_padding_color" properties.
* app/display/display-enums.[ch]: added enum GimpDisplayPaddingMode
which can be one of { theme, light check, dark check, custom }.
* app/display/gimpdisplay.h
* app/display/gimpdisplay-handlers.c: removed cached monitor
resolution values...
* app/display/gimpdisplayshell.[ch]: ...and added them here. Added
padding state as in GimpDisplayConfig. Added utility function
gimp_display_shell_set_padding() which hides all the details.
Added the new padding modes to the padding color button's context
menu.
* app/display/gimpdisplayshell-callbacks.[ch]: don't fiddle
with colors manually but use gimp_display_shell_set_padding()
in realize() and in the color button callbacks.
* app/display/gimpdisplayshell-handlers.c: connect to
notify::monitor-[xy]resolution and
notify::canvas-padding-[mode|color] and update accordingly.
* app/widgets/gimppropwidgets.[ch]: added
gimp_prop_color_button_new().
* app/widgets/gimpdialogfactory.[ch]: added
gimp_dialog_factories_session_clear() (unimplemented).
* app/gui/preferences-dialog.c: added widgets for padding mode and
color. Removed some callbacks by connecting the functions they
called directly. Cleanup.
2002-11-23 Jakub Steiner <jimmac@ximian.com>
 
* themes/Default/images/preferences/folders-environ.png:
......
......@@ -177,7 +177,7 @@ gimp_config_serialize_changed_properties (GObject *new,
g_object_get_property (new, prop_spec->name, &new_value);
g_object_get_property (old, prop_spec->name, &old_value);
if (!gimp_config_values_equal (&new_value, &old_value))
if (g_param_values_cmp (prop_spec, &new_value, &old_value) != 0)
{
if (property_written)
g_string_assign (str, "\n");
......
......@@ -30,40 +30,6 @@
#include "gimpconfig-utils.h"
gboolean
gimp_config_values_equal (const GValue *a,
const GValue *b)
{
g_return_val_if_fail (G_VALUE_TYPE (a) == G_VALUE_TYPE (b), FALSE);
if (g_value_fits_pointer (a))
{
if (a->data[0].v_pointer == b->data[0].v_pointer)
return TRUE;
if (G_VALUE_HOLDS_STRING (a))
{
const gchar *a_str = g_value_get_string (a);
const gchar *b_str = g_value_get_string (b);
if (a_str && b_str)
return (strcmp (a_str, b_str) == 0);
else
return FALSE;
}
else
{
g_warning ("%s: Can not compare values of type %s.",
G_STRLOC, G_VALUE_TYPE_NAME (a));
return FALSE;
}
}
else
{
return (a->data[0].v_uint64 == b->data[0].v_uint64);
}
}
void
gimp_config_copy_properties (GObject *src,
GObject *dest)
......
......@@ -23,8 +23,6 @@
#define __GIMP_CONFIG_UTILS_H__
gboolean gimp_config_values_equal (const GValue *a,
const GValue *b);
void gimp_config_copy_properties (GObject *src,
GObject *dest);
......
......@@ -163,7 +163,7 @@ gimp_config_iface_equal (GObject *a,
g_object_get_property (a, prop_spec->name, &a_value);
g_object_get_property (b, prop_spec->name, &b_value);
equal = gimp_config_values_equal (&a_value, &b_value);
equal = (g_param_values_cmp (prop_spec, &a_value, &b_value) == 0);
g_value_unset (&a_value);
g_value_unset (&b_value);
......
......@@ -23,6 +23,7 @@
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpbase/gimpbase.h"
#include "config-types.h"
......@@ -68,7 +69,9 @@ enum
PROP_MONITOR_XRESOLUTION,
PROP_MONITOR_YRESOLUTION,
PROP_MONITOR_RES_FROM_GDK,
PROP_NAV_PREVIEW_SIZE
PROP_NAV_PREVIEW_SIZE,
PROP_CANVAS_PADDING_MODE,
PROP_CANVAS_PADDING_COLOR
};
static GObjectClass *parent_class = NULL;
......@@ -106,6 +109,7 @@ static void
gimp_display_config_class_init (GimpDisplayConfigClass *klass)
{
GObjectClass *object_class;
GimpRGB white;
parent_class = g_type_class_peek_parent (klass);
......@@ -115,6 +119,8 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass)
object_class->set_property = gimp_display_config_set_property;
object_class->get_property = gimp_display_config_get_property;
gimp_rgba_set (&white, 1.0, 1.0, 1.0, 1.0);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_MARCHING_ANTS_SPEED,
"marching-ants-speed",
50, G_MAXINT, 300,
......@@ -182,8 +188,18 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass)
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_NAV_PREVIEW_SIZE,
"navigation-preview-size",
GIMP_TYPE_PREVIEW_SIZE, GIMP_PREVIEW_SIZE_MEDIUM,
GIMP_TYPE_PREVIEW_SIZE,
GIMP_PREVIEW_SIZE_MEDIUM,
0);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CANVAS_PADDING_MODE,
"canvas-padding-mode",
GIMP_TYPE_DISPLAY_PADDING_MODE,
GIMP_DISPLAY_PADDING_MODE_DEFAULT,
0);
GIMP_CONFIG_INSTALL_PROP_COLOR (object_class, PROP_CANVAS_PADDING_COLOR,
"canvas-padding-color",
&white,
0);
}
static void
......@@ -264,6 +280,12 @@ gimp_display_config_set_property (GObject *object,
case PROP_NAV_PREVIEW_SIZE:
display_config->nav_preview_size = g_value_get_enum (value);
break;
case PROP_CANVAS_PADDING_MODE:
display_config->canvas_padding_mode = g_value_get_enum (value);
break;
case PROP_CANVAS_PADDING_COLOR:
display_config->canvas_padding_color = *(GimpRGB *) g_value_get_boxed (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -334,6 +356,12 @@ gimp_display_config_get_property (GObject *object,
case PROP_NAV_PREVIEW_SIZE:
g_value_set_enum (value, display_config->nav_preview_size);
break;
case PROP_CANVAS_PADDING_MODE:
g_value_set_enum (value, display_config->canvas_padding_mode);
break;
case PROP_CANVAS_PADDING_COLOR:
g_value_set_boxed (value, &display_config->canvas_padding_color);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......
......@@ -38,25 +38,27 @@ typedef struct _GimpDisplayConfigClass GimpDisplayConfigClass;
struct _GimpDisplayConfig
{
GimpCoreConfig parent_instance;
GimpCoreConfig parent_instance;
gint marching_ants_speed;
gboolean colormap_cycling;
gboolean resize_windows_on_zoom;
gboolean resize_windows_on_resize;
gboolean default_dot_for_dot;
gboolean perfect_mouse;
GimpCursorMode cursor_mode;
gboolean cursor_updating;
gchar *image_title_format;
gchar *image_status_format;
gboolean show_rulers;
gboolean show_statusbar;
gboolean confirm_on_close;
gdouble monitor_xres;
gdouble monitor_yres;
gboolean monitor_res_from_gdk;
GimpPreviewSize nav_preview_size;
gint marching_ants_speed;
gboolean colormap_cycling;
gboolean resize_windows_on_zoom;
gboolean resize_windows_on_resize;
gboolean default_dot_for_dot;
gboolean perfect_mouse;
GimpCursorMode cursor_mode;
gboolean cursor_updating;
gchar *image_title_format;
gchar *image_status_format;
gboolean show_rulers;
gboolean show_statusbar;
gboolean confirm_on_close;
gdouble monitor_xres;
gdouble monitor_yres;
gboolean monitor_res_from_gdk;
GimpPreviewSize nav_preview_size;
GimpDisplayPaddingMode canvas_padding_mode;
GimpRGB canvas_padding_color;
};
struct _GimpDisplayConfigClass
......
......@@ -58,9 +58,6 @@ struct _GimpDisplay
gint instance; /* the instance # of this gdisplay as */
/* taken from the gimage at creation */
gdouble monitor_xres;
gdouble monitor_yres;
GtkWidget *shell; /* shell widget for this gdisplay */
gboolean draw_guides; /* should the guides be drawn? */
......
......@@ -36,6 +36,7 @@
#include "widgets/gimpdeviceinfo.h"
#include "widgets/gimpdevices.h"
#include "widgets/gimpdialogfactory.h"
#include "widgets/gimppropwidgets.h"
#include "gui.h"
......@@ -66,19 +67,15 @@ static void prefs_cancel_callback (GtkWidget *widget,
static void prefs_ok_callback (GtkWidget *widget,
GtkWidget *dialog);
static void prefs_clear_session_info_callback (GtkWidget *widget,
gpointer data);
static void prefs_default_resolution_callback (GtkWidget *widget,
GtkWidget *size_sizeentry);
static void prefs_res_source_callback (GtkWidget *widget,
GObject *config);
static void prefs_resolution_calibrate_callback (GtkWidget *widget,
gpointer data);
GtkWidget *sizeentry);
static void prefs_input_dialog_able_callback (GtkWidget *widget,
GdkDevice *device,
gpointer data);
static void prefs_input_dialog_save_callback (GtkWidget *widget,
gpointer data);
static void prefs_restart_notification (void);
......@@ -422,19 +419,6 @@ prefs_ok_callback (GtkWidget *widget,
g_object_unref (config_copy);
}
static void
prefs_clear_session_info_callback (GtkWidget *widget,
gpointer data)
{
#ifdef __GNUC__
#warning FIXME: g_list_free (session_info_updates);
#endif
#if 0
g_list_free (session_info_updates);
session_info_updates = NULL;
#endif
}
static void
prefs_default_resolution_callback (GtkWidget *widget,
GtkWidget *size_sizeentry)
......@@ -489,19 +473,18 @@ prefs_res_source_callback (GtkWidget *widget,
static void
prefs_resolution_calibrate_callback (GtkWidget *widget,
gpointer data)
GtkWidget *sizeentry)
{
GtkWidget *dialog;
GtkWidget *notebook;
GtkWidget *image;
dialog = gtk_widget_get_toplevel (GTK_WIDGET (data));
dialog = gtk_widget_get_toplevel (sizeentry);
notebook = g_object_get_data (G_OBJECT (dialog), "notebook");
notebook = g_object_get_data (G_OBJECT (dialog), "notebook");
image = g_object_get_data (G_OBJECT (notebook), "image");
image = g_object_get_data (G_OBJECT (notebook), "image");
resolution_calibrate_dialog (GTK_WIDGET (data),
resolution_calibrate_dialog (sizeentry,
gtk_image_get_pixbuf (GTK_IMAGE (image)),
NULL, NULL, NULL);
}
......@@ -514,13 +497,6 @@ prefs_input_dialog_able_callback (GtkWidget *widget,
gimp_device_info_changed_by_device (device);
}
static void
prefs_input_dialog_save_callback (GtkWidget *widget,
gpointer data)
{
gimp_devices_save (GIMP (data));
}
static GtkWidget *
prefs_notebook_append_page (Gimp *gimp,
GtkNotebook *notebook,
......@@ -654,7 +630,7 @@ prefs_frame_new (gchar *label,
gboolean expand)
{
GtkWidget *frame;
GtkWidget *vbox2;
GtkWidget *vbox;
frame = gtk_frame_new (label);
......@@ -665,12 +641,12 @@ prefs_frame_new (gchar *label,
gtk_widget_show (frame);
vbox2 = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox2), 2);
gtk_container_add (GTK_CONTAINER (frame), vbox2);
gtk_widget_show (vbox2);
vbox = gtk_vbox_new (FALSE, 2);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
return vbox2;
return vbox;
}
static GtkWidget *
......@@ -733,6 +709,27 @@ prefs_check_button_add (GObject *config,
return button;
}
static GtkWidget *
prefs_color_button_add (GObject *config,
const gchar *property_name,
const gchar *label,
const gchar *title,
GtkTable *table,
gint table_row)
{
GtkWidget *button;
button = gimp_prop_color_button_new (config, property_name, title,
20, 20, GIMP_COLOR_AREA_SMALL_CHECKS);
if (button)
gimp_table_attach_aligned (table, 0, table_row,
label, 1.0, 0.5,
button, 1, TRUE);
return button;
}
static GtkWidget *
prefs_enum_option_menu_add (GObject *config,
const gchar *property_name,
......@@ -1231,7 +1228,7 @@ prefs_dialog_new (Gimp *gimp,
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (prefs_clear_session_info_callback),
G_CALLBACK (gimp_dialog_factories_session_clear),
NULL);
......@@ -1369,9 +1366,9 @@ prefs_dialog_new (Gimp *gimp,
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
g_signal_connect (G_OBJECT (button), "clicked",
G_CALLBACK (prefs_input_dialog_save_callback),
gimp);
g_signal_connect_swapped (G_OBJECT (button), "clicked",
G_CALLBACK (gimp_devices_save),
gimp);
/*******************************/
......@@ -1406,11 +1403,18 @@ prefs_dialog_new (Gimp *gimp,
_("Show S_tatusbar"),
GTK_BOX (vbox2));
table = prefs_table_new (1, GTK_CONTAINER (vbox2), FALSE);
table = prefs_table_new (3, GTK_CONTAINER (vbox2), FALSE);
prefs_spin_button_add (config, "marching-ants-speed", 10.0, 100.0, 0,
_("Marching _Ants Speed:"),
GTK_TABLE (table), 0);
prefs_enum_option_menu_add (config, "canvas-padding-mode", 0, 0,
_("Canvas Padding Mode:"),
GTK_TABLE (table), 1);
prefs_color_button_add (config, "canvas-padding-color",
_("Custom Canvas _Padding Color:"),
_("Select Custom Canvas Padding Color"),
GTK_TABLE (table), 2);
vbox2 = prefs_frame_new (_("Pointer Movement Feedback"),
GTK_CONTAINER (vbox), FALSE);
......@@ -1464,29 +1468,29 @@ prefs_dialog_new (Gimp *gimp,
N_("Show memory usage")
};
gchar *formats[] =
{
display_config->image_title_format,
display_config->image_status_format
};
const gchar *format_titles[] =
struct
{
N_("Image Title Format"),
N_("Image Statusbar Format")
};
const gchar *format_properties[] =
gchar *current_setting;
const gchar *title;
const gchar *property_name;
}
formats[] =
{
"image-title-format",
"image-status-format"
{
display_config->image_title_format,
N_("Image Title Format"),
"image-title-format"
},
{
display_config->image_status_format,
N_("Image Statusbar Format"),
"image-status-format"
}
};
gint format;
g_assert (G_N_ELEMENTS (format_strings) == G_N_ELEMENTS (format_names));
g_assert (G_N_ELEMENTS (formats) == G_N_ELEMENTS (format_titles));
g_assert (G_N_ELEMENTS (formats) == G_N_ELEMENTS (format_properties));
for (format = 0; format < G_N_ELEMENTS (formats); format++)
{
......@@ -1500,12 +1504,12 @@ prefs_dialog_new (Gimp *gimp,
GtkTreeSelection *sel;
gint i;
format_strings[0] = formats[format];
format_strings[0] = formats[format].current_setting;
vbox2 = prefs_frame_new (gettext (format_titles[format]),
GTK_CONTAINER (vbox), TRUE);
vbox2 = prefs_frame_new (gettext (formats[format].title),
GTK_CONTAINER (vbox), TRUE);
entry = gimp_prop_entry_new (config, format_properties[format], 0);
entry = gimp_prop_entry_new (config, formats[format].property_name, 0);
gtk_box_pack_start (GTK_BOX (vbox2), entry, FALSE, FALSE, 0);
gtk_widget_show (entry);
......@@ -1813,7 +1817,10 @@ prefs_dialog_new (Gimp *gimp,
}
}
/*********************/
/* Folders / <paths> */
/*********************/
{
static const struct
{
......
......@@ -28,5 +28,26 @@ gimp_cursor_mode_get_type (void)
}
static const GEnumValue gimp_display_padding_mode_enum_values[] =
{
{ GIMP_DISPLAY_PADDING_MODE_DEFAULT, N_("From Theme"), "default" },
{ GIMP_DISPLAY_PADDING_MODE_LIGHT_CHECK, N_("Light Check Color"), "light-check" },
{ GIMP_DISPLAY_PADDING_MODE_DARK_CHECK, N_("Dark Check Color"), "dark-check" },
{ GIMP_DISPLAY_PADDING_MODE_CUSTOM, N_("Custom Color"), "custom" },
{ 0, NULL, NULL }
};
GType
gimp_display_padding_mode_get_type (void)
{
static GType enum_type = 0;
if (!enum_type)
enum_type = g_enum_register_static ("GimpDisplayPaddingMode", gimp_display_padding_mode_enum_values);
return enum_type;
}
/* Generated data ends here */
......@@ -32,4 +32,17 @@ typedef enum
} GimpCursorMode;
#define GIMP_TYPE_DISPLAY_PADDING_MODE (gimp_display_padding_mode_get_type ())
GType gimp_display_padding_mode_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_DISPLAY_PADDING_MODE_DEFAULT, /*< desc="From Theme" >*/
GIMP_DISPLAY_PADDING_MODE_LIGHT_CHECK, /*< desc="Light Check Color" >*/
GIMP_DISPLAY_PADDING_MODE_DARK_CHECK, /*< desc="Dark Check Color" >*/
GIMP_DISPLAY_PADDING_MODE_CUSTOM /*< desc="Custom Color" >*/
} GimpDisplayPaddingMode;
#endif /* __DISPLAY_ENUMS_H__ */
......@@ -60,9 +60,6 @@ gimp_display_connect (GimpDisplay *gdisp,
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (gdisp->gimage == NULL);
gdisp->monitor_xres = GIMP_DISPLAY_CONFIG (gimage->gimp->config)->monitor_xres;
gdisp->monitor_yres = GIMP_DISPLAY_CONFIG (gimage->gimp->config)->monitor_yres;
gdisp->gimage = gimage;
gdisp->instance = gimage->instance_count;
......
......@@ -58,9 +58,6 @@ struct _GimpDisplay
gint instance; /* the instance # of this gdisplay as */
/* taken from the gimage at creation */
gdouble monitor_xres;
gdouble monitor_yres;
GtkWidget *shell; /* shell widget for this gdisplay */
gboolean draw_guides; /* should the guides be drawn? */
......
......@@ -55,14 +55,13 @@
#include "gimpdisplayshell.h"
#include "gimpdisplayshell-callbacks.h"
#include "gimpdisplayshell-layer-select.h"
#include "gimpdisplayshell-render.h"
#include "gimpdisplayshell-scale.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-selection.h"
#include "gimpnavigationview.h"
#include "gimpstatusbar.h"
#include "app_procs.h"
#include "libgimp/gimpintl.h"
......@@ -238,46 +237,19 @@ void
gimp_display_shell_canvas_realize (GtkWidget *canvas,
GimpDisplayShell *shell)
{
/* FIXME!! */
GimpDisplayConfig *config = GIMP_DISPLAY_CONFIG (the_gimp->config);
GimpDisplay *gdisp;
GdkColor color;
guchar r, g, b;
GimpDisplayConfig *config;
GimpDisplay *gdisp;
gdisp = shell->gdisp;
gdisp = shell->gdisp;
config = GIMP_DISPLAY_CONFIG (gdisp->gimage->gimp->config);
gtk_widget_grab_focus (shell->canvas);
if (TRUE /* gimprc.use_style_padding_color */)
{
r = shell->canvas->style->bg[GTK_STATE_NORMAL].red >> 8;
g = shell->canvas->style->bg[GTK_STATE_NORMAL].green >> 8;
b = shell->canvas->style->bg[GTK_STATE_NORMAL].blue >> 8;
gimp_rgb_set_uchar (&shell->padding_color, r, g, b);
g_signal_handlers_block_by_func (G_OBJECT (shell->padding_button),