]> git.sur5r.net Git - glabels/commitdiff
Replaced hardcoded object defaults with defaults from prefs module.
authorJim Evins <evins@snaught.com>
Wed, 4 Sep 2002 03:58:48 +0000 (03:58 +0000)
committerJim Evins <evins@snaught.com>
Wed, 4 Sep 2002 03:58:48 +0000 (03:58 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@89 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/Makefile.am
glabels2/src/color.c
glabels2/src/view-barcode.c
glabels2/src/view-box.c
glabels2/src/view-ellipse.c
glabels2/src/view-image.c
glabels2/src/view-line.c
glabels2/src/view-text.c

index 24068f4ab0801e98721403c226e2850ae58c834c..a9acaca8a6cb9b1a6ae6f86f34783cf0f631990f 100644 (file)
@@ -185,8 +185,6 @@ glabels_SOURCES =                   \
 
 glabels_batch_SOURCES =                \
        glabels-batch.c                 \
-       prefs.c                         \
-       prefs.h                         \
        print.c                         \
        print.h                         \
        bc.c                            \
index d8caf6c4a40085c41b30dadb1f582697367841df..7a49f02e9ac0a10d0d2d3a6884f591f2c651ff51 100644 (file)
@@ -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;
 }
 
index 364b24fe9e81ebc079ca0f4391d95dff76a34f71..f88c338e6842845905a47d33db9cd18c398d5acf 100644 (file)
@@ -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);
index 6fe809ddbc94cbc31a49e0d546e8fbacb9db7f43..e4e270ff9e803137a227272b1d8c306994d77db9 100644 (file)
@@ -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"
 /*========================================================*/
 /* 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),
index fe6100a31ab549cbe02e3be8cc58804d7d5040f5..80c3ab24475aea2826904548d2fa7843bead1e79 100644 (file)
@@ -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"
 /*========================================================*/
 /* 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);
index a9c8741f742eaf8fcff246496e2d6cc5d0056931..13615201ddf935a29909dc74508775417e9b505a 100644 (file)
@@ -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;
index 511f6c99099663c242e9ee7aabb898b50a62cb57..e80f0bb51651a0a3cc10bffc10b25719d6602820 100644 (file)
@@ -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);
index f38c4ae355225014223279f210309e6320514e19..0e69702ab3206157ebd524d55393f9a76c6ad7dc 100644 (file)
@@ -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);