[dia] Obsolete color_gdk_black, color_gdk_white global variables
- From: Hans Breuer <hans src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] Obsolete color_gdk_black, color_gdk_white global variables
- Date: Sat, 14 Dec 2013 21:32:37 +0000 (UTC)
commit ea97be7ab2594f69794b7cdf67f2430937ebee97
Author: Hans Breuer <hans breuer org>
Date: Sun Nov 17 11:40:21 2013 +0100
Obsolete color_gdk_black, color_gdk_white global variables
These variables need system/compiler specific handling and are
considered bad programming style anyway. This is also fixing
some theming issue with the line width widget, instead of
unconditional black now using the widgets foreground color.
app/linewidth_area.c | 7 +++----
app/magnify.c | 7 +++++--
app/modify_tool.c | 5 ++++-
lib/color.c | 5 -----
lib/color.h | 1 -
lib/libdia.def | 2 --
plug-ins/libart/dialibartrenderer.c | 12 ++++++++----
7 files changed, 20 insertions(+), 19 deletions(-)
---
diff --git a/app/linewidth_area.c b/app/linewidth_area.c
index 42d14c3..6baf0ea 100644
--- a/app/linewidth_area.c
+++ b/app/linewidth_area.c
@@ -66,8 +66,7 @@ linewidth_area_target (int x, int y)
static void
linewidth_area_draw (GtkWidget *linewidth_area)
{
- GdkColor *win_bg;
- GdkColor line;
+ GdkColor *win_bg, *win_fg;
int width, height;
int i;
int x_offs;
@@ -90,13 +89,13 @@ linewidth_area_draw (GtkWidget *linewidth_area)
style = gtk_widget_get_style (linewidth_area);
win_bg = &(style->bg[GTK_STATE_NORMAL]);
- line = color_gdk_black;
+ win_fg = &(style->fg[GTK_STATE_NORMAL]);
gdk_gc_set_foreground (linewidth_area_gc, win_bg);
gdk_draw_rectangle (linewidth_area_pixmap, linewidth_area_gc, 1,
0, 0, width, height);
- gdk_gc_set_foreground (linewidth_area_gc, &line);
+ gdk_gc_set_foreground (linewidth_area_gc, win_fg);
for (i=0;i<=NUMLINES;i++) {
x_offs = X_OFFSET(i);
diff --git a/app/magnify.c b/app/magnify.c
index c47affb..df4a84b 100644
--- a/app/magnify.c
+++ b/app/magnify.c
@@ -105,14 +105,17 @@ magnify_motion(MagnifyTool *tool, GdkEventMotion *event,
{
intPoint tl, br;
- if (tool->box_active) {
+ if (tool->box_active) {
+ GdkColor white;
+
tool->moved = TRUE;
+ color_convert(&color_white, &white);
if (tool->gc == NULL) {
tool->gc = gdk_gc_new(gtk_widget_get_window(ddisp->canvas));
gdk_gc_set_line_attributes(tool->gc, 1, GDK_LINE_ON_OFF_DASH,
GDK_CAP_BUTT, GDK_JOIN_MITER);
- gdk_gc_set_foreground(tool->gc, &color_gdk_white);
+ gdk_gc_set_foreground(tool->gc, &white);
gdk_gc_set_function(tool->gc, GDK_XOR);
}
diff --git a/app/modify_tool.c b/app/modify_tool.c
index b181a9f..e463c15 100644
--- a/app/modify_tool.c
+++ b/app/modify_tool.c
@@ -273,10 +273,13 @@ modify_button_press(ModifyTool *tool, GdkEventButton *event,
tool->y1 = tool->y2 = (int) event->y;
if (tool->gc == NULL) {
+ GdkColor white;
+
+ color_convert(&color_white, &white);
tool->gc = gdk_gc_new(gtk_widget_get_window(ddisp->canvas));
gdk_gc_set_line_attributes(tool->gc, 1, GDK_LINE_ON_OFF_DASH,
GDK_CAP_BUTT, GDK_JOIN_MITER);
- gdk_gc_set_foreground(tool->gc, &color_gdk_white);
+ gdk_gc_set_foreground(tool->gc, &white);
gdk_gc_set_function(tool->gc, GDK_XOR);
}
diff --git a/lib/color.c b/lib/color.c
index 799b108..354705a 100644
--- a/lib/color.c
+++ b/lib/color.c
@@ -31,8 +31,6 @@ Color color_black = { 0.0f, 0.0f, 0.0f, 1.0f };
Color color_white = { 1.0f, 1.0f, 1.0f, 1.0f };
#endif
-GdkColor color_gdk_black, color_gdk_white;
-
gboolean _color_initialized = FALSE;
/** Initialize color access (gdk) and set up default colors.
@@ -45,9 +43,6 @@ color_init(void)
colormap = gdk_colormap_new (visual, FALSE);
_color_initialized = TRUE;
-
- color_convert(&color_black, &color_gdk_black);
- color_convert(&color_white, &color_gdk_white);
}
}
diff --git a/lib/color.h b/lib/color.h
index b625369..a7b7723 100644
--- a/lib/color.h
+++ b/lib/color.h
@@ -46,7 +46,6 @@ static Color color_white = { 1.0f, 1.0f, 1.0f, 1.0f };
#else
DIAVAR Color color_black, color_white;
#endif
-DIAVAR GdkColor color_gdk_black, color_gdk_white;
#define DIA_COLOR_TO_GDK(from, to) \
(to).pixel = 0; \
diff --git a/lib/libdia.def b/lib/libdia.def
index a573ce4..7894204 100644
--- a/lib/libdia.def
+++ b/lib/libdia.def
@@ -1,8 +1,6 @@
EXPORTS
; variables need to be exported by DIAVAR
render_bounding_boxes
- color_gdk_black
- color_gdk_white
; exported functions
apply_textattr_properties
diff --git a/plug-ins/libart/dialibartrenderer.c b/plug-ins/libart/dialibartrenderer.c
index 6b86464..3c4b56d 100644
--- a/plug-ins/libart/dialibartrenderer.c
+++ b/plug-ins/libart/dialibartrenderer.c
@@ -1175,16 +1175,20 @@ draw_text_line(DiaRenderer *self, TextLine *text_line,
GdkPixmap *pixmap = gdk_pixmap_new (NULL, width, height, 24);
GdkGC *gc = gdk_gc_new (pixmap);
GdkImage *image;
+ GdkColor black, white;
+
+ color_convert(&color_black, &black);
+ color_convert(&color_white, &white);
rowstride = 32*((width+31)/31);
#if 1 /* with 8 bit pixmap we would probably need to set the whole gray palette */
gdk_gc_set_colormap (gc, gdk_colormap_get_system ());
- gdk_gc_set_foreground (gc, &color_gdk_black);
- gdk_gc_set_background (gc, &color_gdk_white);
+ gdk_gc_set_foreground (gc, &black);
+ gdk_gc_set_background (gc, &white);
gdk_draw_rectangle (GDK_DRAWABLE (pixmap), gc, TRUE, 0, 0, width, height);
#endif
- gdk_gc_set_foreground (gc, &color_gdk_white);
- gdk_gc_set_background (gc, &color_gdk_black);
+ gdk_gc_set_foreground (gc, &white);
+ gdk_gc_set_background (gc, &black);
gdk_draw_layout (GDK_DRAWABLE (pixmap), gc, 0, 0, layout);
image = gdk_drawable_get_image (GDK_DRAWABLE (pixmap), 0, 0, width, height);
g_object_unref (G_OBJECT (gc));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]