From 1f96e4e8cf4e39298501708c269654283779b80b Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 4 Sep 2002 03:58:48 +0000 Subject: [PATCH] Replaced hardcoded object defaults with defaults from prefs module. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@89 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/Makefile.am | 2 -- glabels2/src/color.c | 4 +++- glabels2/src/view-barcode.c | 9 ++++++++- glabels2/src/view-box.c | 24 +++++++----------------- glabels2/src/view-ellipse.c | 24 ++++++++---------------- glabels2/src/view-image.c | 4 ++-- glabels2/src/view-line.c | 16 +++++----------- glabels2/src/view-text.c | 16 ++++++++++++++++ 8 files changed, 49 insertions(+), 50 deletions(-) diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index 24068f4a..a9acaca8 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -185,8 +185,6 @@ glabels_SOURCES = \ glabels_batch_SOURCES = \ glabels-batch.c \ - prefs.c \ - prefs.h \ print.c \ print.h \ bc.c \ diff --git a/glabels2/src/color.c b/glabels2/src/color.c index d8caf6c4..7a49f02e 100644 --- a/glabels2/src/color.c +++ b/glabels2/src/color.c @@ -32,6 +32,8 @@ gl_color_set_opacity (guint 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; } diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index 364b24fe..f88c338e 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -34,6 +34,8 @@ #include "wdgt-bc-props.h" #include "wdgt-bc-style.h" #include "wdgt-position.h" +#include "color.h" +#include "prefs.h" #include "pixmaps/cursor_barcode.xbm" #include "pixmaps/cursor_barcode_mask.xbm" @@ -645,7 +647,7 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas, gl_label_barcode_set_props (GL_LABEL_BARCODE(object), GL_BARCODE_STYLE_POSTNET, FALSE, - GNOME_CANVAS_COLOR_A (0,0,0,255), + gl_color_set_opacity (gl_prefs->default_line_color, 0.5), 1.0); view_barcode = gl_view_barcode_new (GL_LABEL_BARCODE(object), view); @@ -668,6 +670,11 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas, event->button.y, &x, &y); gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); + gl_label_barcode_set_props (GL_LABEL_BARCODE(object), + GL_BARCODE_STYLE_POSTNET, + FALSE, + gl_prefs->default_line_color, + 1.0); gl_view_unselect_all (view); gl_view_object_select (GL_VIEW_OBJECT(view_barcode)); gl_view_arrow_mode (view); diff --git a/glabels2/src/view-box.c b/glabels2/src/view-box.c index 6fe809dd..e4e270ff 100644 --- a/glabels2/src/view-box.c +++ b/glabels2/src/view-box.c @@ -31,6 +31,8 @@ #include "wdgt-fill.h" #include "wdgt-size.h" #include "wdgt-position.h" +#include "color.h" +#include "prefs.h" #include "pixmaps/cursor_box.xbm" #include "pixmaps/cursor_box_mask.xbm" @@ -40,11 +42,6 @@ /*========================================================*/ /* Private macros and constants. */ /*========================================================*/ -#define CREATE_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 192) -#define CREATE_FILL_COLOR GNOME_CANVAS_COLOR_A (0, 255, 0, 192) - -#define DEFAULT_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 255) -#define DEFAULT_FILL_COLOR GNOME_CANVAS_COLOR_A (0, 255, 0, 255) #define DELTA 0.01 @@ -603,7 +600,6 @@ gl_view_box_create_event_handler (GnomeCanvas *canvas, static gboolean dragging = FALSE; static glViewObject *view_box; static GObject *object; - gdouble line_width; guint line_color, fill_color; gdouble x, y, w, h; @@ -624,17 +620,15 @@ gl_view_box_create_event_handler (GnomeCanvas *canvas, gnome_canvas_window_to_world (canvas, event->button.x, event->button.y, &x, &y); - gl_debug (DEBUG_VIEW, "BUTTON_PRESS (%f, %f) -> (%f, %f)", event->button.x, event->button.y, x, y); object = gl_label_box_new (view->label); gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); gl_label_object_set_size (GL_LABEL_OBJECT(object), 0.0, 0.0); - line_width = 1.0; - line_color = CREATE_LINE_COLOR; - fill_color = CREATE_FILL_COLOR; + line_color = gl_color_set_opacity (gl_prefs->default_line_color, 0.5); + fill_color = gl_color_set_opacity (gl_prefs->default_fill_color, 0.5); gl_label_box_set_line_width (GL_LABEL_BOX(object), - line_width); + gl_prefs->default_line_width); gl_label_box_set_line_color (GL_LABEL_BOX(object), line_color); gl_label_box_set_fill_color (GL_LABEL_BOX(object), @@ -657,7 +651,6 @@ gl_view_box_create_event_handler (GnomeCanvas *canvas, gnome_canvas_window_to_world (canvas, event->button.x, event->button.y, &x, &y); - gl_debug (DEBUG_VIEW, "BUTTON_RELEASE (%f, %f) -> (%f, %f)", event->button.x, event->button.y, x, y); if ((x0 == x) && (y0 == y)) { x = x0 + 36.0; y = y0 + 36.0; @@ -668,12 +661,10 @@ gl_view_box_create_event_handler (GnomeCanvas *canvas, h = MAX (y, y0) - MIN (y, y0); gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); - line_color = DEFAULT_LINE_COLOR; - fill_color = DEFAULT_FILL_COLOR; gl_label_box_set_line_color (GL_LABEL_BOX(object), - line_color); + gl_prefs->default_line_color); gl_label_box_set_fill_color (GL_LABEL_BOX(object), - fill_color); + gl_prefs->default_fill_color); gl_view_unselect_all (view); gl_view_object_select (GL_VIEW_OBJECT(view_box)); gl_view_arrow_mode (view); @@ -690,7 +681,6 @@ gl_view_box_create_event_handler (GnomeCanvas *canvas, event->motion.y, &x, &y); gl_label_object_set_position (GL_LABEL_OBJECT(object), MIN (x, x0), MIN (y, y0)); - gl_debug (DEBUG_VIEW, "BUTTON_MOTION (%f, %f) -> (%f, %f)", event->button.x, event->button.y, x, y); w = MAX (x, x0) - MIN (x, x0); h = MAX (y, y0) - MIN (y, y0); gl_label_object_set_size (GL_LABEL_OBJECT(object), diff --git a/glabels2/src/view-ellipse.c b/glabels2/src/view-ellipse.c index fe6100a3..80c3ab24 100644 --- a/glabels2/src/view-ellipse.c +++ b/glabels2/src/view-ellipse.c @@ -31,6 +31,8 @@ #include "wdgt-fill.h" #include "wdgt-size.h" #include "wdgt-position.h" +#include "color.h" +#include "prefs.h" #include "pixmaps/cursor_ellipse.xbm" #include "pixmaps/cursor_ellipse_mask.xbm" @@ -40,11 +42,6 @@ /*========================================================*/ /* Private macros and constants. */ /*========================================================*/ -#define CREATE_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 192) -#define CREATE_FILL_COLOR GNOME_CANVAS_COLOR_A (0, 255, 0, 192) - -#define DEFAULT_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 255) -#define DEFAULT_FILL_COLOR GNOME_CANVAS_COLOR_A (0, 255, 0, 255) #define DELTA 0.01 @@ -594,7 +591,7 @@ gl_view_ellipse_get_create_cursor (void) } /*****************************************************************************/ -/* Canvas event handler for creating ellipse objects. */ +/* Canvas event handler for creating ellipse objects. */ /*****************************************************************************/ int gl_view_ellipse_create_event_handler (GnomeCanvas *canvas, @@ -605,7 +602,6 @@ gl_view_ellipse_create_event_handler (GnomeCanvas *canvas, static gboolean dragging = FALSE; static glViewObject *view_ellipse; static GObject *object; - gdouble line_width; guint line_color, fill_color; gdouble x, y, w, h; @@ -631,12 +627,10 @@ gl_view_ellipse_create_event_handler (GnomeCanvas *canvas, x, y); gl_label_object_set_size (GL_LABEL_OBJECT(object), 0.0, 0.0); - line_width = 1.0; - line_color = CREATE_LINE_COLOR; - fill_color = CREATE_FILL_COLOR; + line_color = gl_color_set_opacity (gl_prefs->default_line_color, 0.5); + fill_color = gl_color_set_opacity (gl_prefs->default_fill_color, 0.5); gl_label_ellipse_set_line_width (GL_LABEL_ELLIPSE(object), - line_width); - gl_label_ellipse_set_line_color (GL_LABEL_ELLIPSE(object), + gl_prefs->default_line_width); gl_label_ellipse_set_line_color (GL_LABEL_ELLIPSE(object), line_color); gl_label_ellipse_set_fill_color (GL_LABEL_ELLIPSE(object), fill_color); @@ -668,12 +662,10 @@ gl_view_ellipse_create_event_handler (GnomeCanvas *canvas, h = MAX (y, y0) - MIN (y, y0); gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); - line_color = DEFAULT_LINE_COLOR; - fill_color = DEFAULT_FILL_COLOR; gl_label_ellipse_set_line_color (GL_LABEL_ELLIPSE(object), - line_color); + gl_prefs->default_line_color); gl_label_ellipse_set_fill_color (GL_LABEL_ELLIPSE(object), - fill_color); + gl_prefs->default_fill_color); gl_view_unselect_all (view); gl_view_object_select (GL_VIEW_OBJECT(view_ellipse)); gl_view_arrow_mode (view); diff --git a/glabels2/src/view-image.c b/glabels2/src/view-image.c index a9c8741f..13615201 100644 --- a/glabels2/src/view-image.c +++ b/glabels2/src/view-image.c @@ -588,7 +588,7 @@ gl_view_image_get_create_cursor (void) } /*****************************************************************************/ -/* Canvas event handler for creating image objects. */ +/* Canvas event handler for creating image objects. */ /*****************************************************************************/ int gl_view_image_create_event_handler (GnomeCanvas *canvas, @@ -626,7 +626,7 @@ gl_view_image_create_event_handler (GnomeCanvas *canvas, gl_label_object_set_size (GL_LABEL_OBJECT(object), 0.0, 0.0); view_image = gl_view_image_new (GL_LABEL_IMAGE(object), - view); + view); x0 = x; y0 = y; return TRUE; diff --git a/glabels2/src/view-line.c b/glabels2/src/view-line.c index 511f6c99..e80f0bb5 100644 --- a/glabels2/src/view-line.c +++ b/glabels2/src/view-line.c @@ -30,6 +30,8 @@ #include "wdgt-line.h" #include "wdgt-vector.h" #include "wdgt-position.h" +#include "color.h" +#include "prefs.h" #include "pixmaps/cursor_line.xbm" #include "pixmaps/cursor_line_mask.xbm" @@ -39,9 +41,6 @@ /*========================================================*/ /* Private macros and constants. */ /*========================================================*/ -#define CREATE_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 192) - -#define DEFAULT_LINE_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 255) /*========================================================*/ /* Private types. */ @@ -561,8 +560,6 @@ gl_view_line_create_event_handler (GnomeCanvas *canvas, static gboolean dragging = FALSE; static glViewObject *view_line; static GObject *object; - gdouble line_width; - guint line_color; gdouble x, y, w, h; gl_debug (DEBUG_VIEW, ""); @@ -587,12 +584,10 @@ gl_view_line_create_event_handler (GnomeCanvas *canvas, x, y); gl_label_object_set_size (GL_LABEL_OBJECT(object), 0.0, 0.0); - line_width = 1.0; - line_color = CREATE_LINE_COLOR; gl_label_line_set_line_width (GL_LABEL_LINE(object), - line_width); + gl_prefs->default_line_width); gl_label_line_set_line_color (GL_LABEL_LINE(object), - line_color); + gl_color_set_opacity (gl_prefs->default_line_color, 0.5)); view_line = gl_view_line_new (GL_LABEL_LINE(object), view); x0 = x; @@ -619,9 +614,8 @@ gl_view_line_create_event_handler (GnomeCanvas *canvas, h = y - y0; gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); - line_color = DEFAULT_LINE_COLOR; gl_label_line_set_line_color (GL_LABEL_LINE(object), - line_color); + gl_prefs->default_line_color); gl_view_unselect_all (view); gl_view_object_select (GL_VIEW_OBJECT(view_line)); gl_view_arrow_mode (view); diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index f38c4ae3..0e69702a 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -33,6 +33,8 @@ #include "wdgt-text-entry.h" #include "wdgt-text-props.h" #include "wdgt-position.h" +#include "color.h" +#include "prefs.h" #include "pixmaps/cursor_text.xbm" #include "pixmaps/cursor_text_mask.xbm" @@ -602,6 +604,13 @@ gl_view_text_create_event_handler (GnomeCanvas *canvas, object = gl_label_text_new (view->label); gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); + gl_label_text_set_props (GL_LABEL_TEXT(object), + gl_prefs->default_font_family, + gl_prefs->default_font_size, + gl_prefs->default_font_weight, + gl_prefs->default_font_italic_flag, + gl_color_set_opacity (gl_prefs->default_text_color, 0.5), + gl_prefs->default_text_alignment); lines = gl_text_node_lines_new_from_text (_("Text")); gl_label_text_set_lines (GL_LABEL_TEXT(object), lines); view_text = gl_view_text_new (GL_LABEL_TEXT(object), @@ -625,6 +634,13 @@ gl_view_text_create_event_handler (GnomeCanvas *canvas, event->button.y, &x, &y); gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); + gl_label_text_set_props (GL_LABEL_TEXT(object), + gl_prefs->default_font_family, + gl_prefs->default_font_size, + gl_prefs->default_font_weight, + gl_prefs->default_font_italic_flag, + gl_prefs->default_text_color, + gl_prefs->default_text_alignment); gl_view_unselect_all (view); gl_view_object_select (GL_VIEW_OBJECT(view_text)); gl_view_arrow_mode (view); -- 2.39.5