mirror of https://github.com/GNOME/gimp.git
Make XOR color configurable (bug #421466):
2007-03-23 Sven Neumann <sven@gimp.org> Make XOR color configurable (bug #421466): * app/config/gimprc-blurbs.h * app/config/gimpdisplayconfig.[ch]: added gimprc option for the XOR color. * app/display/gimpcanvas.[ch]: keep a reference to the Gimp object and take the XOR color from GimpDisplayConfig. * app/display/gimpdisplayshell.c: pass gimp to gimp_canvas_new(). svn path=/trunk/; revision=22164
This commit is contained in:
parent
ce489b17ae
commit
9ae026c39e
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2007-03-23 Sven Neumann <sven@gimp.org>
|
||||
|
||||
Make XOR color configurable (bug #421466):
|
||||
|
||||
* app/config/gimprc-blurbs.h
|
||||
* app/config/gimpdisplayconfig.[ch]: added gimprc option for the
|
||||
XOR color.
|
||||
|
||||
* app/display/gimpcanvas.[ch]: keep a reference to the Gimp object
|
||||
and take the XOR color from GimpDisplayConfig.
|
||||
|
||||
* app/display/gimpdisplayshell.c: pass gimp to gimp_canvas_new().
|
||||
|
||||
2007-03-22 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimplayer.c (gimp_layer_add_mask): allow adding a mask
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
#include "config-types.h"
|
||||
|
@ -66,7 +67,8 @@ enum
|
|||
PROP_DEFAULT_VIEW,
|
||||
PROP_DEFAULT_FULLSCREEN_VIEW,
|
||||
PROP_ACTIVATE_ON_FOCUS,
|
||||
PROP_SPACE_BAR_ACTION
|
||||
PROP_SPACE_BAR_ACTION,
|
||||
PROP_XOR_COLOR
|
||||
};
|
||||
|
||||
|
||||
|
@ -97,6 +99,9 @@ static void
|
|||
gimp_display_config_class_init (GimpDisplayConfigClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpRGB color;
|
||||
|
||||
gimp_rgb_set_uchar (&color, 0x80, 0xff, 0x80);
|
||||
|
||||
object_class->finalize = gimp_display_config_finalize;
|
||||
object_class->set_property = gimp_display_config_set_property;
|
||||
|
@ -222,6 +227,10 @@ gimp_display_config_class_init (GimpDisplayConfigClass *klass)
|
|||
GIMP_TYPE_SPACE_BAR_ACTION,
|
||||
GIMP_SPACE_BAR_ACTION_PAN,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
GIMP_CONFIG_INSTALL_PROP_RGB (object_class, PROP_XOR_COLOR,
|
||||
"xor-color", XOR_COLOR_BLURB,
|
||||
FALSE, &color,
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -348,6 +357,9 @@ gimp_display_config_set_property (GObject *object,
|
|||
case PROP_SPACE_BAR_ACTION:
|
||||
display_config->space_bar_action = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_XOR_COLOR:
|
||||
display_config->xor_color = *(GimpRGB *) g_value_get_boxed (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -437,6 +449,9 @@ gimp_display_config_get_property (GObject *object,
|
|||
case PROP_SPACE_BAR_ACTION:
|
||||
g_value_set_enum (value, display_config->space_bar_action);
|
||||
break;
|
||||
case PROP_XOR_COLOR:
|
||||
g_value_set_boxed (value, &display_config->xor_color);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
|
|
@ -68,6 +68,7 @@ struct _GimpDisplayConfig
|
|||
GimpDisplayOptions *default_fullscreen_view;
|
||||
gboolean activate_on_focus;
|
||||
GimpSpaceBarAction space_bar_action;
|
||||
GimpRGB xor_color;
|
||||
};
|
||||
|
||||
struct _GimpDisplayConfigClass
|
||||
|
|
|
@ -19,13 +19,13 @@ N_("When enabled, an image will become the active image when its image " \
|
|||
|
||||
#define BRUSH_PATH_WRITABLE_BLURB ""
|
||||
|
||||
#define CANVAS_PADDING_MODE_BLURB \
|
||||
N_("Specifies how the area around the image should be drawn.")
|
||||
|
||||
#define CANVAS_PADDING_COLOR_BLURB \
|
||||
N_("Sets the canvas padding color used if the padding mode is set to " \
|
||||
"custom color.")
|
||||
|
||||
#define CANVAS_PADDING_MODE_BLURB \
|
||||
N_("Specifies how the area around the image should be drawn.")
|
||||
|
||||
#define COLOR_MANAGEMENT_BLURB \
|
||||
"Defines the color management behavior."
|
||||
|
||||
|
@ -429,5 +429,10 @@ N_("Sets the external web browser to be used. This can be an absolute " \
|
|||
"the URL will be appended to the command with a space separating the " \
|
||||
"two.")
|
||||
|
||||
#define XOR_COLOR_BLURB \
|
||||
"Sets the color that is used for XOR drawing. This setting only exists as " \
|
||||
"a workaround for buggy display drivers. If lines on the canvas are not " \
|
||||
"correctly undrawn, try to set this to white."
|
||||
|
||||
|
||||
#endif /* __GIMP_RC_BLURBS_H__ */
|
||||
|
|
|
@ -20,19 +20,42 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
|
||||
#include "display-types.h"
|
||||
|
||||
#include "config/gimpdisplayconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gimpcanvas.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_GIMP
|
||||
};
|
||||
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_canvas_realize (GtkWidget *widget);
|
||||
static void gimp_canvas_unrealize (GtkWidget *widget);
|
||||
static GdkGC * gimp_canvas_gc_new (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style);
|
||||
static void gimp_canvas_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_canvas_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_canvas_realize (GtkWidget *widget);
|
||||
static void gimp_canvas_unrealize (GtkWidget *widget);
|
||||
|
||||
static GdkGC * gimp_canvas_gc_new (GimpCanvas *canvas,
|
||||
GimpCanvasStyle style);
|
||||
|
||||
|
||||
G_DEFINE_TYPE (GimpCanvas, gimp_canvas, GTK_TYPE_DRAWING_AREA)
|
||||
|
@ -128,10 +151,20 @@ static const guchar stipples[GIMP_CANVAS_NUM_STIPPLES][8] =
|
|||
static void
|
||||
gimp_canvas_class_init (GimpCanvasClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
||||
|
||||
widget_class->realize = gimp_canvas_realize;
|
||||
widget_class->unrealize = gimp_canvas_unrealize;
|
||||
object_class->set_property = gimp_canvas_set_property;
|
||||
object_class->get_property = gimp_canvas_get_property;
|
||||
|
||||
widget_class->realize = gimp_canvas_realize;
|
||||
widget_class->unrealize = gimp_canvas_unrealize;
|
||||
|
||||
g_object_class_install_property (object_class, PROP_GIMP,
|
||||
g_param_spec_object ("gimp", NULL, NULL,
|
||||
GIMP_TYPE_GIMP,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -146,6 +179,44 @@ gimp_canvas_init (GimpCanvas *canvas)
|
|||
canvas->stipple[i] = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_canvas_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpCanvas *canvas = GIMP_CANVAS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
canvas->gimp = g_value_get_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_canvas_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpCanvas *canvas = GIMP_CANVAS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_GIMP:
|
||||
g_value_set_object (value, canvas->gimp);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_canvas_realize (GtkWidget *widget)
|
||||
{
|
||||
|
@ -254,6 +325,10 @@ gimp_canvas_gc_new (GimpCanvas *canvas,
|
|||
gdk_gc_set_dashes (gc, 0, &one, 1);
|
||||
}
|
||||
|
||||
bg.red = 0x0;
|
||||
bg.green = 0x0;
|
||||
bg.blue = 0x0;
|
||||
|
||||
switch (style)
|
||||
{
|
||||
default:
|
||||
|
@ -262,23 +337,22 @@ gimp_canvas_gc_new (GimpCanvas *canvas,
|
|||
case GIMP_CANVAS_STYLE_XOR_DOTTED:
|
||||
case GIMP_CANVAS_STYLE_XOR_DASHED:
|
||||
case GIMP_CANVAS_STYLE_XOR:
|
||||
fg.red = 0x8080;
|
||||
fg.green = 0xffff;
|
||||
fg.blue = 0x8080;
|
||||
{
|
||||
GimpDisplayConfig *config = GIMP_DISPLAY_CONFIG (canvas->gimp->config);
|
||||
guchar r, g, b;
|
||||
|
||||
bg.red = 0x0;
|
||||
bg.green = 0x0;
|
||||
bg.blue = 0x0;
|
||||
gimp_rgb_get_uchar (&config->xor_color, &r, &g, &b);
|
||||
|
||||
fg.red = (r << 8) | r;
|
||||
fg.green = (g << 8) | g;
|
||||
fg.blue = (b << 8) | b;
|
||||
}
|
||||
break;
|
||||
|
||||
case GIMP_CANVAS_STYLE_WHITE:
|
||||
fg.red = 0xffff;
|
||||
fg.green = 0xffff;
|
||||
fg.blue = 0xffff;
|
||||
|
||||
bg.red = 0x0;
|
||||
bg.green = 0x0;
|
||||
bg.blue = 0x0;
|
||||
break;
|
||||
|
||||
case GIMP_CANVAS_STYLE_BLACK:
|
||||
|
@ -379,10 +453,13 @@ gimp_canvas_ensure_style (GimpCanvas *canvas,
|
|||
* Return value: a new #GimpCanvas widget
|
||||
**/
|
||||
GtkWidget *
|
||||
gimp_canvas_new (void)
|
||||
gimp_canvas_new (Gimp *gimp)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
||||
|
||||
return g_object_new (GIMP_TYPE_CANVAS,
|
||||
"name", "gimp-canvas",
|
||||
"gimp", gimp,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ struct _GimpCanvas
|
|||
{
|
||||
GtkDrawingArea parent_instance;
|
||||
|
||||
Gimp *gimp;
|
||||
|
||||
GdkGC *gc[GIMP_CANVAS_NUM_STYLES];
|
||||
GdkBitmap *stipple[GIMP_CANVAS_NUM_STIPPLES];
|
||||
PangoLayout *layout;
|
||||
|
@ -73,7 +75,7 @@ struct _GimpCanvasClass
|
|||
|
||||
GType gimp_canvas_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_canvas_new (void);
|
||||
GtkWidget * gimp_canvas_new (Gimp *gimp);
|
||||
|
||||
void gimp_canvas_draw_cursor (GimpCanvas *canvas,
|
||||
gint x,
|
||||
|
|
|
@ -861,7 +861,7 @@ gimp_display_shell_new (GimpDisplay *display,
|
|||
_("Access the image menu"),
|
||||
GIMP_HELP_IMAGE_WINDOW_ORIGIN);
|
||||
|
||||
shell->canvas = gimp_canvas_new ();
|
||||
shell->canvas = gimp_canvas_new (shell->display->image->gimp);
|
||||
|
||||
gimp_display_shell_selection_init (shell);
|
||||
|
||||
|
|
Loading…
Reference in New Issue