From: Jim Evins Date: Mon, 5 Feb 2007 03:45:58 +0000 (+0000) Subject: 2007-02-04 Jim Evins X-Git-Tag: glabels-2_3_0~360 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0e1789c306720da62df98918ddd2b9d724f446dd;p=glabels 2007-02-04 Jim Evins * src/color.c: * src/color.h: * src/prefs-model.c: * src/print.c: (draw_text_object): * src/wdgt-mini-preview.c: (gl_wdgt_mini_preview_construct): Removed GnomeCanvas artifacts from color.[ch] and related modules. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@612 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index eb3fa134..6125200b 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,12 @@ +2007-02-04 Jim Evins + + * src/color.c: + * src/color.h: + * src/prefs-model.c: + * src/print.c: (draw_text_object): + * src/wdgt-mini-preview.c: (gl_wdgt_mini_preview_construct): + Removed GnomeCanvas artifacts from color.[ch] and related modules. + 2007-02-04 Jim Evins * src/wdgt-mini-preview.c: diff --git a/glabels2/src/color.c b/glabels2/src/color.c index 38d40a95..f268a8ad 100644 --- a/glabels2/src/color.c +++ b/glabels2/src/color.c @@ -1,9 +1,11 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * * color.c: various small utilities for dealing with canvas colors * - * Copyright (C) 2002 Jim Evins . + * Copyright (C) 2002-2007 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,13 +30,13 @@ /*****************************************************************************/ guint gl_color_set_opacity (guint color, - gdouble opacity) + gdouble opacity) { - guint new_color; + guint new_color; - new_color = (color & 0xFFFFFF00) | (((guint)(255.0*opacity)) & 0xFF); + new_color = (color & 0xFFFFFF00) | (((guint)(255.0*opacity)) & 0xFF); - return new_color; + return new_color; } /*****************************************************************************/ @@ -43,15 +45,15 @@ gl_color_set_opacity (guint color, GdkColor * gl_color_to_gdk_color (guint color) { - GdkColor *gdk_color; + GdkColor *gdk_color; - gdk_color = g_new0 (GdkColor, 1); + gdk_color = g_new0 (GdkColor, 1); - gdk_color->red = GL_COLOR_F_RED (color) * 65535; - gdk_color->green = GL_COLOR_F_GREEN (color) * 65535; - gdk_color->blue = GL_COLOR_F_BLUE (color) * 65535; + gdk_color->red = GL_COLOR_F_RED (color) * 65535; + gdk_color->green = GL_COLOR_F_GREEN (color) * 65535; + gdk_color->blue = GL_COLOR_F_BLUE (color) * 65535; - return gdk_color; + return gdk_color; } /*****************************************************************************/ @@ -60,13 +62,13 @@ gl_color_to_gdk_color (guint color) guint gl_color_from_gdk_color (GdkColor *gdk_color) { - guint color; + guint color; - color = GL_COLOR ((gdk_color->red >>8), - (gdk_color->green >>8), - (gdk_color->blue >>8)); + color = GL_COLOR ((gdk_color->red >>8), + (gdk_color->green >>8), + (gdk_color->blue >>8)); - return color; + return color; } /*****************************************************************************/ @@ -74,15 +76,15 @@ gl_color_from_gdk_color (GdkColor *gdk_color) /*****************************************************************************/ guint gl_color_shadow (guint base_color, - gdouble opacity, - guint object_color) + gdouble opacity, + guint object_color) { - guint color; + guint color; - color = gl_color_set_opacity (base_color, - opacity * GL_COLOR_F_ALPHA (object_color)); + color = gl_color_set_opacity (base_color, + opacity * GL_COLOR_F_ALPHA (object_color)); - return color; + return color; } /****************************************************************************/ @@ -91,15 +93,15 @@ gl_color_shadow (guint base_color, glColorNode * gl_color_node_new_default () { - glColorNode* color_node; - - color_node = g_new0(glColorNode,1); - - color_node->field_flag = FALSE; - color_node->color = GL_COLOR_NONE; - color_node->key = NULL; - - return color_node; + glColorNode* color_node; + + color_node = g_new0(glColorNode,1); + + color_node->field_flag = FALSE; + color_node->color = GL_COLOR_NONE; + color_node->key = NULL; + + return color_node; } /****************************************************************************/ @@ -108,24 +110,24 @@ gl_color_node_new_default () glColorNode * gl_color_node_dup (glColorNode *src) { - glColorNode *dst; + glColorNode *dst; - if ( src == NULL ) return NULL; + if ( src == NULL ) return NULL; - dst = g_new0 (glColorNode, 1); + dst = g_new0 (glColorNode, 1); - dst->field_flag = src->field_flag; - if (src->key != NULL) - { - dst->key = g_strdup (src->key); - } - else - { - dst->key = NULL; - } - dst->color = src->color; + dst->field_flag = src->field_flag; + if (src->key != NULL) + { + dst->key = g_strdup (src->key); + } + else + { + dst->key = NULL; + } + dst->color = src->color; - return dst; + return dst; } /****************************************************************************/ @@ -133,38 +135,38 @@ gl_color_node_dup (glColorNode *src) /****************************************************************************/ gboolean gl_color_node_equal (glColorNode *color_node1, - glColorNode *color_node2) + glColorNode *color_node2) { - /* First take care of the case of either or both being NULL. */ - if ( color_node1 == NULL ) { - return ( color_node2 == NULL ); - } else { - if ( color_node2 == NULL ) { - return FALSE; - } - } - - /* Bail if field flags differ. */ - if ( color_node1->field_flag != color_node2->field_flag ) { - return FALSE; - } - - /* Now take care of the case of either or both color fields being different. */ - if ( color_node1->color != color_node2->color ){ - return FALSE; - } - - /* Then take care of the case of either or both key fields being NULL. */ - if ( color_node1->key == NULL ) { - return ( color_node2->key == NULL ); - } else { - if ( color_node2->key == NULL ) { - return FALSE; - } - } - - /* Field flags are identical, so now compare the keys. */ - return (strcmp (color_node1->key, color_node2->key) == 0); + /* First take care of the case of either or both being NULL. */ + if ( color_node1 == NULL ) { + return ( color_node2 == NULL ); + } else { + if ( color_node2 == NULL ) { + return FALSE; + } + } + + /* Bail if field flags differ. */ + if ( color_node1->field_flag != color_node2->field_flag ) { + return FALSE; + } + + /* Now take care of the case of either or both color fields being different. */ + if ( color_node1->color != color_node2->color ){ + return FALSE; + } + + /* Then take care of the case of either or both key fields being NULL. */ + if ( color_node1->key == NULL ) { + return ( color_node2->key == NULL ); + } else { + if ( color_node2->key == NULL ) { + return FALSE; + } + } + + /* Field flags are identical, so now compare the keys. */ + return (strcmp (color_node1->key, color_node2->key) == 0); } /****************************************************************************/ @@ -172,37 +174,37 @@ gl_color_node_equal (glColorNode *color_node1, /****************************************************************************/ guint gl_color_node_expand (glColorNode *color_node, - glMergeRecord *record) + glMergeRecord *record) { - gchar* text; - GdkColor *gdk_color; - guint color; - - if (color_node->field_flag) { - if (record == NULL) { - return GL_COLOR_NONE; - } else { - text = gl_merge_eval_key (record, color_node->key); - if (text != NULL) { - gdk_color = g_new0 (GdkColor, 1); - if (gdk_color_parse (text, gdk_color)) - { - color = gl_color_from_gdk_color (gdk_color); - g_free (gdk_color); - return color; - } - else - { - g_free (gdk_color); - return GL_COLOR_NONE; - } - } else { - return GL_COLOR_NONE; - } - } - } else { - return color_node->color; - } + gchar* text; + GdkColor *gdk_color; + guint color; + + if (color_node->field_flag) { + if (record == NULL) { + return GL_COLOR_NONE; + } else { + text = gl_merge_eval_key (record, color_node->key); + if (text != NULL) { + gdk_color = g_new0 (GdkColor, 1); + if (gdk_color_parse (text, gdk_color)) + { + color = gl_color_from_gdk_color (gdk_color); + g_free (gdk_color); + return color; + } + else + { + g_free (gdk_color); + return GL_COLOR_NONE; + } + } else { + return GL_COLOR_NONE; + } + } + } else { + return color_node->color; + } } /****************************************************************************/ @@ -211,10 +213,10 @@ gl_color_node_expand (glColorNode *color_node, void gl_color_node_free (glColorNode **color_node) { - if ( *color_node == NULL ) return; + if ( *color_node == NULL ) return; - g_free ((*color_node)->key); - (*color_node)->key = NULL; - g_free (*color_node); - *color_node = NULL; + g_free ((*color_node)->key); + (*color_node)->key = NULL; + g_free (*color_node); + *color_node = NULL; } diff --git a/glabels2/src/color.h b/glabels2/src/color.h index ae0b2ae7..1faaa66a 100644 --- a/glabels2/src/color.h +++ b/glabels2/src/color.h @@ -1,9 +1,11 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * * color.h: various small utilities for dealing with canvas colors * - * Copyright (C) 2002 Jim Evins . + * Copyright (C) 2002-2007 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,19 +25,28 @@ #ifndef __COLOR_H__ #define __COLOR_H__ -#include #include "merge.h" +#include G_BEGIN_DECLS typedef struct { - gboolean field_flag; - guint color; - gchar *key; + gboolean field_flag; + guint color; + gchar *key; } glColorNode; -#define GL_COLOR(r,g,b) GNOME_CANVAS_COLOR(r,g,b) -#define GL_COLOR_A(r,g,b,a) GNOME_CANVAS_COLOR_A(r,g,b,a) + +#define GL_COLOR(r,g,b) ( (((unsigned int) (r) & 0xff) << 24) \ + | (((unsigned int) (g) & 0xff) << 16) \ + | (((unsigned int) (b) & 0xff) << 8) \ + | 0xff ) + +#define GL_COLOR_A(r,g,b,a) ( (((unsigned int) (r) & 0xff) << 24) \ + | (((unsigned int) (g) & 0xff) << 16) \ + | (((unsigned int) (b) & 0xff) << 8) \ + | ( (unsigned int) (a) & 0xff ) ) + #define GL_COLOR_NONE GL_COLOR_A(0,0,0,0) #define GL_COLOR_FILL_MERGE_DEFAULT GL_COLOR_A(255,255,255,128) @@ -43,6 +54,7 @@ typedef struct { #define GL_COLOR_SHADOW_DEFAULT GL_COLOR(0,0,0) #define GL_COLOR_SHADOW_MERGE_DEFAULT GL_COLOR_A(0,0,0,255) + #define GL_COLOR_I_RED(x) (((x)>>24) & 0xff) #define GL_COLOR_I_GREEN(x) (((x)>>16) & 0xff) #define GL_COLOR_I_BLUE(x) (((x)>>8) & 0xff) @@ -53,22 +65,26 @@ typedef struct { #define GL_COLOR_F_BLUE(x) ( (((x)>>8) & 0xff) / 255.0 ) #define GL_COLOR_F_ALPHA(x) ( ( (x) & 0xff) / 255.0 ) -guint gl_color_set_opacity (guint color, gdouble opacity); -GdkColor *gl_color_to_gdk_color (guint color); -guint gl_color_from_gdk_color (GdkColor *gdk_color); +guint gl_color_set_opacity (guint color, + gdouble opacity); + +GdkColor *gl_color_to_gdk_color (guint color); + +guint gl_color_from_gdk_color (GdkColor *gdk_color); + +guint gl_color_shadow (guint base_color, + gdouble opacity, + guint object_color); -guint gl_color_shadow (guint base_color, - gdouble opacity, - guint object_color); glColorNode *gl_color_node_new_default (); glColorNode *gl_color_node_dup (glColorNode *color_node); gboolean gl_color_node_equal (glColorNode *color_node1, - glColorNode *color_node2); + glColorNode *color_node2); guint gl_color_node_expand (glColorNode *color_node, - glMergeRecord *record); + glMergeRecord *record); void gl_color_node_free (glColorNode **color_node); diff --git a/glabels2/src/prefs-model.c b/glabels2/src/prefs-model.c index 881ad833..abe34b2b 100644 --- a/glabels2/src/prefs-model.c +++ b/glabels2/src/prefs-model.c @@ -78,13 +78,13 @@ #define DEFAULT_FONT_WEIGHT_STRING gl_util_weight_to_string (PANGO_WEIGHT_NORMAL) #define DEFAULT_FONT_ITALIC_FLAG FALSE #define DEFAULT_TEXT_ALIGN_STRING gl_util_align_to_string (PANGO_ALIGN_LEFT) -#define DEFAULT_TEXT_COLOR GNOME_CANVAS_COLOR (0,0,0) +#define DEFAULT_TEXT_COLOR GL_COLOR (0,0,0) #define DEFAULT_TEXT_LINE_SPACING 1.0 #define DEFAULT_LINE_WIDTH 1.0 -#define DEFAULT_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 255) +#define DEFAULT_LINE_COLOR GL_COLOR_A (0, 0, 0, 255) -#define DEFAULT_FILL_COLOR GNOME_CANVAS_COLOR_A (0, 255, 0, 255) +#define DEFAULT_FILL_COLOR GL_COLOR_A (0, 255, 0, 255) /*========================================================*/ /* Private types. */ diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 196219bf..b4b792d2 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -674,8 +674,6 @@ draw_text_object (PrintInfo *pi, guint color; glColorNode *color_node; gboolean auto_shrink; - ArtDRect bbox; - gdouble affine[6]; gdouble text_line_spacing; gboolean shadow_state; gdouble shadow_x, shadow_y; diff --git a/glabels2/src/wdgt-mini-preview.c b/glabels2/src/wdgt-mini-preview.c index 283c0325..9ef51d80 100644 --- a/glabels2/src/wdgt-mini-preview.c +++ b/glabels2/src/wdgt-mini-preview.c @@ -275,10 +275,6 @@ gl_wdgt_mini_preview_construct (glWdgtMiniPreview *preview, gint height, gint width) { - GnomeCanvasGroup *group; - GtkStyle *style; - guint shadow_color; - gl_debug (DEBUG_MINI_PREVIEW, "START"); preview->priv->height = height;