X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=glabels2%2Fsrc%2Fview-barcode.c;h=a7bbfc60133eb3810e315113e48c0f145e979308;hb=6836860e2dab3b384e89982b8df9856b64c6c911;hp=364b24fe9e81ebc079ca0f4391d95dff76a34f71;hpb=84a5fe2c73ed0ecd311133364f5e53d336cdc122;p=glabels diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index 364b24fe..a7bbfc60 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -1,9 +1,9 @@ /* * (GLABELS) Label and Business Card Creation program for GNOME * - * view_barcode.c: GLabels label barcode object widget + * view_text.c: GLabels label text object widget * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2003 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 @@ -26,14 +26,11 @@ #include "view-barcode.h" #include "canvas-hacktext.h" - #include "view-highlight.h" -#include "glabels.h" -#include "wdgt-bc-data.h" -#include "wdgt-bc-props.h" -#include "wdgt-bc-style.h" -#include "wdgt-position.h" +#include "color.h" +#include "object-editor.h" +#include "stock.h" #include "pixmaps/cursor_barcode.xbm" #include "pixmaps/cursor_barcode_mask.xbm" @@ -50,17 +47,8 @@ struct _glViewBarcodePrivate { - GList *item_list; - - /* Page 0 widgets */ - GtkWidget *bc_data; - - /* Page 1 widgets */ - GtkWidget *bc_props; - GtkWidget *bc_style; + GList *item_list; - /* Page 2 widgets */ - GtkWidget *position; }; /*========================================================*/ @@ -74,35 +62,31 @@ static glViewObjectClass *parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_barcode_class_init (glViewBarcodeClass *klass); -static void gl_view_barcode_instance_init (glViewBarcode *view_barcode); -static void gl_view_barcode_finalize (GObject *object); +static void gl_view_barcode_class_init (glViewBarcodeClass *klass); +static void gl_view_barcode_instance_init (glViewBarcode *view_bc); +static void gl_view_barcode_finalize (GObject *object); -static void update_view_barcode_cb (glLabelObject *object, - glViewBarcode *view_barcode); +static GtkWidget *construct_properties_editor (glViewObject *view_object); -static GtkWidget *construct_properties_dialog (glViewBarcode *view_barcode); +static void update_canvas_item_from_object_cb (glLabelObject *object, + glViewBarcode *view_bc); -static void response_cb (GtkDialog *dialog, - gint response, - glViewBarcode *view_barcode); +static void update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object); -static void bc_data_changed_cb (glWdgtBCData *bc_data, - glViewBarcode *view_barcode); +static void update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor); -static void bc_props_changed_cb (glWdgtBCProps *bc_props, - glViewBarcode *view_barcode); +static void update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor); -static void bc_style_changed_cb (glWdgtBCStyle *bc_style, - glViewBarcode *view_barcode); +static void update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor); -static void position_changed_cb (glWdgtPosition *position, - glViewBarcode *view_barcode); +static void draw_barcode (glViewBarcode *view_bc); -static void update_dialog_cb (glLabelObject *object, - glViewBarcode *view_barcode); - -static void draw_barcode (glViewBarcode *view_barcode); /*****************************************************************************/ @@ -136,7 +120,8 @@ gl_view_barcode_get_type (void) static void gl_view_barcode_class_init (glViewBarcodeClass *klass) { - GObjectClass *object_class = (GObjectClass *) klass; + GObjectClass *object_class = (GObjectClass *) klass; + glViewObjectClass *view_object_class = (glViewObjectClass *) klass; gl_debug (DEBUG_VIEW, "START"); @@ -144,15 +129,17 @@ gl_view_barcode_class_init (glViewBarcodeClass *klass) object_class->finalize = gl_view_barcode_finalize; + view_object_class->construct_editor = construct_properties_editor; + gl_debug (DEBUG_VIEW, "END"); } static void -gl_view_barcode_instance_init (glViewBarcode *view_barcode) +gl_view_barcode_instance_init (glViewBarcode *view_bc) { gl_debug (DEBUG_VIEW, "START"); - view_barcode->private = g_new0 (glViewBarcodePrivate, 1); + view_bc->private = g_new0 (glViewBarcodePrivate, 1); gl_debug (DEBUG_VIEW, "END"); } @@ -178,394 +165,212 @@ glViewObject * gl_view_barcode_new (glLabelBarcode *object, glView *view) { - glViewBarcode *view_barcode; + glViewBarcode *view_bc; GtkMenu *menu; - GtkWidget *dialog; gl_debug (DEBUG_VIEW, "START"); g_return_if_fail (object && GL_IS_LABEL_BARCODE (object)); g_return_if_fail (view && GL_IS_VIEW (view)); - view_barcode = g_object_new (gl_view_barcode_get_type(), NULL); + view_bc = g_object_new (gl_view_barcode_get_type(), NULL); - gl_view_object_set_view (GL_VIEW_OBJECT(view_barcode), view); - gl_view_object_set_object (GL_VIEW_OBJECT(view_barcode), + gl_view_object_set_view (GL_VIEW_OBJECT(view_bc), view); + gl_view_object_set_object (GL_VIEW_OBJECT(view_bc), GL_LABEL_OBJECT(object), - GL_VIEW_HIGHLIGHT_SIMPLE); + GL_VIEW_HIGHLIGHT_BOX_RESIZABLE); /* Create analogous canvas items. */ - draw_barcode (view_barcode); + draw_barcode (view_bc); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_view_barcode_cb), view_barcode); - - /* Create a dialog for controlling/viewing object properties. */ - dialog = construct_properties_dialog (view_barcode); - gl_view_object_set_dialog (GL_VIEW_OBJECT(view_barcode), dialog); + G_CALLBACK (update_canvas_item_from_object_cb), view_bc); gl_debug (DEBUG_VIEW, "END"); - return GL_VIEW_OBJECT (view_barcode); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -update_view_barcode_cb (glLabelObject *object, - glViewBarcode *view_barcode) -{ - glView *view; - GnomeCanvasItem *group; - - gl_debug (DEBUG_VIEW, "START"); - - view = gl_view_object_get_view (GL_VIEW_OBJECT(view_barcode)); - - /* Adjust appearance of analogous canvas items. */ - draw_barcode (view_barcode); - - /* Adjust highlight */ - gl_view_object_update_highlight (GL_VIEW_OBJECT(view_barcode)); - - gl_debug (DEBUG_VIEW, "END"); + return GL_VIEW_OBJECT (view_bc); } /*****************************************************************************/ -/* Create a properties dialog for a barcode object. */ +/* Create a properties editor for a barcode object. */ /*****************************************************************************/ static GtkWidget * -construct_properties_dialog (glViewBarcode *view_barcode) +construct_properties_editor (glViewObject *view_object) { - GtkWidget *dialog, *notebook, *wvbox, *wbutton; - BonoboWindow *win = glabels_get_active_window (); + GtkWidget *editor; + glViewBarcode *view_bc = (glViewBarcode *)view_object; glLabelObject *object; - gdouble x, y, w, h, label_width, label_height; - glTextNode *text_node; - glBarcodeStyle style; - gboolean text_flag; - guint color; - gdouble scale; - glMerge *merge; gl_debug (DEBUG_VIEW, "START"); - /* retrieve object and query parameters */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object)); - gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &color, &scale); - gl_label_get_size (GL_LABEL(object->parent), - &label_width, &label_height); - merge = gl_label_get_merge (GL_LABEL(object->parent)); + object = gl_view_object_get_object (GL_VIEW_OBJECT(view_bc)); - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - gl_debug (DEBUG_VIEW, "Creating dialog..."); - dialog = gtk_dialog_new_with_buttons ( _("Edit barcode object properties"), - GTK_WINDOW (win), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL ); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (response_cb), view_barcode); - - notebook = gtk_notebook_new (); - gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), - notebook, TRUE, TRUE, 0); - - /*---------------------------*/ - /* Data Notebook Tab */ - /*---------------------------*/ - gl_debug (DEBUG_VIEW, "Creating data tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, - gtk_label_new (_("Data"))); - - /* barcode data */ - gl_debug (DEBUG_VIEW, "Creating data entry..."); - view_barcode->private->bc_data = - gl_wdgt_bc_data_new (_("Barcode data"), merge->field_defs); - gl_debug (DEBUG_VIEW, "1"); - gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data), - (merge->type != GL_MERGE_NONE), - text_node); - gl_debug (DEBUG_VIEW, "2"); - gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_data, - FALSE, FALSE, 0); - gl_debug (DEBUG_VIEW, "3"); - g_signal_connect ( G_OBJECT(view_barcode->private->bc_data), - "changed", G_CALLBACK (bc_data_changed_cb), - view_barcode); - - - /*---------------------------*/ - /* Appearance Notebook Tab */ - /*---------------------------*/ - gl_debug (DEBUG_VIEW, "Creating props tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, - gtk_label_new (_("Appearance"))); - - /* barcode props entry */ - gl_debug (DEBUG_VIEW, "Creating props entry..."); - view_barcode->private->bc_props = - gl_wdgt_bc_props_new (_("Barcode Properties")); - gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props), - scale, color); - gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_props, - FALSE, FALSE, 0); - g_signal_connect ( G_OBJECT(view_barcode->private->bc_props), - "changed", G_CALLBACK (bc_props_changed_cb), - view_barcode); - - /* ------ Barcode Style Frame ------ */ - view_barcode->private->bc_style = gl_wdgt_bc_style_new (_("Style")); - gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style), - style, text_flag); - gtk_box_pack_start (GTK_BOX (wvbox), view_barcode->private->bc_style, - FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (view_barcode->private->bc_style), - "changed", G_CALLBACK (bc_style_changed_cb), - view_barcode); - - - /*----------------------------*/ - /* Position/Size Notebook Tab */ - /*----------------------------*/ - gl_debug (DEBUG_VIEW, "Creating position tab..."); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), wvbox, - gtk_label_new (_("Position"))); - - /* ------ Position Frame ------ */ - gl_debug (DEBUG_VIEW, "Creating position entry..."); - view_barcode->private->position = gl_wdgt_position_new (_("Position")); - gl_wdgt_position_set_params (GL_WDGT_POSITION (view_barcode->private->position), - x, y, - label_width, label_height); - gtk_box_pack_start (GTK_BOX (wvbox), - view_barcode->private->position, - FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (view_barcode->private->position), - "changed", - G_CALLBACK(position_changed_cb), view_barcode); - - - /*----------------------------*/ - /* Track object changes. */ - /*----------------------------*/ + /* Build editor. */ + editor = gl_object_editor_new (GL_STOCK_BARCODE, _("Barcode object properties"), + GL_OBJECT_EDITOR_POSITION_PAGE, + GL_OBJECT_EDITOR_SIZE_PAGE, + GL_OBJECT_EDITOR_BC_PAGE, + GL_OBJECT_EDITOR_DATA_PAGE, + 0); + + /* Update */ + update_editor_from_object_cb (object, GL_OBJECT_EDITOR(editor)); + update_editor_from_move_cb (object, 0, 0, GL_OBJECT_EDITOR(editor)); + update_editor_from_label_cb (object->parent, GL_OBJECT_EDITOR(editor)); + + /* Connect signals. */ + g_signal_connect (G_OBJECT (editor), "changed", + G_CALLBACK(update_object_from_editor_cb), object); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_dialog_cb), view_barcode); + G_CALLBACK (update_editor_from_object_cb), editor); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_editor_from_move_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "size_changed", + G_CALLBACK (update_editor_from_label_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "merge_changed", + G_CALLBACK (update_editor_from_label_cb), editor); gl_debug (DEBUG_VIEW, "END"); - return dialog; + return editor; } /*---------------------------------------------------------------------------*/ -/* PRIVATE. "Response" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -response_cb (GtkDialog *dialog, - gint response, - glViewBarcode *view_barcode) +update_canvas_item_from_object_cb (glLabelObject *object, + glViewBarcode *view_bc) { gl_debug (DEBUG_VIEW, "START"); - g_return_if_fail(dialog != NULL); - g_return_if_fail(GTK_IS_DIALOG(dialog)); - - switch(response) { - case GTK_RESPONSE_CLOSE: - gtk_widget_hide (GTK_WIDGET(dialog)); - break; - default: - g_assert_not_reached(); - } + /* Adjust appearance of analogous canvas item. */ + draw_barcode (view_bc); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. barcode data "changed" callback. */ +/* PRIVATE. editor "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -bc_data_changed_cb (glWdgtBCData *bc_data, - glViewBarcode *view_barcode) +update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object) { - glLabelObject *object; - glTextNode *text_node; + gdouble x, y, w, h; + glTextNode *text_node; + glBarcodeStyle style; + gboolean text_flag, cs_flag; + guint color; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); - - text_node = gl_wdgt_bc_data_get_data (bc_data); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - - gl_text_node_free (&text_node); - - gl_debug (DEBUG_VIEW, "END"); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. barcode props "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -bc_props_changed_cb (glWdgtBCProps *text_props, - glViewBarcode *view_barcode) -{ - glLabelObject *object; - glBarcodeStyle style; - gboolean text_flag; - guint color; - gdouble scale; + update_editor_from_object_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); - gl_debug (DEBUG_VIEW, "START"); + gl_object_editor_get_position (editor, &x, &y); + gl_label_object_set_position (object, x, y); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); + gl_object_editor_get_size (editor, &w, &h); + gl_label_object_set_size (object, w, h); - gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &color, &scale); - gl_wdgt_bc_props_get_params (text_props, &scale, &color); + text_node = gl_object_editor_get_data (editor); + gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node); + gl_text_node_free (&text_node); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); + gl_object_editor_get_bc_style (editor, &style, &text_flag, &cs_flag); + color = gl_object_editor_get_bc_color (editor); gl_label_barcode_set_props (GL_LABEL_BARCODE(object), - style, text_flag, color, scale); + style, text_flag, cs_flag); + gl_label_object_set_line_color (object, color); + + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_object_cb, + editor); g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); + update_editor_from_move_cb, + editor); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. barcode style "changed" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -bc_style_changed_cb (glWdgtBCStyle *bc_style, - glViewBarcode *view_barcode) +update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor) { - glLabelObject *object; + gdouble w, h; + glTextNode *text_node; glBarcodeStyle style; - gboolean text_flag; + gboolean text_flag, cs_flag; guint color; - gdouble scale; - + glMerge *merge; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); + gl_label_object_get_size (object, &w, &h); + gl_object_editor_set_size (editor, w, h); gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &color, &scale); - gl_wdgt_bc_style_get_params (bc_style, &style, &text_flag); + &style, &text_flag, &cs_flag); + color = gl_label_object_get_line_color (object); + gl_object_editor_set_bc_style (editor, style, text_flag, cs_flag); + gl_object_editor_set_bc_color (editor, color); + + text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE(object)); + merge = gl_label_get_merge (GL_LABEL(object->parent)); + gl_object_editor_set_data (editor, (merge != NULL), text_node); + gl_text_node_free (&text_node); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - gl_label_barcode_set_props (GL_LABEL_BARCODE(object), - style, text_flag, color, scale); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. position "changed" callback. */ +/* PRIVATE. label object "moved" callback. */ /*---------------------------------------------------------------------------*/ static void -position_changed_cb (glWdgtPosition *position, - glViewBarcode *view_barcode) +update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor) { - glLabelObject *object; gdouble x, y; gl_debug (DEBUG_VIEW, "START"); - gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y); - - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); - - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); + gl_label_object_get_position (object, &x, &y); + gl_object_editor_set_position (editor, x, y); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ +/* PRIVATE. label "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_cb (glLabelObject *object, - glViewBarcode *view_barcode) +update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor) { - gdouble x, y; - glTextNode *text_node; - glBarcodeStyle style; - gboolean text_flag; - guint color; - gdouble scale; - glMerge *merge; + gdouble label_width, label_height; + glMerge *merge; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object)); - gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &color, &scale); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - merge = gl_label_get_merge (GL_LABEL(object->parent)); + gl_label_get_size (label, &label_width, &label_height); + gl_object_editor_set_max_position (GL_OBJECT_EDITOR (editor), + label_width, label_height); + gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor), + label_width, label_height); - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_data), - bc_data_changed_cb, view_barcode); - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_props), - bc_props_changed_cb, view_barcode); - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_style), - bc_style_changed_cb, view_barcode); - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position), - position_changed_cb, view_barcode); - - /* Update widgets in property dialog */ - - gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data), - (merge->type != GL_MERGE_NONE), - text_node); - gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props), - scale, color); - gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style), - style, text_flag); - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position), - x, y); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_data), - bc_data_changed_cb, view_barcode); - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_props), - bc_props_changed_cb, view_barcode); - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_style), - bc_style_changed_cb, view_barcode); - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position), - position_changed_cb, view_barcode); - - gl_text_node_free (&text_node); + merge = gl_label_get_merge (label); + gl_object_editor_set_key_names (editor, merge); gl_debug (DEBUG_VIEW, "END"); } @@ -627,12 +432,11 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas, switch (event->button.button) { case 1: dragging = TRUE; - gdk_pointer_grab (GTK_WIDGET (view->canvas)->window, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, NULL, event->button.time); + gnome_canvas_item_grab (canvas->root, + GDK_POINTER_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_BUTTON_PRESS_MASK, + NULL, event->button.time); gnome_canvas_window_to_world (canvas, event->button.x, event->button.y, &x, &y); @@ -645,8 +449,11 @@ 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), - 1.0); + TRUE); + gl_label_object_set_line_color (GL_LABEL_OBJECT(object), + gl_color_set_opacity ( + gl_view_get_default_line_color(view), + 0.5)); view_barcode = gl_view_barcode_new (GL_LABEL_BARCODE(object), view); x0 = x; @@ -662,12 +469,18 @@ gl_view_barcode_create_event_handler (GnomeCanvas *canvas, switch (event->button.button) { case 1: dragging = FALSE; - gdk_pointer_ungrab (event->button.time); + gnome_canvas_item_ungrab (canvas->root, event->button.time); gnome_canvas_window_to_world (canvas, event->button.x, 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, + TRUE); + gl_label_object_set_line_color (GL_LABEL_OBJECT(object), + gl_view_get_default_line_color(view)); gl_view_unselect_all (view); gl_view_object_select (GL_VIEW_OBJECT(view_barcode)); gl_view_arrow_mode (view); @@ -703,12 +516,13 @@ static void draw_barcode (glViewBarcode *view_barcode) { glLabelObject *object; - GnomeCanvasItem *group, *item; + GnomeCanvasItem *item; glTextNode *text_node; glBarcodeStyle style; gboolean text_flag; + gboolean checksum_flag; guint color; - gdouble scale; + gdouble w, h; glBarcodeLine *line; glBarcodeChar *bchar; glBarcode *gbc; @@ -725,7 +539,9 @@ draw_barcode (glViewBarcode *view_barcode) /* Query label object and properties */ object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &color, &scale); + &style, &text_flag, &checksum_flag); + color = gl_label_object_get_line_color (object); + gl_label_object_get_size (object, &w, &h); text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object)); if (text_node->field_flag) { digits = gl_barcode_default_digits (style); @@ -733,9 +549,6 @@ draw_barcode (glViewBarcode *view_barcode) digits = gl_text_node_expand (text_node, NULL); } - /* get parent item/group to render to. */ - group = gl_view_object_get_group (GL_VIEW_OBJECT(view_barcode)); - /* remove previous items from group. */ for (li = view_barcode->private->item_list; li!=NULL; li = li->next) { gl_debug (DEBUG_VIEW, "in loop"); @@ -752,7 +565,7 @@ draw_barcode (glViewBarcode *view_barcode) FALSE, 10.0); - gbc = gl_barcode_new (style, text_flag, scale, digits); + gbc = gl_barcode_new (style, text_flag, checksum_flag, w, h, digits); if (gbc == NULL) { cstring = _("Invalid barcode"); @@ -763,11 +576,11 @@ draw_barcode (glViewBarcode *view_barcode) strlen (cstring)); y_offset = 10.0 - gnome_font_get_descender (font); - item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group), - gl_canvas_hacktext_get_type (), - "x", 0.0, - "y", y_offset, - "glyphlist", glyphlist, NULL); + item = gl_view_object_item_new (GL_VIEW_OBJECT(view_barcode), + gl_canvas_hacktext_get_type (), + "x", 0.0, + "y", y_offset, + "glyphlist", glyphlist, NULL); view_barcode->private->item_list = g_list_prepend (view_barcode->private->item_list, item); @@ -782,13 +595,12 @@ draw_barcode (glViewBarcode *view_barcode) points->coords[2] = line->x; points->coords[3] = line->y + line->length; - item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (group), - gnome_canvas_line_get_type - (), "points", points, - "width_units", line->width, - "fill_color_rgba", color, - NULL); + item = gl_view_object_item_new (GL_VIEW_OBJECT(view_barcode), + gnome_canvas_line_get_type (), + "points", points, + "width_units", line->width, + "fill_color_rgba", color, + NULL); view_barcode->private->item_list = g_list_prepend (view_barcode->private->item_list, item); } @@ -811,13 +623,12 @@ draw_barcode (glViewBarcode *view_barcode) 1); y_offset = bchar->fsize - gnome_font_get_descender (font); - item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (group), - gnome_canvas_hacktext_get_type - (), "x", bchar->x, "y", - bchar->y + y_offset, - "glyphlist", glyphlist, - NULL); + item = gl_view_object_item_new (GL_VIEW_OBJECT(view_barcode), + gl_canvas_hacktext_get_type (), + "x", bchar->x, + "y", bchar->y + y_offset, + "glyphlist", glyphlist, + NULL); view_barcode->private->item_list = g_list_prepend (view_barcode->private->item_list, item);