diff options
Diffstat (limited to 'glabels1/src')
132 files changed, 0 insertions, 25813 deletions
diff --git a/glabels1/src/Makefile.am b/glabels1/src/Makefile.am deleted file mode 100644 index a7034c9..0000000 --- a/glabels1/src/Makefile.am +++ /dev/null @@ -1,176 +0,0 @@ -LIB_BARCODE_DIR = ../barcode-0.98 - -SUBDIRS = pixmaps - -INCLUDES = \ - -I$(top_srcdir)/intl \ - $(GNOME_INCLUDEDIR) \ - $(GNOME_XML_CFLAGS) \ - $(GNOME_PRINT_CFLAGS) \ - $(GDK_PIXBUF_CFLAGS) \ - $(GNOME_CANVAS_PIXBUF_CFLAGS) \ - -I$(LIB_BARCODE_DIR) - -bin_PROGRAMS = glabels glabels-batch - -glabels_SOURCES = \ - glabels.c \ - splash.h \ - splash.c \ - mdi.h \ - mdi.c \ - display.c \ - display.h \ - item.c \ - item.h \ - item_text.c \ - item_text.h \ - item_line.c \ - item_line.h \ - item_box.c \ - item_box.h \ - item_ellipse.c \ - item_ellipse.h \ - item_image.c \ - item_image.h \ - item_barcode.c \ - item_barcode.h \ - highlight.c \ - highlight.h \ - propertybox.c \ - propertybox.h \ - prop_size.c \ - prop_size.h \ - prop_position.c \ - prop_position.h \ - prop_line.c \ - prop_line.h \ - prop_fill.c \ - prop_fill.h \ - prop_text.c \ - prop_text.h \ - prop_text_entry.c \ - prop_text_entry.h \ - prop_vector.c \ - prop_vector.h \ - prop_bc.c \ - prop_bc.h \ - prop_bc_style.c \ - prop_bc_style.h \ - prop_bc_data.c \ - prop_bc_data.h \ - label.h \ - label.c \ - template.h \ - template.c \ - text_node.h \ - text_node.c \ - merge_properties.h \ - merge_properties.c \ - merge.h \ - merge.c \ - merge_text.h \ - merge_text.c \ - merge_ui.h \ - merge_ui.c \ - merge_ui_text.h \ - merge_ui_text.c \ - bc.c \ - bc.h \ - bc_postnet.c \ - bc_postnet.h \ - bc_gnubarcode.c \ - bc_gnubarcode.h \ - tools.h \ - tools.c \ - stock.h \ - stock.c \ - menu.h \ - menu.c \ - file.c \ - file.h \ - media_select.c \ - media_select.h \ - rotate_select.c \ - rotate_select.h \ - print.c \ - print.h \ - print_dialog.c \ - print_dialog.h \ - print_copies.c \ - print_copies.h \ - print_merge.c \ - print_merge.h \ - mini_preview.c \ - mini_preview.h \ - edit.c \ - edit.h \ - prefs.h \ - prefs.c \ - util.c \ - util.h \ - hack.c \ - hack.h \ - gnome-canvas-hacktext.h \ - debug.h - -glabels_LDADD = \ - $(GNOME_LIBDIR) \ - $(GNOMEUI_LIBS) \ - $(INTLLIBS) \ - $(GNOME_XML_LIBS) \ - $(GNOME_PRINT_LIBS) \ - $(GDK_PIXBUF_LIBS) \ - $(GNOME_CANVAS_PIXBUF_LIBS) \ - -L$(LIB_BARCODE_DIR) -lbarcode - -glabels_batch_SOURCES = \ - glabels_batch.c \ - label.h \ - label.c \ - template.h \ - template.c \ - text_node.h \ - text_node.c \ - merge.h \ - merge.c \ - merge_text.h \ - merge_text.c \ - bc.c \ - bc.h \ - bc_postnet.c \ - bc_postnet.h \ - bc_gnubarcode.c \ - bc_gnubarcode.h \ - print.c \ - print.h \ - util.c \ - util.h \ - hack.c \ - hack.h \ - debug.h - -glabels_batch_LDADD = \ - $(GNOME_LIBDIR) \ - $(GNOMEUI_LIBS) \ - $(INTLLIBS) \ - $(GNOME_XML_LIBS) \ - $(GNOME_PRINT_LIBS) \ - $(GDK_PIXBUF_LIBS) \ - $(GNOME_CANVAS_PIXBUF_LIBS) \ - -L$(LIB_BARCODE_DIR) -lbarcode - -$(bin_PROGRAMS): $(LIB_BARCODE_DIR)/libbarcode.a - -$(LIB_BARCODE_DIR)/libbarcode.a: - cd $(LIB_BARCODE_DIR); $(MAKE) - -clean: barcode_clean - -barcode_clean: - cd $(LIB_BARCODE_DIR); $(MAKE) clean - -distclean maintainer-clean: barcode_distclean - -barcode_distclean: - cd $(LIB_BARCODE_DIR); $(MAKE) distclean diff --git a/glabels1/src/bc.c b/glabels1/src/bc.c deleted file mode 100644 index 9969b78..0000000 --- a/glabels1/src/bc.c +++ /dev/null @@ -1,201 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * bc.c: GLabels barcode module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include <config.h> - -#include "bc.h" -#include "bc_postnet.h" -#include "bc_gnubarcode.h" - -#include "debug.h" - -/*****************************************************************************/ -/* Call appropriate barcode backend to create barcode in intermediate format.*/ -/*****************************************************************************/ -glBarcode * -gl_barcode (glBarcodeStyle style, - gboolean text_flag, - gdouble scale, - gchar * digits) -{ - glBarcode *gbc; - - switch (style) { - - case GL_BARCODE_STYLE_POSTNET: - /* Use the POSTNET backend module */ - gbc = gl_barcode_postnet (digits); - break; - - default: - /* Use the GNU barcode library backend */ - gbc = gl_barcode_gnubarcode (style, text_flag, scale, digits); - break; - - } - return gbc; -} - -/*****************************************************************************/ -/* Free previously created barcode. */ -/*****************************************************************************/ -void -gl_barcode_free (glBarcode ** gbc) -{ - GList *p; - - if (*gbc != NULL) { - - for (p = (*gbc)->lines; p != NULL; p = p->next) { - g_free (p->data); - p->data = NULL; - } - g_list_free ((*gbc)->lines); - (*gbc)->lines = NULL; - - for (p = (*gbc)->chars; p != NULL; p = p->next) { - g_free (p->data); - p->data = NULL; - } - g_list_free ((*gbc)->chars); - (*gbc)->chars = NULL; - - g_free (*gbc); - *gbc = NULL; - } -} - -/*****************************************************************************/ -/* Return an appropriate set of digits for the given barcode style. */ -/*****************************************************************************/ -gchar * -gl_barcode_default_digits (glBarcodeStyle style) -{ - switch (style) { - - case GL_BARCODE_STYLE_POSTNET: - return g_strdup ("000000000"); - case GL_BARCODE_STYLE_EAN: - return g_strdup ("000000000000 00000"); - case GL_BARCODE_STYLE_UPC: - return g_strdup ("00000000000 00000"); - case GL_BARCODE_STYLE_ISBN: - return g_strdup ("0-00000-000-0 00000"); - case GL_BARCODE_STYLE_39: - case GL_BARCODE_STYLE_128: - case GL_BARCODE_STYLE_128C: - case GL_BARCODE_STYLE_128B: - case GL_BARCODE_STYLE_I25: - case GL_BARCODE_STYLE_CBR: - case GL_BARCODE_STYLE_MSI: - case GL_BARCODE_STYLE_PLS: - return g_strdup ("0000000000"); - default: - return g_strdup ("0"); - } - -} - -/*****************************************************************************/ -/* Convert style to text. */ -/*****************************************************************************/ -const gchar * -gl_barcode_style_to_text (glBarcodeStyle style) -{ - switch (style) { - case GL_BARCODE_STYLE_POSTNET: - return "POSTNET"; - case GL_BARCODE_STYLE_EAN: - return "EAN"; - case GL_BARCODE_STYLE_UPC: - return "UPC"; - case GL_BARCODE_STYLE_ISBN: - return "ISBN"; - case GL_BARCODE_STYLE_39: - return "Code39"; - case GL_BARCODE_STYLE_128: - return "Code128"; - case GL_BARCODE_STYLE_128C: - return "Code128C"; - case GL_BARCODE_STYLE_128B: - return "Code128B"; - case GL_BARCODE_STYLE_I25: - return "I25"; - case GL_BARCODE_STYLE_CBR: - return "CBR"; - case GL_BARCODE_STYLE_MSI: - return "MSI"; - case GL_BARCODE_STYLE_PLS: - return "PLS"; - default: - WARN( "Illegal barcode style %d", style ); - return "?"; - } -} - -/*****************************************************************************/ -/* Convert text to style. */ -/*****************************************************************************/ -glBarcodeStyle -gl_barcode_text_to_style (const gchar * text) -{ - - if (g_strcasecmp (text, "POSTNET") == 0) { - return GL_BARCODE_STYLE_POSTNET; - } - if (g_strcasecmp (text, "EAN") == 0) { - return GL_BARCODE_STYLE_EAN; - } - if (g_strcasecmp (text, "UPC") == 0) { - return GL_BARCODE_STYLE_UPC; - } - if (g_strcasecmp (text, "ISBN") == 0) { - return GL_BARCODE_STYLE_ISBN; - } - if (g_strcasecmp (text, "Code39") == 0) { - return GL_BARCODE_STYLE_39; - } - if (g_strcasecmp (text, "Code128") == 0) { - return GL_BARCODE_STYLE_128; - } - if (g_strcasecmp (text, "Code128C") == 0) { - return GL_BARCODE_STYLE_128C; - } - if (g_strcasecmp (text, "Code128B") == 0) { - return GL_BARCODE_STYLE_128B; - } - if (g_strcasecmp (text, "I25") == 0) { - return GL_BARCODE_STYLE_I25; - } - if (g_strcasecmp (text, "CBR") == 0) { - return GL_BARCODE_STYLE_CBR; - } - if (g_strcasecmp (text, "MSI") == 0) { - return GL_BARCODE_STYLE_MSI; - } - if (g_strcasecmp (text, "PLS") == 0) { - return GL_BARCODE_STYLE_PLS; - } else { - WARN( "Unknown barcode style text \"%s\"", text ); - return GL_BARCODE_STYLE_POSTNET; - } - -} diff --git a/glabels1/src/bc.h b/glabels1/src/bc.h deleted file mode 100644 index 22441f7..0000000 --- a/glabels1/src/bc.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * bc.h: GLabels barcode module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __BC_H__ -#define __BC_H__ - -#include <glib.h> - -typedef enum { - GL_BARCODE_STYLE_POSTNET, - GL_BARCODE_STYLE_EAN, - GL_BARCODE_STYLE_UPC, - GL_BARCODE_STYLE_ISBN, - GL_BARCODE_STYLE_39, - GL_BARCODE_STYLE_128, - GL_BARCODE_STYLE_128C, - GL_BARCODE_STYLE_128B, - GL_BARCODE_STYLE_I25, - GL_BARCODE_STYLE_128RAW, - GL_BARCODE_STYLE_CBR, - GL_BARCODE_STYLE_MSI, - GL_BARCODE_STYLE_PLS, -} glBarcodeStyle; - -typedef struct { - gdouble x, y, length, width; -} glBarcodeLine; - -typedef struct { - gdouble x, y, fsize; - gchar c; -} glBarcodeChar; - -typedef struct { - gdouble width, height; - GList *lines; /* List of glBarcodeLine */ - GList *chars; /* List of glBarcodeChar */ -} glBarcode; - -#define GL_BARCODE_FONT_FAMILY "Helvetica" -#define GL_BARCODE_FONT_WEIGHT GNOME_FONT_BOOK - -extern glBarcode *gl_barcode (glBarcodeStyle style, - gboolean text_flag, - gdouble scale, - gchar * digits); - -extern void - gl_barcode_free (glBarcode ** bc); - -extern gchar *gl_barcode_default_digits (glBarcodeStyle style); -extern const gchar *gl_barcode_style_to_text (glBarcodeStyle style); -extern glBarcodeStyle gl_barcode_text_to_style (const gchar * text); - -#endif diff --git a/glabels1/src/bc_gnubarcode.c b/glabels1/src/bc_gnubarcode.c deleted file mode 100644 index 31f71b0..0000000 --- a/glabels1/src/bc_gnubarcode.c +++ /dev/null @@ -1,239 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * bc-gnubarcode.c: front-end to GNU-barcode-library module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * Some of this code is borrowed from the postscript renderer (ps.c) - * from the GNU barcode library: - * - * Copyright (C) 1999 Alessaandro Rubini (rubini@gnu.org) - * Copyright (C) 1999 Prosa Srl. (prosa@prosa.it) - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <ctype.h> -#include <string.h> - -#include "bc.h" -#include "bc_gnubarcode.h" - -#include "barcode.h" - -#include "debug.h" - -#define SHRINK_AMOUNT 0.15 /* shrink bars to account for ink spreading */ -#define FONT_SCALE 0.95 /* Shrink fonts just a hair */ - -static glBarcode *render_pass1 (struct Barcode_Item *bci, - gboolean text_flag, - gdouble scale); - -/*****************************************************************************/ -/* Generate intermediate representation of barcode. */ -/*****************************************************************************/ -glBarcode * -gl_barcode_gnubarcode (glBarcodeStyle style, - gboolean text_flag, - gdouble scale, - gchar * digits) -{ - glBarcode *gbc; - struct Barcode_Item *bci; - gint flags; - - bci = Barcode_Create (digits); - - /* First encode using GNU Barcode library */ - switch (style) { - case GL_BARCODE_STYLE_EAN: - flags = BARCODE_EAN; - break; - case GL_BARCODE_STYLE_UPC: - flags = BARCODE_UPC; - break; - case GL_BARCODE_STYLE_ISBN: - flags = BARCODE_ISBN; - break; - case GL_BARCODE_STYLE_39: - flags = BARCODE_39; - break; - case GL_BARCODE_STYLE_128: - flags = BARCODE_128; - break; - case GL_BARCODE_STYLE_128C: - flags = BARCODE_128C; - break; - case GL_BARCODE_STYLE_128B: - flags = BARCODE_128B; - break; - case GL_BARCODE_STYLE_I25: - flags = BARCODE_I25; - break; - case GL_BARCODE_STYLE_CBR: - flags = BARCODE_CBR; - break; - case GL_BARCODE_STYLE_MSI: - flags = BARCODE_MSI; - break; - case GL_BARCODE_STYLE_PLS: - flags = BARCODE_PLS; - break; - default: - WARN( "Illegal barcode style %d", style ); - flags = BARCODE_ANY; - break; - } - Barcode_Encode (bci, flags); - if (!bci->partial || !bci->textinfo) { - WARN ("Barcode Data Invalid"); - Barcode_Delete (bci); - return NULL; - } - - /* now render with our custom back-end, - to create appropriate intermdediate format */ - gbc = render_pass1 (bci, text_flag, scale); - - Barcode_Delete (bci); - return gbc; -} - -/*-------------------------------------------------------------------------- - * PRIVATE. Render to glBarcode intermediate representation of barcode. - * - * Some of this code is borrowed from the postscript renderer (ps.c) - * from the GNU barcode library: - * - * Copyright (C) 1999 Alessaandro Rubini (rubini@gnu.org) - * Copyright (C) 1999 Prosa Srl. (prosa@prosa.it) - * - *--------------------------------------------------------------------------*/ -static glBarcode * -render_pass1 (struct Barcode_Item *bci, - gboolean text_flag, - gdouble scale) -{ - glBarcode *gbc; - glBarcodeLine *line; - glBarcodeChar *bchar; - gdouble x; - gint i, j, barlen; - gdouble f1, f2; - gint mode = '-'; /* text below bars */ - gdouble x0, y0, yr; - guchar *p, c; - - /* First calculate barlen */ - barlen = bci->partial[0] - '0'; - for (p = bci->partial + 1; *p != 0; p++) { - if (isdigit (*p)) { - barlen += *p - '0'; - } else { - if ((*p != '+') && (*p != '-')) { - barlen += *p - 'a' + 1; - } - } - } - - /* The width defaults to "just enough" */ - bci->width = barlen * scale + 1; - - /* The height defaults to 80 points (rescaled) */ - if (!bci->height) - bci->height = 80 * scale; - - gbc = g_new0 (glBarcode, 1); - - /* Now traverse the code string and create a list of lines */ - x = bci->margin + (bci->partial[0] - '0') * scale; - for (p = bci->partial + 1, i = 1; *p != 0; p++, i++) { - /* special cases: '+' and '-' */ - if (*p == '+' || *p == '-') { - mode = *p; /* don't count it */ - i++; - continue; - } - /* j is the width of this bar/space */ - if (isdigit (*p)) - j = *p - '0'; - else - j = *p - 'a' + 1; - if (i % 2) { /* bar */ - x0 = x + (j * scale) / 2; - y0 = bci->margin; - yr = bci->height; - if (text_flag) { /* leave space for text */ - if (mode == '-') { - /* text below bars: 10 or 5 points */ - yr -= (isdigit (*p) ? 10 : 5) * scale; - } else { /* '+' */ - /* above bars: 10 or 0 from bottom, - and 10 from top */ - y0 += 10 * scale; - yr -= (isdigit (*p) ? 20 : 10) * scale; - } - } - line = g_new0 (glBarcodeLine, 1); - line->x = x0; - line->y = y0; - line->length = yr; - line->width = (j * scale) - SHRINK_AMOUNT; - gbc->lines = g_list_append (gbc->lines, line); - } - x += j * scale; - - } - - /* Now the text */ - mode = '-'; /* reinstantiate default */ - if (text_flag) { - for (p = bci->textinfo; p; p = strchr (p, ' ')) { - while (*p == ' ') - p++; - if (!*p) - break; - if (*p == '+' || *p == '-') { - mode = *p; - continue; - } - if (sscanf (p, "%lf:%lf:%c", &f1, &f2, &c) != 3) { - WARN ("impossible data: %s", p); - continue; - } - bchar = g_new0 (glBarcodeChar, 1); - bchar->x = f1 * scale + bci->margin; - if (mode == '-') { - bchar->y = - bci->margin + bci->height - 8 * scale; - } else { - bchar->y = bci->margin; - } - bchar->fsize = f2 * FONT_SCALE * scale; - bchar->c = c; - gbc->chars = g_list_append (gbc->chars, bchar); - } - } - - /* Fill in other info */ - gbc->height = bci->height + 2.0 * bci->margin; - gbc->width = bci->width + 2.0 * bci->margin; - - return gbc; -} diff --git a/glabels1/src/bc_gnubarcode.h b/glabels1/src/bc_gnubarcode.h deleted file mode 100644 index 263b403..0000000 --- a/glabels1/src/bc_gnubarcode.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * bc_gnubarcode.h: front-end to GNU-barcode-library module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __BC_GNUBARCODE_H__ -#define __BC_GNUBARCODE_H__ - -#include "bc.h" - -extern glBarcode *gl_barcode_gnubarcode (glBarcodeStyle style, - gboolean text_flag, - gdouble scale, - gchar * digits); - -#endif diff --git a/glabels1/src/bc_postnet.c b/glabels1/src/bc_postnet.c deleted file mode 100644 index eaf3197..0000000 --- a/glabels1/src/bc_postnet.c +++ /dev/null @@ -1,150 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * bc_postnet.c: GLabels POSTNET barcode module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/* - * This module implements the POSTNET barcode specified in the USPS - * publication 25, Mar 2001. - */ - -#include <config.h> - -#include <ctype.h> - -#include "bc.h" -#include "bc_postnet.h" - -#include "debug.h" - -static gchar *symbols[] = { - /* 0 */ "11000", - /* 1 */ "00011", - /* 2 */ "00101", - /* 3 */ "00110", - /* 4 */ "01001", - /* 5 */ "01010", - /* 6 */ "01100", - /* 7 */ "10001", - /* 8 */ "10010", - /* 9 */ "10100", -}; - -static gchar *frame_symbol = "1"; - -#define POSTNET_BAR_WIDTH 1.25 -#define POSTNET_FULLBAR_HEIGHT 9.00 -#define POSTNET_HALFBAR_HEIGHT 3.50 -#define POSTNET_BAR_PITCH 3.25 -#define POSTNET_HORIZ_MARGIN 9.00 -#define POSTNET_VERT_MARGIN 3.00 - -static gchar *postnet_code (gchar * digits); - -/****************************************************************************/ -/* Generate list of rectangles that form the barcode for the given digits. */ -/****************************************************************************/ -glBarcode * -gl_barcode_postnet (gchar * digits) -{ - gchar *code, *p; - glBarcode *gbc; - glBarcodeLine *line; - gdouble x; - - gbc = g_new0 (glBarcode, 1); - - /* First get code string */ - code = postnet_code (digits); - if (code == NULL) { - return NULL; - } - - /* Now traverse the code string and create a list of lines */ - x = POSTNET_HORIZ_MARGIN; - for (p = code; *p != 0; p++) { - line = g_new0 (glBarcodeLine, 1); - line->x = x; - line->y = POSTNET_VERT_MARGIN; - if (*p == '0') { - line->y += - POSTNET_FULLBAR_HEIGHT - POSTNET_HALFBAR_HEIGHT; - line->length = POSTNET_HALFBAR_HEIGHT; - } else { - line->length = POSTNET_FULLBAR_HEIGHT; - } - line->width = POSTNET_BAR_WIDTH; - - gbc->lines = g_list_append (gbc->lines, line); - - x += POSTNET_BAR_PITCH; - } - - g_free (code); - - gbc->width = x + POSTNET_HORIZ_MARGIN; - gbc->height = POSTNET_FULLBAR_HEIGHT + 2 * POSTNET_VERT_MARGIN; - - gbc->chars = NULL; - - return gbc; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Generate string of symbols, representing barcode. */ -/*--------------------------------------------------------------------------*/ -static gchar * -postnet_code (gchar * digits) -{ - gchar *p; - gint len; - gint d, sum; - GString *code; - gchar *ret; - - /* Left frame bar */ - code = g_string_new (frame_symbol); - - sum = 0; - for (p = digits, len = 0; (*p != 0) && (len < 11); p++) { - if (isdigit (*p)) { - /* Only translate valid characters (0-9) */ - d = (*p) - '0'; - sum += d; - code = g_string_append (code, symbols[d]); - len++; - } - } - if ((len != 5) && (len != 9) && (len != 11)) { - WARN ("Invalid POSTNET length %d, should be 5(ZIP), 9(ZIP+4), or 11(DPBC)", len); - } - - /* Create correction character */ - d = (10 - (sum % 10)) % 10; - code = g_string_append (code, symbols[d]); - - /* Right frame bar */ - code = g_string_append (code, frame_symbol); - - ret = g_strdup (code->str); - g_string_free (code, TRUE); - - return ret; -} diff --git a/glabels1/src/bc_postnet.h b/glabels1/src/bc_postnet.h deleted file mode 100644 index e503507..0000000 --- a/glabels1/src/bc_postnet.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * bc_postnet.h: GLabels POSTNET barcode module header file - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __BC_POSTNET_H__ -#define __BC_POSTNET_H__ - -#include <glib.h> - -glBarcode *gl_barcode_postnet (gchar * digits); - -#endif diff --git a/glabels1/src/debug.h b/glabels1/src/debug.h deleted file mode 100644 index 08e3fc9..0000000 --- a/glabels1/src/debug.h +++ /dev/null @@ -1,70 +0,0 @@ -/* Macros/functions for debugging gLabels */ -#ifndef __DEBUG_H__ -#define __DEBUG_H__ - -#include "glib.h" - -#ifdef __GNUC__ - -#define DEBUG(args...) { \ - gchar *__string__; \ - __string__ = g_strdup_printf( args ); \ - g_message( "%s:%d (%s): %s\n", \ - __FILE__, __LINE__, __FUNCTION__, __string__ ); \ - g_free( __string__ ); \ - __string__ = NULL; \ - } - -#define WARN(args...) { \ - gchar *__string__; \ - __string__ = g_strdup_printf( args ); \ - g_warning( "%s:%d (%s): %s\n", \ - __FILE__, __LINE__, __FUNCTION__, __string__ ); \ - g_free( __string__ ); \ - __string__ = NULL; \ - } - -#define ERROR(args...) { \ - gchar *__string__; \ - __string__ = g_strdup_printf( args ); \ - g_error( "%s:%d (%s): %s\n", \ - __FILE__, __LINE__, __FUNCTION__, __string__ ); \ - g_free( __string__ ); \ - __string__ = NULL; \ - } - -#else /* !__GNUC__ */ - -static -DEBUG (const gchar * format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args); - va_end (args); -} - -static -WARN (const gchar * format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args); - va_end (args); -} - -static -ERROR (const gchar * format, - ...) -{ - va_list args; - va_start (args, format); - g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args); - va_end (args); -} - -#endif /* !__GNUC__ */ - -#endif /* __DEBUG_H__ */ diff --git a/glabels1/src/display.c b/glabels1/src/display.c deleted file mode 100644 index 9440820..0000000 --- a/glabels1/src/display.c +++ /dev/null @@ -1,1739 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * display.c: GLabels Display module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> -#include <gtk/gtkinvisible.h> - -#include <string.h> -#include <math.h> - -#include "display.h" -#include "item.h" - -#include "debug.h" - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -/* "CLIPBOARD" selection */ -static GdkAtom clipboard_atom = GDK_NONE; - -#define HOME_SCALE 2.0 -static gdouble scales[] = { 8.0, 6.0, 4.0, 3.0, - 2.0, - 1.5, 1.0, 0.5, 0.25, - 0.0 -}; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_display_class_init (glDisplayClass * class); -static void gl_display_init (glDisplay * display); -static void gl_display_destroy (GtkObject * object); - -static void gl_display_construct (glDisplay * display); -static GtkWidget *gl_display_construct_canvas (glDisplay * display); -static void gl_display_construct_selection (glDisplay * display); - -static gdouble get_apropriate_scale (glLabel * label); - -static void draw_rect_bg (glDisplay * display); -static void draw_rounded_rect_bg (glDisplay * display); -static void draw_round_bg (glDisplay * display); -static void draw_cd_bg (glDisplay * display); - -static int canvas_event (GnomeCanvas * canvas, - GdkEvent * event, gpointer data); -static int canvas_event_arrow_mode (GnomeCanvas * canvas, - GdkEvent * event, gpointer data); - -static GnomeCanvasItem *display_item_at (glDisplay * display, - gdouble x, gdouble y); -static gboolean item_selected (glDisplay * display, - GnomeCanvasItem * item); -static gboolean multiple_items_selected (glDisplay * display); - -static int item_event_arrow_mode (GnomeCanvasItem * item, - GdkEvent * event, gpointer data); - -static void popup_selection_menu (glDisplay * display, - GnomeCanvasItem * item, GdkEvent * event); - -static void delete_item_cb (GtkWidget * widget, GnomeCanvasItem * item); -static void raise_item_cb (GtkWidget * widget, GnomeCanvasItem * item); -static void lower_item_cb (GtkWidget * widget, GnomeCanvasItem * item); - -static void move_selected_items (glDisplay * display, gdouble dx, gdouble dy); -static void move_item (GnomeCanvasItem * item, gdouble dx, gdouble dy); - -static void delete_selection_cb (GtkWidget * widget, glDisplay * display); -static void raise_selection_cb (GtkWidget * widget, glDisplay * display); -static void lower_selection_cb (GtkWidget * widget, glDisplay * display); - -static void selection_clear_cb (GtkWidget * widget, - GdkEventSelection * event, gpointer data); - -static void selection_get_cb (GtkWidget * widget, - GtkSelectionData * selection_data, guint info, - guint time, gpointer data); - -static void selection_received_cb (GtkWidget * widget, - GtkSelectionData * selection_data, - guint time, gpointer data); - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_display_get_type (void) -{ - static guint display_type = 0; - - if (!display_type) { - GtkTypeInfo display_info = { - "glDisplay", - sizeof (glDisplay), - sizeof (glDisplayClass), - (GtkClassInitFunc) gl_display_class_init, - (GtkObjectInitFunc) gl_display_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - display_type = - gtk_type_unique (gtk_vbox_get_type (), &display_info); - } - - return display_type; -} - -static void -gl_display_class_init (glDisplayClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_display_destroy; -} - -static void -gl_display_init (glDisplay * display) -{ - display->label = NULL; -} - -static void -gl_display_destroy (GtkObject * object) -{ - glDisplay *display; - glDisplayClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_DISPLAY (object)); - - display = GL_DISPLAY (object); - class = GL_DISPLAY_CLASS (GTK_OBJECT (display)->klass); - - display->label = NULL; - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_display_new (glLabel * label) -{ - glDisplay *display = gtk_type_new (gl_display_get_type ()); - - display->label = label; - - gl_display_construct (display); - - gl_display_clear_modified (display); - - return GTK_WIDGET (display); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*---------------------------------------------------------------------------*/ -static void -gl_display_construct (glDisplay * display) -{ - GtkWidget *wvbox, *wscroll; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - wvbox = GTK_WIDGET (display); - - display->state = GL_DISPLAY_STATE_ARROW; - display->item_list = NULL; - - gl_display_construct_canvas (display); - wscroll = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wscroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_box_pack_start (GTK_BOX (wvbox), wscroll, TRUE, TRUE, 0); - gtk_container_add (GTK_CONTAINER (wscroll), display->canvas); - - gl_display_construct_selection (display); - - display->menu = gl_display_new_selection_menu (display); - - display->modified = FALSE; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Create canvas w/ a background in the shape of the label/card. */ -/*---------------------------------------------------------------------------*/ -static GtkWidget * -gl_display_construct_canvas (glDisplay * display) -{ - gdouble scale; - glLabel *label = display->label; - GList *p_obj; - glLabelObject *object; - GnomeCanvasItem *item; - - g_return_val_if_fail (GL_IS_DISPLAY (display), NULL); - g_return_val_if_fail (label != NULL, NULL); - -#ifdef AA_CANVAS - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - display->canvas = gnome_canvas_new_aa (); - gtk_widget_pop_colormap (); - gtk_widget_pop_visual (); -#else - gtk_widget_push_visual (gdk_imlib_get_visual ()); - gtk_widget_push_colormap (gdk_imlib_get_colormap ()); - display->canvas = gnome_canvas_new (); - gtk_widget_pop_colormap (); - gtk_widget_pop_visual (); -#endif - - scale = get_apropriate_scale (label); - - gtk_widget_set_usize (display->canvas, - scale * label->width + 40, - scale * label->height + 40); - gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (display->canvas), - scale); - display->scale = scale; - - gnome_canvas_set_scroll_region (GNOME_CANVAS (display->canvas), - 0.0, 0.0, label->width, label->height); - - /* Draw background shape of label/card */ - switch (label->template->style) { - - case GL_TEMPLATE_STYLE_RECT: - if (label->template->label_round == 0.0) { - /* Square corners. */ - draw_rect_bg (display); - } else { - /* Rounded corners. */ - draw_rounded_rect_bg (display); - } - break; - - case GL_TEMPLATE_STYLE_ROUND: - draw_round_bg (display); - break; - - case GL_TEMPLATE_STYLE_CD: - draw_cd_bg (display); - break; - - default: - WARN ("Unknown template label style"); - break; - } - - gtk_signal_connect (GTK_OBJECT (display->canvas), "event", - GTK_SIGNAL_FUNC (canvas_event), display); - - for (p_obj = label->objects; p_obj != NULL; p_obj = p_obj->next) { - object = (glLabelObject *) p_obj->data; - item = gl_item_new (object, display); - gl_display_add_item (display, item); - } - - return display->canvas; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Create selection targets. */ -/*---------------------------------------------------------------------------*/ -static void -gl_display_construct_selection (glDisplay * display) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - - display->have_selection = FALSE; - display->selection_data = NULL; - display->invisible = gtk_invisible_new (); - - display->selected_item_list = NULL; - - if (!clipboard_atom) { - clipboard_atom = gdk_atom_intern ("GLABELS_CLIPBOARD", FALSE); - } - - gtk_selection_add_target (display->invisible, - clipboard_atom, GDK_SELECTION_TYPE_STRING, 1); - - gtk_signal_connect (GTK_OBJECT (display->invisible), - "selection_clear_event", - GTK_SIGNAL_FUNC (selection_clear_cb), display); - - gtk_signal_connect (GTK_OBJECT (display->invisible), "selection_get", - GTK_SIGNAL_FUNC (selection_get_cb), display); - - gtk_signal_connect (GTK_OBJECT (display->invisible), - "selection_received", - GTK_SIGNAL_FUNC (selection_received_cb), display); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Determine an apropriate scale for given label & screen size */ -/*---------------------------------------------------------------------------*/ -static gdouble -get_apropriate_scale (glLabel * label) -{ - gdouble w, h; - gdouble w_screen, h_screen; - gint i; - gdouble k; - - g_return_val_if_fail (label != NULL, 1.0); - - w = label->width; - h = label->height; - w_screen = (gdouble) gdk_screen_width (); - h_screen = (gdouble) gdk_screen_height (); - - for (i = 0; scales[i] > 0.0; i++) { - k = scales[i]; - if (k <= HOME_SCALE) { - if ((k * w < (w_screen - 256)) - && (k * h < (h_screen - 256))) - return k; - } - } - - return 0.25; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw simple recangular background. */ -/*---------------------------------------------------------------------------*/ -static void -draw_rect_bg (glDisplay * display) -{ - glLabel *label = display->label; - GnomeCanvasItem *item; - GnomeCanvasGroup *group; - gdouble margin; - - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail (label != NULL); - - display->n_bg_items = 0; - display->bg_item_list = NULL; - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - - item = gnome_canvas_item_new (group, - gnome_canvas_rect_get_type (), - "x1", 0.0, - "y1", 0.0, - "x2", label->width, - "y2", label->height, - "fill_color", "white", - NULL); - display->n_bg_items++; - display->bg_item_list = g_list_append (display->bg_item_list, item); - - /* Bounding box @ margin */ - margin = label->template->label_margin; - gnome_canvas_item_new (group, - gnome_canvas_rect_get_type (), - "x1", margin, - "y1", margin, - "x2", label->width - margin, - "y2", label->height - margin, - "width_pixels", 1, - "outline_color", "light blue", - NULL); - display->n_bg_items++; - display->bg_item_list = g_list_append (display->bg_item_list, item); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw rounded recangular background. */ -/*---------------------------------------------------------------------------*/ -static void -draw_rounded_rect_bg (glDisplay * display) -{ - glLabel *label = display->label; - GnomeCanvasPoints *points; - gint i_coords, i_theta; - gdouble r, w, h, m; - GnomeCanvasItem *item; - GnomeCanvasGroup *group; - - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail (label != NULL); - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - - display->n_bg_items = 0; - display->bg_item_list = NULL; - - r = label->template->label_round; - w = label->width; - h = label->height; - m = label->template->label_margin; - - points = gnome_canvas_points_new (4 * (1 + 90 / 5)); - i_coords = 0; - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - points->coords[i_coords++] = - r - r * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - r - r * cos (i_theta * M_PI / 180.0); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - points->coords[i_coords++] = - r - r * cos (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - (h - r) + r * sin (i_theta * M_PI / 180.0); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - points->coords[i_coords++] = - (w - r) + r * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - (h - r) + r * cos (i_theta * M_PI / 180.0); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - points->coords[i_coords++] = - (w - r) + r * cos (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - r - r * sin (i_theta * M_PI / 180.0); - } - item = gnome_canvas_item_new (group, - gnome_canvas_polygon_get_type (), - "points", points, - "fill_color", "white", - NULL); - gnome_canvas_points_free (points); - display->n_bg_items++; - display->bg_item_list = g_list_append (display->bg_item_list, item); - - /* Bounding box @ margin */ - if (label->template->label_margin >= label->template->label_round) { - /* simple rectangle */ - item = gnome_canvas_item_new (group, - gnome_canvas_rect_get_type (), - "x1", m, - "y1", m, - "x2", w - m, - "y2", h - m, - "width_pixels", 1, - "outline_color", "light blue", - NULL); - display->n_bg_items++; - display->bg_item_list = - g_list_append (display->bg_item_list, item); - } else { - r = label->template->label_round - m; - w = label->width - 2 * label->template->label_margin; - h = label->height - 2 * label->template->label_margin; - - /* rectangle with rounded corners */ - points = gnome_canvas_points_new (4 * (1 + 90 / 5)); - i_coords = 0; - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - points->coords[i_coords++] = - m + r - r * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - m + r - r * cos (i_theta * M_PI / 180.0); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - points->coords[i_coords++] = - m + r - r * cos (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - m + (h - r) + r * sin (i_theta * M_PI / 180.0); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - points->coords[i_coords++] = - m + (w - r) + r * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - m + (h - r) + r * cos (i_theta * M_PI / 180.0); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - points->coords[i_coords++] = - m + (w - r) + r * cos (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - m + r - r * sin (i_theta * M_PI / 180.0); - } - item = gnome_canvas_item_new (group, - gnome_canvas_polygon_get_type (), - "points", points, - "width_pixels", 1, - "outline_color", "light blue", - NULL); - gnome_canvas_points_free (points); - display->n_bg_items++; - display->bg_item_list = - g_list_append (display->bg_item_list, item); - } -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw round background. */ -/*---------------------------------------------------------------------------*/ -static void -draw_round_bg (glDisplay * display) -{ - glLabel *label = display->label; - GnomeCanvasPoints *points; - gint i_coords, i_theta; - gdouble r, r1; - GnomeCanvasItem *item; - GnomeCanvasGroup *group; - - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail (label != NULL); - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - - display->n_bg_items = 0; - display->bg_item_list = NULL; - - r1 = label->template->label_radius; - points = gnome_canvas_points_new (1 + 360/2); - i_coords = 0; - for (i_theta = 0; i_theta <= 360; i_theta += 2) { - points->coords[i_coords++] = - r1 - r1 * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - r1 - r1 * cos (i_theta * M_PI / 180.0); - } - item = gnome_canvas_item_new (group, - gnome_canvas_polygon_get_type (), - "points", points, - "fill_color", "white", - NULL); - gnome_canvas_points_free (points); - display->n_bg_items++; - display->bg_item_list = g_list_append (display->bg_item_list, item); - - /* Bounding box @ margin */ - r = label->template->label_radius - label->template->label_margin; - points = gnome_canvas_points_new (360 / 2); - i_coords = 0; - for (i_theta = 0; i_theta < 360; i_theta += 2) { - points->coords[i_coords++] = - r1 - r * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - r1 - r * cos (i_theta * M_PI / 180.0); - } - item = gnome_canvas_item_new (group, - gnome_canvas_polygon_get_type (), - "points", points, - "width_pixels", 1, - "outline_color", "light blue", NULL); - gnome_canvas_points_free (points); - display->n_bg_items++; - display->bg_item_list = g_list_append (display->bg_item_list, item); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw CD style background, circular w/ concentric hole. */ -/*---------------------------------------------------------------------------*/ -static void -draw_cd_bg (glDisplay * display) -{ - glLabel *label = display->label; - GnomeCanvasPoints *points; - gint i_coords, i_theta; - gdouble r, r1, r2; - GnomeCanvasItem *item; - GnomeCanvasGroup *group; - - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail (label != NULL); - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - - display->n_bg_items = 0; - display->bg_item_list = NULL; - - r1 = label->template->label_radius; - r2 = label->template->label_hole; - points = gnome_canvas_points_new (2 * (1 + 360 / 2)); - i_coords = 0; - for (i_theta = 0; i_theta <= 360; i_theta += 2) { - points->coords[i_coords++] = - r1 - r1 * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - r1 - r1 * cos (i_theta * M_PI / 180.0); - } - for (i_theta = 0; i_theta <= 360; i_theta += 2) { - points->coords[i_coords++] = - r1 - r2 * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - r1 - r2 * cos (i_theta * M_PI / 180.0); - } - item = gnome_canvas_item_new (group, - gnome_canvas_polygon_get_type (), - "points", points, - "fill_color", "white", - NULL); - gnome_canvas_points_free (points); - display->n_bg_items++; - display->bg_item_list = g_list_append (display->bg_item_list, item); - - /* Bounding box @ margin */ - /* outer margin */ - r = label->template->label_radius - label->template->label_margin; - points = gnome_canvas_points_new (360 / 2); - i_coords = 0; - for (i_theta = 0; i_theta < 360; i_theta += 2) { - points->coords[i_coords++] = - r1 - r * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - r1 - r * cos (i_theta * M_PI / 180.0); - } - item = gnome_canvas_item_new (group, - gnome_canvas_polygon_get_type (), - "points", points, - "width_pixels", 1, - "outline_color", "light blue", NULL); - gnome_canvas_points_free (points); - display->n_bg_items++; - display->bg_item_list = g_list_append (display->bg_item_list, item); - - /* inner margin */ - r = label->template->label_hole + label->template->label_margin; - points = gnome_canvas_points_new (360 / 2); - i_coords = 0; - for (i_theta = 0; i_theta < 360; i_theta += 2) { - points->coords[i_coords++] = - r1 - r * sin (i_theta * M_PI / 180.0); - points->coords[i_coords++] = - r1 - r * cos (i_theta * M_PI / 180.0); - } - item = gnome_canvas_item_new (group, - gnome_canvas_polygon_get_type (), - "points", points, - "width_pixels", 1, - "outline_color", "light blue", - NULL); - gnome_canvas_points_free (points); - display->n_bg_items++; - display->bg_item_list = g_list_append (display->bg_item_list, item); -} - -/*****************************************************************************/ -/* Set arrow mode. */ -/*****************************************************************************/ -void -gl_display_arrow_mode (glDisplay * display) -{ - static GdkCursor *cursor = NULL; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - if (!cursor) { - cursor = gdk_cursor_new (GDK_LEFT_PTR); - } - - gdk_window_set_cursor (display->canvas->window, cursor); - - display->state = GL_DISPLAY_STATE_ARROW; -} - -/*****************************************************************************/ -/* Set create text object mode. */ -/*****************************************************************************/ -void -gl_display_object_create_mode (glDisplay * display, - glLabelObjectType type) -{ - GdkCursor *cursor; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - cursor = gl_item_get_create_cursor (type); - gdk_window_set_cursor (display->canvas->window, cursor); - - display->state = GL_DISPLAY_STATE_OBJECT_CREATE; - display->create_type = type; -} - -/*****************************************************************************/ -/* Add canvas item to list of display items. */ -/*****************************************************************************/ -void -gl_display_add_item (glDisplay * display, - GnomeCanvasItem * item) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - - display->item_list = g_list_prepend (display->item_list, item); -} - -/*****************************************************************************/ -/* Select all items. */ -/*****************************************************************************/ -void -gl_display_select_all (glDisplay * display) -{ - GList *p; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - gl_display_unselect_all (display); - - for (p = display->item_list; p != NULL; p = p->next) { - gl_display_select_item (display, GNOME_CANVAS_ITEM (p->data)); - } -} - -/*****************************************************************************/ -/* Select all items within given rectangular region */ -/*****************************************************************************/ -void -gl_display_select_region (glDisplay * display, - gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2) -{ - GList *p; - GnomeCanvasItem *item; - gdouble i_x1, i_y1, i_x2, i_y2; - - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail ((x1 <= x2) && (y1 <= y2)); - - for (p = display->item_list; p != NULL; p = p->next) { - item = GNOME_CANVAS_ITEM (p->data); - if (!item_selected (display, item)) { - - gl_item_get_bounds (item, &i_x1, &i_y1, &i_x2, &i_y2); - if ((i_x1 >= x1) && (i_x2 <= x2) && (i_y1 >= y1) - && (i_y2 <= y2)) { - gl_display_select_item (display, item); - } - - } - } -} - -/*****************************************************************************/ -/* Remove all selections */ -/*****************************************************************************/ -void -gl_display_unselect_all (glDisplay * display) -{ - GList *p, *p_next; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - for (p = display->selected_item_list; p != NULL; p = p_next) { - p_next = p->next; - gl_display_unselect_item (display, GNOME_CANVAS_ITEM (p->data)); - } -} - -/*****************************************************************************/ -/* Select an item. */ -/*****************************************************************************/ -void -gl_display_select_item (glDisplay * display, - GnomeCanvasItem * item) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - if (!item_selected (display, item)) { - display->selected_item_list = - g_list_prepend (display->selected_item_list, item); - } - gl_item_highlight (item); - gtk_widget_grab_focus (GTK_WIDGET (display->canvas)); -} - -/*****************************************************************************/ -/* Un-select items. */ -/*****************************************************************************/ -void -gl_display_unselect_item (glDisplay * display, - GnomeCanvasItem * item) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - gl_item_unhighlight (item); - - display->selected_item_list = - g_list_remove (display->selected_item_list, item); -} - -/*****************************************************************************/ -/* Has display been modified? */ -/*****************************************************************************/ -gboolean -gl_display_modified (glDisplay * display) -{ - g_return_val_if_fail (GL_IS_DISPLAY (display), FALSE); - - return display->modified; -} - -/*****************************************************************************/ -/* Set to modified state. */ -/*****************************************************************************/ -void -gl_display_set_modified (glDisplay * display) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - - display->modified = TRUE; -} - -/*****************************************************************************/ -/* Reset to un-modified state. */ -/*****************************************************************************/ -void -gl_display_clear_modified (glDisplay * display) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - - display->modified = FALSE; -} - -/*****************************************************************************/ -/* "Cut" selected items and place in clipboard selections. */ -/*****************************************************************************/ -void -gl_display_cut (glDisplay * display) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - - gl_display_copy (display); - delete_selection_cb (GTK_WIDGET (display), display); -} - -/*****************************************************************************/ -/* "Copy" selected items to clipboard selections. */ -/*****************************************************************************/ -void -gl_display_copy (glDisplay * display) -{ - GList *p; - GnomeCanvasItem *item; - glLabelObject *object; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - if (display->selected_item_list) { - - gl_label_free (&display->selection_data); - display->selection_data = - gl_label_new_with_template (display->label-> - template_name, - display->label->rotate_flag); - - for (p = display->selected_item_list; p != NULL; p = p->next) { - - item = GNOME_CANVAS_ITEM (p->data); - object = gl_item_get_object (item); - gl_label_object_new_from_object (display-> - selection_data, - object); - - } - - gtk_selection_owner_set (display->invisible, - clipboard_atom, GDK_CURRENT_TIME); - display->have_selection = TRUE; - - } -} - -/*****************************************************************************/ -/* "Paste" from private clipboard selection. */ -/*****************************************************************************/ -void -gl_display_paste (glDisplay * display) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - - gtk_selection_convert (GTK_WIDGET (display->invisible), - clipboard_atom, GDK_SELECTION_TYPE_STRING, - GDK_CURRENT_TIME); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Canvas event handler. */ -/*---------------------------------------------------------------------------*/ -static int -canvas_event (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - glDisplay *display = GL_DISPLAY (data); - - switch (display->state) { - - case GL_DISPLAY_STATE_ARROW: - return canvas_event_arrow_mode (canvas, event, data); - - case GL_DISPLAY_STATE_OBJECT_CREATE: - return gl_item_create_event_handler (canvas, event, data); - - default: - WARN ("Invalid display state."); /* Should not happen! */ - return FALSE; - - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Canvas event handler (arrow mode) */ -/*---------------------------------------------------------------------------*/ -static int -canvas_event_arrow_mode (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - static gdouble x0, y0; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - glDisplay *display = GL_DISPLAY (data); - gdouble x, y, x1, y1, x2, y2; - GnomeCanvasGroup *group; - GdkCursor *cursor; - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - - if (display_item_at (display, x, y) == NULL) { - if (!(event->button.state & GDK_CONTROL_MASK)) { - gl_display_unselect_all (display); - } - - dragging = TRUE; - gdk_pointer_grab (GTK_WIDGET (display->canvas)-> - window, FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, NULL, - NULL, event->button.time); - group = - gnome_canvas_root (GNOME_CANVAS - (display->canvas)); - item = - gnome_canvas_item_new (group, - gnome_canvas_rect_get_type (), - "x1", x, "y1", y, - "x2", x, "y2", y, - "width_pixels", 2, - "outline_color_rgba", - GNOME_CANVAS_COLOR_A - (0, 0, 255, 128), - NULL); - x0 = x; - y0 = y; - - } - return FALSE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - if (dragging) { - dragging = FALSE; - gdk_pointer_ungrab (event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, - &x, &y); - x1 = MIN (x, x0); - y1 = MIN (y, y0); - x2 = MAX (x, x0); - y2 = MAX (y, y0); - gl_display_select_region (display, x1, y1, x2, - y2); - gtk_object_destroy (GTK_OBJECT (item)); - return TRUE; - } - return FALSE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - gnome_canvas_window_to_world (canvas, - event->motion.x, - event->motion.y, &x, &y); - - gnome_canvas_item_set (item, - "x1", MIN (x, x0), - "y1", MIN (y, y0), - "x2", MAX (x, x0), - "y2", MAX (y, y0), NULL); - return TRUE; - } else { - return FALSE; - } - - case GDK_KEY_PRESS: - if (!dragging) { - switch (event->key.keyval) { - case GDK_Left: - case GDK_KP_Left: - move_selected_items (display, - -1.0 / (display->scale), - 0.0); - break; - case GDK_Up: - case GDK_KP_Up: - move_selected_items (display, 0.0, - -1.0 / (display->scale)); - break; - case GDK_Right: - case GDK_KP_Right: - move_selected_items (display, - 1.0 / (display->scale), - 0.0); - break; - case GDK_Down: - case GDK_KP_Down: - move_selected_items (display, 0.0, - 1.0 / (display->scale)); - break; - case GDK_Delete: - case GDK_KP_Delete: - delete_selection_cb (GTK_WIDGET (canvas), - display); - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, - cursor); - gdk_cursor_destroy (cursor); - break; - default: - return FALSE; - } - } - return TRUE; /* We handled this or we were dragging. */ - - default: - return FALSE; - } - -} - -/*****************************************************************************/ -/* Item event handler. */ -/*****************************************************************************/ -gint -gl_display_item_event_handler (GnomeCanvasItem * item, - GdkEvent * event, - gpointer data) -{ - glDisplay *display = GL_DISPLAY (data); - - switch (display->state) { - - case GL_DISPLAY_STATE_ARROW: - return item_event_arrow_mode (item, event, data); - - default: - return FALSE; - - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Item event handler (arrow mode) */ -/*---------------------------------------------------------------------------*/ -static int -item_event_arrow_mode (GnomeCanvasItem * item, - GdkEvent * event, - gpointer data) -{ - glDisplay *display = GL_DISPLAY (data); - static gdouble x, y; - static gboolean dragging = FALSE; - GdkCursor *cursor; - gdouble item_x, item_y; - gdouble new_x, new_y; - gboolean control_key_pressed; - - item_x = event->button.x; - item_y = event->button.y; - gnome_canvas_item_w2i (item->parent, &item_x, &item_y); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - control_key_pressed = event->button.state & GDK_CONTROL_MASK; - switch (event->button.button) { - case 1: - if (control_key_pressed) { - if (item_selected (display, item)) { - /* Un-selecting an already selected item */ - gl_display_unselect_item (display, - item); - return TRUE; - } else { - /* Add to current selection */ - gl_display_select_item (display, item); - } - } else { - if (!item_selected (display, item)) { - /* No control, key so remove any selections before adding */ - gl_display_unselect_all (display); - /* Add to current selection */ - gl_display_select_item (display, item); - } - } - /* Go into dragging mode while button remains pressed. */ - x = item_x; - y = item_y; - cursor = gdk_cursor_new (GDK_FLEUR); - gnome_canvas_item_grab (item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - cursor, event->button.time); - gdk_cursor_destroy (cursor); - dragging = TRUE; - return TRUE; - - case 3: - if (!item_selected (display, item)) { - if (!control_key_pressed) { - /* No control, key so remove any selections before adding */ - gl_display_unselect_all (display); - } - } - /* Add to current selection */ - gl_display_select_item (display, item); - /* bring up apropriate menu for selection. */ - popup_selection_menu (display, item, event); - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - /* Exit dragging mode */ - gnome_canvas_item_ungrab (item, event->button.time); - dragging = FALSE; - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - /* Dragging mode, move selection */ - new_x = item_x; - new_y = item_y; - move_selected_items (display, (new_x - x), (new_y - y)); - x = new_x; - y = new_y; - return TRUE; - } else { - return FALSE; - } - - case GDK_2BUTTON_PRESS: - switch (event->button.button) { - case 1: - /* Also exit dragging mode on a a double-click, bring up menu */ - gnome_canvas_item_ungrab (item, event->button.time); - dragging = FALSE; - gl_display_select_item (display, item); - gl_item_edit_dialog (item); - return TRUE; - - default: - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_FLEUR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*****************************************************************************/ -/* create menu for multiple selections. */ -/*****************************************************************************/ -GtkWidget * -gl_display_new_selection_menu (glDisplay * display) -{ - GtkWidget *menu, *menuitem; - - g_return_val_if_fail (GL_IS_DISPLAY (display), NULL); - - menu = gtk_menu_new (); - - menuitem = gtk_menu_item_new_with_label (_("Delete")); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (delete_selection_cb), display); - - menuitem = gtk_menu_item_new (); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Bring to front")); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (raise_selection_cb), display); - - menuitem = gtk_menu_item_new_with_label (_("Send to back")); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (lower_selection_cb), display); - - return menu; -} - -/*****************************************************************************/ -/* create menu for given item. */ -/*****************************************************************************/ -GtkWidget * -gl_display_new_item_menu (GnomeCanvasItem * item) -{ - GtkWidget *menu, *menuitem; - - g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), NULL); - - menu = gtk_menu_new (); - - menuitem = gtk_menu_item_new_with_label (_("Edit properties...")); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - gtk_signal_connect_object (GTK_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (gl_item_edit_dialog), - GTK_OBJECT (item)); - - menuitem = gtk_menu_item_new (); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Delete")); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (delete_item_cb), item); - - menuitem = gtk_menu_item_new (); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - - menuitem = gtk_menu_item_new_with_label (_("Bring to front")); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (raise_item_cb), item); - - menuitem = gtk_menu_item_new_with_label (_("Send to back")); - gtk_menu_append (GTK_MENU (menu), menuitem); - gtk_widget_show (menuitem); - gtk_signal_connect (GTK_OBJECT (menuitem), "activate", - GTK_SIGNAL_FUNC (lower_item_cb), item); - - gtk_object_set_data (GTK_OBJECT (item), "object_menu", menu); - - return menu; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. popup menu for given item. */ -/*---------------------------------------------------------------------------*/ -static void -popup_selection_menu (glDisplay * display, - GnomeCanvasItem * item, - GdkEvent * event) -{ - GtkWidget *menu; - - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - if (multiple_items_selected (display)) { - if (display->menu != NULL) { - gtk_menu_popup (GTK_MENU (display->menu), - NULL, NULL, NULL, NULL, - event->button.button, - event->button.time); - } - } else { - - menu = gl_item_get_menu (item); - if (menu != NULL) { - gtk_menu_popup (GTK_MENU (menu), - NULL, NULL, NULL, NULL, - event->button.button, - event->button.time); - } - - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. delete selection callback. */ -/*---------------------------------------------------------------------------*/ -static void -delete_selection_cb (GtkWidget * widget, - glDisplay * display) -{ - GList *p, *p_next; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - for (p = display->selected_item_list; p != NULL; p = p_next) { - p_next = p->next; - delete_item_cb (widget, GNOME_CANVAS_ITEM (p->data)); - } -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. raise item to front callback. */ -/*---------------------------------------------------------------------------*/ -static void -raise_selection_cb (GtkWidget * widget, - glDisplay * display) -{ - GList *p; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - for (p = display->selected_item_list; p != NULL; p = p->next) { - raise_item_cb (widget, GNOME_CANVAS_ITEM (p->data)); - } -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. lower item to back callback. */ -/*---------------------------------------------------------------------------*/ -static void -lower_selection_cb (GtkWidget * widget, - glDisplay * display) -{ - GList *p; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - for (p = display->selected_item_list; p != NULL; p = p->next) { - lower_item_cb (widget, GNOME_CANVAS_ITEM (p->data)); - } -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. delete item callback. */ -/*---------------------------------------------------------------------------*/ -static void -delete_item_cb (GtkWidget * widget, - GnomeCanvasItem * item) -{ - glDisplay *display; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - display = gl_item_get_display (item); - - gl_display_unselect_item (display, item); - display->item_list = g_list_remove (display->item_list, item); - - gl_item_free (&item); - - gl_display_set_modified (display); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. raise item to front callback. */ -/*---------------------------------------------------------------------------*/ -static void -raise_item_cb (GtkWidget * widget, - GnomeCanvasItem * item) -{ - glLabelObject *object; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - object = gl_item_get_object (item); - gl_label_object_raise_to_front (object); - - gnome_canvas_item_raise_to_top (item); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. lower item to back callback. */ -/*---------------------------------------------------------------------------*/ -static void -lower_item_cb (GtkWidget * widget, - GnomeCanvasItem * item) -{ - glLabelObject *object; - glDisplay *display; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - object = gl_item_get_object (item); - display = gl_item_get_display (item); - - gl_label_object_lower_to_back (object); - - /* Send to bottom */ - gnome_canvas_item_lower_to_bottom (item); - - /* now raise it above all items that form the backgound */ - gnome_canvas_item_raise (item, display->n_bg_items); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. move selected items */ -/*---------------------------------------------------------------------------*/ -static void -move_selected_items (glDisplay * display, - gdouble dx, - gdouble dy) -{ - GList *p; - GnomeCanvasItem *item; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - for (p = display->selected_item_list; p != NULL; p = p->next) { - - item = GNOME_CANVAS_ITEM (p->data); - - move_item (item, dx, dy); - gl_item_highlight (item); - - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. move item/object */ -/*---------------------------------------------------------------------------*/ -static void -move_item (GnomeCanvasItem * item, - gdouble dx, - gdouble dy) -{ - glLabelObject *object; - glDisplay *display; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - object = gl_item_get_object (item); - - object->x += dx; - object->y += dy; - - gnome_canvas_item_move (item, dx, dy); - - display = gl_item_get_display (item); - gl_display_set_modified (display); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Return item at (x,y) if it is in our list of managed items. */ -/*---------------------------------------------------------------------------*/ -static GnomeCanvasItem * -display_item_at (glDisplay * display, - gdouble x, - gdouble y) -{ - GnomeCanvasItem *item; - - g_return_val_if_fail (GL_IS_DISPLAY (display), NULL); - - item = gnome_canvas_get_item_at (GNOME_CANVAS (display->canvas), x, y); - - /* No item is at x, y */ - if (item == NULL) - return NULL; - - /* Don't include our background items */ - if (g_list_find (display->bg_item_list, item) != NULL) - return NULL; - - return item; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Is the item in our current selection? */ -/*---------------------------------------------------------------------------*/ -static gboolean -item_selected (glDisplay * display, - GnomeCanvasItem * item) -{ - g_return_val_if_fail (GL_IS_DISPLAY (display), FALSE); - g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), FALSE); - - if (g_list_find (display->selected_item_list, item) == NULL) { - return FALSE; - } - return TRUE; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Are there multiple items in our current selection? */ -/*---------------------------------------------------------------------------*/ -static gboolean -multiple_items_selected (glDisplay * display) -{ - g_return_val_if_fail (GL_IS_DISPLAY (display), FALSE); - - if (display->selected_item_list == NULL) - return FALSE; - if (display->selected_item_list->next == NULL) - return FALSE; - return TRUE; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Handle "selection-clear" signal. */ -/*---------------------------------------------------------------------------*/ -static void -selection_clear_cb (GtkWidget * widget, - GdkEventSelection * event, - gpointer data) -{ - glDisplay *display = GL_DISPLAY (data); - - g_return_if_fail (GL_IS_DISPLAY (display)); - - display->have_selection = FALSE; - gl_label_free (&display->selection_data); - display->selection_data = NULL; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Handle "selection-get" signal. */ -/*---------------------------------------------------------------------------*/ -static void -selection_get_cb (GtkWidget * widget, - GtkSelectionData * selection_data, - guint info, - guint time, - gpointer data) -{ - glDisplay *display = GL_DISPLAY (data); - gchar *buffer; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - if (display->have_selection) { - - gl_label_save_xml_buffer (display->selection_data, &buffer); - gtk_selection_data_set (selection_data, - GDK_SELECTION_TYPE_STRING, 8, buffer, - strlen (buffer)); - g_free (buffer); - } -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Handle "selection-received" signal. (Result of Paste) */ -/*---------------------------------------------------------------------------*/ -static void -selection_received_cb (GtkWidget * widget, - GtkSelectionData * selection_data, - guint time, - gpointer data) -{ - glDisplay *display = GL_DISPLAY (data); - glLabel *label = NULL; - GList *p; - glLabelObject *object, *newobject; - GnomeCanvasItem *item; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - if (selection_data->length < 0) { - return; - } - if (selection_data->type != GDK_SELECTION_TYPE_STRING) { - return; - } - - gl_display_unselect_all (display); - - gl_label_open_xml_buffer (&label, selection_data->data); - for (p = label->objects; p != NULL; p = p->next) { - object = (glLabelObject *) p->data; - newobject = - gl_label_object_new_from_object (display->label, object); - item = gl_item_new (newobject, display); - gl_display_add_item (display, item); - gl_display_select_item (display, item); - } - gl_label_free (&label); - - gl_display_set_modified (display); -} - -/*****************************************************************************/ -/* Zoom in one "notch" */ -/*****************************************************************************/ -void -gl_display_zoom_in (glDisplay * display) -{ - gint i, i_min; - gdouble dist, dist_min; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - /* Find index of current scale (or best match) */ - i_min = 1; /* start with 2nd largest scale */ - dist_min = fabs (scales[1] - display->scale); - for (i = 2; scales[i] != 0.0; i++) { - dist = fabs (scales[i] - display->scale); - if (dist < dist_min) { - i_min = i; - dist_min = dist; - } - } - - /* zoom in one "notch" */ - i = MAX (0, i_min - 1); - gl_display_set_zoom (display, scales[i] / HOME_SCALE); -} - -/*****************************************************************************/ -/* Zoom out one "notch" */ -/*****************************************************************************/ -void -gl_display_zoom_out (glDisplay * display) -{ - gint i, i_min; - gdouble dist, dist_min; - - g_return_if_fail (GL_IS_DISPLAY (display)); - - /* Find index of current scale (or best match) */ - i_min = 0; /* start with largest scale */ - dist_min = fabs (scales[0] - display->scale); - for (i = 1; scales[i] != 0.0; i++) { - dist = fabs (scales[i] - display->scale); - if (dist < dist_min) { - i_min = i; - dist_min = dist; - } - } - - /* zoom out one "notch" */ - if (scales[i_min] == 0.0) - return; - i = i_min + 1; - if (scales[i] == 0.0) - return; - gl_display_set_zoom (display, scales[i] / HOME_SCALE); - -} - -/*****************************************************************************/ -/* Set current zoom factor to explicit value. */ -/*****************************************************************************/ -void -gl_display_set_zoom (glDisplay * display, - gdouble scale) -{ - g_return_if_fail (GL_IS_DISPLAY (display)); - g_return_if_fail (scale > 0.0); - - display->scale = scale * HOME_SCALE; - gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (display->canvas), - scale * HOME_SCALE); -} - -/*****************************************************************************/ -/* Get current zoom factor. */ -/*****************************************************************************/ -gdouble -gl_display_get_zoom (glDisplay * display) -{ - g_return_val_if_fail (GL_IS_DISPLAY (display), 1.0); - - return display->scale / HOME_SCALE; -} diff --git a/glabels1/src/display.h b/glabels1/src/display.h deleted file mode 100644 index 704e8aa..0000000 --- a/glabels1/src/display.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * display.h: GLabels Display module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __DISPLAY_H__ -#define __DISPLAY_H__ - -#include <gtk/gtk.h> -#include "label.h" - -typedef enum { - GL_DISPLAY_STATE_ARROW, - GL_DISPLAY_STATE_OBJECT_CREATE -} glDisplayState; - -#define GL_TYPE_DISPLAY (gl_display_get_type ()) -#define GL_DISPLAY(obj) (GTK_CHECK_CAST((obj), GL_TYPE_DISPLAY, glDisplay )) -#define GL_DISPLAY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_DISPLAY, glDisplayClass)) -#define GL_IS_DISPLAY(obj) (GTK_CHECK_TYPE ((obj), GL_TYPE_DISPLAY)) -#define GL_IS_DISPLAY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_DISPLAY)) - -typedef struct _glDisplay glDisplay; -typedef struct _glDisplayClass glDisplayClass; - -struct _glDisplay { - GtkVBox parent_widget; - - glLabel *label; - - GtkWidget *canvas; - gdouble scale; - gint n_bg_items; - GList *bg_item_list; - - glDisplayState state; - glLabelObjectType create_type; - - gboolean modified; - - GList *item_list; - GList *selected_item_list; - - gint have_selection; - glLabel *selection_data; - GtkWidget *invisible; - - GtkWidget *menu; -}; - -struct _glDisplayClass { - GtkVBoxClass parent_class; -}; - -extern guint gl_display_get_type (void); - -extern GtkWidget *gl_display_new (glLabel * label); - -extern void gl_display_arrow_mode (glDisplay * display); -extern void gl_display_object_create_mode (glDisplay * display, - glLabelObjectType type); - -extern void gl_display_add_item (glDisplay * display, - GnomeCanvasItem * item); - -extern void gl_display_select_all (glDisplay * display); -extern void gl_display_select_region (glDisplay * display, - gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2); -extern void gl_display_unselect_all (glDisplay * display); - -extern void gl_display_select_item (glDisplay * display, - GnomeCanvasItem * item); -extern void gl_display_unselect_item (glDisplay * display, - GnomeCanvasItem * item); - -extern int gl_display_item_event_handler (GnomeCanvasItem * item, - GdkEvent * event, - gpointer data); - -extern GtkWidget *gl_display_new_selection_menu (glDisplay * display); -extern GtkWidget *gl_display_new_item_menu (GnomeCanvasItem * item); - -extern gboolean gl_display_modified (glDisplay * display); -extern void gl_display_set_modified (glDisplay * display); -extern void gl_display_clear_modified (glDisplay * display); - -extern void gl_display_cut (glDisplay * display); -extern void gl_display_copy (glDisplay * display); -extern void gl_display_paste (glDisplay * display); - -extern void gl_display_zoom_in (glDisplay * display); -extern void gl_display_zoom_out (glDisplay * display); -extern void gl_display_set_zoom (glDisplay * display, gdouble scale); -extern gdouble gl_display_get_zoom (glDisplay * display); - -#endif diff --git a/glabels1/src/edit.c b/glabels1/src/edit.c deleted file mode 100644 index 88ceaef..0000000 --- a/glabels1/src/edit.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * edit.c: Edit module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <gnome.h> - -#include "edit.h" - -#include "display.h" -#include "mdi.h" - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*============================================*/ -/* Private function prototypes. */ -/*============================================*/ - -/*****************************************************************************/ -/* "Cut" */ -/*****************************************************************************/ -void -gl_edit_cut_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - glDisplay *display; - - g_return_if_fail (child != NULL); - g_return_if_fail (app != NULL); - - display = gl_mdi_get_display (child); - - gl_display_cut (display); - -} - -/*****************************************************************************/ -/* "Copy" */ -/*****************************************************************************/ -void -gl_edit_copy_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - glDisplay *display; - - g_return_if_fail (child != NULL); - g_return_if_fail (app != NULL); - - display = gl_mdi_get_display (child); - - gl_display_copy (display); - -} - -/*****************************************************************************/ -/* "Paste" */ -/*****************************************************************************/ -void -gl_edit_paste_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - g_return_if_fail (child != NULL); - - display = gl_mdi_get_display (child); - - gl_display_paste (display); -} - -/*****************************************************************************/ -/* "Select ALL" */ -/*****************************************************************************/ -void -gl_edit_select_all_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - g_return_if_fail (child != NULL); - - display = gl_mdi_get_display (child); - - gl_display_select_all (display); -} - -/*****************************************************************************/ -/* "Un-select" */ -/*****************************************************************************/ -void -gl_edit_unselect_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - g_return_if_fail (child != NULL); - - display = gl_mdi_get_display (child); - - gl_display_unselect_all (display); -} diff --git a/glabels1/src/edit.h b/glabels1/src/edit.h deleted file mode 100644 index 0a9854b..0000000 --- a/glabels1/src/edit.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * edit.h: Edit module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __EDIT_H__ -#define __EDIT_H__ - -#include <gtk/gtk.h> - -extern void gl_edit_add_cb (GtkWidget * widget, gpointer data); - -extern void gl_edit_delete_cb (GtkWidget * widget, gpointer data); - -extern void gl_edit_title_cb (GtkWidget * widget, gpointer data); - -extern void gl_edit_select_all_cb (GtkWidget * widget, gpointer data); - -extern void gl_edit_unselect_cb (GtkWidget * widget, gpointer data); - -extern void gl_edit_cut_cb (GtkWidget * widget, gpointer data); - -extern void gl_edit_copy_cb (GtkWidget * widget, gpointer data); - -extern void gl_edit_paste_cb (GtkWidget * widget, gpointer data); - -#endif /* __EDIT_H__ */ diff --git a/glabels1/src/file.c b/glabels1/src/file.c deleted file mode 100644 index 9d3243f..0000000 --- a/glabels1/src/file.c +++ /dev/null @@ -1,415 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * file.c: FILE menu dialog module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <gnome.h> -#include <string.h> - -#include "file.h" -#include "mdi.h" -#include "util.h" -#include "media_select.h" -#include "rotate_select.h" - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/* Saved state for new dialog */ -static gchar *page_size = NULL; -static gchar *sheet_name = NULL; -static gboolean rotate_flag = FALSE; - -/* Saved state of file selectors */ -static gchar *open_path = NULL; -static gchar *save_path = NULL; - -/*===========================================*/ -/* Local function prototypes. */ -/*===========================================*/ -static void create_new_dialog_widgets (GnomeDialog * new_dlg); -static void new_template_changed (glMediaSelect * select, - gpointer data); -static void new_ok (GtkWidget * widget, - gpointer data); -static void open_ok (GtkWidget * widget, - GtkFileSelection * fsel); -static void save_as_ok (GtkWidget * widget, - GtkFileSelection * fsel); - -/*****************************************************************************/ -/* "New" menu callback. */ -/*****************************************************************************/ -void -gl_file_new_cb (GtkWidget * widget, - gpointer data) -{ - GtkWidget *new_dlg; - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - - g_return_if_fail (app != NULL); - - new_dlg = gnome_dialog_new (_("New Label or Card"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, NULL); - gtk_window_set_transient_for (GTK_WINDOW (new_dlg), GTK_WINDOW (app)); - - create_new_dialog_widgets (GNOME_DIALOG (new_dlg)); - - gnome_dialog_button_connect (GNOME_DIALOG (new_dlg), 0, - GTK_SIGNAL_FUNC (new_ok), new_dlg); - - gnome_dialog_button_connect_object (GNOME_DIALOG (new_dlg), 1, - GTK_SIGNAL_FUNC - (gtk_widget_destroy), - GTK_OBJECT (new_dlg)); - - gtk_widget_show_all (GTK_WIDGET (new_dlg)); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Create widgets to enter a bond by sn and idate. */ -/*---------------------------------------------------------------------------*/ -static void -create_new_dialog_widgets (GnomeDialog * new_dlg) -{ - GtkWidget *wframe, *wvbox, *template_entry, *rotate_sel; - - wframe = gtk_frame_new (_("Media Type")); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (new_dlg)->vbox), - wframe, FALSE, FALSE, 0); - - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gtk_container_add (GTK_CONTAINER (wframe), wvbox); - - template_entry = gl_media_select_new (); - gtk_container_add (GTK_CONTAINER (wvbox), template_entry); - - wframe = gtk_frame_new (_("Label orientation")); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (new_dlg)->vbox), - wframe, FALSE, FALSE, 0); - - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gtk_container_add (GTK_CONTAINER (wframe), wvbox); - - rotate_sel = gl_rotate_select_new (); - gtk_box_pack_start (GTK_BOX (wvbox), rotate_sel, FALSE, FALSE, 0); - - gtk_object_set_data (GTK_OBJECT (new_dlg), "template_entry", - template_entry); - gtk_object_set_data (GTK_OBJECT (new_dlg), "rotate_sel", rotate_sel); - - gtk_signal_connect (GTK_OBJECT (template_entry), "changed", - GTK_SIGNAL_FUNC (new_template_changed), rotate_sel); - - if (page_size != NULL) { - gl_media_select_set_page_size (GL_MEDIA_SELECT (template_entry), - page_size); - } - if (sheet_name != NULL) { - gl_media_select_set_name (GL_MEDIA_SELECT (template_entry), - sheet_name); - gl_rotate_select_set_template_name (GL_ROTATE_SELECT - (rotate_sel), sheet_name); - } else { - sheet_name = - gl_media_select_get_name (GL_MEDIA_SELECT (template_entry)); - gl_rotate_select_set_template_name (GL_ROTATE_SELECT - (rotate_sel), sheet_name); - } - gl_rotate_select_set_state (GL_ROTATE_SELECT (rotate_sel), rotate_flag); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. New template changed callback. */ -/*---------------------------------------------------------------------------*/ -static void -new_template_changed (glMediaSelect * select, - gpointer data) -{ - glRotateSelect *rotate_sel = GL_ROTATE_SELECT (data); - gchar *name; - - name = gl_media_select_get_name (GL_MEDIA_SELECT (select)); - - gl_rotate_select_set_template_name (GL_ROTATE_SELECT (rotate_sel), - name); - - g_free (name); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. New "ok" button callback. */ -/*---------------------------------------------------------------------------*/ -static void -new_ok (GtkWidget * widget, - gpointer data) -{ - GnomeDialog *new_dlg = GNOME_DIALOG (data); - GtkWidget *template_entry, *rotate_sel; - - template_entry = - GTK_WIDGET (gtk_object_get_data - (GTK_OBJECT (new_dlg), "template_entry")); - rotate_sel = - GTK_WIDGET (gtk_object_get_data - (GTK_OBJECT (new_dlg), "rotate_sel")); - - if (page_size != NULL) - g_free (page_size); - page_size = - gl_media_select_get_page_size (GL_MEDIA_SELECT (template_entry)); - - if (sheet_name != NULL) - g_free (sheet_name); - sheet_name = - gl_media_select_get_name (GL_MEDIA_SELECT (template_entry)); - - rotate_flag = - gl_rotate_select_get_state (GL_ROTATE_SELECT (rotate_sel)); - - gl_mdi_new_child (sheet_name, rotate_flag); - - gtk_widget_destroy (GTK_WIDGET (new_dlg)); -} - -/*****************************************************************************/ -/* "Open" menu callback. */ -/*****************************************************************************/ -void -gl_file_open_cb (GtkWidget * widget, - gpointer data) -{ - GtkFileSelection *fsel; - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - - g_return_if_fail (app != NULL); - - fsel = GTK_FILE_SELECTION (gtk_file_selection_new (_("Open"))); - gtk_window_set_transient_for (GTK_WINDOW (fsel), GTK_WINDOW (app)); - gtk_window_set_title (GTK_WINDOW (fsel), _("Open label")); - - gtk_signal_connect (GTK_OBJECT (fsel->ok_button), "clicked", - GTK_SIGNAL_FUNC (open_ok), fsel); - - gtk_signal_connect_object (GTK_OBJECT (fsel->cancel_button), "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (fsel)); - - /* Recover state of open dialog */ - if (open_path != NULL) { - gtk_file_selection_set_filename (fsel, open_path); - } - - /* show the dialog */ - gtk_widget_show (GTK_WIDGET (fsel)); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Open "O.K." button callback. */ -/*---------------------------------------------------------------------------*/ -static void -open_ok (GtkWidget * widget, - GtkFileSelection * fsel) -{ - gchar *filename; - GtkWidget *dlg; - - g_return_if_fail (GTK_IS_FILE_SELECTION (fsel)); - - /* get the filename */ - filename = g_strdup (gtk_file_selection_get_filename (fsel)); - if (filename) { - if (!gl_mdi_new_child_from_xml_file (filename)) { - - dlg = - gnome_error_dialog_parented (_("Cannot open file"), - GTK_WINDOW (fsel)); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - - } else { - - gtk_widget_destroy (GTK_WIDGET (fsel)); - - if (open_path != NULL) - g_free (open_path); - open_path = g_dirname (filename); - if (open_path != NULL) - open_path = g_strconcat (open_path, "/", NULL); - - } - } - - g_free (filename); -} - -/*****************************************************************************/ -/* "Save" menu callback. */ -/*****************************************************************************/ -void -gl_file_save_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - gchar *filename; - - g_return_if_fail (child != NULL); - g_return_if_fail (app != NULL); - - filename = gl_mdi_get_filename (child); - if (!filename) { - gl_file_save_as_cb (widget, data); - } else { - if (!gl_mdi_save_child_to_xml_file (child, filename)) { - gnome_error_dialog_parented (_("Cannot save file"), - GTK_WINDOW (app)); - } - } - - g_free (filename); -} - -/*****************************************************************************/ -/* "Save As" menu callback. */ -/*****************************************************************************/ -void -gl_file_save_as_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - GtkFileSelection *fsel; - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - gint id; - - g_return_if_fail (child != NULL); - g_return_if_fail (app != NULL); - - fsel = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save As"))); - id = gl_mdi_get_id (child); - gtk_object_set_data (GTK_OBJECT (fsel), "id", GINT_TO_POINTER (id)); - - gtk_window_set_transient_for (GTK_WINDOW (fsel), GTK_WINDOW (app)); - gtk_window_set_title (GTK_WINDOW (fsel), _("Save label as")); - - gtk_signal_connect (GTK_OBJECT (fsel->ok_button), "clicked", - GTK_SIGNAL_FUNC (save_as_ok), fsel); - - gtk_signal_connect_object (GTK_OBJECT (fsel->cancel_button), "clicked", - GTK_SIGNAL_FUNC (gtk_widget_destroy), - GTK_OBJECT (fsel)); - - /* Recover proper state of save-as dialog */ - if (save_path != NULL) { - gtk_file_selection_set_filename (fsel, save_path); - } - - /* show the dialog */ - gtk_widget_show (GTK_WIDGET (fsel)); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Save As" ok button callback. */ -/*---------------------------------------------------------------------------*/ -static void -save_as_ok (GtkWidget * widget, - GtkFileSelection * fsel) -{ - gchar *raw_filename, *filename; - GtkWidget *dlg; - gint id = - GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (fsel), "id")); - GnomeMDIChild *child = gl_mdi_find_child (id); - - g_return_if_fail (GTK_IS_FILE_SELECTION (fsel)); - - if (child == NULL) { - gtk_widget_destroy (GTK_WIDGET (fsel)); - dlg = gnome_error_dialog (_("Label no longer valid!")); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - return; - } - - /* get the filename */ - raw_filename = g_strdup (gtk_file_selection_get_filename (fsel)); - - if (!raw_filename || (raw_filename[strlen (raw_filename) - 1] == '/')) { - - dlg = gnome_warning_dialog_parented (_("Must supply file name"), - GTK_WINDOW (fsel)); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - - } else { - - filename = gl_util_add_extension (raw_filename); - - if (!gl_mdi_save_child_to_xml_file (child, filename)) { - - dlg = - gnome_error_dialog_parented (_ - ("Error writing file"), - GTK_WINDOW (fsel)); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - - } else { - - if (save_path != NULL) - g_free (save_path); - save_path = g_dirname (filename); - if (save_path != NULL) - save_path = g_strconcat (save_path, "/", NULL); - - gtk_widget_destroy (GTK_WIDGET (fsel)); - } - - g_free (filename); - } - - g_free (raw_filename); -} - -/*****************************************************************************/ -/* "Close" menu callback. */ -/*****************************************************************************/ -void -gl_file_close_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - - gl_mdi_close_child (child); -} - -/*****************************************************************************/ -/* "Exit" menu callback. */ -/*****************************************************************************/ -void -gl_file_exit_cb (GtkWidget * widget, - gpointer data) -{ - gl_mdi_close_all (); -} diff --git a/glabels1/src/file.h b/glabels1/src/file.h deleted file mode 100644 index f5d035e..0000000 --- a/glabels1/src/file.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * file.h: FILE menu dialog module header file - * - * Copyright (C) 2000 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __FILE_H__ -#define __FILE_H__ - -#include <gtk/gtk.h> - -void gl_file_new_cb (GtkWidget * widget, gpointer data); -void gl_file_open_cb (GtkWidget * widget, gpointer data); -void gl_file_save_cb (GtkWidget * widget, gpointer data); -void gl_file_save_as_cb (GtkWidget * widget, gpointer data); -void gl_file_close_cb (GtkWidget * widget, gpointer data); -void gl_file_exit_cb (GtkWidget * widget, gpointer data); - -#endif /* __FILE_H__ */ diff --git a/glabels1/src/glabels.c b/glabels1/src/glabels.c deleted file mode 100644 index 6e68fb9..0000000 --- a/glabels1/src/glabels.c +++ /dev/null @@ -1,164 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * glabels.c: main program module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <gnome.h> -#include <libgnomeui/gnome-window-icon.h> - -#include "splash.h" -#include "stock.h" -#include "merge.h" -#include "merge_ui.h" -#include "mdi.h" -#include "template.h" -#include "debug.h" - -#ifdef PACKAGE_DATA_DIR -#define ICON_PIXMAP (PACKAGE_DATA_DIR "/pixmaps/glabels/glabels-icon.png") -#else -#define ICON_PIXMAP gnome_pixmap_file("glabels/glabels-icon.png") -#endif - -/*============================================*/ -/* Private globals */ -/*============================================*/ -static struct poptOption options[] = { - {NULL, '\0', 0, NULL, 0, NULL, NULL} -}; - -/*============================================*/ -/* Private function prototypes */ -/*============================================*/ -static void session_die (GnomeClient * client, - gpointer client_data); -static gint save_session (GnomeClient * client, - gint phase, - GnomeSaveStyle save_style, - gint is_shutdown, - GnomeInteractStyle interact_style, - gint is_fast, - gpointer client_data); - - -/*****************************************************************************/ -/* Main */ -/*****************************************************************************/ -int -main (int argc, - char *argv[]) -{ - poptContext pctx; - gchar **args; - GnomeMDI *mdi; - GnomeClient *client; - GSList *p, *file_list = NULL; - gint i, opened; - - bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); - textdomain (PACKAGE); - - gnome_init_with_popt_table (PACKAGE, VERSION, - argc, argv, options, 0, &pctx); - - /* Splash screen */ - gl_splash (); - - if (!g_file_exists (ICON_PIXMAP)) { - WARN ("Could not find %s", ICON_PIXMAP); - } - gnome_window_icon_set_default_from_file (ICON_PIXMAP); - - /* argument parsing */ - args = (char **) poptGetArgs (pctx); - for (i = 0; args && args[i]; i++) { - file_list = g_slist_append (file_list, args[i]); - } - poptFreeContext (pctx); - - /* session management */ - client = gnome_master_client (); - gtk_signal_connect (GTK_OBJECT (client), "save_yourself", - GTK_SIGNAL_FUNC (save_session), argv[0]); - gtk_signal_connect (GTK_OBJECT (client), "die", - GTK_SIGNAL_FUNC (session_die), NULL); - - gl_stock_init (); - gl_merge_init (); - gl_merge_ui_init (); - gl_template_init (); - - mdi = gl_mdi_init (); - - /* Any files on command line? */ - opened = 0; - for (p = file_list; p; p = p->next) { - if (gl_mdi_new_child_from_xml_file (p->data)) - opened++; - } - g_slist_free (file_list); - - if (!opened) { - gnome_mdi_open_toplevel (mdi); - } - - /* Now start main loop */ - gtk_main (); - - return 0; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Save Session signal callback. */ -/*---------------------------------------------------------------------------*/ -static gint -save_session (GnomeClient * client, - gint phase, - GnomeSaveStyle save_style, - gint is_shutdown, - GnomeInteractStyle interact_style, - gint is_fast, - gpointer client_data) -{ - gchar **argv; - guint argc; - - argv = g_malloc0 (4 * sizeof (gchar *)); - argc = 1; - - argv[0] = client_data; - - gnome_client_set_clone_command (client, argc, argv); - gnome_client_set_restart_command (client, argc, argv); - - return TRUE; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Session Die signal callback. */ -/*---------------------------------------------------------------------------*/ -static void -session_die (GnomeClient * client, - gpointer client_data) -{ - gtk_main_quit (); -} diff --git a/glabels1/src/glabels_batch.c b/glabels1/src/glabels_batch.c deleted file mode 100644 index 480f207..0000000 --- a/glabels1/src/glabels_batch.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * glabels.c: main program module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <unistd.h> -#include <stdlib.h> -#include <gnome.h> -#include <libgnomeprint/gnome-printer.h> - -#include "merge.h" -#include "label.h" -#include "template.h" -#include "print.h" -#include "util.h" - -/*============================================*/ -/* Private globals */ -/*============================================*/ -static gboolean help_flag = FALSE; -static gboolean version_flag = FALSE; -static gchar *output = "output.ps"; -static gint n_copies = 1; -static gint n_sheets = 1; -static gboolean outline_flag = FALSE; -static gboolean reverse_flag = FALSE; - -static struct poptOption options[] = { - {"help", 'h', POPT_ARG_NONE, &help_flag, 1, - N_("print this message"), NULL}, - {"version", 'v', POPT_ARG_NONE, &version_flag, 0, - N_("print the version of glabels-batch being used"), NULL}, - {"output", 'o', POPT_ARG_STRING, &output, 0, - N_("set output filename (default=\"output.ps\")"), N_("filename")}, - {"sheets", 's', POPT_ARG_INT, &n_sheets, 0, - N_("number of sheets (default=1)"), N_("sheets")}, - {"copies", 'c', POPT_ARG_INT, &n_copies, 0, - N_("number of copies (default=1)"), N_("copies")}, - {"outline", 'l', POPT_ARG_NONE, &outline_flag, 0, - N_("print outlines (to test printer alignment)"), NULL}, - {"reverse", 'r', POPT_ARG_NONE, &reverse_flag, 0, - N_("print in reverse (i.e. a mirror image)"), NULL}, - {NULL, '\0', 0, NULL, 0, NULL, NULL} -}; - - - -/*****************************************************************************/ -/* Main */ -/*****************************************************************************/ -int -main (int argc, - char *argv[]) -{ - poptContext pctx; - gchar **args; - gint rc; - GSList *p, *file_list = NULL; - gint n_files; - GnomePrintMaster *master = NULL; - gchar *abs_fn; - GnomePrinter *prn = NULL; - glLabel *label = NULL; - - bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); - textdomain (PACKAGE); - - setlocale (LC_ALL, ""); - gtk_type_init (); - - /* argument parsing */ - pctx = poptGetContext (NULL, argc, argv, options, 0); - poptSetOtherOptionHelp (pctx, _("[OPTION...] GLABELS_FILE...") ); - if ( (rc = poptGetNextOpt(pctx)) < -1 ) { - fprintf (stderr, "%s: %s\n", - poptBadOption (pctx,0), poptStrerror(rc)); - poptPrintUsage (pctx, stderr, 0); - return -1; - } - if ( version_flag ) { - fprintf ( stderr, "glabels-batch %s\n", VERSION ); - } - if ( help_flag ) { - poptPrintHelp (pctx, stderr, 0); - return -1; - } - args = (char **) poptGetArgs (pctx); - for (n_files = 0; args && args[n_files]; n_files++) { - file_list = g_slist_append (file_list, args[n_files]); - } - if ( !n_files ) { - fprintf ( stderr, _("missing glabels file\n") ); - poptPrintHelp (pctx, stderr, 0); - return -1; - } - poptFreeContext (pctx); - - /* initialize components */ - gl_merge_init (); - gl_template_init (); - - /* now print the files */ - for (p = file_list; p; p = p->next) { - if ( gl_label_open_xml( &label, p->data ) == LABEL_OK ) { - - if ( master == NULL ) { - master = gnome_print_master_new (); - abs_fn = gl_util_make_absolute ( output ); - prn = gnome_printer_new_generic_ps ( abs_fn ); - g_free( abs_fn ); - gnome_print_master_set_printer ( master, prn ); - } - - gl_print_batch( master, label, n_sheets, n_copies, - outline_flag, reverse_flag ); - - gl_label_free( &label ); - } - else { - fprintf ( stderr, _("cannot open glabels file %s\n"), - (char *)p->data ); - } - } - if ( master != NULL ) { - unlink (output); - gnome_print_master_print (master); - } - - g_slist_free (file_list); - - return 0; -} - diff --git a/glabels1/src/gnome-canvas-hacktext.h b/glabels1/src/gnome-canvas-hacktext.h deleted file mode 100644 index f36ec1a..0000000 --- a/glabels1/src/gnome-canvas-hacktext.h +++ /dev/null @@ -1,76 +0,0 @@ -/* Hacktext item type for GnomeCanvas widget - * - * GnomeCanvas is basically a port of the Tk toolkit's most excellent canvas widget. Tk is - * copyrighted by the Regents of the University of California, Sun Microsystems, and other parties. - * - * Copyright (C) 1998,1999 The Free Software Foundation - * - * Authors: Federico Mena <federico@nuclecu.unam.mx> - * Raph Levien <raph@acm.org> - */ - -#ifndef GNOME_CANVAS_HACKTEXT_H -#define GNOME_CANVAS_HACKTEXT_H - -BEGIN_GNOME_DECLS - -/* Hacktext item for the canvas. The API is totally unstable - it needs to be replaced with one - * that supports Unicode and the merged GnomeText/GScript API. However, I need a text item now, - * and the GnomeText/GScript integration is going to take a bit more effort. - * - * The following object arguments are available: - * - * name type read/write description - * ------------------------------------------------------------------------------------------ - * text char * RW The string of the text item. - * glyphlist GnomeGlyphList * W Glyphlist - * fill_color string W X color specification for fill color, - * or NULL pointer for no color (transparent). - * fill_color_gdk GdkColor* RW Allocated GdkColor for fill. - */ - -#define GNOME_TYPE_CANVAS_HACKTEXT (gnome_canvas_hacktext_get_type ()) -#define GNOME_CANVAS_HACKTEXT(obj) (GTK_CHECK_CAST ((obj), GNOME_TYPE_CANVAS_HACKTEXT, GnomeCanvasHacktext)) -#define GNOME_CANVAS_HACKTEXT_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GNOME_TYPE_CANVAS_HACKTEXT, GnomeCanvasHacktextClass)) -#define GNOME_IS_CANVAS_HACKTEXT(obj) (GTK_CHECK_TYPE ((obj), GNOME_TYPE_CANVAS_HACKTEXT)) -#define GNOME_IS_CANVAS_HACKTEXT_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GNOME_TYPE_CANVAS_HACKTEXT)) - -typedef struct _GnomeCanvasHacktext GnomeCanvasHacktext; -typedef struct _GnomeCanvasHacktextPriv GnomeCanvasHacktextPriv; -typedef struct _GnomeCanvasHacktextClass GnomeCanvasHacktextClass; - -#include <libgnomeui/gnome-canvas.h> - -struct _GnomeCanvasHacktext { - GnomeCanvasItem item; - - char *text; /* String of the text item */ - - guint fill_color; /* Fill color, RGBA */ - - gulong fill_pixel; /* Color for fill */ - - guint fill_set : 1; /* Is fill color set? */ - - double size; /* size in user units */ - - double x, y; /* x, y coords of text origin */ - - /* Antialiased specific stuff follows */ - guint32 fill_rgba; /* RGBA color for filling */ - - GnomeCanvasHacktextPriv *priv; /* Private data */ -}; - -struct _GnomeCanvasHacktextClass { - GnomeCanvasItemClass parent_class; -}; - - -/* Standard Gtk function */ -GtkType gnome_canvas_hacktext_get_type (void); - - -END_GNOME_DECLS - -#endif diff --git a/glabels1/src/hack.c b/glabels1/src/hack.c deleted file mode 100644 index 07ecf0a..0000000 --- a/glabels1/src/hack.c +++ /dev/null @@ -1,146 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * hack.c: various small hacks to deal with I18N - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * - * The g_unichar_to_utf8 has been borrowed from gnumeric, which was borrowed - * from glib-1.3: - * g_unichar_to_utf8: Copyright Red Hat, Inc - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <gdk/gdk.h> -#include <string.h> -#include <stdlib.h> - -#include "hack.h" - -static int g_unichar_to_utf8 (gint c, gchar * outbuf); - -/*****************************************************************************/ -/* Convert text to UTF8. */ -/*****************************************************************************/ -gchar * -gl_hack_text_to_utf8 (gchar * text) -{ - gint len; - GdkWChar *wide_text; - gint enc_status; - gchar *p, *utf8_text; - gint i; - - len = strlen (text); - wide_text = g_new (GdkWChar, len + 1); - enc_status = mbstowcs ((wchar_t *)wide_text, (char *)text, len); - if (enc_status < 0) { - g_free (wide_text); - return NULL; - } - - p = utf8_text = g_new (gchar, enc_status * 6 + 1); - for (i = 0; i < enc_status; i++) { - p += g_unichar_to_utf8 ((gint) wide_text[i], p); - } - *p = 0; /* terminate */ - - g_free (wide_text); - - return utf8_text; -} - -/*****************************************************************************/ -/* Calculate width of text with given font. */ -/*****************************************************************************/ -double -gl_hack_get_width_string (GnomeFont * font, - gchar * text) -{ - gint len; - GdkWChar *wide_text; - gint enc_status; - gint i; - gdouble w; - - len = strlen (text); - wide_text = g_new (GdkWChar, len + 1); - enc_status = mbstowcs ((wchar_t *)wide_text, (char *)text, len); - if (enc_status < 0) { - g_free (wide_text); - return 0.0; - } - - w = 0; - for (i = 0; i < enc_status; i++) { - w += gnome_font_get_glyph_width (font, - gnome_font_lookup_default - (font, wide_text[i])); - } - - g_free (wide_text); - - return w; -} - -/*----------------------------------------------------------------------------- - * This is cut & pasted from glib 1.3 - * - * We need it only for iso-8859-1 converter and it will be - * abandoned, if glib 2.0 or any other unicode library will - * be introduced. - *---------------------------------------------------------------------------*/ -static int -g_unichar_to_utf8 (gint c, - gchar * outbuf) -{ - size_t len = 0; - int first; - int i; - - if (c < 0x80) { - first = 0; - len = 1; - } else if (c < 0x800) { - first = 0xc0; - len = 2; - } else if (c < 0x10000) { - first = 0xe0; - len = 3; - } else if (c < 0x200000) { - first = 0xf0; - len = 4; - } else if (c < 0x4000000) { - first = 0xf8; - len = 5; - } else { - first = 0xfc; - len = 6; - } - - if (outbuf) { - for (i = len - 1; i > 0; --i) { - outbuf[i] = (c & 0x3f) | 0x80; - c >>= 6; - } - outbuf[0] = c | first; - } - - return len; -} diff --git a/glabels1/src/hack.h b/glabels1/src/hack.h deleted file mode 100644 index 2f0b868..0000000 --- a/glabels1/src/hack.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * hack.h: various small hacks to deal with I18N - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __HACK_H__ -#define __HACK_H__ - -#include <libgnomeprint/gnome-font.h> - -extern gchar *gl_hack_text_to_utf8 (gchar * text); - -extern double gl_hack_get_width_string (GnomeFont * font, gchar * text); - -#endif /* __HACK_H__ */ diff --git a/glabels1/src/highlight.c b/glabels1/src/highlight.c deleted file mode 100644 index 6acc388..0000000 --- a/glabels1/src/highlight.c +++ /dev/null @@ -1,1443 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * highlight.c: GLabels Resizable Highlight module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "highlight.h" -#include "item.h" - -#include "math.h" - -#include "debug.h" - -#define MIN_ITEM_SIZE 1.0 - -/*===========================================*/ -/* Private data types */ -/*===========================================*/ - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void highlight_resizable_box (GnomeCanvasItem * item, - glHighlightStyle style); -static void highlight_resizable_line (GnomeCanvasItem * item); -static void highlight_simple (GnomeCanvasItem * item); - -static int tl_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); -static int tr_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); -static int bl_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); -static int br_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); - -static int sl_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); -static int sr_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); -static int st_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); -static int sb_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); - -static int p1_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); -static int p2_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); - -static int passthrough_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, gpointer data); - -/*****************************************************************************/ -/* Create/Update & Display a resizable highlight for given item. */ -/*****************************************************************************/ -void -gl_highlight (GnomeCanvasItem * item, - glHighlightStyle style) -{ - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - switch (style) { - - case GL_HIGHLIGHT_BOX_RESIZABLE: - case GL_HIGHLIGHT_ELLIPSE_RESIZABLE: - highlight_resizable_box (item, style); - break; - - case GL_HIGHLIGHT_LINE_RESIZABLE: - highlight_resizable_line (item); - break; - - case GL_HIGHLIGHT_SIMPLE: - highlight_simple (item); - break; - - default: - WARN ("Invalid resizable highlight style"); - - } -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Create/Update & Display a resizable box highlight. */ -/*---------------------------------------------------------------------------*/ -static void -highlight_resizable_box (GnomeCanvasItem * item, - glHighlightStyle style) -{ - GnomeCanvasItem *highlight; - gdouble x, y, w, h; - GnomeCanvasItem *outline; /* Outline around item */ - GnomeCanvasItem *tl, *tr, *bl, *br; /* Handles at four corners */ - GnomeCanvasItem *sl, *sr, *st, *sb; /* Handles at each side */ - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - highlight = gtk_object_get_data (GTK_OBJECT (item), "highlight"); - - gl_item_get_position_size (item, &x, &y, &w, &h); - - if (highlight == NULL) { - - highlight = - gnome_canvas_item_new (gnome_canvas_root - (GNOME_CANVAS (item->canvas)), - gnome_canvas_group_get_type (), "x", - x, "y", y, NULL); - - switch (style) { - case GL_HIGHLIGHT_BOX_RESIZABLE: - outline = - gnome_canvas_item_new (GNOME_CANVAS_GROUP - (highlight), - gnome_canvas_rect_get_type - (), - "x1", -0.5, - "y1", -0.5, - "x2", w + 0.5, - "y2", h + 0.5, - "width_pixels", 2, - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, - 255, - 255), - NULL); - break; - case GL_HIGHLIGHT_ELLIPSE_RESIZABLE: - outline = - gnome_canvas_item_new (GNOME_CANVAS_GROUP - (highlight), - gnome_canvas_ellipse_get_type - (), - "x1", -0.5, - "y1", -0.5, - "x2", w + 0.5, - "y2", h + 0.5, - "width_pixels", 2, - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, - 255, - 255), - NULL); - break; - default: - outline = NULL; - WARN ("Invalid resizable highlight style"); - } - - tl = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", -1.0, - "y1", -1.0, - "x2", +1.0, - "y2", +1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - tr = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", w - 1.0, - "y1", -1.0, - "x2", w + 1.0, - "y2", +1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - bl = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", -1.0, - "y1", h - 1.0, - "x2", +1.0, - "y2", h + 1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - br = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", w - 1.0, - "y1", h - 1.0, - "x2", w + 1.0, - "y2", h + 1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - sl = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", -1.0, - "y1", h / 2.0 - 1.0, - "x2", +1.0, - "y2", h / 2.0 + 1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - sr = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", w - 1.0, - "y1", h / 2.0 - 1.0, - "x2", w + 1.0, - "y2", h / 2.0 + 1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - st = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", w / 2.0 - 1.0, - "y1", -1.0, - "x2", w / 2.0 + 1.0, - "y2", +1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - sb = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", w / 2.0 - 1.0, - "y1", h - 1.0, - "x2", w / 2.0 + 1.0, - "y2", h + 1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - gtk_object_set_data (GTK_OBJECT (item), "highlight", highlight); - - gtk_object_set_data (GTK_OBJECT (highlight), "outline", - outline); - - gtk_object_set_data (GTK_OBJECT (highlight), "tl", tl); - gtk_object_set_data (GTK_OBJECT (highlight), "tr", tr); - gtk_object_set_data (GTK_OBJECT (highlight), "bl", bl); - gtk_object_set_data (GTK_OBJECT (highlight), "br", br); - gtk_object_set_data (GTK_OBJECT (highlight), "sl", sl); - gtk_object_set_data (GTK_OBJECT (highlight), "sr", sr); - gtk_object_set_data (GTK_OBJECT (highlight), "st", st); - gtk_object_set_data (GTK_OBJECT (highlight), "sb", sb); - - gtk_signal_connect (GTK_OBJECT (tl), "event", - GTK_SIGNAL_FUNC (tl_resize_event_handler), - item); - gtk_signal_connect (GTK_OBJECT (tr), "event", - GTK_SIGNAL_FUNC (tr_resize_event_handler), - item); - gtk_signal_connect (GTK_OBJECT (bl), "event", - GTK_SIGNAL_FUNC (bl_resize_event_handler), - item); - gtk_signal_connect (GTK_OBJECT (br), "event", - GTK_SIGNAL_FUNC (br_resize_event_handler), - item); - gtk_signal_connect (GTK_OBJECT (sl), "event", - GTK_SIGNAL_FUNC (sl_resize_event_handler), - item); - gtk_signal_connect (GTK_OBJECT (sr), "event", - GTK_SIGNAL_FUNC (sr_resize_event_handler), - item); - gtk_signal_connect (GTK_OBJECT (st), "event", - GTK_SIGNAL_FUNC (st_resize_event_handler), - item); - gtk_signal_connect (GTK_OBJECT (sb), "event", - GTK_SIGNAL_FUNC (sb_resize_event_handler), - item); - - gtk_signal_connect (GTK_OBJECT (outline), "event", - GTK_SIGNAL_FUNC (passthrough_event_handler), - item); - - } else { - - gnome_canvas_item_set (highlight, "x", x, "y", y, NULL); - - outline = - gtk_object_get_data (GTK_OBJECT (highlight), "outline"); - - tl = gtk_object_get_data (GTK_OBJECT (highlight), "tl"); - tr = gtk_object_get_data (GTK_OBJECT (highlight), "tr"); - bl = gtk_object_get_data (GTK_OBJECT (highlight), "bl"); - br = gtk_object_get_data (GTK_OBJECT (highlight), "br"); - sl = gtk_object_get_data (GTK_OBJECT (highlight), "sl"); - sr = gtk_object_get_data (GTK_OBJECT (highlight), "sr"); - st = gtk_object_get_data (GTK_OBJECT (highlight), "st"); - sb = gtk_object_get_data (GTK_OBJECT (highlight), "sb"); - - gnome_canvas_item_set (outline, - "x1", -0.5, - "y1", -0.5, - "x2", w + 0.5, "y2", h + 0.5, NULL); - - gnome_canvas_item_set (tl, - "x1", -1.0, - "y1", -1.0, - "x2", +1.0, "y2", +1.0, NULL); - - gnome_canvas_item_set (tr, - "x1", w - 1.0, - "y1", -1.0, - "x2", w + 1.0, "y2", +1.0, NULL); - - gnome_canvas_item_set (bl, - "x1", -1.0, - "y1", h - 1.0, - "x2", +1.0, "y2", h + 1.0, NULL); - - gnome_canvas_item_set (br, - "x1", w - 1.0, - "y1", h - 1.0, - "x2", w + 1.0, "y2", h + 1.0, NULL); - - gnome_canvas_item_set (sl, - "x1", -1.0, - "y1", h / 2.0 - 1.0, - "x2", +1.0, "y2", h / 2.0 + 1.0, NULL); - - gnome_canvas_item_set (sr, - "x1", w - 1.0, - "y1", h / 2.0 - 1.0, - "x2", w + 1.0, - "y2", h / 2.0 + 1.0, NULL); - - gnome_canvas_item_set (st, - "x1", w / 2.0 - 1.0, - "y1", -1.0, - "x2", w / 2.0 + 1.0, "y2", +1.0, NULL); - - gnome_canvas_item_set (sb, - "x1", w / 2.0 - 1.0, - "y1", h - 1.0, - "x2", w / 2.0 + 1.0, - "y2", h + 1.0, NULL); - - gnome_canvas_item_show (highlight); - - } - - gnome_canvas_item_raise_to_top (highlight); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Create/Update & Display a resizable line highlight. */ -/*---------------------------------------------------------------------------*/ -static void -highlight_resizable_line (GnomeCanvasItem * item) -{ - GnomeCanvasItem *highlight; - gdouble x, y, dx, dy; - GnomeCanvasPoints *points; - GnomeCanvasItem *outline; /* Outline around item */ - GnomeCanvasItem *p1, *p2; /* Handles at endpoints */ - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - highlight = gtk_object_get_data (GTK_OBJECT (item), "highlight"); - - gl_item_get_position_size (item, &x, &y, &dx, &dy); - - points = gnome_canvas_points_new (2); - - if (highlight == NULL) { - - highlight = - gnome_canvas_item_new (gnome_canvas_root - (GNOME_CANVAS (item->canvas)), - gnome_canvas_group_get_type (), "x", - x, "y", y, NULL); - - points->coords[0] = 0.0; - points->coords[1] = 0.0; - points->coords[2] = dx; - points->coords[3] = dy; - outline = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_line_get_type (), - "points", points, - "width_pixels", 3, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), NULL); - - p1 = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", -1.0, - "y1", -1.0, - "x2", +1.0, - "y2", +1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - p2 = gnome_canvas_item_new (GNOME_CANVAS_GROUP (highlight), - gnome_canvas_rect_get_type (), - "x1", dx - 1.0, - "y1", dy - 1.0, - "x2", dx + 1.0, - "y2", dy + 1.0, - "fill_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (255, 255, 255, - 255), NULL); - - gtk_object_set_data (GTK_OBJECT (item), "highlight", highlight); - - gtk_object_set_data (GTK_OBJECT (highlight), "outline", - outline); - - gtk_object_set_data (GTK_OBJECT (highlight), "p1", p1); - gtk_object_set_data (GTK_OBJECT (highlight), "p2", p2); - - gtk_signal_connect (GTK_OBJECT (outline), "event", - GTK_SIGNAL_FUNC (passthrough_event_handler), - item); - - gtk_signal_connect (GTK_OBJECT (p1), "event", - GTK_SIGNAL_FUNC (p1_resize_event_handler), - item); - gtk_signal_connect (GTK_OBJECT (p2), "event", - GTK_SIGNAL_FUNC (p2_resize_event_handler), - item); - - } else { - - gnome_canvas_item_set (highlight, "x", x, "y", y, NULL); - - outline = - gtk_object_get_data (GTK_OBJECT (highlight), "outline"); - - p1 = gtk_object_get_data (GTK_OBJECT (highlight), "p1"); - p2 = gtk_object_get_data (GTK_OBJECT (highlight), "p2"); - - points->coords[0] = 0.0; - points->coords[1] = 0.0; - points->coords[2] = dx; - points->coords[3] = dy; - gnome_canvas_item_set (outline, "points", points, NULL); - - gnome_canvas_item_set (p1, - "x1", -1.0, - "y1", -1.0, - "x2", +1.0, "y2", +1.0, NULL); - - gnome_canvas_item_set (p2, - "x1", dx - 1.0, - "y1", dy - 1.0, - "x2", dx + 1.0, "y2", dy + 1.0, NULL); - - gnome_canvas_item_show (highlight); - - } - - gnome_canvas_points_free (points); - - gnome_canvas_item_raise_to_top (highlight); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Create/Update & Display a simple box highlight. */ -/*---------------------------------------------------------------------------*/ -static void -highlight_simple (GnomeCanvasItem * item) -{ - GnomeCanvasItem *highlight; - gdouble x1, y1, x2, y2; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - highlight = gtk_object_get_data (GTK_OBJECT (item), "highlight"); - - gl_item_get_bounds (item, &x1, &y1, &x2, &y2); - - if (highlight == NULL) { - - highlight = - gnome_canvas_item_new (gnome_canvas_root - (GNOME_CANVAS (item->canvas)), - gnome_canvas_rect_get_type (), "x1", - x1 - 0.5, "y1", y1 - 0.5, "x2", - x2 + 0.5, "y2", y2 + 0.5, - "width_pixels", 2, - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, - 255), NULL); - - gtk_object_set_data (GTK_OBJECT (item), "highlight", highlight); - - gtk_signal_connect (GTK_OBJECT (highlight), "event", - GTK_SIGNAL_FUNC (passthrough_event_handler), - item); - - } else { - - gnome_canvas_item_set (highlight, - "x1", x1 - 0.5, - "y1", y1 - 0.5, - "x2", x2 + 0.5, - "y2", y2 + 0.5, - "width_pixels", 2, - "outline_color_rgba", - GNOME_CANVAS_COLOR_A (0, 0, 255, 255), - NULL); - - gnome_canvas_item_show (highlight); - - } - - gnome_canvas_item_raise_to_top (highlight); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Top-left" Resize event handler. */ -/*---------------------------------------------------------------------------*/ -static int -tl_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, w, h; - static gdouble x2, y2; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &w, &h); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to bottom-right corner */ - x2 = x + w; - y2 = y + h; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - x = MIN (event->button.x, x2 - MIN_ITEM_SIZE); - y = MIN (event->button.y, y2 - MIN_ITEM_SIZE); - w = MAX (x2 - event->button.x, MIN_ITEM_SIZE); - h = MAX (y2 - event->button.y, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - x = MIN (event->button.x, x2 - MIN_ITEM_SIZE); - y = MIN (event->button.y, y2 - MIN_ITEM_SIZE); - w = MAX (x2 - event->button.x, MIN_ITEM_SIZE); - h = MAX (y2 - event->button.y, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Top-right" Resize event handler. */ -/*---------------------------------------------------------------------------*/ -static int -tr_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, w, h; - static gdouble x1, y2; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &w, &h); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to bottom-left corner */ - x1 = x; - y2 = y + h; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - x = x1; - y = MIN (event->button.y, y2 - MIN_ITEM_SIZE); - w = MAX (event->button.x - x1, MIN_ITEM_SIZE); - h = MAX (y2 - event->button.y, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - x = x1; - y = MIN (event->button.y, y2 - MIN_ITEM_SIZE); - w = MAX (event->button.x - x1, MIN_ITEM_SIZE); - h = MAX (y2 - event->button.y, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Bottom-left" Resize event handler. */ -/*---------------------------------------------------------------------------*/ -static int -bl_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, w, h; - static gdouble x2, y1; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &w, &h); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to top-right corner */ - x2 = x + w; - y1 = y; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - x = MIN (event->button.x, x2 - MIN_ITEM_SIZE); - y = y1; - w = MAX (x2 - event->button.x, MIN_ITEM_SIZE); - h = MAX (event->button.y - y1, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - x = MIN (event->button.x, x2 - MIN_ITEM_SIZE); - y = y1; - w = MAX (x2 - event->button.x, MIN_ITEM_SIZE); - h = MAX (event->button.y - y1, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Bottom-right" Resize event handler. */ -/*---------------------------------------------------------------------------*/ -static int -br_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, w, h; - static gdouble x1, y1; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &w, &h); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to top-left corner */ - x1 = x; - y1 = y; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - x = x1; - y = y1; - w = MAX (event->button.x - x1, MIN_ITEM_SIZE); - h = MAX (event->button.y - y1, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - x = x1; - y = y1; - w = MAX (event->button.x - x1, MIN_ITEM_SIZE); - h = MAX (event->button.y - y1, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Left-side" Resize event handler. */ -/*---------------------------------------------------------------------------*/ -static int -sl_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, w, h; - static gdouble x2; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &w, &h); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to right side */ - x2 = x + w; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - x = MIN (event->button.x, x2 - MIN_ITEM_SIZE); - w = MAX (x2 - event->button.x, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - x = MIN (event->button.x, x2 - MIN_ITEM_SIZE); - w = MAX (x2 - event->button.x, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Right-side" Resize event handler. */ -/*---------------------------------------------------------------------------*/ -static int -sr_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, w, h; - static gdouble x1; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &w, &h); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to left side */ - x1 = x; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - x = x1; - w = MAX (event->button.x - x1, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - x = x1; - w = MAX (event->button.x - x1, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Top-side" Resize event handler. */ -/*---------------------------------------------------------------------------*/ -static int -st_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, w, h; - static gdouble y2; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &w, &h); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to bottom-right corner */ - y2 = y + h; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - y = MIN (event->button.y, y2 - MIN_ITEM_SIZE); - h = MAX (y2 - event->button.y, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - y = MIN (event->button.y, y2 - MIN_ITEM_SIZE); - h = MAX (y2 - event->button.y, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Bottom-side" Resize event handler. */ -/*---------------------------------------------------------------------------*/ -static int -sb_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, w, h; - static gdouble y1; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &w, &h); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to top side */ - y1 = y; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - y = y1; - h = MAX (event->button.y - y1, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - y = y1; - h = MAX (event->button.y - y1, MIN_ITEM_SIZE); - gl_item_set_position_size (item, x, y, w, h); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Resize "P1" event handler. */ -/*---------------------------------------------------------------------------*/ -static int -p1_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, dx, dy; - static gdouble x0, y0; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &dx, &dy); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to P2 */ - x0 = x + dx; - y0 = y + dy; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - x = x0; - y = y0; - dx = (event->button.x - x0); - dy = (event->button.y - y0); - gl_item_set_position_size (item, x, y, dx, dy); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - x = x0; - y = y0; - dx = (event->button.x - x0); - dy = (event->button.y - y0); - gl_item_set_position_size (item, x, y, dx, dy); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Resize "P2" event handler. */ -/*---------------------------------------------------------------------------*/ -static int -p2_resize_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - gdouble x, y, dx, dy; - static gdouble x0, y0; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glDisplay *display; - GdkCursor *cursor; - - item = GNOME_CANVAS_ITEM (data); - gl_item_get_position_size (item, &x, &y, &dx, &dy); - display = gl_item_get_display (item); - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gnome_canvas_item_grab (handle_item, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); - /* Anchor to P1 */ - x0 = x; - y0 = y; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gnome_canvas_item_ungrab (handle_item, - event->button.time); - x = x0; - y = y0; - dx = (event->button.x - x0); - dy = (event->button.y - y0); - gl_item_set_position_size (item, x, y, dx, dy); - gl_display_select_item (display, item); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - x = x0; - y = y0; - dx = (event->button.x - x0); - dy = (event->button.y - y0); - gl_item_set_position_size (item, x, y, dx, dy); - gl_display_select_item (display, item); - return TRUE; - } else { - return FALSE; - } - - case GDK_ENTER_NOTIFY: - cursor = gdk_cursor_new (GDK_CROSSHAIR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - case GDK_LEAVE_NOTIFY: - cursor = gdk_cursor_new (GDK_LEFT_PTR); - gdk_window_set_cursor (display->canvas->window, cursor); - gdk_cursor_destroy (cursor); - return TRUE; - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Passthrough event handler. */ -/*---------------------------------------------------------------------------*/ -static int -passthrough_event_handler (GnomeCanvasItem * handle_item, - GdkEvent * event, - gpointer data) -{ - static GnomeCanvasItem *item; - static glDisplay *display; - - item = GNOME_CANVAS_ITEM (data); - display = gl_item_get_display (item); - return gl_display_item_event_handler (item, event, display); - -} diff --git a/glabels1/src/highlight.h b/glabels1/src/highlight.h deleted file mode 100644 index a0aaa0e..0000000 --- a/glabels1/src/highlight.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * highlight.h: GLabels Resizable Highlight module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __HIGHLIGHT_H__ -#define __HIGHLIGHT_H__ - -#include <gnome.h> - -typedef enum { - GL_HIGHLIGHT_BOX_RESIZABLE, - GL_HIGHLIGHT_ELLIPSE_RESIZABLE, - GL_HIGHLIGHT_LINE_RESIZABLE, - GL_HIGHLIGHT_SIMPLE, -} glHighlightStyle; - -extern void gl_highlight (GnomeCanvasItem * item, glHighlightStyle style); - -#endif diff --git a/glabels1/src/item.c b/glabels1/src/item.c deleted file mode 100644 index e72a354..0000000 --- a/glabels1/src/item.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item.c: GLabels canvas item wrapper module module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "item.h" - -#include "display.h" -#include "item_text.h" -#include "item_box.h" -#include "item_line.h" -#include "item_ellipse.h" -#include "item_image.h" -#include "item_barcode.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -/*****************************************************************************/ -/* Create new canvas item from object. */ -/*****************************************************************************/ -GnomeCanvasItem * -gl_item_new (glLabelObject * object, - glDisplay * display) -{ - GnomeCanvasItem *item; - - g_return_val_if_fail (object != NULL, NULL); - g_return_val_if_fail (GL_IS_DISPLAY (display), NULL); - - switch (object->type) { - case GL_LABEL_OBJECT_TEXT: - item = gl_item_text_new (object, display); - break; - case GL_LABEL_OBJECT_BOX: - item = gl_item_box_new (object, display); - break; - case GL_LABEL_OBJECT_LINE: - item = gl_item_line_new (object, display); - break; - case GL_LABEL_OBJECT_ELLIPSE: - item = gl_item_ellipse_new (object, display); - break; - case GL_LABEL_OBJECT_IMAGE: - item = gl_item_image_new (object, display); - break; - case GL_LABEL_OBJECT_BARCODE: - item = gl_item_barcode_new (object, display); - break; - default: - item = NULL; - WARN ("Invalid label object type."); /* Should not happen! */ - break; - } - - return item; -} - -/*****************************************************************************/ -/* Free a canvas item and all our associated data. */ -/*****************************************************************************/ -void -gl_item_free (GnomeCanvasItem ** item) -{ - glLabelObject *object; - GtkWidget *menu; - GnomeCanvasItem *highlight; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (*item)); - - menu = gtk_object_get_data (GTK_OBJECT (*item), "object_menu"); - object = gtk_object_get_data (GTK_OBJECT (*item), "label_object"); - highlight = gtk_object_get_data (GTK_OBJECT (*item), "highlight"); - - gtk_menu_popdown (GTK_MENU (menu)); - gtk_widget_unref (GTK_WIDGET (menu)); - - gl_label_object_free (&object); - - if (highlight != NULL) { - gtk_object_destroy (GTK_OBJECT (highlight)); - } - - gtk_object_destroy (GTK_OBJECT (*item)); - *item = NULL; -} - -/*****************************************************************************/ -/* Get position and size of object. */ -/*****************************************************************************/ -void -gl_item_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h) -{ - glLabelObject *object; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - switch (object->type) { - case GL_LABEL_OBJECT_TEXT: - gl_item_text_get_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_BOX: - gl_item_box_get_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_LINE: - gl_item_line_get_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_ELLIPSE: - gl_item_ellipse_get_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_IMAGE: - gl_item_image_get_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_BARCODE: - gl_item_barcode_get_position_size (item, x, y, w, h); - break; - default: - WARN ("Invalid label object type."); /* Should not happen! */ - break; - } - -} - -/*****************************************************************************/ -/* Get position and size of object. */ -/*****************************************************************************/ -void -gl_item_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h) -{ - glLabelObject *object; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - switch (object->type) { - case GL_LABEL_OBJECT_TEXT: - gl_item_text_set_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_BOX: - gl_item_box_set_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_LINE: - gl_item_line_set_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_ELLIPSE: - gl_item_ellipse_set_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_IMAGE: - gl_item_image_set_position_size (item, x, y, w, h); - break; - case GL_LABEL_OBJECT_BARCODE: - gl_item_barcode_set_position_size (item, x, y, w, h); - break; - default: - WARN ("Invalid label object type."); /* Should not happen! */ - break; - } - -} - -/*****************************************************************************/ -/* Get object associated with canvas item. */ -/*****************************************************************************/ -glLabelObject * -gl_item_get_object (GnomeCanvasItem * item) -{ - g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), NULL); - - return gtk_object_get_data (GTK_OBJECT (item), "label_object"); -} - -/*****************************************************************************/ -/* Get display associated with canvas item. */ -/*****************************************************************************/ -glDisplay * -gl_item_get_display (GnomeCanvasItem * item) -{ - g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), NULL); - - return gtk_object_get_data (GTK_OBJECT (item), "display"); -} - -/*****************************************************************************/ -/* Get menu associated with canvas item. */ -/*****************************************************************************/ -GtkWidget * -gl_item_get_menu (GnomeCanvasItem * item) -{ - g_return_val_if_fail (GNOME_IS_CANVAS_ITEM (item), NULL); - - return gtk_object_get_data (GTK_OBJECT (item), "object_menu"); -} - -/*****************************************************************************/ -/* Turn on item highlight. */ -/*****************************************************************************/ -void -gl_item_highlight (GnomeCanvasItem * item) -{ - glLabelObject *object; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - switch (object->type) { - case GL_LABEL_OBJECT_TEXT: - gl_item_text_highlight (item); - break; - case GL_LABEL_OBJECT_BOX: - gl_item_box_highlight (item); - break; - case GL_LABEL_OBJECT_LINE: - gl_item_line_highlight (item); - break; - case GL_LABEL_OBJECT_ELLIPSE: - gl_item_ellipse_highlight (item); - break; - case GL_LABEL_OBJECT_IMAGE: - gl_item_image_highlight (item); - break; - case GL_LABEL_OBJECT_BARCODE: - gl_item_barcode_highlight (item); - break; - default: - WARN ("Invalid label object type."); /* Should not happen! */ - break; - } - -} - -/*****************************************************************************/ -/* Turn off item highlight. */ -/*****************************************************************************/ -void -gl_item_unhighlight (GnomeCanvasItem * item) -{ - GnomeCanvasItem *sel_box; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - if (item != NULL) { - - sel_box = gtk_object_get_data (GTK_OBJECT (item), "highlight"); - gnome_canvas_item_hide (sel_box); - - } -} - -/*****************************************************************************/ -/* Get item bounds using appropriate custom function. */ -/*****************************************************************************/ -void -gl_item_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2) -{ - glLabelObject *object; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - switch (object->type) { - case GL_LABEL_OBJECT_TEXT: - gl_item_text_get_bounds (item, x1, y1, x2, y2); - break; - case GL_LABEL_OBJECT_BOX: - gl_item_box_get_bounds (item, x1, y1, x2, y2); - break; - case GL_LABEL_OBJECT_LINE: - gl_item_line_get_bounds (item, x1, y1, x2, y2); - break; - case GL_LABEL_OBJECT_ELLIPSE: - gl_item_ellipse_get_bounds (item, x1, y1, x2, y2); - break; - case GL_LABEL_OBJECT_IMAGE: - gl_item_image_get_bounds (item, x1, y1, x2, y2); - break; - case GL_LABEL_OBJECT_BARCODE: - gl_item_barcode_get_bounds (item, x1, y1, x2, y2); - break; - default: - WARN ("Invalid label object type."); /* Should not happen! */ - break; - } - -} - -/*****************************************************************************/ -/* launch apropriate edit dialog for item/object */ -/*****************************************************************************/ -void -gl_item_edit_dialog (GnomeCanvasItem * item) -{ - glLabelObject *object; - glDisplay *display; - - g_return_if_fail (GNOME_IS_CANVAS_ITEM (item)); - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - - switch (object->type) { - case GL_LABEL_OBJECT_TEXT: - gl_item_text_edit_dialog (item); - break; - case GL_LABEL_OBJECT_BOX: - gl_item_box_edit_dialog (item); - break; - case GL_LABEL_OBJECT_LINE: - gl_item_line_edit_dialog (item); - break; - case GL_LABEL_OBJECT_ELLIPSE: - gl_item_ellipse_edit_dialog (item); - break; - case GL_LABEL_OBJECT_IMAGE: - gl_item_image_edit_dialog (item); - break; - case GL_LABEL_OBJECT_BARCODE: - gl_item_barcode_edit_dialog (item); - break; - default: - WARN ("Invalid label object type."); /* Should not happen! */ - break; - } - - /* Update highlight of item */ - gl_item_highlight (item); -} - -/*****************************************************************************/ -/* Return apropos item create mode cursor for given object type. */ -/*****************************************************************************/ -GdkCursor * -gl_item_get_create_cursor (glLabelObjectType type) -{ - switch (type) { - - case GL_LABEL_OBJECT_TEXT: - return gl_item_text_get_create_cursor (); - - case GL_LABEL_OBJECT_BOX: - return gl_item_box_get_create_cursor (); - - case GL_LABEL_OBJECT_LINE: - return gl_item_line_get_create_cursor (); - - case GL_LABEL_OBJECT_ELLIPSE: - return gl_item_ellipse_get_create_cursor (); - - case GL_LABEL_OBJECT_IMAGE: - return gl_item_image_get_create_cursor (); - - case GL_LABEL_OBJECT_BARCODE: - return gl_item_barcode_get_create_cursor (); - - default: - WARN ("Invalid label object type."); /* Should not happen! */ - return NULL; - - } - -} - -/*****************************************************************************/ -/* Item/object creation canvas event handler. */ -/*****************************************************************************/ -gint -gl_item_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - glDisplay * display) -{ - switch (display->create_type) { - - case GL_LABEL_OBJECT_TEXT: - return gl_item_text_create_event_handler (canvas, event, - display); - - case GL_LABEL_OBJECT_BOX: - return gl_item_box_create_event_handler (canvas, event, - display); - - case GL_LABEL_OBJECT_LINE: - return gl_item_line_create_event_handler (canvas, event, - display); - - case GL_LABEL_OBJECT_ELLIPSE: - return gl_item_ellipse_create_event_handler (canvas, event, - display); - - case GL_LABEL_OBJECT_IMAGE: - return gl_item_image_create_event_handler (canvas, event, - display); - - case GL_LABEL_OBJECT_BARCODE: - return gl_item_barcode_create_event_handler (canvas, event, - display); - - default: - WARN ("Invalid label object type."); /* Should not happen! */ - return FALSE; - - } - -} diff --git a/glabels1/src/item.h b/glabels1/src/item.h deleted file mode 100644 index 23b25f9..0000000 --- a/glabels1/src/item.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item.h: GLabels canvas item wrapper module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __ITEM_H__ -#define __ITEM_H__ - -#include <gnome.h> - -#include "label.h" -#include "display.h" - -extern GnomeCanvasItem *gl_item_new (glLabelObject * object, - glDisplay * display); - -extern void gl_item_free (GnomeCanvasItem ** item); - -extern void gl_item_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h); - -extern void gl_item_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h); - -extern glLabelObject *gl_item_get_object (GnomeCanvasItem * item); - -extern glDisplay *gl_item_get_display (GnomeCanvasItem * item); - -extern GtkWidget *gl_item_get_menu (GnomeCanvasItem * item); - -extern void gl_item_highlight (GnomeCanvasItem * item); - -extern void gl_item_unhighlight (GnomeCanvasItem * item); - -extern void gl_item_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2); - -extern void gl_item_edit_dialog (GnomeCanvasItem * item); - -extern GdkCursor *gl_item_get_create_cursor (glLabelObjectType type); - -extern gint gl_item_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - glDisplay * display); - -#endif diff --git a/glabels1/src/item_barcode.c b/glabels1/src/item_barcode.c deleted file mode 100644 index e129f33..0000000 --- a/glabels1/src/item_barcode.c +++ /dev/null @@ -1,656 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_barcode.c: GLabels Barcode Object (canvas item) module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <string.h> - -#include "display.h" -#include "item_barcode.h" -#include "bc.h" - -#include "highlight.h" - -#include "mdi.h" -#include "propertybox.h" -#include "prop_bc_data.h" -#include "prop_bc.h" -#include "prop_bc_style.h" -#include "prop_position.h" - -#include "pixmaps/cursor_barcode.xbm" -#include "pixmaps/cursor_barcode_mask.xbm" - -#ifdef HACKTEXT -#include "gnome-canvas-hacktext.h" -#include <libgnomeprint/gnome-glyphlist.h> -#endif - -#include "debug.h" - -#define Y_FONT_ADJUST (-1.0) /* Adjust font vertical position */ - -/*===========================================*/ -/* Private data types */ -/*===========================================*/ - -typedef struct { - GnomeCanvasItem *item; - - /* Page 0 widgets */ - GtkWidget *data_entry; - - /* Page 1 widgets */ - GtkWidget *bcprop; - GtkWidget *style; - - /* Page 2 widgets */ - GtkWidget *position; -} PropertyDialogPassback; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void item_barcode_update (GnomeCanvasItem * item); - -static void changed_cb (glPropertyBox * propertybox); -static void apply_cb (glPropertyBox * propertybox, gint page, - PropertyDialogPassback * data); - -static void draw_barcode (GnomeCanvasItem * item, - glBarcodeStyle style, - guint color, - gboolean text_flag, - gdouble scale, - gchar * digits, - gdouble canvas_scale); - -/*****************************************************************************/ -/* Create a barcode object */ -/*****************************************************************************/ -GnomeCanvasItem * -gl_item_barcode_new (glLabelObject * object, - glDisplay * display) -{ - GnomeCanvasGroup *group; - GnomeCanvasItem *item; - gchar *text; - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - item = gnome_canvas_item_new (group, gnome_canvas_group_get_type (), - "x", object->x, "y", object->y, NULL); - - if (object->arg.barcode.text_node->field_flag) { - text = gl_barcode_default_digits (object->arg.barcode.style); - } else { - text = - gl_text_node_expand (object->arg.barcode.text_node, NULL); - } - draw_barcode (item, - object->arg.barcode.style, - object->arg.barcode.color, - object->arg.barcode.text_flag, - object->arg.barcode.scale, text, display->scale); - g_free (text); - - /* Squirrel away pointers to object and display in the canvas item. */ - gtk_object_set_data (GTK_OBJECT (item), "label_object", object); - gtk_object_set_data (GTK_OBJECT (item), "display", display); - gtk_object_set_data (GTK_OBJECT (item), "highlight", NULL); - - gtk_signal_connect (GTK_OBJECT (item), "event", - GTK_SIGNAL_FUNC (gl_display_item_event_handler), - display); - - gl_display_new_item_menu (item); - - gl_display_set_modified (display); - - return item; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Update a barcode object */ -/*---------------------------------------------------------------------------*/ -static void -item_barcode_update (GnomeCanvasItem * item) -{ - glLabelObject *object; - glDisplay *display; - GList *item_list, *li; - gdouble affine[6]; - gchar *text; - - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - item_list = gtk_object_get_data (GTK_OBJECT (item), "item_list"); - for (li = item_list; li != NULL; li = li->next) { - gtk_object_destroy (GTK_OBJECT (li->data)); - } - g_list_free (item_list); - gtk_object_set_data (GTK_OBJECT (item), "item_list", NULL); - - if (object->arg.barcode.text_node->field_flag) { - text = gl_barcode_default_digits (object->arg.barcode.style); - } else { - text = - gl_text_node_expand (object->arg.barcode.text_node, NULL); - } - draw_barcode (item, - object->arg.barcode.style, - object->arg.barcode.color, - object->arg.barcode.text_flag, - object->arg.barcode.scale, text, display->scale); - g_free (text); - - art_affine_identity (affine); - gnome_canvas_item_affine_absolute (item, affine); - gnome_canvas_item_set (item, "x", object->x, "y", object->y, NULL); - - gl_display_set_modified (display); -} - -/*****************************************************************************/ -/* Highlight given canvas item. */ -/*****************************************************************************/ -void -gl_item_barcode_highlight (GnomeCanvasItem * item) -{ - gl_highlight (item, GL_HIGHLIGHT_SIMPLE); -} - -/*****************************************************************************/ -/* Get position and size of object. */ -/*****************************************************************************/ -void -gl_item_barcode_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h) -{ - glLabelObject *object; - glBarcode *gbc; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - *x = object->x; - *y = object->y; - - gbc = gtk_object_get_data (GTK_OBJECT (item), "bc"); - *w = gbc->width; - *h = gbc->height; - -} - -/*****************************************************************************/ -/* Get position and size of object. */ -/*****************************************************************************/ -void -gl_item_barcode_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - object->x = x; - object->y = y; - - /* Currently ignore w, h */ - - item_barcode_update (item); -} - -/*****************************************************************************/ -/* Get barcode item bounds. */ -/*****************************************************************************/ -void -gl_item_barcode_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2) -{ - glBarcode *gbc; - glLabelObject *object; - - gbc = gtk_object_get_data (GTK_OBJECT (item), "bc"); - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - if (gbc == NULL) { - gnome_canvas_item_get_bounds (item, x1, y1, x2, y2); - } else { - *x1 = object->x; - *y1 = object->y; - *x2 = *x1 + gbc->width; - *y2 = *y1 + gbc->height; - } -} - -/*****************************************************************************/ -/* Create and run an edit dialog on a barcode object. */ -/*****************************************************************************/ -void -gl_item_barcode_edit_dialog (GnomeCanvasItem * item) -{ - GtkWidget *dialog; - static PropertyDialogPassback *data = NULL; - glLabelObject *object; - glDisplay *display; - GtkWidget *wvbox; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - if (data == NULL) { - data = g_new0 (PropertyDialogPassback, 1); - } - data->item = item; - - dialog = gl_property_box_new (); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (gl_mdi_get_active_window ())); - gtk_window_set_title (GTK_WINDOW (dialog), - _("Edit barcode object properties")); - gtk_signal_connect (GTK_OBJECT (dialog), "apply", - GTK_SIGNAL_FUNC (apply_cb), data); - - /*---------------------------*/ - /* Data Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), - wvbox, gtk_label_new (_("Data"))); - - data->data_entry = gl_prop_bc_data_new (_("Barcode data"), - object->parent->merge_fields); - gl_prop_bc_data_set_data (GL_PROP_BC_DATA (data->data_entry), - (object->parent->merge_type != GL_MERGE_NONE), - object->arg.barcode.text_node->field_flag, - object->arg.barcode.text_node->data, - object->arg.barcode.text_node->data); - gtk_box_pack_start (GTK_BOX (wvbox), data->data_entry, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->data_entry), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*---------------------------*/ - /* Appearance Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), - wvbox, gtk_label_new (_("Appearance"))); - - /* ------ Begin Barcode Properties Frame ------ */ - data->bcprop = gl_prop_bc_new (_("General")); - gl_prop_bc_set_params (GL_PROP_BC (data->bcprop), - object->arg.barcode.scale, - object->arg.barcode.color); - gtk_box_pack_start (GTK_BOX (wvbox), data->bcprop, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->bcprop), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /* ------ Barcode Style Frame ------ */ - data->style = gl_prop_bc_style_new (_("Style")); - gl_prop_bc_style_set_params (GL_PROP_BC_STYLE (data->style), - object->arg.barcode.style, - object->arg.barcode.text_flag); - gtk_box_pack_start (GTK_BOX (wvbox), data->style, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->style), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*----------------------------*/ - /* Position Notebook Tab */ - /*----------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), - wvbox, gtk_label_new (_("Position"))); - - /* ------ Position Frame ------ */ - data->position = gl_prop_position_new (_("Position")); - gl_prop_position_set_params (GL_PROP_POSITION (data->position), - object->x, object->y, - display->label->width, - display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->position, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->position), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*-----------------------------------------------------------------*/ - /* Run dialog, and update state of object if "Applied." */ - /*-----------------------------------------------------------------*/ - gtk_widget_show_all (GTK_WIDGET (dialog)); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the dialog has changed. */ -/*---------------------------------------------------------------------------*/ -static void -changed_cb (glPropertyBox * propertybox) -{ - gl_property_box_changed (propertybox); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Apply" callback. */ -/*---------------------------------------------------------------------------*/ -static void -apply_cb (glPropertyBox * propertybox, - gint page, - PropertyDialogPassback * data) -{ - glLabelObject *object; - glDisplay *display; - gboolean flag; - gchar *tmp1, *tmp2; - - object = gtk_object_get_data (GTK_OBJECT (data->item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (data->item), "display"); - - switch (page) { - - case 0: - /* ------- Get updated digit data ------ */ - gl_prop_bc_data_get_data (GL_PROP_BC_DATA (data->data_entry), - &flag, &tmp1, &tmp2); - object->arg.barcode.text_node->field_flag = flag; - if (!flag) { - object->arg.barcode.text_node->data = tmp1; - g_free (tmp2); - } else { - object->arg.barcode.text_node->data = tmp2; - g_free (tmp1); - } - break; - - case 1: - /* ------- Get updated scale/color ------ */ - gl_prop_bc_get_params (GL_PROP_BC (data->bcprop), - &object->arg.barcode.scale, - &object->arg.barcode.color); - /* ------ Get updated style ------ */ - gl_prop_bc_style_get_params (GL_PROP_BC_STYLE (data->style), - &object->arg.barcode.style, - &object->arg.barcode.text_flag); - break; - - case 2: - /* ------ get updated position ------ */ - gl_prop_position_get_position (GL_PROP_POSITION - (data->position), &object->x, - &object->y); - break; - - default: - return; - } - - /* ------ Udate state of object ------ */ - item_barcode_update (data->item); - gl_display_select_item (display, data->item); - -} - -/*****************************************************************************/ -/* Return apropos cursor for create object mode. */ -/*****************************************************************************/ -GdkCursor * -gl_item_barcode_get_create_cursor (void) -{ - static GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; - - if (!cursor) { - pixmap_data = gdk_bitmap_create_from_data (NULL, - cursor_barcode_bits, - cursor_barcode_width, - cursor_barcode_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - cursor_barcode_mask_bits, - cursor_barcode_mask_width, - cursor_barcode_mask_height); - cursor = - gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_barcode_x_hot, - cursor_barcode_y_hot); - } - - return cursor; -} - -/*****************************************************************************/ -/* Canvas event handler (barcode mode) */ -/*****************************************************************************/ -int -gl_item_barcode_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - glDisplay *display = GL_DISPLAY (data); - gdouble x, y; - glLabelObject *object; - GnomeCanvasItem *item; - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - object = - gl_label_object_new (display->label, - GL_LABEL_OBJECT_BARCODE); - object->x = x; - object->y = y; - object->arg.barcode.text_node = - gl_text_node_new_from_text ("123456789"); - object->arg.barcode.style = GL_BARCODE_STYLE_POSTNET; - object->arg.barcode.color = - GNOME_CANVAS_COLOR_A (0, 0, 0, 255); - object->arg.barcode.text_flag = TRUE; - object->arg.barcode.scale = 1.0; - item = gl_item_barcode_new (object, display); - gl_display_add_item (display, item); - gl_display_unselect_all (display); - gl_display_select_item (display, item); - gl_display_arrow_mode (display); - return TRUE; - - default: - return FALSE; - } - - default: - return FALSE; - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw barcode to canvas item (group). */ -/*---------------------------------------------------------------------------*/ -static void -draw_barcode (GnomeCanvasItem * group, - glBarcodeStyle style, - guint color, - gboolean text_flag, - gdouble scale, - gchar * digits, - gdouble canvas_scale) -{ - glBarcodeLine *line; - glBarcodeChar *bchar; - glBarcode *gbc; - GList *li; - GnomeCanvasItem *item; - GList *item_list = NULL; - GnomeCanvasPoints *points; - gchar *cstring; -#ifdef HACKTEXT - GnomeFont *font; - GnomeGlyphList *glyphlist; - gdouble y_offset; -#else - GdkFont *gdk_font; - GnomeDisplayFont *display_font; -#endif - - gbc = gtk_object_get_data (GTK_OBJECT (group), "bc"); - gl_barcode_free (&gbc); - gbc = gl_barcode (style, text_flag, scale, digits); - if (gbc == NULL) { -#ifdef HACKTEXT - font = gnome_font_new_closest (GL_BARCODE_FONT_FAMILY, - GL_BARCODE_FONT_WEIGHT, - FALSE, 10.0); - cstring = _("Invalid barcode"); - glyphlist = gnome_glyphlist_from_text_sized_dumb (font, - color, - 0.0, 0.0, - cstring, - strlen - (cstring)); - y_offset = 10.0 - gnome_font_get_descender (font); - item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group), - gnome_canvas_hacktext_get_type (), - "x", 0.0, - "y", y_offset, - "glyphlist", glyphlist, NULL); -#else - display_font = gnome_get_display_font (GL_BARCODE_FONT_FAMILY, - GL_BARCODE_FONT_WEIGHT, - FALSE, - 10.0, canvas_scale); - gdk_font = gnome_display_font_get_gdk_font (display_font); - item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group), - gnome_canvas_text_get_type (), - "x", 0.0, - "y", 0.0, - "text", _("Invalid barcode"), - "font_gdk", gdk_font, - "anchor", GTK_ANCHOR_NW, - "fill_color_rgba", color, NULL); -#endif - item_list = g_list_prepend (item_list, item); - } else { - - points = gnome_canvas_points_new (2); - for (li = gbc->lines; li != NULL; li = li->next) { - line = (glBarcodeLine *) li->data; - - points->coords[0] = line->x; - points->coords[1] = line->y; - 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_list = g_list_prepend (item_list, item); - } - gnome_canvas_points_free (points); - - for (li = gbc->chars; li != NULL; li = li->next) { - bchar = (glBarcodeChar *) li->data; - -#ifdef HACKTEXT - font = gnome_font_new_closest (GL_BARCODE_FONT_FAMILY, - GL_BARCODE_FONT_WEIGHT, - FALSE, bchar->fsize); - glyphlist = gnome_glyphlist_from_text_sized_dumb (font, - color, - 0.0, - 0.0, - & - (bchar-> - c), - 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); -#else - display_font = - gnome_get_display_font (GL_BARCODE_FONT_FAMILY, - GL_BARCODE_FONT_WEIGHT, - FALSE, bchar->fsize, - canvas_scale); - gdk_font = - gnome_display_font_get_gdk_font (display_font); - cstring = g_strdup_printf ("%c", bchar->c); - item = - gnome_canvas_item_new (GNOME_CANVAS_GROUP (group), - gnome_canvas_text_get_type - (), "x", bchar->x, "y", - bchar->y + Y_FONT_ADJUST, - "text", cstring, "font_gdk", - gdk_font, "anchor", - GTK_ANCHOR_NW, - "fill_color_rgba", color, - NULL); - g_free (cstring); -#endif - item_list = g_list_prepend (item_list, item); - - } - - } - - /* attach item list to group, so we can get at these again */ - gtk_object_set_data (GTK_OBJECT (group), "item_list", item_list); - - gtk_object_set_data (GTK_OBJECT (group), "bc", gbc); - -} diff --git a/glabels1/src/item_barcode.h b/glabels1/src/item_barcode.h deleted file mode 100644 index d18d6ba..0000000 --- a/glabels1/src/item_barcode.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_barcode.h: GLabels Barcode Object (canvas item) module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __ITEM_BARCODE_H__ -#define __ITEM_BARCODE_H__ - -#include <gnome.h> - -#include "label.h" - -extern GnomeCanvasItem *gl_item_barcode_new (glLabelObject * object, - glDisplay * display); - -extern void gl_item_barcode_highlight (GnomeCanvasItem * item); - -extern void gl_item_barcode_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h); - -extern void gl_item_barcode_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h); - -extern void gl_item_barcode_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2); - -extern void gl_item_barcode_edit_dialog (GnomeCanvasItem * item); - -extern GdkCursor *gl_item_barcode_get_create_cursor (void); - -extern gint gl_item_barcode_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data); - -#endif diff --git a/glabels1/src/item_box.c b/glabels1/src/item_box.c deleted file mode 100644 index 8020094..0000000 --- a/glabels1/src/item_box.c +++ /dev/null @@ -1,489 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_box.c: GLabels Box Object (canvas item) module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <string.h> - -#include "display.h" -#include "item_box.h" - -#include "highlight.h" - -#include "mdi.h" -#include "propertybox.h" -#include "prop_line.h" -#include "prop_fill.h" -#include "prop_size.h" -#include "prop_position.h" - -#include "pixmaps/cursor_box.xbm" -#include "pixmaps/cursor_box_mask.xbm" - -#include "debug.h" - -/*===========================================*/ -/* Private data types */ -/*===========================================*/ - -typedef struct { - GnomeCanvasItem *item; - gboolean keep_aspect_ratio_flag; - - /* Page 0 widgets */ - GtkWidget *line; - GtkWidget *fill; - - /* Page 1 widgets */ - GtkWidget *position; - GtkWidget *size; -} PropertyDialogPassback; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void item_box_update (GnomeCanvasItem * item); - -static void changed_cb (glPropertyBox * propertybox); -static void apply_cb (glPropertyBox * propertybox, - gint page, PropertyDialogPassback * data); - -/*****************************************************************************/ -/* Create a box object */ -/*****************************************************************************/ -GnomeCanvasItem * -gl_item_box_new (glLabelObject * object, - glDisplay * display) -{ - GnomeCanvasGroup *group; - GnomeCanvasItem *item; - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - item = gnome_canvas_item_new (group, gnome_canvas_rect_get_type (), - "x1", object->x, - "y1", object->y, - "x2", object->x + object->arg.box.w, - "y2", object->y + object->arg.box.h, - "width_units", object->arg.box.line_width, - "outline_color_rgba", - object->arg.box.line_color, - "fill_color_rgba", - object->arg.box.fill_color, NULL); - - /* Squirrel away pointers to object and display in the canvas item. */ - gtk_object_set_data (GTK_OBJECT (item), "label_object", object); - gtk_object_set_data (GTK_OBJECT (item), "display", display); - gtk_object_set_data (GTK_OBJECT (item), "highlight", NULL); - - gtk_signal_connect (GTK_OBJECT (item), "event", - GTK_SIGNAL_FUNC (gl_display_item_event_handler), - display); - - gl_display_new_item_menu (item); - - gl_display_set_modified (display); - - return item; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Update a box object */ -/*---------------------------------------------------------------------------*/ -static void -item_box_update (GnomeCanvasItem * item) -{ - glLabelObject *object; - glDisplay *display; - gdouble affine[6]; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - art_affine_identity (affine); - gnome_canvas_item_affine_absolute (item, affine); - gnome_canvas_item_set (item, - "x1", object->x, - "y1", object->y, - "x2", object->x + object->arg.box.w, - "y2", object->y + object->arg.box.h, - "width_units", object->arg.box.line_width, - "outline_color_rgba", object->arg.box.line_color, - "fill_color_rgba", object->arg.box.fill_color, - NULL); - - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - gl_display_set_modified (display); -} - -/*****************************************************************************/ -/* Return a selection canvas item/group for given item */ -/*****************************************************************************/ -void -gl_item_box_highlight (GnomeCanvasItem * item) -{ - gl_highlight (item, GL_HIGHLIGHT_BOX_RESIZABLE); -} - -/*****************************************************************************/ -/* Get position and size of object. */ -/*****************************************************************************/ -void -gl_item_box_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - *x = object->x; - *y = object->y; - - *w = object->arg.box.w; - *h = object->arg.box.h; -} - -/*****************************************************************************/ -/* Get position and size of object. */ -/*****************************************************************************/ -void -gl_item_box_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - object->x = x; - object->y = y; - - object->arg.box.w = w; - object->arg.box.h = h; - - item_box_update (item); -} - -/*****************************************************************************/ -/* Get box item bounds. */ -/*****************************************************************************/ -void -gl_item_box_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2) -{ - gnome_canvas_item_get_bounds (item, x1, y1, x2, y2); -} - -/*****************************************************************************/ -/* Create and run an edit dialog on a box object. */ -/*****************************************************************************/ -void -gl_item_box_edit_dialog (GnomeCanvasItem * item) -{ - GtkWidget *dialog; - static PropertyDialogPassback *data = NULL; - glLabelObject *object; - glDisplay *display; - GtkWidget *wvbox; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - if (data == NULL) { - data = g_new0 (PropertyDialogPassback, 1); - } - data->item = item; - - dialog = gl_property_box_new (); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (gl_mdi_get_active_window ())); - gtk_window_set_title (GTK_WINDOW (dialog), - _("Edit box object properties")); - gtk_signal_connect (GTK_OBJECT (dialog), "apply", - GTK_SIGNAL_FUNC (apply_cb), data); - - /*---------------------------*/ - /* Appearance Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Appearance"))); - - /* ------ Line box ------ */ - data->line = gl_prop_line_new (_("Outline")); - gl_prop_line_set_params (GL_PROP_LINE (data->line), - object->arg.box.line_width, - object->arg.box.line_color); - gtk_box_pack_start (GTK_BOX (wvbox), data->line, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->line), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /* ------ Fill box ------ */ - data->fill = gl_prop_fill_new (_("Fill")); - gl_prop_fill_set_params (GL_PROP_FILL (data->fill), - object->arg.box.fill_color); - gtk_box_pack_start (GTK_BOX (wvbox), data->fill, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->fill), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*----------------------------*/ - /* Position/Size Notebook Tab */ - /*----------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Position/Size"))); - - /* ------ Position Frame ------ */ - data->position = gl_prop_position_new (_("Position")); - gl_prop_position_set_params (GL_PROP_POSITION (data->position), - object->x, object->y, - display->label->width, - display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->position, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->position), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /* ------ Size Frame ------ */ - data->size = gl_prop_size_new (_("Size")); - gl_prop_size_set_params (GL_PROP_SIZE (data->size), - object->arg.box.w, object->arg.box.h, - data->keep_aspect_ratio_flag, - display->label->width, display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->size, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->size), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*-----------------------------------------------------------------*/ - /* Run dialog, and update state of object if "Applied." */ - /*-----------------------------------------------------------------*/ - gtk_widget_show_all (GTK_WIDGET (dialog)); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the dialog has changed. */ -/*---------------------------------------------------------------------------*/ -static void -changed_cb (glPropertyBox * propertybox) -{ - gl_property_box_changed (propertybox); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Apply" callback. */ -/*---------------------------------------------------------------------------*/ -static void -apply_cb (glPropertyBox * propertybox, - gint page, - PropertyDialogPassback * data) -{ - glLabelObject *object; - glDisplay *display; - - object = gtk_object_get_data (GTK_OBJECT (data->item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (data->item), "display"); - - switch (page) { - - case 0: - /* ------- Get updated line width & color ------ */ - gl_prop_line_get_params (GL_PROP_LINE (data->line), - &object->arg.box.line_width, - &object->arg.box.line_color); - /* ------- Get updated fill color ------ */ - gl_prop_fill_get_params (GL_PROP_FILL (data->fill), - &object->arg.box.fill_color); - break; - - case 1: - /* ------ get updated position ------ */ - gl_prop_position_get_position (GL_PROP_POSITION - (data->position), &object->x, - &object->y); - - /* ------ get updated size ------ */ - gl_prop_size_get_size (GL_PROP_SIZE (data->size), - &object->arg.box.w, &object->arg.box.h, - &data->keep_aspect_ratio_flag); - break; - - default: - return; - } - - /* ------ Udate state of object ------ */ - item_box_update (data->item); - gl_display_select_item (display, data->item); - -} - -/*****************************************************************************/ -/* Return apropos cursor for create object mode. */ -/*****************************************************************************/ -GdkCursor * -gl_item_box_get_create_cursor (void) -{ - static GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; - - if (!cursor) { - pixmap_data = gdk_bitmap_create_from_data (NULL, - cursor_box_bits, - cursor_box_width, - cursor_box_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - cursor_box_mask_bits, - cursor_box_mask_width, - cursor_box_mask_height); - cursor = - gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_box_x_hot, - cursor_box_y_hot); - } - - return cursor; -} - -/*****************************************************************************/ -/* Canvas event handler (box mode) */ -/*****************************************************************************/ -int -gl_item_box_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - static gdouble x0, y0; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glLabelObject *object; - glDisplay *display = GL_DISPLAY (data); - gdouble x, y; - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gdk_pointer_grab (GTK_WIDGET (display->canvas)->window, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, NULL, event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - object = - gl_label_object_new (display->label, - GL_LABEL_OBJECT_BOX); - object->x = x; - object->y = y; - object->arg.box.w = 0.0; - object->arg.box.h = 0.0; - object->arg.box.line_width = 1.0; - object->arg.box.line_color = - GNOME_CANVAS_COLOR_A (0, 0, 255, 128); - object->arg.box.fill_color = - GNOME_CANVAS_COLOR_A (128, 128, 128, 128); - item = gl_item_box_new (object, display); - x0 = x; - y0 = y; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gdk_pointer_ungrab (event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - if ((x0 == x) && (y0 == y)) { - x = x0 + 36.0; - y = y0 + 36.0; - } - object->x = MIN (x, x0); - object->y = MIN (y, y0); - object->arg.box.w = MAX (x, x0) - MIN (x, x0); - object->arg.box.h = MAX (y, y0) - MIN (y, y0); - object->arg.box.line_color = - GNOME_CANVAS_COLOR_A (0, 0, 0, 255); - object->arg.box.fill_color = - GNOME_CANVAS_COLOR_A (0, 255, 0, 255); - item_box_update (item); - gl_display_add_item (display, item); - gl_display_unselect_all (display); - gl_display_select_item (display, item); - gl_display_arrow_mode (display); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - gnome_canvas_window_to_world (canvas, - event->motion.x, - event->motion.y, &x, &y); - object->x = MIN (x, x0); - object->y = MIN (y, y0); - object->arg.box.w = MAX (x, x0) - MIN (x, x0); - object->arg.box.h = MAX (y, y0) - MIN (y, y0); - item_box_update (item); - return TRUE; - } else { - return FALSE; - } - - default: - return FALSE; - } - -} diff --git a/glabels1/src/item_box.h b/glabels1/src/item_box.h deleted file mode 100644 index 789fce8..0000000 --- a/glabels1/src/item_box.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_box.h: GLabels Box Object (canvas item) module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __ITEM_BOX_H__ -#define __ITEM_BOX_H__ - -#include <gnome.h> - -#include "label.h" - -extern GnomeCanvasItem *gl_item_box_new (glLabelObject * object, - glDisplay * display); - -extern void gl_item_box_highlight (GnomeCanvasItem * item); - -extern void gl_item_box_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h); - -extern void gl_item_box_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h); - -extern void gl_item_box_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2); - -extern void gl_item_box_edit_dialog (GnomeCanvasItem * item); - -extern GdkCursor *gl_item_box_get_create_cursor (void); - -extern gint gl_item_box_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data); - -#endif diff --git a/glabels1/src/item_ellipse.c b/glabels1/src/item_ellipse.c deleted file mode 100644 index 5a45b48..0000000 --- a/glabels1/src/item_ellipse.c +++ /dev/null @@ -1,493 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_ellipse.c: gLabels Ellipse Object (canvas item) module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <string.h> - -#include "display.h" -#include "item_ellipse.h" - -#include "highlight.h" - -#include "mdi.h" -#include "propertybox.h" -#include "prop_line.h" -#include "prop_fill.h" -#include "prop_size.h" -#include "prop_position.h" - -#include "pixmaps/cursor_ellipse.xbm" -#include "pixmaps/cursor_ellipse_mask.xbm" - -#include "debug.h" - -/*===========================================*/ -/* Private data types */ -/*===========================================*/ - -typedef struct { - GnomeCanvasItem *item; - gboolean keep_aspect_ratio_flag; - - /* Page 0 widgets */ - GtkWidget *line; - GtkWidget *fill; - - /* Page 1 widgets */ - GtkWidget *position; - GtkWidget *size; -} PropertyDialogPassback; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void item_ellipse_update (GnomeCanvasItem * item); - -static void changed_cb (glPropertyBox * propertybox); -static void apply_cb (glPropertyBox * propertybox, - gint page, PropertyDialogPassback * data); - -/****************************************************************************/ -/* Create an ellipse object */ -/****************************************************************************/ -GnomeCanvasItem * -gl_item_ellipse_new (glLabelObject * object, - glDisplay * display) -{ - GnomeCanvasGroup *group; - GnomeCanvasItem *item; - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - item = gnome_canvas_item_new (group, gnome_canvas_ellipse_get_type (), - "x1", object->x, - "y1", object->y, - "x2", object->x + object->arg.ellipse.w, - "y2", object->y + object->arg.ellipse.h, - "width_units", - object->arg.ellipse.line_width, - "outline_color_rgba", - object->arg.ellipse.line_color, - "fill_color_rgba", - object->arg.ellipse.fill_color, NULL); - - /* Squirrel away pointers to object and display in the canvas item. */ - gtk_object_set_data (GTK_OBJECT (item), "label_object", object); - gtk_object_set_data (GTK_OBJECT (item), "display", display); - gtk_object_set_data (GTK_OBJECT (item), "highlight", NULL); - - gtk_signal_connect (GTK_OBJECT (item), "event", - GTK_SIGNAL_FUNC (gl_display_item_event_handler), - display); - - gl_display_new_item_menu (item); - - gl_display_set_modified (display); - - return item; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Update a ellipse object */ -/*--------------------------------------------------------------------------*/ -static void -item_ellipse_update (GnomeCanvasItem * item) -{ - glLabelObject *object; - glDisplay *display; - gdouble affine[6]; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - art_affine_identity (affine); - gnome_canvas_item_affine_absolute (item, affine); - gnome_canvas_item_set (item, - "x1", object->x, - "y1", object->y, - "x2", object->x + object->arg.ellipse.w, - "y2", object->y + object->arg.ellipse.h, - "width_units", object->arg.ellipse.line_width, - "outline_color_rgba", - object->arg.ellipse.line_color, - "fill_color_rgba", - object->arg.ellipse.fill_color, NULL); - - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - gl_display_set_modified (display); -} - -/****************************************************************************/ -/* Return a selection canvas item/group for given item */ -/****************************************************************************/ -void -gl_item_ellipse_highlight (GnomeCanvasItem * item) -{ - gl_highlight (item, GL_HIGHLIGHT_ELLIPSE_RESIZABLE); -} - -/****************************************************************************/ -/* Get position and size of object. */ -/****************************************************************************/ -void -gl_item_ellipse_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - *x = object->x; - *y = object->y; - - *w = object->arg.ellipse.w; - *h = object->arg.ellipse.h; -} - -/****************************************************************************/ -/* Get position and size of object. */ -/****************************************************************************/ -void -gl_item_ellipse_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - object->x = x; - object->y = y; - - object->arg.ellipse.w = w; - object->arg.ellipse.h = h; - - item_ellipse_update (item); -} - -/****************************************************************************/ -/* Get ellipse item bounds. */ -/****************************************************************************/ -void -gl_item_ellipse_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2) -{ - gnome_canvas_item_get_bounds (item, x1, y1, x2, y2); -} - -/****************************************************************************/ -/* Create and run an edit dialog on an ellipse object. */ -/****************************************************************************/ -void -gl_item_ellipse_edit_dialog (GnomeCanvasItem * item) -{ - GtkWidget *dialog; - static PropertyDialogPassback *data = NULL; - glLabelObject *object; - glDisplay *display; - GtkWidget *wvbox; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - if (data == NULL) { - data = g_new0 (PropertyDialogPassback, 1); - } - data->item = item; - - dialog = gl_property_box_new (); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (gl_mdi_get_active_window ())); - gtk_window_set_title (GTK_WINDOW (dialog), - _("Edit ellipse object properties")); - gtk_signal_connect (GTK_OBJECT (dialog), "apply", - GTK_SIGNAL_FUNC (apply_cb), data); - - /*---------------------------*/ - /* Appearance Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Appearance"))); - - /* ------ Line box ------ */ - data->line = gl_prop_line_new (_("Outline")); - gl_prop_line_set_params (GL_PROP_LINE (data->line), - object->arg.ellipse.line_width, - object->arg.ellipse.line_color); - gtk_box_pack_start (GTK_BOX (wvbox), data->line, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->line), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /* ------ Fill box ------ */ - data->fill = gl_prop_fill_new (_("Fill")); - gl_prop_fill_set_params (GL_PROP_FILL (data->fill), - object->arg.ellipse.fill_color); - gtk_box_pack_start (GTK_BOX (wvbox), data->fill, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->fill), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*----------------------------*/ - /* Position/Size Notebook Tab */ - /*----------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Position/Size"))); - - /* ------ Position Frame ------ */ - data->position = gl_prop_position_new (_("Position")); - gl_prop_position_set_params (GL_PROP_POSITION (data->position), - object->x, object->y, - display->label->width, - display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->position, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->position), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /* ------ Size Frame ------ */ - data->size = gl_prop_size_new (_("Size")); - gl_prop_size_set_params (GL_PROP_SIZE (data->size), - object->arg.ellipse.w, object->arg.ellipse.h, - data->keep_aspect_ratio_flag, - display->label->width, display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->size, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->size), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*-----------------------------------------------------------------*/ - /* Run dialog, and update state of object if "Applied." */ - /*-----------------------------------------------------------------*/ - gtk_widget_show_all (GTK_WIDGET (dialog)); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the dialog has changed. */ -/*---------------------------------------------------------------------------*/ -static void -changed_cb (glPropertyBox * propertybox) -{ - gl_property_box_changed (propertybox); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Apply" callback. */ -/*---------------------------------------------------------------------------*/ -static void -apply_cb (glPropertyBox * propertybox, - gint page, - PropertyDialogPassback * data) -{ - glLabelObject *object; - glDisplay *display; - - object = gtk_object_get_data (GTK_OBJECT (data->item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (data->item), "display"); - - switch (page) { - - case 0: - /* ------- Get updated line width & color ------ */ - gl_prop_line_get_params (GL_PROP_LINE (data->line), - &object->arg.ellipse.line_width, - &object->arg.ellipse.line_color); - /* ------- Get updated fill color ------ */ - gl_prop_fill_get_params (GL_PROP_FILL (data->fill), - &object->arg.ellipse.fill_color); - break; - - case 1: - /* ------ get updated position ------ */ - gl_prop_position_get_position (GL_PROP_POSITION - (data->position), &object->x, - &object->y); - - /* ------ get updated size ------ */ - gl_prop_size_get_size (GL_PROP_SIZE (data->size), - &object->arg.ellipse.w, - &object->arg.ellipse.h, - &data->keep_aspect_ratio_flag); - break; - - default: - return; - } - - /* ------ Udate state of object ------ */ - item_ellipse_update (data->item); - gl_display_select_item (display, data->item); - -} - -/****************************************************************************/ -/* Return apropos cursor for create object mode. */ -/****************************************************************************/ -GdkCursor * -gl_item_ellipse_get_create_cursor (void) -{ - static GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; - - if (!cursor) { - pixmap_data = gdk_bitmap_create_from_data (NULL, - cursor_ellipse_bits, - cursor_ellipse_width, - cursor_ellipse_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - cursor_ellipse_mask_bits, - cursor_ellipse_mask_width, - cursor_ellipse_mask_height); - cursor = - gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_ellipse_x_hot, - cursor_ellipse_y_hot); - } - - return cursor; -} - -/****************************************************************************/ -/* Canvas event handler (ellipse mode) */ -/****************************************************************************/ -int -gl_item_ellipse_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - static gdouble x0, y0; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glLabelObject *object; - glDisplay *display = GL_DISPLAY (data); - gdouble x, y; - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gdk_pointer_grab (GTK_WIDGET (display->canvas)->window, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, NULL, event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - object = - gl_label_object_new (display->label, - GL_LABEL_OBJECT_ELLIPSE); - object->x = x; - object->y = y; - object->arg.ellipse.w = 0.0; - object->arg.ellipse.h = 0.0; - object->arg.ellipse.line_width = 1.0; - object->arg.ellipse.line_color = - GNOME_CANVAS_COLOR_A (0, 0, 255, 128); - object->arg.ellipse.fill_color = - GNOME_CANVAS_COLOR_A (128, 128, 128, 128); - item = gl_item_ellipse_new (object, display); - x0 = x; - y0 = y; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gdk_pointer_ungrab (event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - if ((x0 == x) || (y0 == y)) { - x = x0 + 36.0; - y = y0 + 36.0; - } - object->x = MIN (x, x0); - object->y = MIN (y, y0); - object->arg.ellipse.w = MAX (x, x0) - MIN (x, x0); - object->arg.ellipse.h = MAX (y, y0) - MIN (y, y0); - object->arg.ellipse.line_color = - GNOME_CANVAS_COLOR_A (0, 0, 0, 255); - object->arg.ellipse.fill_color = - GNOME_CANVAS_COLOR_A (0, 255, 0, 255); - item_ellipse_update (item); - gl_display_add_item (display, item); - gl_display_unselect_all (display); - gl_display_select_item (display, item); - gl_display_arrow_mode (display); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - gnome_canvas_window_to_world (canvas, - event->motion.x, - event->motion.y, &x, &y); - object->x = MIN (x, x0); - object->y = MIN (y, y0); - object->arg.ellipse.w = MAX (x, x0) - MIN (x, x0); - object->arg.ellipse.h = MAX (y, y0) - MIN (y, y0); - item_ellipse_update (item); - return TRUE; - } else { - return FALSE; - } - - default: - return FALSE; - } - -} diff --git a/glabels1/src/item_ellipse.h b/glabels1/src/item_ellipse.h deleted file mode 100644 index c4cf54e..0000000 --- a/glabels1/src/item_ellipse.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_ellipse.h: GLabels Ellipse Object (canvas item) module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __ITEM_ELLIPSE_H__ -#define __ITEM_ELLIPSE_H__ - -#include <gnome.h> - -#include "label.h" - -extern GnomeCanvasItem *gl_item_ellipse_new (glLabelObject * object, - glDisplay * display); - -extern void gl_item_ellipse_highlight (GnomeCanvasItem * item); - -extern void gl_item_ellipse_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h); - -extern void gl_item_ellipse_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h); - -extern void gl_item_ellipse_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2); - -extern void gl_item_ellipse_edit_dialog (GnomeCanvasItem * item); - -extern GdkCursor *gl_item_ellipse_get_create_cursor (void); - -extern gint gl_item_ellipse_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data); - -#endif diff --git a/glabels1/src/item_image.c b/glabels1/src/item_image.c deleted file mode 100644 index 4eee6c6..0000000 --- a/glabels1/src/item_image.c +++ /dev/null @@ -1,612 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_image.c: GLabels Image Object (canvas item) module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <string.h> - -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gdk-pixbuf/gnome-canvas-pixbuf.h> - -#include "display.h" -#include "item_image.h" - -#include "highlight.h" - -#include "mdi.h" -#include "propertybox.h" -#include "prop_position.h" -#include "prop_size.h" - -#include "pixmaps/cursor_image.xbm" -#include "pixmaps/cursor_image_mask.xbm" - -#include "pixmaps/checkerboard.xpm" - -#include "debug.h" - -#define RED(x) ( ((x)>>24) & 0xff ) -#define GREEN(x) ( ((x)>>16) & 0xff ) -#define BLUE(x) ( ((x)>>8) & 0xff ) -#define ALPHA(x) ( (x) & 0xff ) - -/*===========================================*/ -/* Private data types */ -/*===========================================*/ - -typedef struct { - GnomeCanvasItem *item; - gboolean keep_aspect_ratio_flag; - - /* Page 0 widgets */ - GtkWidget *pixmap_entry; - - /* Page 1 widgets */ - GtkWidget *position; - GtkWidget *size; -} PropertyDialogPassback; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/* Save state of image file entry */ -static gchar *image_path = NULL; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void item_image_update (GnomeCanvasItem * item); - -static void changed_cb (glPropertyBox * propertybox); -static void size_reset_cb (glPropertyBox * propertybox); -static void apply_cb (glPropertyBox * propertybox, - gint page, PropertyDialogPassback * data); - -/****************************************************************************/ -/* Create a image object */ -/****************************************************************************/ -GnomeCanvasItem * -gl_item_image_new (glLabelObject * object, - glDisplay * display) -{ - GnomeCanvasGroup *group; - GnomeCanvasItem *item; - - if (object->arg.image.image == NULL) { - object->arg.image.image = - gdk_pixbuf_new_from_xpm_data ((const char **) - checkerboard_xpm); - } - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - item = gnome_canvas_item_new (group, gnome_canvas_pixbuf_get_type (), - "x", object->x, - "y", object->y, - "width_set", TRUE, - "height_set", TRUE, - "width", object->arg.image.w, - "height", object->arg.image.h, - "pixbuf", object->arg.image.image, NULL); - - /* Squirrel away pointers to object and display in the canvas item. */ - gtk_object_set_data (GTK_OBJECT (item), "label_object", object); - gtk_object_set_data (GTK_OBJECT (item), "display", display); - gtk_object_set_data (GTK_OBJECT (item), "highlight", NULL); - - gtk_signal_connect (GTK_OBJECT (item), "event", - GTK_SIGNAL_FUNC (gl_display_item_event_handler), - display); - - gl_display_new_item_menu (item); - - gl_display_set_modified (display); - - return item; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Update an image object */ -/*--------------------------------------------------------------------------*/ -static void -item_image_update (GnomeCanvasItem * item) -{ - glLabelObject *object; - glDisplay *display; - gdouble affine[6]; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - if (object->arg.image.image == NULL) { - object->arg.image.image = - gdk_pixbuf_new_from_xpm_data ((const char **) - checkerboard_xpm); - } - - art_affine_identity (affine); - gnome_canvas_item_affine_absolute (item, affine); - gnome_canvas_item_set (item, - "x", object->x, - "y", object->y, - "width_set", TRUE, - "height_set", TRUE, - "width", object->arg.image.w, - "height", object->arg.image.h, - "pixbuf", object->arg.image.image, NULL); - - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - gl_display_set_modified (display); -} - -/****************************************************************************/ -/* Return a selection canvas item/group for given item */ -/****************************************************************************/ -void -gl_item_image_highlight (GnomeCanvasItem * item) -{ - gl_highlight (item, GL_HIGHLIGHT_BOX_RESIZABLE); -} - -/****************************************************************************/ -/* Get position and size of object. */ -/****************************************************************************/ -void -gl_item_image_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - *x = object->x; - *y = object->y; - - *w = object->arg.image.w; - *h = object->arg.image.h; -} - -/****************************************************************************/ -/* Get position and size of object. */ -/****************************************************************************/ -void -gl_item_image_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - object->x = x; - object->y = y; - - object->arg.image.w = w; - object->arg.image.h = h; - - item_image_update (item); -} - -/****************************************************************************/ -/* Get image item bounds. */ -/****************************************************************************/ -void -gl_item_image_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2) -{ - gnome_canvas_item_get_bounds (item, x1, y1, x2, y2); -} - -/****************************************************************************/ -/* Create and run an edit dialog on a image object. */ -/****************************************************************************/ -void -gl_item_image_edit_dialog (GnomeCanvasItem * item) -{ - GtkWidget *dialog; - static PropertyDialogPassback *data = NULL; - GtkWidget *wbutton; - glLabelObject *object; - glDisplay *display; - GtkWidget *wvbox; - gdouble image_w, image_h; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - if (data == NULL) { - data = g_new0 (PropertyDialogPassback, 1); - } - data->item = item; - - dialog = gl_property_box_new (); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (gl_mdi_get_active_window ())); - gtk_window_set_title (GTK_WINDOW (dialog), - _("Edit image object properties")); - gtk_signal_connect (GTK_OBJECT (dialog), "apply", - GTK_SIGNAL_FUNC (apply_cb), data); - gtk_object_set_data (GTK_OBJECT (dialog), "data", data); - - /*---------------------------*/ - /* Image Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Image"))); - - /* image entry */ - data->pixmap_entry = - gnome_pixmap_entry_new ("image", "Load image", TRUE); - gnome_pixmap_entry_set_preview_size (GNOME_PIXMAP_ENTRY - (data->pixmap_entry), 128, 128); - - /* Set default path for image entry */ - if (object->arg.image.filename != NULL) { - /* Set default path to the directory containing image. */ - if (image_path != NULL) - g_free (image_path); - image_path = g_dirname (object->arg.image.filename); - if (image_path != NULL) { - image_path = g_strconcat (image_path, "/", NULL); - } - } else if (image_path == NULL) { - /* First time, set it to our CWD. */ - image_path = g_get_current_dir (); - } - /* Otherwise, leave it in the last directory that we got an image. */ - gnome_file_entry_set_default_path (GNOME_FILE_ENTRY - (GNOME_PIXMAP_ENTRY - (data->pixmap_entry)->fentry), - image_path); - - if (object->arg.image.filename != NULL) { - gtk_entry_set_text (GTK_ENTRY - (gnome_pixmap_entry_gtk_entry - (GNOME_PIXMAP_ENTRY (data->pixmap_entry))), - object->arg.image.filename); - } - gtk_box_pack_start (GTK_BOX (wvbox), data->pixmap_entry, FALSE, FALSE, - 0); - gtk_signal_connect_object (GTK_OBJECT - (gnome_pixmap_entry_gtk_entry - (GNOME_PIXMAP_ENTRY (data->pixmap_entry))), - "changed", GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*----------------------------*/ - /* Position/Size Notebook Tab */ - /*----------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Position/Size"))); - - /* ------ Position Frame ------ */ - data->position = gl_prop_position_new (_("Position")); - gl_prop_position_set_params (GL_PROP_POSITION (data->position), - object->x, object->y, - display->label->width, - display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->position, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->position), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /* ------ Size Frame ------ */ - data->size = gl_prop_size_new (_("Size")); - image_w = gdk_pixbuf_get_width (object->arg.image.image); - image_h = gdk_pixbuf_get_height (object->arg.image.image); - gl_prop_size_set_params (GL_PROP_SIZE (data->size), - object->arg.image.w, object->arg.image.h, - data->keep_aspect_ratio_flag, - display->label->width, display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->size, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->size), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /* ------ Size Reset Button ------ */ - wbutton = gtk_button_new_with_label (_("Reset image size")); - gtk_box_pack_start (GTK_BOX (wvbox), wbutton, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (wbutton), "clicked", - GTK_SIGNAL_FUNC (size_reset_cb), - GTK_OBJECT (dialog)); - - /*-----------------------------------------------------------------*/ - /* Run dialog, and update state of object if "Applied." */ - /*-----------------------------------------------------------------*/ - gtk_widget_show_all (GTK_WIDGET (dialog)); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the dialog has changed. */ -/*---------------------------------------------------------------------------*/ -static void -changed_cb (glPropertyBox * propertybox) -{ - gl_property_box_changed (propertybox); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Callback to reset size to original image size. */ -/*---------------------------------------------------------------------------*/ -static void -size_reset_cb (glPropertyBox * propertybox) -{ - PropertyDialogPassback *data = NULL; - glDisplay *display; - gchar *filename, *ext; - GdkPixbuf *image; - gdouble image_w, image_h; - - data = gtk_object_get_data (GTK_OBJECT (propertybox), "data"); - - display = gtk_object_get_data (GTK_OBJECT (data->item), "display"); - - filename = - gnome_pixmap_entry_get_filename (GNOME_PIXMAP_ENTRY - (data->pixmap_entry)); - if (filename != NULL) { - ext = strrchr (filename, '.'); - if (g_strcasecmp (ext, ".tga") != 0) { - image = gdk_pixbuf_new_from_file (filename); - } else { - gnome_error_dialog (_ - ("Image format not currently supported")); - return; - } - } else { - return; - } - image_w = gdk_pixbuf_get_width (image); - image_h = gdk_pixbuf_get_height (image); - gdk_pixbuf_unref (image); - - data->keep_aspect_ratio_flag = TRUE; - - gl_prop_size_set_params (GL_PROP_SIZE (data->size), - image_w, image_h, - data->keep_aspect_ratio_flag, - display->label->width, display->label->height); - - gl_property_box_changed (propertybox); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Apply" callback. */ -/*---------------------------------------------------------------------------*/ -static void -apply_cb (glPropertyBox * propertybox, - gint page, - PropertyDialogPassback * data) -{ - glLabelObject *object; - glDisplay *display; - gchar *filename, *ext; - gdouble image_w, image_h; - - object = gtk_object_get_data (GTK_OBJECT (data->item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (data->item), "display"); - - switch (page) { - - case 0: - /* ------ Update image ------ */ - filename = - gnome_pixmap_entry_get_filename (GNOME_PIXMAP_ENTRY - (data->pixmap_entry)); - if (filename != NULL) { - ext = strrchr (filename, '.'); - if (g_strcasecmp (ext, ".tga") != 0) { - - g_free (object->arg.image.filename); - object->arg.image.filename = filename; - gdk_pixbuf_unref (object->arg.image.image); - object->arg.image.image = - gdk_pixbuf_new_from_file (object->arg.image. - filename); - - /* save state of image entry. */ - if (image_path != NULL) - g_free (image_path); - image_path = g_dirname (filename); - if (image_path != NULL) { - image_path = - g_strconcat (image_path, "/", NULL); - } - - } else { - gnome_error_dialog (_ - ("Image format not currently supported")); - } - } - break; - - case 1: - /* ------ get updated position ------ */ - gl_prop_position_get_position (GL_PROP_POSITION - (data->position), &object->x, - &object->y); - - /* ------ get updated size ------ */ - gl_prop_size_get_size (GL_PROP_SIZE (data->size), - &object->arg.image.w, - &object->arg.image.h, - &data->keep_aspect_ratio_flag); - break; - - default: - return; - } - - /* ------ Udate state of object ------ */ - item_image_update (data->item); - gl_display_select_item (display, data->item); - - /* update size controls */ - image_w = gdk_pixbuf_get_width (object->arg.image.image); - image_h = gdk_pixbuf_get_height (object->arg.image.image); - gl_prop_size_set_params (GL_PROP_SIZE (data->size), - object->arg.image.w, object->arg.image.h, - data->keep_aspect_ratio_flag, - display->label->width, display->label->height); -} - -/****************************************************************************/ -/* Return apropos cursor for create object mode. */ -/****************************************************************************/ -GdkCursor * -gl_item_image_get_create_cursor (void) -{ - static GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; - - if (!cursor) { - pixmap_data = gdk_bitmap_create_from_data (NULL, - cursor_image_bits, - cursor_image_width, - cursor_image_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - cursor_image_mask_bits, - cursor_image_mask_width, - cursor_image_mask_height); - cursor = - gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_image_x_hot, - cursor_image_y_hot); - } - - return cursor; -} - -/****************************************************************************/ -/* Canvas event handler (image mode) */ -/****************************************************************************/ -gint -gl_item_image_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - static gdouble x0, y0; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glLabelObject *object; - glDisplay *display = GL_DISPLAY (data); - gdouble x, y; - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gdk_pointer_grab (GTK_WIDGET (display->canvas)->window, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, NULL, event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - object = - gl_label_object_new (display->label, - GL_LABEL_OBJECT_IMAGE); - object->x = x; - object->y = y; - object->arg.image.w = 1.0; - object->arg.image.h = 1.0; - object->arg.image.image = NULL; - object->arg.image.filename = NULL; - item = gl_item_image_new (object, display); - x0 = x; - y0 = y; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gdk_pointer_ungrab (event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - if ((x0 == x) || (y0 == y)) { - x = x0 + 24.0; - y = y0 + 24.0; - } - object->x = MIN (x, x0); - object->y = MIN (y, y0); - object->arg.image.w = MAX (x, x0) - MIN (x, x0); - object->arg.image.h = MAX (y, y0) - MIN (y, y0); - item_image_update (item); - gl_display_add_item (display, item); - gl_display_unselect_all (display); - gl_display_select_item (display, item); - gl_display_arrow_mode (display); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - gnome_canvas_window_to_world (canvas, - event->motion.x, - event->motion.y, &x, &y); - object->x = MIN (x, x0); - object->y = MIN (y, y0); - object->arg.image.w = MAX (x, x0) - MIN (x, x0); - object->arg.image.h = MAX (y, y0) - MIN (y, y0); - item_image_update (item); - return TRUE; - } else { - return FALSE; - } - - default: - return FALSE; - } - -} diff --git a/glabels1/src/item_image.h b/glabels1/src/item_image.h deleted file mode 100644 index 674a9c0..0000000 --- a/glabels1/src/item_image.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_image.h: GLabels Image Object (canvas item) module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __ITEM_IMAGE_H__ -#define __ITEM_IMAGE_H__ - -#include <gnome.h> - -#include "label.h" - -extern GnomeCanvasItem *gl_item_image_new (glLabelObject * object, - glDisplay * display); - -extern void gl_item_image_highlight (GnomeCanvasItem * item); - -extern void gl_item_image_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h); - -extern void gl_item_image_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h); - -extern void gl_item_image_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2); - -extern void gl_item_image_edit_dialog (GnomeCanvasItem * item); - -extern GdkCursor *gl_item_image_get_create_cursor (void); - -extern gint gl_item_image_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data); - -#endif diff --git a/glabels1/src/item_line.c b/glabels1/src/item_line.c deleted file mode 100644 index 9d14abe..0000000 --- a/glabels1/src/item_line.c +++ /dev/null @@ -1,481 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_line.c: GLabels Line Object (canvas item) module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <string.h> -#include <math.h> - -#include "display.h" -#include "item_line.h" - -#include "highlight.h" - -#include "mdi.h" -#include "propertybox.h" -#include "prop_line.h" -#include "prop_position.h" -#include "prop_vector.h" - -#include "pixmaps/cursor_line.xbm" -#include "pixmaps/cursor_line_mask.xbm" - -#include "debug.h" - -/*===========================================*/ -/* Private data types */ -/*===========================================*/ - -typedef struct { - GnomeCanvasItem *item; - - /* Page 0 widgets */ - GtkWidget *line; - - /* Page 1 widgets */ - GtkWidget *position; - GtkWidget *vector; -} PropertyDialogPassback; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void item_line_update (GnomeCanvasItem * item); - -static void changed_cb (glPropertyBox * propertybox); -static void apply_cb (glPropertyBox * propertybox, - gint page, PropertyDialogPassback * data); - -/****************************************************************************/ -/* Create a line object */ -/****************************************************************************/ -GnomeCanvasItem * -gl_item_line_new (glLabelObject * object, - glDisplay * display) -{ - GnomeCanvasGroup *group; - GnomeCanvasItem *item; - GnomeCanvasPoints *points; - - points = gnome_canvas_points_new (2); - points->coords[0] = object->x; - points->coords[1] = object->y; - points->coords[2] = object->x + object->arg.line.dx; - points->coords[3] = object->y + object->arg.line.dy; - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - item = gnome_canvas_item_new (group, gnome_canvas_line_get_type (), - "points", points, - "width_units", - object->arg.line.line_width, - "fill_color_rgba", - object->arg.line.line_color, NULL); - - gnome_canvas_points_free (points); - - /* Squirrel away pointers to object and display in the canvas item. */ - gtk_object_set_data (GTK_OBJECT (item), "label_object", object); - gtk_object_set_data (GTK_OBJECT (item), "display", display); - gtk_object_set_data (GTK_OBJECT (item), "highlight", NULL); - - gtk_signal_connect (GTK_OBJECT (item), "event", - GTK_SIGNAL_FUNC (gl_display_item_event_handler), - display); - - gl_display_new_item_menu (item); - - gl_display_set_modified (display); - - return item; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Update a line object */ -/*--------------------------------------------------------------------------*/ -static void -item_line_update (GnomeCanvasItem * item) -{ - glLabelObject *object; - glDisplay *display; - GnomeCanvasPoints *points; - gdouble affine[6]; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - points = gnome_canvas_points_new (2); - points->coords[0] = object->x; - points->coords[1] = object->y; - points->coords[2] = object->x + object->arg.line.dx; - points->coords[3] = object->y + object->arg.line.dy; - - art_affine_identity (affine); - gnome_canvas_item_affine_absolute (item, affine); - gnome_canvas_item_set (item, - "points", points, - "width_units", object->arg.line.line_width, - "fill_color_rgba", object->arg.line.line_color, - NULL); - - gnome_canvas_points_free (points); - - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - gl_display_set_modified (display); -} - -/****************************************************************************/ -/* Create a selection canvas item/group for given item */ -/****************************************************************************/ -void -gl_item_line_highlight (GnomeCanvasItem * item) -{ - gl_highlight (item, GL_HIGHLIGHT_LINE_RESIZABLE); -} - -/****************************************************************************/ -/* Get position and size of object. */ -/****************************************************************************/ -void -gl_item_line_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - *x = object->x; - *y = object->y; - - *w = object->arg.line.dx; - *h = object->arg.line.dy; -} - -/****************************************************************************/ -/* Get position and size of object. */ -/****************************************************************************/ -void -gl_item_line_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - object->x = x; - object->y = y; - - object->arg.line.dx = w; - object->arg.line.dy = h; - - item_line_update (item); -} - -/****************************************************************************/ -/* Get line item bounds. */ -/****************************************************************************/ -void -gl_item_line_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2) -{ - gnome_canvas_item_get_bounds (item, x1, y1, x2, y2); -} - -/****************************************************************************/ -/* Create and run an edit dialog on a line object. */ -/****************************************************************************/ -void -gl_item_line_edit_dialog (GnomeCanvasItem * item) -{ - GtkWidget *dialog; - static PropertyDialogPassback *data = NULL; - glLabelObject *object; - glDisplay *display; - GtkWidget *wvbox; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - if (data == NULL) { - data = g_new0 (PropertyDialogPassback, 1); - } - data->item = item; - - dialog = gl_property_box_new (); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (gl_mdi_get_active_window ())); - gtk_window_set_title (GTK_WINDOW (dialog), - _("Edit line object properties")); - gtk_signal_connect (GTK_OBJECT (dialog), "apply", - GTK_SIGNAL_FUNC (apply_cb), data); - - /*---------------------------*/ - /* Appearance Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Appearance"))); - - /* ------ Begin Line box ------ */ - data->line = gl_prop_line_new (_("Line")); - gl_prop_line_set_params (GL_PROP_LINE (data->line), - object->arg.line.line_width, - object->arg.line.line_color); - gtk_box_pack_start (GTK_BOX (wvbox), data->line, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->line), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*----------------------------*/ - /* Position/Size Notebook Tab */ - /*----------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Position/Size"))); - - /* ------ Position Frame ------ */ - data->position = gl_prop_position_new (_("Position")); - gl_prop_position_set_params (GL_PROP_POSITION (data->position), - object->x, object->y, - display->label->width, - display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->position, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->position), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /* ------ Size Frame ------ */ - data->vector = gl_prop_vector_new (_("Size")); - gl_prop_vector_set_params (GL_PROP_VECTOR (data->vector), - object->arg.line.dx, object->arg.line.dy, - display->label->width, - display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->vector, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->vector), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*-----------------------------------------------------------------*/ - /* Run dialog, and update state of object if "Applied." */ - /*-----------------------------------------------------------------*/ - gtk_widget_show_all (GTK_WIDGET (dialog)); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the dialog has changed. */ -/*---------------------------------------------------------------------------*/ -static void -changed_cb (glPropertyBox * propertybox) -{ - gl_property_box_changed (propertybox); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Apply" callback. */ -/*---------------------------------------------------------------------------*/ -static void -apply_cb (glPropertyBox * propertybox, - gint page, - PropertyDialogPassback * data) -{ - glLabelObject *object; - glDisplay *display; - - object = gtk_object_get_data (GTK_OBJECT (data->item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (data->item), "display"); - - switch (page) { - - case 0: - /* ------- Get updated line width & color ------ */ - gl_prop_line_get_params (GL_PROP_LINE (data->line), - &object->arg.line.line_width, - &object->arg.line.line_color); - break; - - case 1: - /* ------ get updated position ------ */ - gl_prop_position_get_position (GL_PROP_POSITION - (data->position), &object->x, - &object->y); - /* ------ get updated size ------ */ - gl_prop_vector_get_params (GL_PROP_VECTOR (data->vector), - &object->arg.line.dx, - &object->arg.line.dy); - break; - - default: - return; - } - - /* ------ Udate state of object ------ */ - item_line_update (data->item); - gl_display_select_item (display, data->item); - -} - -/****************************************************************************/ -/* Return apropos cursor for create object mode. */ -/****************************************************************************/ -GdkCursor * -gl_item_line_get_create_cursor (void) -{ - static GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; - - if (!cursor) { - pixmap_data = gdk_bitmap_create_from_data (NULL, - cursor_line_bits, - cursor_line_width, - cursor_line_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - cursor_line_mask_bits, - cursor_line_mask_width, - cursor_line_mask_height); - cursor = - gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_line_x_hot, - cursor_line_y_hot); - } - - return cursor; -} - -/****************************************************************************/ -/* Canvas event handler (line mode) */ -/****************************************************************************/ -gint -gl_item_line_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - static gdouble x0, y0; - static gboolean dragging = FALSE; - static GnomeCanvasItem *item; - static glLabelObject *object; - glDisplay *display = GL_DISPLAY (data); - gdouble x, y; - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - dragging = TRUE; - gdk_pointer_grab (GTK_WIDGET (display->canvas)->window, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, NULL, event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - object = - gl_label_object_new (display->label, - GL_LABEL_OBJECT_LINE); - object->x = x; - object->y = y; - object->arg.line.dx = 0.0; - object->arg.line.dy = 0.0; - object->arg.line.line_width = 1.0; - object->arg.line.line_color = - GNOME_CANVAS_COLOR_A (0, 0, 255, 128); - item = gl_item_line_new (object, display); - x0 = x; - y0 = y; - return TRUE; - - default: - return FALSE; - } - - case GDK_BUTTON_RELEASE: - switch (event->button.button) { - case 1: - dragging = FALSE; - gdk_pointer_ungrab (event->button.time); - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - if ((x0 == x) && (y0 == y)) { - x = x0 + 36.0; - y = y0 + 36.0; - } - object->x = x0; - object->y = y0; - object->arg.line.dx = (x - x0); - object->arg.line.dy = (y - y0); - object->arg.line.line_color = - GNOME_CANVAS_COLOR (0, 0, 0); - item_line_update (item); - gl_display_add_item (display, item); - gl_display_unselect_all (display); - gl_display_select_item (display, item); - gl_display_arrow_mode (display); - return TRUE; - - default: - return FALSE; - } - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - gnome_canvas_window_to_world (canvas, - event->motion.x, - event->motion.y, &x, &y); - object->x = x0; - object->y = y0; - object->arg.line.dx = (x - x0); - object->arg.line.dy = (y - y0); - item_line_update (item); - return TRUE; - } else { - return FALSE; - } - - default: - return FALSE; - } - -} diff --git a/glabels1/src/item_line.h b/glabels1/src/item_line.h deleted file mode 100644 index 3bb48fe..0000000 --- a/glabels1/src/item_line.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_line.h: GLabels Line Object (canvas item) module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __ITEM_LINE_H__ -#define __ITEM_LINE_H__ - -#include <gnome.h> - -#include "label.h" - -extern GnomeCanvasItem *gl_item_line_new (glLabelObject * object, - glDisplay * display); - -extern void gl_item_line_highlight (GnomeCanvasItem * item); - -extern void gl_item_line_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h); - -extern void gl_item_line_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h); - -extern void gl_item_line_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2); - -extern void gl_item_line_edit_dialog (GnomeCanvasItem * item); - -extern GdkCursor *gl_item_line_get_create_cursor (void); - -extern gint gl_item_line_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data); - -#endif diff --git a/glabels1/src/item_text.c b/glabels1/src/item_text.c deleted file mode 100644 index 0a0172a..0000000 --- a/glabels1/src/item_text.c +++ /dev/null @@ -1,780 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_text.c: GLabels Text Object (canvas item) module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <string.h> - -#include "display.h" -#include "item_text.h" - -#include "highlight.h" - -#include "mdi.h" -#include "propertybox.h" -#include "prop_text_entry.h" -#include "prop_text.h" -#include "prop_position.h" - -#include "pixmaps/cursor_text.xbm" -#include "pixmaps/cursor_text_mask.xbm" - -#ifdef HACKTEXT -#include "gnome-canvas-hacktext.h" -#include <libgnomeprint/gnome-glyphlist.h> -#include "hack.h" -#endif - -#include "debug.h" - -#define DEFAULT_FONT_FAMILY "Helvetica" -#define DEFAULT_FONT_SIZE 14.0 -#define DEFAULT_FONT_WEIGHT GNOME_FONT_BOOK -#define DEFAULT_FONT_ITALIC_FLAG FALSE - -/*===========================================*/ -/* Private data types */ -/*===========================================*/ - -typedef struct { - GnomeCanvasItem *item; - - /* Page 0 widgets */ - GtkWidget *text_entry; - - /* Page 1 widgets */ - GtkWidget *text; - - /* Page 2 widgets */ - GtkWidget *position; -} PropertyDialogPassback; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void item_text_update (GnomeCanvasItem * item); - -static void changed_cb (glPropertyBox * propertybox); -static void apply_cb (glPropertyBox * propertybox, - gint page, PropertyDialogPassback * data); - -#ifdef HACKTEXT -static void draw_hacktext (GnomeCanvasItem * group, - gchar * text, - gchar * font_family, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - gdouble font_size, - guint color, - GtkJustification just, - gdouble scale); - -static void hacktext_get_size (gchar * text, - gchar * font_family, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - gdouble font_size, - gdouble * w, - gdouble * h); -#endif - -/****************************************************************************/ -/* Create a text object */ -/****************************************************************************/ -GnomeCanvasItem * -gl_item_text_new (glLabelObject * object, - glDisplay * display) -{ - GnomeCanvasGroup *group; - GnomeCanvasItem *item; -#ifndef HACKTEXT - GdkFont *gdk_font; - GnomeDisplayFont *display_font; - GtkAnchorType anchor; -#endif - gchar *text; - - text = gl_text_node_lines_expand (object->arg.text.lines, NULL); - -#ifdef HACKTEXT - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - item = gnome_canvas_item_new (group, gnome_canvas_group_get_type (), - "x", object->x, "y", object->y, NULL); - draw_hacktext (item, - text, - object->arg.text.font_family, - object->arg.text.font_weight, - object->arg.text.font_italic_flag, - object->arg.text.font_size, - object->arg.text.color, - object->arg.text.just, display->scale); - -#else - - display_font = gnome_get_display_font (object->arg.text.font_family, - object->arg.text.font_weight, - object->arg.text. - font_italic_flag, - object->arg.text.font_size, - display->scale); - gdk_font = gnome_display_font_get_gdk_font (display_font); - - switch (object->arg.text.just) { - case GTK_JUSTIFY_LEFT: - anchor = GTK_ANCHOR_NW; - break; - case GTK_JUSTIFY_CENTER: - anchor = GTK_ANCHOR_N; - break; - case GTK_JUSTIFY_RIGHT: - anchor = GTK_ANCHOR_NE; - break; - default: - anchor = GTK_ANCHOR_NW; - break; - } - - group = gnome_canvas_root (GNOME_CANVAS (display->canvas)); - item = gnome_canvas_item_new (group, gnome_canvas_text_get_type (), - "x", object->x, - "y", object->y, - "text", g_strdup (text), - "font_gdk", gdk_font, - "justification", object->arg.text.just, - "anchor", anchor, - "fill_color_rgba", object->arg.text.color, - NULL); - -#endif - - /* Squirrel away pointers to object and display in the canvas item. */ - gtk_object_set_data (GTK_OBJECT (item), "label_object", object); - gtk_object_set_data (GTK_OBJECT (item), "display", display); - gtk_object_set_data (GTK_OBJECT (item), "highlight", NULL); - - gtk_signal_connect (GTK_OBJECT (item), "event", - GTK_SIGNAL_FUNC (gl_display_item_event_handler), - display); - - gl_display_new_item_menu (item); - - gl_display_set_modified (display); - - g_free (text); - return item; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Update a text object */ -/*--------------------------------------------------------------------------*/ -static void -item_text_update (GnomeCanvasItem * item) -{ - glLabelObject *object; - glDisplay *display; - gdouble affine[6]; -#ifdef HACKTEXT - GList *item_list, *li; -#else - GdkFont *gdk_font; - GnomeDisplayFont *display_font; - GtkAnchorType anchor; -#endif - gchar *text; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - - text = gl_text_node_lines_expand (object->arg.text.lines, NULL); - -#ifdef HACKTEXT - - item_list = gtk_object_get_data (GTK_OBJECT (item), "item_list"); - for (li = item_list; li != NULL; li = li->next) { - gtk_object_destroy (GTK_OBJECT (li->data)); - } - g_list_free (item_list); - gtk_object_set_data (GTK_OBJECT (item), "item_list", NULL); - - draw_hacktext (item, - text, - object->arg.text.font_family, - object->arg.text.font_weight, - object->arg.text.font_italic_flag, - object->arg.text.font_size, - object->arg.text.color, - object->arg.text.just, display->scale); - - art_affine_identity (affine); - gnome_canvas_item_affine_absolute (item, affine); - gnome_canvas_item_set (item, "x", object->x, "y", object->y, NULL); - -#else - - display_font = gnome_get_display_font (object->arg.text.font_family, - object->arg.text.font_weight, - object->arg.text. - font_italic_flag, - object->arg.text.font_size, - display->scale); - gdk_font = gnome_display_font_get_gdk_font (display_font); - - switch (object->arg.text.just) { - case GTK_JUSTIFY_LEFT: - anchor = GTK_ANCHOR_NW; - break; - case GTK_JUSTIFY_CENTER: - anchor = GTK_ANCHOR_N; - break; - case GTK_JUSTIFY_RIGHT: - anchor = GTK_ANCHOR_NE; - break; - default: - anchor = GTK_ANCHOR_NW; - break; - } - - art_affine_identity (affine); - gnome_canvas_item_affine_absolute (item, affine); - gnome_canvas_item_set (item, - "x", object->x, - "y", object->y, - "text", g_strdup (text), - "font_gdk", gdk_font, - "justification", object->arg.text.just, - "anchor", anchor, - "fill_color_rgba", object->arg.text.color, NULL); - -#endif - - g_free (text); - - gl_display_set_modified (display); -} - -/****************************************************************************/ -/* Highlight item. */ -/****************************************************************************/ -void -gl_item_text_highlight (GnomeCanvasItem * item) -{ - gl_highlight (item, GL_HIGHLIGHT_SIMPLE); -} - -/****************************************************************************/ -/* Get position and size of object. */ -/****************************************************************************/ -void -gl_item_text_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h) -{ - glLabelObject *object; -#ifndef HACKTEXT - GtkArg arg_info; - gdouble x1, y1, x2, y2; -#else - gchar *text; -#endif - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - *x = object->x; - *y = object->y; - -#ifdef HACKTEXT - text = gl_text_node_lines_expand (object->arg.text.lines, NULL); - - hacktext_get_size (text, - object->arg.text.font_family, - object->arg.text.font_weight, - object->arg.text.font_italic_flag, - object->arg.text.font_size, w, h); - - g_free (text); -#else - - gnome_canvas_item_get_bounds (item, &x1, &y1, &x2, &y2); - *h = y2 - y1; - - /* workaround: the above bounding box is too wide, correct the width. */ - arg_info.name = "text_width"; - gtk_object_getv (GTK_OBJECT (item), 1, &arg_info); - *w = GTK_VALUE_DOUBLE (arg_info); - -#endif -} - -/****************************************************************************/ -/* Get position and size of object. */ -/****************************************************************************/ -void -gl_item_text_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h) -{ - glLabelObject *object; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - object->x = x; - object->y = y; - - /* Ignore w,h for now */ - - item_text_update (item); -} - -/****************************************************************************/ -/* Get text item bounds. */ -/****************************************************************************/ -void -gl_item_text_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2) -{ -#ifdef HACKTEXT - - glLabelObject *object; - gdouble w, h, x_offset, y_offset; - gchar *text; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - - text = gl_text_node_lines_expand (object->arg.text.lines, NULL); - - hacktext_get_size (text, - object->arg.text.font_family, - object->arg.text.font_weight, - object->arg.text.font_italic_flag, - object->arg.text.font_size, &w, &h); - - g_free (text); - - switch (object->arg.text.just) { - case GTK_JUSTIFY_LEFT: - x_offset = 0.0; - break; - case GTK_JUSTIFY_CENTER: - x_offset = -w / 2.0; - break; - case GTK_JUSTIFY_RIGHT: - x_offset = -w; - break; - default: - x_offset = 0.0; - break; /* shouldn't happen */ - } - - y_offset = 0.0; - - *x1 = object->x + x_offset; - *y1 = object->y + y_offset; - *x2 = *x1 + w; - *y2 = *y1 + h; - -#else - - GtkArg arg_info; - - gnome_canvas_item_get_bounds (item, x1, y1, x2, y2); - - /* workaround: the above bounding box is too wide, correct the width. */ - arg_info.name = "text_width"; - gtk_object_getv (GTK_OBJECT (item), 1, &arg_info); - *x2 = *x1 + GTK_VALUE_DOUBLE (arg_info); - -#endif - -} - -/****************************************************************************/ -/* Create and run an edit dialog on a text object. */ -/****************************************************************************/ -void -gl_item_text_edit_dialog (GnomeCanvasItem * item) -{ - GtkWidget *dialog; - static PropertyDialogPassback *data = NULL; - glLabelObject *object; - glDisplay *display; - GtkWidget *wvbox; - - object = gtk_object_get_data (GTK_OBJECT (item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (item), "display"); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - if (data == NULL) { - data = g_new0 (PropertyDialogPassback, 1); - } - data->item = item; - - dialog = gl_property_box_new (); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (gl_mdi_get_active_window ())); - gtk_window_set_title (GTK_WINDOW (dialog), - _("Edit text object properties")); - gtk_signal_connect (GTK_OBJECT (dialog), "apply", - GTK_SIGNAL_FUNC (apply_cb), data); - - /*---------------------------*/ - /* Text Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Text"))); - - /* Text entry widget */ - data->text_entry = - gl_prop_text_entry_new (_("Text"), object->parent->merge_fields); - gl_prop_text_entry_set_text (GL_PROP_TEXT_ENTRY (data->text_entry), - (object->parent->merge_type != - GL_MERGE_NONE), object->arg.text.lines); - gtk_box_pack_start (GTK_BOX (wvbox), data->text_entry, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->text_entry), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*---------------------------*/ - /* Appearance Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Appearance"))); - - /* ------ Begin Text Properties box ------ */ - data->text = gl_prop_text_new (_("Text Properties")); - gl_prop_text_set_params (GL_PROP_TEXT (data->text), - object->arg.text.font_family, - object->arg.text.font_size, - object->arg.text.font_weight, - object->arg.text.font_italic_flag, - object->arg.text.color, object->arg.text.just); - gtk_box_pack_start (GTK_BOX (wvbox), data->text, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->text), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*---------------------------*/ - /* Position Notebook Tab */ - /*---------------------------*/ - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 10); - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, - gtk_label_new (_("Position"))); - - /* ------ Position Frame ------ */ - data->position = gl_prop_position_new (_("Position")); - gl_prop_position_set_params (GL_PROP_POSITION (data->position), - object->x, object->y, - display->label->width, - display->label->height); - gtk_box_pack_start (GTK_BOX (wvbox), data->position, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (data->position), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (dialog)); - - /*-----------------------------------------------------------------*/ - /* Run dialog, and update state of object if "Applied." */ - /*-----------------------------------------------------------------*/ - gtk_widget_show_all (GTK_WIDGET (dialog)); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the dialog has changed. */ -/*---------------------------------------------------------------------------*/ -static void -changed_cb (glPropertyBox * propertybox) -{ - gl_property_box_changed (propertybox); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. "Apply" callback. */ -/*---------------------------------------------------------------------------*/ -static void -apply_cb (glPropertyBox * propertybox, - gint page, - PropertyDialogPassback * data) -{ - glLabelObject *object; - glDisplay *display; - - object = gtk_object_get_data (GTK_OBJECT (data->item), "label_object"); - display = gtk_object_get_data (GTK_OBJECT (data->item), "display"); - - switch (page) { - - case 0: - /* ------- Get updated text ------ */ - gl_text_node_lines_free (&object->arg.text.lines); - object->arg.text.lines = - gl_prop_text_entry_get_text (GL_PROP_TEXT_ENTRY - (data->text_entry)); - break; - - case 1: - /* ------ Get updated text parameter information ------ */ - gl_prop_text_get_params (GL_PROP_TEXT (data->text), - &object->arg.text.font_family, - &object->arg.text.font_size, - &object->arg.text.font_weight, - &object->arg.text.font_italic_flag, - &object->arg.text.color, - &object->arg.text.just); - break; - - case 2: - /* ------ get updated position ------ */ - gl_prop_position_get_position (GL_PROP_POSITION - (data->position), &object->x, - &object->y); - break; - - default: - return; - } - - /* ------ Udate state of object ------ */ - item_text_update (data->item); - gl_display_select_item (display, data->item); - -} - -/****************************************************************************/ -/* Return apropos cursor for create object mode. */ -/****************************************************************************/ -GdkCursor * -gl_item_text_get_create_cursor (void) -{ - static GdkCursor *cursor = NULL; - GdkPixmap *pixmap_data, *pixmap_mask; - GdkColor fg = { 0, 0, 0, 0 }; - GdkColor bg = { 0, 65535, 65535, 65535 }; - - if (!cursor) { - pixmap_data = gdk_bitmap_create_from_data (NULL, - cursor_text_bits, - cursor_text_width, - cursor_text_height); - pixmap_mask = gdk_bitmap_create_from_data (NULL, - cursor_text_mask_bits, - cursor_text_mask_width, - cursor_text_mask_height); - cursor = - gdk_cursor_new_from_pixmap (pixmap_data, pixmap_mask, &fg, - &bg, cursor_text_x_hot, - cursor_text_y_hot); - } - - return cursor; -} - -/****************************************************************************/ -/* Canvas event handler (text mode) */ -/****************************************************************************/ -gint -gl_item_text_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - glDisplay *display = GL_DISPLAY (data); - gdouble x, y; - glLabelObject *object; - GnomeCanvasItem *item; - - switch (event->type) { - - case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - gnome_canvas_window_to_world (canvas, - event->button.x, - event->button.y, &x, &y); - object = - gl_label_object_new (display->label, - GL_LABEL_OBJECT_TEXT); - object->x = x; - object->y = y; - object->arg.text.lines = - gl_text_node_lines_new_from_text (_("Text")); - object->arg.text.font_family = - g_strdup (DEFAULT_FONT_FAMILY); - object->arg.text.font_size = DEFAULT_FONT_SIZE; - object->arg.text.font_weight = DEFAULT_FONT_WEIGHT; - object->arg.text.font_italic_flag = - DEFAULT_FONT_ITALIC_FLAG; - object->arg.text.just = GTK_JUSTIFY_LEFT; - object->arg.text.color = GNOME_CANVAS_COLOR (0, 0, 0); - item = gl_item_text_new (object, display); - gl_display_add_item (display, item); - gl_display_unselect_all (display); - gl_display_select_item (display, item); - gl_display_arrow_mode (display); - return TRUE; - - default: - return FALSE; - } - - default: - return FALSE; - } - -} - -#ifdef HACKTEXT -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Draw hacktext to item (group). */ -/*--------------------------------------------------------------------------*/ -static void -draw_hacktext (GnomeCanvasItem * group, - gchar * text, - gchar * font_family, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - gdouble font_size, - guint color, - GtkJustification just, - gdouble scale) -{ - GnomeFont *font; - GnomeGlyphList *glyphlist; - gdouble x_offset, y_offset; - gint i; - gdouble w; - gchar **line, *utf8_text; - GnomeCanvasItem *item; - GList *item_list = NULL; - - font = gnome_font_new_closest (font_family, - font_weight, - font_italic_flag, font_size); - - line = g_strsplit (text, "\n", -1); - - for (i = 0; line[i] != NULL; i++) { - - utf8_text = gl_hack_text_to_utf8 (line[i]); - - w = gl_hack_get_width_string (font, line[i]); - - glyphlist = gnome_glyphlist_from_text_sized_dumb (font, - color, - 0.0, 0.0, - utf8_text, - strlen - (utf8_text)); - switch (just) { - case GTK_JUSTIFY_LEFT: - x_offset = 0.0; - break; - case GTK_JUSTIFY_CENTER: - x_offset = -w / 2.0; - break; - case GTK_JUSTIFY_RIGHT: - x_offset = -w; - break; - default: - x_offset = 0.0; - break; /* shouldn't happen */ - } - - y_offset = - (i + 1) * font_size - gnome_font_get_descender (font); - - item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (group), - gnome_canvas_hacktext_get_type (), - "x", x_offset, - "y", y_offset, - "glyphlist", glyphlist, NULL); - item_list = g_list_prepend (item_list, item); - - g_free (utf8_text); - } - - g_strfreev (line); - - /* attach item list to group, so we can get at these again */ - gtk_object_set_data (GTK_OBJECT (group), "item_list", item_list); -} -#endif - -#ifdef HACKTEXT -/*--------------------------------------------------------------------------*/ -/* PRIVATE. get size of hacktext item. */ -/*--------------------------------------------------------------------------*/ -static void -hacktext_get_size (gchar * text, - gchar * font_family, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - gdouble font_size, - gdouble * w, - gdouble * h) -{ - GnomeFont *font; - gchar **line; - gdouble wline; - gint i; - - *w = 0.0; - *h = 0.0; - - font = gnome_font_new_closest (font_family, - font_weight, - font_italic_flag, font_size); - - line = g_strsplit (text, "\n", -1); - - for (i = 0; line[i] != NULL; i++) { - - wline = gl_hack_get_width_string (font, line[i]); - - if (wline > *w) - *w = wline; - *h += font_size; - - } - - g_strfreev (line); - -} -#endif diff --git a/glabels1/src/item_text.h b/glabels1/src/item_text.h deleted file mode 100644 index 091e062..0000000 --- a/glabels1/src/item_text.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * item_text.h: GLabels Text Object (canvas item) module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __ITEM_TEXT_H__ -#define __ITEM_TEXT_H__ - -#include <gnome.h> - -#include "label.h" - -extern GnomeCanvasItem *gl_item_text_new (glLabelObject * object, - glDisplay * display); - -extern void gl_item_text_highlight (GnomeCanvasItem * item); - -extern void gl_item_text_get_position_size (GnomeCanvasItem * item, - gdouble * x, - gdouble * y, - gdouble * w, - gdouble * h); - -extern void gl_item_text_set_position_size (GnomeCanvasItem * item, - gdouble x, - gdouble y, - gdouble w, - gdouble h); - -extern void gl_item_text_get_bounds (GnomeCanvasItem * item, - gdouble * x1, - gdouble * y1, - gdouble * x2, - gdouble * y2); - -extern void gl_item_text_edit_dialog (GnomeCanvasItem * item); - -extern GdkCursor *gl_item_text_get_create_cursor (void); - -extern gint gl_item_text_create_event_handler (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data); - -#endif diff --git a/glabels1/src/label.c b/glabels1/src/label.c deleted file mode 100644 index c33f97c..0000000 --- a/glabels1/src/label.c +++ /dev/null @@ -1,1212 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * label.c: GLabels label module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <gnome.h> - -/* LibXML */ -#include <tree.h> -#include <parser.h> - -#include "label.h" -#include "template.h" - -#include "debug.h" - -#define NAME_SPACE "http://snaught.com/glabels/0.4/" -#define COMPAT01_NAME_SPACE "http://snaught.com/glabels/0.1/" - -static glLabelStatus xml_doc_to_label (xmlDocPtr doc, glLabel ** label); -static gboolean xml_parse_media_description (xmlNodePtr node, glLabel * label); -static void xml_parse_object(xmlNodePtr node, glLabelObject * object, - gboolean compat01_flag); -static void xml_parse_text_props (xmlNodePtr node, glLabelObject * object); -static void xml_parse_text_props_compat01( xmlNodePtr node, - glLabelObject *object ); -static void xml_parse_box_props (xmlNodePtr node, glLabelObject * object); -static void xml_parse_line_props (xmlNodePtr node, glLabelObject * object); -static void xml_parse_ellipse_props (xmlNodePtr node, glLabelObject * object); -static void xml_parse_image_props (xmlNodePtr node, glLabelObject * object); -static void xml_parse_barcode_props (xmlNodePtr node, glLabelObject * object); -static void xml_parse_merge_properties (xmlNodePtr node, glLabel * label); - -static glLabelStatus xml_label_to_doc (glLabel * label, xmlDocPtr * doc); -static void xml_create_media_description (xmlNodePtr root, xmlNsPtr ns, - glLabel * label); -static void xml_create_object (xmlNodePtr root, xmlNsPtr ns, - glLabelObject * object); -static void xml_create_text_props (xmlNodePtr root, xmlNsPtr ns, - glLabelObject * object); -static void xml_create_box_props (xmlNodePtr root, xmlNsPtr ns, - glLabelObject * object); -static void xml_create_line_props (xmlNodePtr root, xmlNsPtr ns, - glLabelObject * object); -static void xml_create_ellipse_props (xmlNodePtr root, xmlNsPtr ns, - glLabelObject * object); -static void xml_create_image_props (xmlNodePtr root, xmlNsPtr ns, - glLabelObject * object); -static void xml_create_barcode_props (xmlNodePtr root, xmlNsPtr ns, - glLabelObject * object); -static void xml_create_merge_properties (xmlNodePtr root, xmlNsPtr ns, - glLabel * label); - -static const gchar *just_to_text (GtkJustification just); -static GtkJustification text_to_just (const gchar * text); - -static const gchar *weight_to_text (GnomeFontWeight weight); -static GnomeFontWeight text_to_weight (const gchar * text); - -/****************************************************************************/ -/* Create a new label. */ -/****************************************************************************/ -glLabel * -gl_label_new (void) -{ - glLabel *label; - - label = g_new0 (glLabel, 1); - - return label; -} - -/****************************************************************************/ -/* Create a new label. */ -/****************************************************************************/ -glLabel * -gl_label_new_with_template (const gchar * tmplt_name, - gboolean rotate_flag) -{ - glLabel *label; - glTemplate *template; - - label = gl_label_new (); - - label->template_name = g_strdup (tmplt_name); - label->template = template = gl_template_from_name (tmplt_name); - label->rotate_flag = rotate_flag; - - switch (template->style) { - - case GL_TEMPLATE_STYLE_RECT: - if (!rotate_flag) { - label->width = template->label_width; - label->height = template->label_height; - } else { - label->width = template->label_height; - label->height = template->label_width; - } - break; - - case GL_TEMPLATE_STYLE_ROUND: - case GL_TEMPLATE_STYLE_CD: - label->width = label->height = 2.0 * template->label_radius; - break; - - default: - WARN ("Unknown template label style"); - break; - } - - label->objects = NULL; - - return label; -} - -/****************************************************************************/ -/* Free a previously allocated label. */ -/****************************************************************************/ -void -gl_label_free (glLabel ** label) -{ - GList *p, *p_next; - glLabelObject *object; - - if (*label != NULL) { - g_free ((*label)->template_name); - (*label)->template_name = NULL; - - gl_template_free (&(*label)->template); - - for (p = (*label)->objects; p != NULL; p = p_next) { - p_next = p->next; /* NOTE: p will be left dangling */ - object = (glLabelObject *) p->data; - gl_label_object_free (&object); - } - - g_free (*label); - *label = NULL; - } -} - -/****************************************************************************/ -/* Open and read label from xml file. */ -/****************************************************************************/ -glLabelStatus -gl_label_open_xml (glLabel ** label, - const gchar * filename) -{ - xmlDocPtr doc; - glLabelStatus status; - - xmlUseNewParser (TRUE); - doc = xmlParseFile (filename); - if (!doc) { - WARN (_("xmlParseFile error")); - *label = NULL; - return LABEL_ERROR_OPEN_XML_PARSE; - } - - status = xml_doc_to_label (doc, label); - - xmlFreeDoc (doc); - - return status; -} - -/****************************************************************************/ -/* Read label from xml buffer. */ -/****************************************************************************/ -glLabelStatus -gl_label_open_xml_buffer (glLabel ** label, - const gchar * buffer) -{ - xmlDocPtr doc; - glLabelStatus status; - - xmlUseNewParser (TRUE); - doc = xmlParseDoc ((xmlChar *) buffer); - if (!doc) { - WARN (_("xmlParseFile error")); - *label = NULL; - return LABEL_ERROR_OPEN_XML_PARSE; - } - - status = xml_doc_to_label (doc, label); - - xmlFreeDoc (doc); - - return status; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse xml doc structure and create label. */ -/*--------------------------------------------------------------------------*/ -static glLabelStatus -xml_doc_to_label (xmlDocPtr doc, - glLabel ** label) -{ - xmlNodePtr root, node; - xmlNsPtr ns; - glLabelObject *object; - glLabelStatus status = LABEL_OK; - gboolean compat01_flag = FALSE; - - LIBXML_TEST_VERSION; - - gl_label_free (label); - - root = xmlDocGetRootElement (doc); - if (!root || !root->name) { - WARN (_("No document root")); - return LABEL_ERROR_OPEN_XML_PARSE; - } - ns = xmlSearchNsByHref (doc, root, NAME_SPACE); - if (ns == NULL) { - /* Try compatability mode */ - ns = xmlSearchNsByHref (doc, root, COMPAT01_NAME_SPACE); - if (ns != NULL) compat01_flag = TRUE; - } - if (ns == NULL) { - WARN (_ - ("document of the wrong type, glabels Namespace not found")); - return LABEL_ERROR_OPEN_XML_PARSE; - } - - if (g_strcasecmp (root->name, "Label") != 0) { - WARN (_("Bad root node = \"%s\""), root->name); - return LABEL_ERROR_OPEN_XML_PARSE; - } - - *label = gl_label_new (); - - (*label)->rotate_flag = - !(g_strcasecmp (xmlGetProp (root, "rotate"), "false") == 0); - (*label)->width = g_strtod (xmlGetProp (root, "width"), NULL); - (*label)->height = g_strtod (xmlGetProp (root, "height"), NULL); - - for (node = root->xmlChildrenNode; node != NULL; node = node->next) { - - if (g_strcasecmp (node->name, "Media_Type") == 0) { - if (!xml_parse_media_description (node, *label)) { - status = LABEL_UNKNOWN_MEDIA; - } - } else if (g_strcasecmp (node->name, "Text") == 0) { - object = - gl_label_object_new (*label, GL_LABEL_OBJECT_TEXT); - xml_parse_object (node, object, compat01_flag); - } else if (g_strcasecmp (node->name, "Box") == 0) { - object = - gl_label_object_new (*label, GL_LABEL_OBJECT_BOX); - xml_parse_object (node, object, compat01_flag); - } else if (g_strcasecmp (node->name, "Line") == 0) { - object = - gl_label_object_new (*label, GL_LABEL_OBJECT_LINE); - xml_parse_object (node, object, compat01_flag); - } else if (g_strcasecmp (node->name, "Ellipse") == 0) { - object = - gl_label_object_new (*label, - GL_LABEL_OBJECT_ELLIPSE); - xml_parse_object (node, object, compat01_flag); - } else if (g_strcasecmp (node->name, "Image") == 0) { - object = - gl_label_object_new (*label, GL_LABEL_OBJECT_IMAGE); - xml_parse_object (node, object, compat01_flag); - } else if (g_strcasecmp (node->name, "Barcode") == 0) { - object = - gl_label_object_new (*label, - GL_LABEL_OBJECT_BARCODE); - xml_parse_object (node, object, compat01_flag); - } else if (g_strcasecmp (node->name, "Merge_Properties") == 0) { - xml_parse_merge_properties (node, *label); - } else { - if (!xmlNodeIsText (node)) { - WARN (_("bad node = \"%s\""), node->name); - } - } - } - - return status; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse Media Description node. */ -/*--------------------------------------------------------------------------*/ -static gboolean -xml_parse_media_description (xmlNodePtr node, - glLabel * label) -{ - label->template_name = xmlNodeGetContent (node); - label->template = gl_template_from_name (label->template_name); - if (label->template == NULL) { - WARN ("Undefined template \"%s\"", label->template_name); - /* Get a default */ - label->template = gl_template_from_name (NULL); - return FALSE; - } - return TRUE; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Object Node */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_object (xmlNodePtr object_node, - glLabelObject * object, - gboolean compat01_flag) -{ - object->x = g_strtod (xmlGetProp (object_node, "x"), NULL); - object->y = g_strtod (xmlGetProp (object_node, "y"), NULL); - - switch (object->type) { - case GL_LABEL_OBJECT_TEXT: - if (compat01_flag) { - xml_parse_text_props_compat01 (object_node, object); - } else { - xml_parse_text_props (object_node, object); - } - break; - case GL_LABEL_OBJECT_BOX: - xml_parse_box_props (object_node, object); - break; - case GL_LABEL_OBJECT_LINE: - xml_parse_line_props (object_node, object); - break; - case GL_LABEL_OBJECT_ELLIPSE: - xml_parse_ellipse_props (object_node, object); - break; - case GL_LABEL_OBJECT_IMAGE: - xml_parse_image_props (object_node, object); - break; - case GL_LABEL_OBJECT_BARCODE: - xml_parse_barcode_props (object_node, object); - break; - default: - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Label->Text Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_text_props (xmlNodePtr object_node, - glLabelObject * object) -{ - xmlNodePtr line_node, text_node; - glTextNode *node_text; - GList *nodes; - - object->arg.text.font_family = xmlGetProp (object_node, "font_family"); - object->arg.text.font_size = - g_strtod (xmlGetProp (object_node, "font_size"), NULL); - object->arg.text.font_weight = - text_to_weight (xmlGetProp (object_node, "font_weight")); - object->arg.text.font_italic_flag = - !(g_strcasecmp (xmlGetProp (object_node, "font_italic"), "false") == - 0); - - object->arg.text.just = - text_to_just (xmlGetProp (object_node, "justify")); - - sscanf (xmlGetProp (object_node, "color"), "%x", - &object->arg.text.color); - - object->arg.text.lines = NULL; - for (line_node = object_node->xmlChildrenNode; line_node != NULL; - line_node = line_node->next) { - - if (g_strcasecmp (line_node->name, "Line") == 0) { - - nodes = NULL; - for (text_node = line_node->xmlChildrenNode; - text_node != NULL; text_node = text_node->next) { - - if (g_strcasecmp (text_node->name, "Field") == - 0) { - node_text = g_new0 (glTextNode, 1); - node_text->field_flag = TRUE; - node_text->data = - xmlGetProp (text_node, "name"); - nodes = - g_list_append (nodes, node_text); - } else if (xmlNodeIsText (text_node)) { - node_text = g_new0 (glTextNode, 1); - node_text->field_flag = FALSE; - node_text->data = - xmlNodeGetContent (text_node); - nodes = - g_list_append (nodes, node_text); - } else { - WARN ("Unexpected Text Line child: \"%s\"", - text_node->name); - } - - } - object->arg.text.lines = - g_list_append (object->arg.text.lines, nodes); - - } else { - WARN ("Unexpected Text child: \"%s\"", line_node->name); - } - - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML label->Text node (Compatability with 0.1 version) */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_text_props_compat01( xmlNodePtr node, glLabelObject *object ) -{ - gchar *text; - - text = xmlNodeGetContent( node ); - object->arg.text.lines = gl_text_node_lines_new_from_text( text ); - g_free( text ); - - object->arg.text.font_family = xmlGetProp( node, "font_family" ); - object->arg.text.font_size = g_strtod( xmlGetProp( node, "font_size" ), - NULL ); - object->arg.text.font_weight = - text_to_weight( xmlGetProp( node, "font_weight" ) ); - object->arg.text.font_italic_flag = - !( g_strcasecmp( xmlGetProp( node, "font_italic" ), - "false" ) == 0 ); - - object->arg.text.just = text_to_just( xmlGetProp( node, "justify" ) ); - - sscanf( xmlGetProp( node, "color" ), "%x", &object->arg.text.color ); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Label->Box Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_box_props (xmlNodePtr node, - glLabelObject * object) -{ - object->arg.box.w = g_strtod (xmlGetProp (node, "w"), NULL); - object->arg.box.h = g_strtod (xmlGetProp (node, "h"), NULL); - - object->arg.box.line_width = g_strtod (xmlGetProp (node, "line_width"), - NULL); - - sscanf (xmlGetProp (node, "line_color"), "%x", - &object->arg.box.line_color); - sscanf (xmlGetProp (node, "fill_color"), "%x", - &object->arg.box.fill_color); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Label->Line Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_line_props (xmlNodePtr node, - glLabelObject * object) -{ - object->arg.line.dx = g_strtod (xmlGetProp (node, "dx"), NULL); - object->arg.line.dy = g_strtod (xmlGetProp (node, "dy"), NULL); - - object->arg.line.line_width = g_strtod (xmlGetProp (node, "line_width"), - NULL); - - sscanf (xmlGetProp (node, "line_color"), "%x", - &object->arg.line.line_color); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Label->Ellipse Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_ellipse_props (xmlNodePtr node, - glLabelObject * object) -{ - object->arg.ellipse.w = g_strtod (xmlGetProp (node, "w"), NULL); - object->arg.ellipse.h = g_strtod (xmlGetProp (node, "h"), NULL); - - object->arg.ellipse.line_width = - g_strtod (xmlGetProp (node, "line_width"), NULL); - - sscanf (xmlGetProp (node, "line_color"), "%x", - &object->arg.ellipse.line_color); - sscanf (xmlGetProp (node, "fill_color"), "%x", - &object->arg.ellipse.fill_color); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Label->Image Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_image_props (xmlNodePtr node, - glLabelObject * object) -{ - object->arg.image.w = g_strtod (xmlGetProp (node, "w"), NULL); - object->arg.image.h = g_strtod (xmlGetProp (node, "h"), NULL); - - object->arg.image.filename = xmlGetProp (node, "filename"); - - object->arg.image.image = - gdk_pixbuf_new_from_file (object->arg.image.filename); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Label->Barcode Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_barcode_props (xmlNodePtr node, - glLabelObject * object) -{ - xmlNodePtr child; - - sscanf (xmlGetProp (node, "color"), "%x", &object->arg.barcode.color); - - object->arg.barcode.style = - gl_barcode_text_to_style (xmlGetProp (node, "style")); - - object->arg.barcode.text_flag = - !(g_strcasecmp (xmlGetProp (node, "text"), "false") == 0); - - object->arg.barcode.scale = - g_strtod (xmlGetProp (node, "scale"), NULL); - if (object->arg.barcode.scale == 0.0) { - object->arg.barcode.scale = 0.5; /* Set to a valid value */ - } - - child = node->xmlChildrenNode; - object->arg.barcode.text_node = g_new0 (glTextNode, 1); - if (g_strcasecmp (child->name, "Field") == 0) { - object->arg.barcode.text_node->field_flag = TRUE; - object->arg.barcode.text_node->data = - xmlGetProp (child, "name"); - } else if (xmlNodeIsText (child)) { - object->arg.barcode.text_node->field_flag = FALSE; - object->arg.barcode.text_node->data = - xmlNodeGetContent (child); - } else { - WARN ("Unexpected Barcode child: \"%s\"", child->name); - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML merge properties tag. */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_merge_properties (xmlNodePtr node, - glLabel * label) -{ - xmlNodePtr child; - glMergeFieldDefinition *field_def; - - label->merge_type = gl_merge_text_to_type (xmlGetProp (node, "type")); - label->merge_src = xmlGetProp (node, "src"); - - for (child = node->xmlChildrenNode; child != NULL; child = child->next) { - - if (g_strcasecmp (child->name, "Field") == 0) { - field_def = g_new0 (glMergeFieldDefinition, 1); - field_def->key = xmlGetProp (child, "key"); - field_def->loc = xmlGetProp (child, "loc"); - label->merge_fields = - g_list_append (label->merge_fields, field_def); - } else { - WARN ("Unexpected Merge_Properties child: \"%s\"", - child->name); - } - - } - -} - -/****************************************************************************/ -/* Save label to xml label file. */ -/****************************************************************************/ -glLabelStatus -gl_label_save_xml (glLabel * label, - const gchar * filename) -{ - xmlDocPtr doc; - glLabelStatus status; - gint xml_ret; - - status = xml_label_to_doc (label, &doc); - - xml_ret = xmlSaveFile (filename, doc); - xmlFreeDoc (doc); - if (xml_ret == -1) { - WARN (_("Problem saving xml file.")); - return LABEL_ERROR_SAVE_XML_FILE; - } - - return status; -} - -/****************************************************************************/ -/* Save label to xml buffer. */ -/****************************************************************************/ -glLabelStatus -gl_label_save_xml_buffer (glLabel * label, - gchar ** buffer) -{ - xmlDocPtr doc; - glLabelStatus status; - gint size; - - status = xml_label_to_doc (label, &doc); - - xmlDocDumpMemory (doc, (xmlChar **) buffer, &size); - xmlFreeDoc (doc); - - return status; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Convert label to xml doc structure. */ -/*--------------------------------------------------------------------------*/ -static glLabelStatus -xml_label_to_doc (glLabel * label, - xmlDocPtr * doc) -{ - xmlNsPtr ns; - gchar *string; - GList *p; - glLabelObject *object; - - LIBXML_TEST_VERSION; - - *doc = xmlNewDoc ("1.0"); - (*doc)->xmlRootNode = xmlNewDocNode (*doc, NULL, "Label", NULL); - - ns = xmlNewNs ((*doc)->xmlRootNode, NAME_SPACE, "glabels"); - xmlSetNs ((*doc)->xmlRootNode, ns); - - xmlSetProp ((*doc)->xmlRootNode, "rotate", - label->rotate_flag ? "True" : "False"); - - string = g_strdup_printf ("%g", label->width); - xmlSetProp ((*doc)->xmlRootNode, "width", string); - g_free (string); - - string = g_strdup_printf ("%g", label->height); - xmlSetProp ((*doc)->xmlRootNode, "height", string); - g_free (string); - - xml_create_media_description ((*doc)->xmlRootNode, ns, label); - - for (p = label->objects; p != NULL; p = p->next) { - object = (glLabelObject *) p->data; - xml_create_object ((*doc)->xmlRootNode, ns, object); - } - - if (label->merge_type != GL_MERGE_NONE) { - xml_create_merge_properties ((*doc)->xmlRootNode, ns, label); - } - - return LABEL_OK; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Label->Text Node */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_media_description (xmlNodePtr root, - xmlNsPtr ns, - glLabel * label) -{ - xmlNodePtr node; - - node = xmlNewTextChild (root, ns, "Media_Type", label->template_name); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML label object Node */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_object (xmlNodePtr root, - xmlNsPtr ns, - glLabelObject * object) -{ - xmlNodePtr object_node; - gchar *string; - - object_node = xmlNewChild (root, ns, "Object", NULL); - - string = g_strdup_printf ("%g", object->x); - xmlSetProp (object_node, "x", string); - g_free (string); - - string = g_strdup_printf ("%g", object->y); - xmlSetProp (object_node, "y", string); - g_free (string); - - switch (object->type) { - case GL_LABEL_OBJECT_TEXT: - xml_create_text_props (object_node, ns, object); - break; - case GL_LABEL_OBJECT_BOX: - xml_create_box_props (object_node, ns, object); - break; - case GL_LABEL_OBJECT_LINE: - xml_create_line_props (object_node, ns, object); - break; - case GL_LABEL_OBJECT_ELLIPSE: - xml_create_ellipse_props (object_node, ns, object); - break; - case GL_LABEL_OBJECT_IMAGE: - xml_create_image_props (object_node, ns, object); - break; - case GL_LABEL_OBJECT_BARCODE: - xml_create_barcode_props (object_node, ns, object); - break; - default: - WARN ("Unknown label object"); - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Label->Text Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_text_props (xmlNodePtr object_node, - xmlNsPtr ns, - glLabelObject * object) -{ - xmlNodePtr line_node, field_node; - gchar *string; - GList *p_line, *p_node; - glTextNode *node_text; - - xmlNodeSetName (object_node, "Text"); - - xmlSetProp (object_node, "font_family", object->arg.text.font_family); - - string = g_strdup_printf ("%g", object->arg.text.font_size); - xmlSetProp (object_node, "font_size", string); - g_free (string); - - xmlSetProp (object_node, "font_weight", - weight_to_text (object->arg.text.font_weight)); - - if (object->arg.text.font_italic_flag) { - xmlSetProp (object_node, "font_italic", "True"); - } else { - xmlSetProp (object_node, "font_italic", "False"); - } - - xmlSetProp (object_node, "justify", - just_to_text (object->arg.text.just)); - - string = g_strdup_printf ("0x%08x", object->arg.text.color); - xmlSetProp (object_node, "color", string); - g_free (string); - - for (p_line = object->arg.text.lines; p_line != NULL; - p_line = p_line->next) { - line_node = xmlNewChild (object_node, ns, "Line", NULL); - - for (p_node = (GList *) p_line->data; p_node != NULL; - p_node = p_node->next) { - node_text = (glTextNode *) p_node->data; - - if (node_text->field_flag) { - field_node = - xmlNewChild (line_node, ns, "Field", NULL); - xmlSetProp (field_node, "name", - node_text->data); - } else { - xmlNodeAddContent (line_node, node_text->data); - } - - } - - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Label->Box Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_box_props (xmlNodePtr object_node, - xmlNsPtr ns, - glLabelObject * object) -{ - gchar *string; - - xmlNodeSetName (object_node, "Box"); - - string = g_strdup_printf ("%g", object->arg.box.w); - xmlSetProp (object_node, "w", string); - g_free (string); - - string = g_strdup_printf ("%g", object->arg.box.h); - xmlSetProp (object_node, "h", string); - g_free (string); - - string = g_strdup_printf ("%g", object->arg.box.line_width); - xmlSetProp (object_node, "line_width", string); - g_free (string); - - string = g_strdup_printf ("0x%08x", object->arg.box.line_color); - xmlSetProp (object_node, "line_color", string); - g_free (string); - - string = g_strdup_printf ("0x%08x", object->arg.box.fill_color); - xmlSetProp (object_node, "fill_color", string); - g_free (string); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Label->Line Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_line_props (xmlNodePtr object_node, - xmlNsPtr ns, - glLabelObject * object) -{ - gchar *string; - - xmlNodeSetName (object_node, "Line"); - - string = g_strdup_printf ("%g", object->arg.line.dx); - xmlSetProp (object_node, "dx", string); - g_free (string); - - string = g_strdup_printf ("%g", object->arg.line.dy); - xmlSetProp (object_node, "dy", string); - g_free (string); - - string = g_strdup_printf ("%g", object->arg.line.line_width); - xmlSetProp (object_node, "line_width", string); - g_free (string); - - string = g_strdup_printf ("0x%08x", object->arg.line.line_color); - xmlSetProp (object_node, "line_color", string); - g_free (string); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Label->Ellipse Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_ellipse_props (xmlNodePtr object_node, - xmlNsPtr ns, - glLabelObject * object) -{ - gchar *string; - - xmlNodeSetName (object_node, "Ellipse"); - - string = g_strdup_printf ("%g", object->arg.ellipse.w); - xmlSetProp (object_node, "w", string); - g_free (string); - - string = g_strdup_printf ("%g", object->arg.ellipse.h); - xmlSetProp (object_node, "h", string); - g_free (string); - - string = g_strdup_printf ("%g", object->arg.ellipse.line_width); - xmlSetProp (object_node, "line_width", string); - g_free (string); - - string = g_strdup_printf ("0x%08x", object->arg.ellipse.line_color); - xmlSetProp (object_node, "line_color", string); - g_free (string); - - string = g_strdup_printf ("0x%08x", object->arg.ellipse.fill_color); - xmlSetProp (object_node, "fill_color", string); - g_free (string); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Label->Image Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_image_props (xmlNodePtr object_node, - xmlNsPtr ns, - glLabelObject * object) -{ - gchar *string; - - xmlNodeSetName (object_node, "Image"); - - string = g_strdup_printf ("%g", object->arg.image.w); - xmlSetProp (object_node, "w", string); - g_free (string); - - string = g_strdup_printf ("%g", object->arg.image.h); - xmlSetProp (object_node, "h", string); - g_free (string); - - xmlSetProp (object_node, "filename", object->arg.image.filename); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Label->Barcode Node Properties */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_barcode_props (xmlNodePtr object_node, - xmlNsPtr ns, - glLabelObject * object) -{ - xmlNodePtr child; - gchar *string; - - xmlNodeSetName (object_node, "Barcode"); - - string = g_strdup_printf ("0x%08x", object->arg.barcode.color); - xmlSetProp (object_node, "color", string); - g_free (string); - - xmlSetProp (object_node, "style", - gl_barcode_style_to_text (object->arg.barcode.style)); - - if (object->arg.barcode.text_flag) { - xmlSetProp (object_node, "text", "True"); - } else { - xmlSetProp (object_node, "text", "False"); - } - - string = g_strdup_printf ("%g", object->arg.barcode.scale); - xmlSetProp (object_node, "scale", string); - g_free (string); - - if (object->arg.barcode.text_node->field_flag) { - child = xmlNewChild (object_node, ns, "Field", NULL); - xmlSetProp (child, "name", - object->arg.barcode.text_node->data); - } else { - xmlNodeSetContent (object_node, - object->arg.barcode.text_node->data); - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Label Merge Properties Node */ -/*--------------------------------------------------------------------------*/ -static void -xml_create_merge_properties (xmlNodePtr root, - xmlNsPtr ns, - glLabel * label) -{ - xmlNodePtr node, child; - gchar *string; - GList *p; - glMergeFieldDefinition *field_def; - - node = xmlNewChild (root, ns, "Merge_Properties", NULL); - - string = gl_merge_type_to_text (label->merge_type); - xmlSetProp (node, "type", string); - g_free (string); - - xmlSetProp (node, "src", label->merge_src); - - for (p = label->merge_fields; p != NULL; p = p->next) { - field_def = (glMergeFieldDefinition *) p->data; - - child = xmlNewChild (node, ns, "Field", NULL); - xmlSetProp (child, "key", field_def->key); - xmlSetProp (child, "loc", field_def->loc); - } - -} - -/****************************************************************************/ -/* Create a new label object of the given type. */ -/****************************************************************************/ -glLabelObject * -gl_label_object_new (glLabel * label, - glLabelObjectType type) -{ - glLabelObject *object; - - object = g_new0 (glLabelObject, 1); - object->parent = label; - object->type = type; - - if (label != NULL) { - label->objects = g_list_append (label->objects, object); - } - - return object; -} - -/****************************************************************************/ -/* Create a new label object from an existing object */ -/****************************************************************************/ -glLabelObject * -gl_label_object_new_from_object (glLabel * label, - glLabelObject * src_object) -{ - glLabelObject *object; - GList *p_line, *nodes, *p_node; - glTextNode *node, *src_node; - - object = g_new0 (glLabelObject, 1); - *object = *src_object; - - /* deep copy */ - switch (object->type) { - - case GL_LABEL_OBJECT_TEXT: - /* deep copy */ - gl_text_node_lines_print (src_object->arg.text.lines); - object->arg.text.lines = NULL; - for (p_line = src_object->arg.text.lines; p_line != NULL; - p_line = p_line->next) { - nodes = NULL; - for (p_node = (GList *) p_line->data; p_node != NULL; - p_node = p_node->next) { - src_node = (glTextNode *) p_node->data; - node = g_new0 (glTextNode, 1); - node->field_flag = src_node->field_flag; - node->data = g_strdup (src_node->data); - nodes = g_list_append (nodes, node); - } - object->arg.text.lines = - g_list_append (object->arg.text.lines, nodes); - } - object->arg.text.font_family = - g_strdup (src_object->arg.text.font_family); - break; - - case GL_LABEL_OBJECT_IMAGE: - object->arg.image.filename - = g_strdup (src_object->arg.image.filename); - object->arg.image.image - = gdk_pixbuf_copy (src_object->arg.image.image); - break; - - case GL_LABEL_OBJECT_BARCODE: - object->arg.barcode.text_node = g_new0 (glTextNode, 1); - object->arg.barcode.text_node->field_flag = - src_object->arg.barcode.text_node->field_flag; - object->arg.barcode.text_node->data = - g_strdup (src_object->arg.barcode.text_node->data); - break; - - default: - break; - - } - - /* set parent */ - object->parent = label; - if (label != NULL) { - label->objects = g_list_append (label->objects, object); - } - - return object; -} - -/****************************************************************************/ -/* Free a previously allocated label object. */ -/****************************************************************************/ -void -gl_label_object_free (glLabelObject ** object) -{ - glLabel *label; - - switch ((*object)->type) { - - case GL_LABEL_OBJECT_TEXT: - gl_text_node_lines_free (&((*object)->arg.text.lines)); - g_free ((*object)->arg.text.font_family); - (*object)->arg.text.font_family = NULL; - break; - - case GL_LABEL_OBJECT_IMAGE: - g_free ((*object)->arg.image.filename); - (*object)->arg.image.filename = NULL; - gdk_pixbuf_unref ((*object)->arg.image.image); - (*object)->arg.image.image = NULL; - break; - - case GL_LABEL_OBJECT_BARCODE: - gl_text_node_free (&((*object)->arg.barcode.text_node)); - break; - - default: - break; - - } - - label = (*object)->parent; - if (label != NULL) { - label->objects = g_list_remove (label->objects, *object); - } - - g_free (*object); - *object = NULL; -} - -/****************************************************************************/ -/* Bring label object to front/top. */ -/****************************************************************************/ -void -gl_label_object_raise_to_front (glLabelObject * object) -{ - glLabel *label; - - label = object->parent; - - /* Move to end of list, representing front most object */ - label->objects = g_list_remove (label->objects, object); - label->objects = g_list_append (label->objects, object); -} - -/****************************************************************************/ -/* Send label object to rear/bottom. */ -/****************************************************************************/ -void -gl_label_object_lower_to_back (glLabelObject * object) -{ - glLabel *label; - - label = object->parent; - - /* Move to front of list, representing rear most object */ - label->objects = g_list_remove (label->objects, object); - label->objects = g_list_prepend (label->objects, object); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Utilities to deal with GTK_JUSTIFICATION types */ -/*--------------------------------------------------------------------------*/ -static const gchar * -just_to_text (GtkJustification just) -{ - switch (just) { - case GTK_JUSTIFY_LEFT: - return "Left"; - case GTK_JUSTIFY_CENTER: - return "Center"; - case GTK_JUSTIFY_RIGHT: - return "Right"; - default: - return "?"; - } -} - -static GtkJustification -text_to_just (const gchar * text) -{ - - if (g_strcasecmp (text, "Left") == 0) { - return GTK_JUSTIFY_LEFT; - } else if (g_strcasecmp (text, "Center") == 0) { - return GTK_JUSTIFY_CENTER; - } else if (g_strcasecmp (text, "Right") == 0) { - return GTK_JUSTIFY_RIGHT; - } else { - return GTK_JUSTIFY_LEFT; - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Utilities to deal with GNOME_FONT_WEIGHT types */ -/*--------------------------------------------------------------------------*/ -static const gchar * -weight_to_text (GnomeFontWeight weight) -{ - switch (weight) { - case GNOME_FONT_BOOK: - return "Regular"; - case GNOME_FONT_BOLD: - return "Bold"; - default: - return "?"; - } -} - -static GnomeFontWeight -text_to_weight (const gchar * text) -{ - - if (g_strcasecmp (text, "Regular") == 0) { - return GNOME_FONT_BOOK; - } else if (g_strcasecmp (text, "Bold") == 0) { - return GNOME_FONT_BOLD; - } else { - return GNOME_FONT_BOOK; - } - -} diff --git a/glabels1/src/label.h b/glabels1/src/label.h deleted file mode 100644 index e0ca5f9..0000000 --- a/glabels1/src/label.h +++ /dev/null @@ -1,151 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * label.h: GLabels label module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __LABEL_H__ -#define __LABEL_H__ - -#include <gtk/gtk.h> -#include <libgnomeprint/gnome-font.h> -#include <gdk-pixbuf/gdk-pixbuf.h> - -#include "merge.h" -#include "text_node.h" -#include "template.h" -#include "bc.h" - -typedef struct { - - gchar *template_name; - glTemplate *template; - gboolean rotate_flag; - - gdouble width, height; - - GList *objects; - - glMergeType merge_type; - gchar *merge_src; - GList *merge_fields; /* Merge Field Definitions */ - -} glLabel; - -typedef enum { - GL_LABEL_OBJECT_TEXT, - GL_LABEL_OBJECT_BOX, - GL_LABEL_OBJECT_LINE, - GL_LABEL_OBJECT_ELLIPSE, - GL_LABEL_OBJECT_IMAGE, - GL_LABEL_OBJECT_BARCODE, - GL_LABEL_OBJECT_N_TYPES -} glLabelObjectType; - -typedef struct { - - glLabel *parent; - - glLabelObjectType type; - gdouble x, y; - - union { - - struct { - GList *lines; /* list of glLabelTextNode lists */ - gchar *font_family; - gdouble font_size; - GnomeFontWeight font_weight; - gboolean font_italic_flag; - GtkJustification just; - guint color; - } text; - - struct { - gdouble w, h; - gdouble line_width; - guint line_color; - guint fill_color; - } box; - - struct { - gdouble dx, dy; - gdouble line_width; - guint line_color; - } line; - - struct { - gdouble w, h; - gdouble line_width; - guint line_color; - guint fill_color; - } ellipse; - - struct { - gchar *filename; - gdouble w, h; - GdkPixbuf *image; - } image; - - struct { - glTextNode *text_node; - glBarcodeStyle style; - guint color; - gboolean text_flag; - gdouble scale; - } barcode; - - } arg; - -} glLabelObject; - -typedef enum { - LABEL_UNKNOWN_MEDIA = 1, - LABEL_OK = 0, - LABEL_ERROR_OPEN_XML_PARSE = -10, - LABEL_ERROR_SAVE_XML_FILE = -20, -} glLabelStatus; - -extern glLabel *gl_label_new (void); -extern glLabel *gl_label_new_with_template (const gchar * tmplt_name, - gboolean rotate_flag); -extern void gl_label_free (glLabel ** label); - -extern glLabelStatus gl_label_open_xml (glLabel ** label, - const gchar * filename); -extern glLabelStatus gl_label_open_xml_buffer (glLabel ** label, - const gchar * buffer); - -extern glLabelStatus gl_label_save_xml (glLabel * label, - const gchar * filename); - -glLabelStatus gl_label_save_xml_buffer (glLabel * label, - gchar ** buffer); - -extern glLabelObject *gl_label_object_new (glLabel * label, - glLabelObjectType type); - -extern glLabelObject *gl_label_object_new_from_object (glLabel * label, - glLabelObject * object); - -extern void gl_label_object_free (glLabelObject ** object); - -extern void gl_label_object_raise_to_front (glLabelObject * object); -extern void gl_label_object_lower_to_back (glLabelObject * object); - -#endif diff --git a/glabels1/src/mdi.c b/glabels1/src/mdi.c deleted file mode 100644 index 4a1b17a..0000000 --- a/glabels1/src/mdi.c +++ /dev/null @@ -1,746 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * mdi.c: GLabels MDI module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <sys/stat.h> -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> -#include <dirent.h> -#include <string.h> - -#include "mdi.h" -#include "menu.h" -#include "display.h" -#include "label.h" -#include "util.h" - -#define DONT_DISPLAY_EXTENSION - -/*============================================*/ -/* Private types. */ -/*============================================*/ -typedef struct _Document Document; -struct _Document { - glLabel *label; - gchar *filename; - gint id; -}; - -/*============================================*/ -/* Private globals. */ -/*============================================*/ -static GnomeMDI *mdi = NULL; -static gint i_unnamed = 0; -static gint next_id = 0; - -/*===========================================*/ -/* Private function prototypes. */ -/*===========================================*/ -static void set_filename (GnomeMDIChild * child, const gchar * filename); - -static gboolean remove_child_handler (GnomeMDI * mdi, GnomeMDIChild * child, - gpointer data); - -static GnomeMDIChild *child_creator (const char *name, glLabel * label, - const char *abs_filename); - -static void child_destroyed (GnomeMDIChild * child, gpointer data); - -static void app_created_handler (GnomeMDI * mdi, GnomeApp * app, gpointer data); - -static GtkWidget *view_creator (GnomeMDIChild * child, gpointer data); - -static gchar *construct_name (GnomeMDIChild * child, const gchar * filename); - -static gboolean close_save (GnomeMDIChild * child); - -static gboolean close_save_as_dialog (GnomeMDIChild * child); - -static void close_save_as_ok_cb (GtkWidget * widget, GtkFileSelection * fsel); - -static void close_save_as_cancel_cb (GtkWidget * widget, GtkFileSelection * fsel); - -static void close_save_as_destroy_cb (GtkWidget * widget, gboolean * destroy_flag); - -/*--------------------------------------------------------------------------*/ -/* Initialize mdi module. */ -/*--------------------------------------------------------------------------*/ -GnomeMDI * -gl_mdi_init (void) -{ - mdi = GNOME_MDI (gnome_mdi_new (PACKAGE, "gLabels")); - - gl_menu_install_menus (mdi); - gl_menu_install_toolbar (mdi); - - gtk_signal_connect (GTK_OBJECT (mdi), "destroy", - GTK_SIGNAL_FUNC (gtk_main_quit), NULL); - - gtk_signal_connect (GTK_OBJECT (mdi), "remove_child", - GTK_SIGNAL_FUNC (remove_child_handler), NULL); - - gtk_signal_connect (GTK_OBJECT (mdi), "app-created", - GTK_SIGNAL_FUNC (app_created_handler), NULL); - - return mdi; -} - -/*--------------------------------------------------------------------------*/ -/* Get active window/app. */ -/*--------------------------------------------------------------------------*/ -GnomeApp * -gl_mdi_get_active_window (void) -{ - return gnome_mdi_get_active_window (mdi); -} - -/*--------------------------------------------------------------------------*/ -/* Create a new view/child with a blank document. */ -/*--------------------------------------------------------------------------*/ -gboolean -gl_mdi_new_child (const gchar * tmplt_name, - gboolean rotate_flag) -{ - gchar *name = NULL; - GnomeMDIChild *child; - - i_unnamed++; - name = g_strdup_printf ("Label%d", i_unnamed); - child = child_creator (name, - gl_label_new_with_template (tmplt_name, - rotate_flag), NULL); - g_free (name); - if (child == NULL) { - return FALSE; - } - - gnome_mdi_add_child (mdi, child); - gnome_mdi_add_view (mdi, child); - - return TRUE; -} - -/*--------------------------------------------------------------------------*/ -/* Create a new view, from xml document. */ -/*--------------------------------------------------------------------------*/ -gboolean -gl_mdi_new_child_from_xml_file (const gchar * filename) -{ - GList *p_child; - GnomeMDIChild *child; - Document *document; - gchar *abs_filename, *name; - glLabel *label = NULL; - glLabelStatus status; - GtkWidget *wdialog; - gchar *msg; - GnomeApp *app; - - abs_filename = gl_util_make_absolute (filename); - - for (p_child = mdi->children; p_child != NULL; p_child = p_child->next) { - child = GNOME_MDI_CHILD (p_child->data); - document = gtk_object_get_user_data (GTK_OBJECT (child)); - if (document->filename != NULL) { - if (strcmp (document->filename, abs_filename) == 0) { - msg = - g_strdup_printf (_ - ("Revert to saved copy of %s?"), - abs_filename); - wdialog = - gnome_message_box_new (msg, - GNOME_MESSAGE_BOX_QUESTION, - GNOME_STOCK_BUTTON_YES, - GNOME_STOCK_BUTTON_NO, - NULL); - g_free (msg); - app = - gnome_mdi_get_app_from_view (GTK_WIDGET - (child->views-> - data)); - gtk_window_set_transient_for (GTK_WINDOW - (wdialog), - GTK_WINDOW (app)); - if (gnome_dialog_run (GNOME_DIALOG (wdialog)) == - 0) { - gnome_mdi_remove_child (mdi, child, - FALSE); - break; - } else { - g_free (abs_filename); - return TRUE; - } - } - } - } - - status = gl_label_open_xml (&label, abs_filename); - if (status < LABEL_OK) { - g_free (abs_filename); - return FALSE; - } - if (status == LABEL_UNKNOWN_MEDIA) { - app = gl_mdi_get_active_window (); - wdialog = - gnome_error_dialog_parented (_ - ("Unknown media type. Using default."), - GTK_WINDOW (app)); - gtk_window_set_modal (GTK_WINDOW (wdialog), TRUE); - } - - name = construct_name (NULL, abs_filename); - child = child_creator (name, label, abs_filename); - g_free (name); - if (child == NULL) { - g_free (abs_filename); - return FALSE; - } - - gnome_mdi_add_child (mdi, child); - gnome_mdi_add_view (mdi, child); - - g_free (abs_filename); - return TRUE; -} - -/*--------------------------------------------------------------------------*/ -/* Save view to xml file. */ -/*--------------------------------------------------------------------------*/ -gboolean -gl_mdi_save_child_to_xml_file (GnomeMDIChild * child, - const gchar * filename) -{ - glDisplay *display; - glLabel *label; - - display = gl_mdi_get_display (child); - label = display->label; - if (gl_label_save_xml (label, filename) == LABEL_OK) { - gl_display_clear_modified (display); - set_filename (child, filename); - return TRUE; - } else { - return FALSE; - } - -} - -/*--------------------------------------------------------------------------*/ -/* Close view. */ -/*--------------------------------------------------------------------------*/ -void -gl_mdi_close_child (GnomeMDIChild * child) -{ - if (child != NULL) { - gnome_mdi_remove_child (mdi, child, FALSE); - } -} - -/*--------------------------------------------------------------------------*/ -/* Close all views, and exit if successful. */ -/*--------------------------------------------------------------------------*/ -void -gl_mdi_close_all (void) -{ - if (gnome_mdi_remove_all (mdi, FALSE)) { - gtk_object_destroy (GTK_OBJECT (mdi)); - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Set filename associated with document. */ -/*--------------------------------------------------------------------------*/ -void -set_filename (GnomeMDIChild * child, - const gchar * filename) -{ - Document *document; - gchar *name; - - document = gtk_object_get_user_data (GTK_OBJECT (child)); - - g_free (document->filename); - document->filename = g_strdup (filename); - - name = construct_name (child, filename); - gnome_mdi_child_set_name (child, name); - g_free (name); -} - -/*--------------------------------------------------------------------------*/ -/* Get filename associated with document. */ -/*--------------------------------------------------------------------------*/ -gchar * -gl_mdi_get_filename (GnomeMDIChild * child) -{ - Document *document; - - document = gtk_object_get_user_data (GTK_OBJECT (child)); - - return g_strdup (document->filename); -} - -/*--------------------------------------------------------------------------*/ -/* Get base filename of document. */ -/*--------------------------------------------------------------------------*/ -gchar * -gl_mdi_get_basename (GnomeMDIChild * child) -{ - Document *document; - - document = gtk_object_get_user_data (GTK_OBJECT (child)); - - if (document->filename != NULL) { - return g_strdup (g_basename (document->filename)); - } else { - return NULL; - } -} - -/*--------------------------------------------------------------------------*/ -/*--------------------------------------------------------------------------*/ -GList * -gl_mdi_get_displays_in_current_window (void) -{ - GnomeApp *app; - GList *p_child; - GnomeMDIChild *child; - GtkWidget *view; - GList *views = NULL; - - app = gnome_mdi_get_active_window (mdi); - - for (p_child = mdi->children; p_child != NULL; p_child = p_child->next) { - child = GNOME_MDI_CHILD (p_child->data); - view = GTK_WIDGET (child->views->data); - if (gnome_mdi_get_app_from_view (view) == app) { - views = g_list_prepend (views, view); - } - } - - return views; -} - -/*--------------------------------------------------------------------------*/ -/* Get label display associated with document. */ -/*--------------------------------------------------------------------------*/ -glDisplay * -gl_mdi_get_display (GnomeMDIChild * child) -{ - if (child == NULL) - return NULL; - if (child->views == NULL) - return NULL; - return GL_DISPLAY (child->views->data); -} - -/*--------------------------------------------------------------------------*/ -/* Get label associated with document. */ -/*--------------------------------------------------------------------------*/ -glLabel * -gl_mdi_get_label (GnomeMDIChild * child) -{ - glDisplay *display; - - display = gl_mdi_get_display (child); - return display->label; -} - -/*--------------------------------------------------------------------------*/ -/* Get uniq id associated with document. */ -/*--------------------------------------------------------------------------*/ -gint -gl_mdi_get_id (GnomeMDIChild * child) -{ - Document *document; - - document = gtk_object_get_user_data (GTK_OBJECT (child)); - - return document->id; -} - -/*--------------------------------------------------------------------------*/ -/* Find child associated with given id. This allows us to verify that a */ -/* child still exists from a non-modal dialog, e.g. if you close a child */ -/* while you have a print or save as dialog open for that child. */ -/*--------------------------------------------------------------------------*/ -GnomeMDIChild * -gl_mdi_find_child (gint id) -{ - GList *p_child; - GnomeMDIChild *child; - Document *document; - - for (p_child = mdi->children; p_child != NULL; p_child = p_child->next) { - child = GNOME_MDI_CHILD (p_child->data); - document = gtk_object_get_user_data (GTK_OBJECT (child)); - if (document->id == id) { - return child; - } - } - - return NULL; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Create a new child. */ -/*--------------------------------------------------------------------------*/ -static GnomeMDIChild * -child_creator (const char *name, - glLabel * label, - const char *abs_filename) -{ - GnomeMDIGenericChild *child; - Document *document; - - document = g_new0 (Document, 1); - - document->label = label; - document->filename = g_strdup (abs_filename); - document->id = next_id++; - - child = gnome_mdi_generic_child_new (name); - - gtk_object_set_user_data (GTK_OBJECT (child), document); - - gnome_mdi_generic_child_set_view_creator (child, view_creator, NULL); - - gtk_signal_connect (GTK_OBJECT (child), "destroy", - GTK_SIGNAL_FUNC (child_destroyed), document); - - return GNOME_MDI_CHILD (child); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Handle remove child signal. */ -/*--------------------------------------------------------------------------*/ -static gboolean -remove_child_handler (GnomeMDI * mdi, - GnomeMDIChild * child, - gpointer data) -{ - GtkWidget *wdialog; - gchar *msg; - GnomeApp *app = gnome_mdi_get_active_window (mdi); - Document *document; - glDisplay *display; - - display = gl_mdi_get_display (child); - document = gtk_object_get_user_data (GTK_OBJECT (child)); - - if (gl_display_modified (display)) { - msg = - g_strdup_printf (_ - ("``%s'' has been modified.\n\nDo you wish to save it?"), - child->name); - wdialog = - gnome_message_box_new (msg, GNOME_MESSAGE_BOX_WARNING, - "Save", _("Don't save"), - GNOME_STOCK_BUTTON_CANCEL, NULL); - g_free (msg); - gtk_window_set_transient_for (GTK_WINDOW (wdialog), - GTK_WINDOW (app)); - switch (gnome_dialog_run (GNOME_DIALOG (wdialog))) { - - case 0: /* Yes / Save */ - if (document->filename != NULL) { - return close_save (child); - } else { - return close_save_as_dialog (child); - } - - case 1: /* No / Don't save */ - return TRUE; - - default: /* Cancel operation */ - return FALSE; - } - } else { - return TRUE; - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Handle destroy child signal. */ -/*--------------------------------------------------------------------------*/ -static void -child_destroyed (GnomeMDIChild * child, - gpointer data) -{ - Document *document = data; - - gl_label_free (&document->label); - g_free (document->filename); - document->filename = NULL; - - g_free (document); - gtk_object_set_user_data (GTK_OBJECT (child), NULL); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Handle "app-created" signal. */ -/*--------------------------------------------------------------------------*/ -static void -app_created_handler (GnomeMDI * mdi, - GnomeApp * app, - gpointer data) -{ - GtkWidget *status; - - status = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_NEVER); - gnome_app_set_statusbar (app, status); - - gnome_app_install_menu_hints (app, - gnome_mdi_get_menubar_info (mdi-> - active_window)); - - gl_menu_install_tools_toolbar (mdi, app); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. View creator. */ -/*--------------------------------------------------------------------------*/ -static GtkWidget * -view_creator (GnomeMDIChild * child, - gpointer data) -{ - GtkWidget *widget; - Document *document; - - document = gtk_object_get_user_data (GTK_OBJECT (child)); - - widget = gl_display_new (document->label); - gtk_widget_show_all (widget); - - return widget; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct a child name, based on filename. */ -/*--------------------------------------------------------------------------*/ -static gchar * -construct_name (GnomeMDIChild * my_child, - const gchar * filename) -{ - gchar *name, *test_name, *final_name; - gint test_name_length; - GList *p_child; - gint duplicates = 0; - GnomeMDIChild *child; - - name = g_strdup (g_basename (filename)); -#ifdef DONT_DISPLAY_EXTENSION - { - gchar *p_extension = strrchr (name, '.'); - if (p_extension != NULL) - *p_extension = 0; /* wipe out extension */ - } -#endif - test_name = g_strdup_printf ("%s <", name); - test_name_length = strlen (test_name); - - for (p_child = mdi->children; p_child != NULL; p_child = p_child->next) { - child = GNOME_MDI_CHILD (p_child->data); - if (my_child != child) { - if (strcmp (child->name, name) == 0) { - duplicates++; - } - if (strncmp (child->name, test_name, test_name_length) - == 0) { - duplicates++; - } - } - } - g_free (test_name); - - if (duplicates > 0) { - final_name = g_strdup_printf ("%s <%d>", name, duplicates + 1); - } else { - final_name = g_strdup (name); - } - - g_free (name); - return final_name; - -} - -/*=================================================================*/ -/* PRIVATE. Save a document on close. */ -/*=================================================================*/ -static gboolean -close_save (GnomeMDIChild * child) -{ - Document *document = gtk_object_get_user_data (GTK_OBJECT (child)); - GtkWidget *dlg; - GnomeApp *app = gnome_mdi_get_active_window (mdi); - - if (gl_mdi_save_child_to_xml_file (child, document->filename)) { - return TRUE; - } else { - dlg = gnome_error_dialog_parented (_("Cannot save file"), - GTK_WINDOW (app)); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - return FALSE; - } -} - -/*=================================================================*/ -/* PRIVATE. Special modal "Save As" dialog for closing children. */ -/*=================================================================*/ -static gboolean -close_save_as_dialog (GnomeMDIChild * child) -{ - GtkFileSelection *fsel; - GnomeApp *app = gnome_mdi_get_active_window (mdi); - gint id; - gboolean flag = FALSE; - gboolean destroy_flag = FALSE; - - g_return_val_if_fail (child != NULL, FALSE); - g_return_val_if_fail (app != NULL, FALSE); - - fsel = GTK_FILE_SELECTION (gtk_file_selection_new (_("Save As"))); - gtk_window_set_modal (GTK_WINDOW (fsel), TRUE); - gtk_window_set_transient_for (GTK_WINDOW (fsel), GTK_WINDOW (app)); - gtk_window_set_title (GTK_WINDOW (fsel), _("Close / Save label as")); - - id = gl_mdi_get_id (child); - gtk_object_set_data (GTK_OBJECT (fsel), "id", GINT_TO_POINTER (id)); - gtk_object_set_data (GTK_OBJECT (fsel), "flag", &flag); - - gtk_signal_connect (GTK_OBJECT (fsel->ok_button), "clicked", - GTK_SIGNAL_FUNC (close_save_as_ok_cb), fsel); - - gtk_signal_connect (GTK_OBJECT (fsel->cancel_button), "clicked", - GTK_SIGNAL_FUNC (close_save_as_cancel_cb), fsel); - - gtk_signal_connect (GTK_OBJECT (fsel), "destroy", - GTK_SIGNAL_FUNC (close_save_as_destroy_cb), - &destroy_flag); - - /* show the dialog */ - gtk_widget_show (GTK_WIDGET (fsel)); - - /* Hold here and process events until we are done with this dialog. */ - gtk_main (); - - /* Destroy dialog if not already destroyed. */ - if (!destroy_flag) { - /* Disconnect our destroy callback first, so that we don't kill the - * current gtk_main() loop. */ - gtk_signal_disconnect_by_func (GTK_OBJECT (fsel), - GTK_SIGNAL_FUNC - (close_save_as_destroy_cb), - &destroy_flag); - gtk_widget_destroy (GTK_WIDGET (fsel)); - } - - /* Return flag as set by one of the above callbacks, TRUE = saved */ - return flag; -} - -/*==============================================*/ -/* PRIVATE. "Save As" ok button callback. */ -/*==============================================*/ -static void -close_save_as_ok_cb (GtkWidget * widget, - GtkFileSelection * fsel) -{ - gchar *raw_filename, *filename; - GtkWidget *dlg; - gint id = - GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (fsel), "id")); - GnomeMDIChild *child = gl_mdi_find_child (id); - gboolean *flag = gtk_object_get_data (GTK_OBJECT (fsel), "flag"); - - g_return_if_fail (GTK_IS_FILE_SELECTION (fsel)); - - if (child == NULL) { - dlg = gnome_error_dialog (_("Label no longer valid!")); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - *flag = TRUE; - gtk_widget_hide (GTK_WIDGET (fsel)); - gtk_main_quit (); - return; - } - - /* get the filename */ - raw_filename = g_strdup (gtk_file_selection_get_filename (fsel)); - - if (!raw_filename || (raw_filename[strlen (raw_filename) - 1] == '/')) { - - dlg = gnome_warning_dialog_parented (_("Must supply file name"), - GTK_WINDOW (fsel)); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - - } else { - - filename = gl_util_add_extension (raw_filename); - - if (!gl_mdi_save_child_to_xml_file (child, filename)) { - - dlg = - gnome_error_dialog_parented (_ - ("Error writing file"), - GTK_WINDOW (fsel)); - gtk_window_set_modal (GTK_WINDOW (dlg), TRUE); - - } else { - *flag = TRUE; - gtk_widget_hide (GTK_WIDGET (fsel)); - gtk_main_quit (); - } - - g_free (filename); - } - - g_free (raw_filename); -} - -/*==============================================*/ -/* PRIVATE. "Save As" cancel button callback. */ -/*==============================================*/ -static void -close_save_as_cancel_cb (GtkWidget * widget, - GtkFileSelection * fsel) -{ - gboolean *flag = gtk_object_get_data (GTK_OBJECT (fsel), "flag"); - - g_return_if_fail (GTK_IS_FILE_SELECTION (fsel)); - - *flag = FALSE; - gtk_widget_hide (GTK_WIDGET (fsel)); - gtk_main_quit (); -} - -/*==============================================*/ -/* PRIVATE. "Save As" destroy callback. */ -/*==============================================*/ -static void -close_save_as_destroy_cb (GtkWidget * widget, - gboolean * destroy_flag) -{ - *destroy_flag = TRUE; - gtk_main_quit (); -} diff --git a/glabels1/src/mdi.h b/glabels1/src/mdi.h deleted file mode 100644 index faeeedc..0000000 --- a/glabels1/src/mdi.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * mdi.h: GLabels MDI module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __MDI_H__ -#define __MDI_H__ - -#include <gnome.h> -#include <display.h> - -extern GnomeMDI *gl_mdi_init (void); -extern GnomeApp *gl_mdi_get_active_window (void); - -extern gboolean gl_mdi_new_child (const gchar * tmplt_name, - gboolean rotate_flag); -extern gboolean gl_mdi_new_child_from_xml_file (const gchar * filename); - -extern gboolean gl_mdi_save_child_to_xml_file (GnomeMDIChild * child, - const gchar * filename); - -extern void gl_mdi_close_child (GnomeMDIChild * child); -extern void gl_mdi_close_all (void); - -extern gchar *gl_mdi_get_filename (GnomeMDIChild * child); -extern gchar *gl_mdi_get_basename (GnomeMDIChild * child); - -extern GList *gl_mdi_get_displays_in_current_window (void); -extern glDisplay *gl_mdi_get_display (GnomeMDIChild * child); -extern glLabel *gl_mdi_get_label (GnomeMDIChild * child); - -extern gint gl_mdi_get_id (GnomeMDIChild * child); -extern GnomeMDIChild *gl_mdi_find_child (gint id); - -#endif /* __MDI_H__ */ diff --git a/glabels1/src/media_select.c b/glabels1/src/media_select.c deleted file mode 100644 index 6d82946..0000000 --- a/glabels1/src/media_select.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * media_select.c: media selection widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "media_select.h" -#include "template.h" -#include "mini_preview.h" -#include "prefs.h" -#include "util.h" - -#include "debug.h" - -#define MINI_PREVIEW_WIDTH 160 -#define MINI_PREVIEW_HEIGHT 200 - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glMediaSelectSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint media_select_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_media_select_class_init (glMediaSelectClass * class); -static void gl_media_select_init (glMediaSelect * media_select); -static void gl_media_select_destroy (GtkObject * object); - -static void gl_media_select_construct (glMediaSelect * media_select); - -static void page_size_entry_changed_cb (GtkEntry * entry, gpointer user_data); -static void template_entry_changed_cb (GtkEntry * entry, gpointer user_data); - -static void details_update (glMediaSelect * media_select, gchar * name); - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_media_select_get_type (void) -{ - static guint media_select_type = 0; - - if (!media_select_type) { - GtkTypeInfo media_select_info = { - "glMediaSelect", - sizeof (glMediaSelect), - sizeof (glMediaSelectClass), - (GtkClassInitFunc) gl_media_select_class_init, - (GtkObjectInitFunc) gl_media_select_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - media_select_type = gtk_type_unique (gtk_vbox_get_type (), - &media_select_info); - } - - return media_select_type; -} - -static void -gl_media_select_class_init (glMediaSelectClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_media_select_destroy; - - media_select_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glMediaSelectClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, media_select_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_media_select_init (glMediaSelect * media_select) -{ - media_select->page_size_entry = NULL; - media_select->template_entry = NULL; - - media_select->mini_preview = NULL; - - media_select->desc_label = NULL; - media_select->sheet_size_label = NULL; - media_select->number_label = NULL; - media_select->label_size_label = NULL; -} - -static void -gl_media_select_destroy (GtkObject * object) -{ - glMediaSelect *media_select; - glMediaSelectClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_MEDIA_SELECT (object)); - - media_select = GL_MEDIA_SELECT (object); - class = GL_MEDIA_SELECT_CLASS (GTK_OBJECT (media_select)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_media_select_new (void) -{ - glMediaSelect *media_select; - - media_select = gtk_type_new (gl_media_select_get_type ()); - - gl_media_select_construct (media_select); - - return GTK_WIDGET (media_select); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_media_select_construct (glMediaSelect * media_select) -{ - GtkWidget *whbox, *wvbox, *wcombo, *wvbox1, *whbox1; - gchar *name; - GList *template_names, *page_sizes = NULL; - const gchar *page_size; - - page_size = gl_prefs_get_page_size (); - - wvbox = GTK_WIDGET (media_select); - - whbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (wvbox), whbox, TRUE, TRUE, GNOME_PAD); - - /* Page size selection control */ - wcombo = gtk_combo_new (); - page_sizes = g_list_append (page_sizes, "US-Letter"); - page_sizes = g_list_append (page_sizes, "A4"); - gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), page_sizes); - g_list_free (page_sizes); - media_select->page_size_entry = GTK_COMBO (wcombo)->entry; - gtk_entry_set_editable (GTK_ENTRY (media_select->page_size_entry), - FALSE); - gtk_widget_set_usize (media_select->page_size_entry, 100, 0); - gtk_entry_set_text (GTK_ENTRY (media_select->page_size_entry), - page_size); - gtk_box_pack_start (GTK_BOX (whbox), wcombo, FALSE, FALSE, GNOME_PAD); - - /* Actual selection control */ - template_names = gl_template_get_name_list (page_size); - media_select->template_combo = gtk_combo_new (); - gtk_combo_set_popdown_strings (GTK_COMBO (media_select->template_combo), - template_names); - gl_template_free_name_list (&template_names); - media_select->template_entry = - GTK_COMBO (media_select->template_combo)->entry; - gtk_entry_set_editable (GTK_ENTRY (media_select->template_entry), - FALSE); - gtk_widget_set_usize (media_select->template_entry, 400, 0); - gtk_box_pack_start (GTK_BOX (whbox), media_select->template_combo, - FALSE, FALSE, GNOME_PAD); - - whbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (wvbox), whbox, TRUE, TRUE, GNOME_PAD); - - /* mini_preview canvas */ - media_select->mini_preview = gl_mini_preview_new ( MINI_PREVIEW_HEIGHT, - MINI_PREVIEW_WIDTH); - gtk_box_pack_start (GTK_BOX (whbox), media_select->mini_preview, - FALSE, FALSE, GNOME_PAD); - - /* Label column */ - wvbox1 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (whbox), wvbox1, FALSE, FALSE, 0); - - whbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (wvbox1), whbox1, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (whbox1), - gtk_label_new (_("Description:")), - FALSE, FALSE, GNOME_PAD); - whbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (wvbox1), whbox1, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (whbox1), - gtk_label_new (_("Page size:")), - FALSE, FALSE, GNOME_PAD); - whbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (wvbox1), whbox1, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (whbox1), - gtk_label_new (_("Label size:")), - FALSE, FALSE, GNOME_PAD); - whbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (wvbox1), whbox1, FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (whbox1), - gtk_label_new (_("Layout:")), - FALSE, FALSE, GNOME_PAD); - - /* detail widgets column */ - wvbox1 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (whbox), wvbox1, FALSE, FALSE, 0); - - whbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (wvbox1), whbox1, FALSE, FALSE, 0); - media_select->desc_label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (whbox1), media_select->desc_label, - FALSE, FALSE, GNOME_PAD); - whbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (wvbox1), whbox1, FALSE, FALSE, 0); - media_select->sheet_size_label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (whbox1), media_select->sheet_size_label, - FALSE, FALSE, GNOME_PAD); - whbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (wvbox1), whbox1, FALSE, FALSE, 0); - media_select->label_size_label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (whbox1), media_select->label_size_label, - FALSE, FALSE, GNOME_PAD); - whbox1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (wvbox1), whbox1, FALSE, FALSE, 0); - media_select->number_label = gtk_label_new (""); - gtk_box_pack_start (GTK_BOX (whbox1), media_select->number_label, - FALSE, FALSE, GNOME_PAD); - - /* Update mini_preview and details from default template */ - name = - gtk_editable_get_chars (GTK_EDITABLE (media_select->template_entry), - 0, -1); - gl_mini_preview_set_label (GL_MINI_PREVIEW (media_select->mini_preview), - name); - details_update (media_select, name); - g_free (name); - - /* Connect signals to controls */ - gtk_signal_connect (GTK_OBJECT (media_select->page_size_entry), - "changed", - GTK_SIGNAL_FUNC (page_size_entry_changed_cb), - media_select); - gtk_signal_connect (GTK_OBJECT (media_select->template_entry), - "changed", - GTK_SIGNAL_FUNC (template_entry_changed_cb), - media_select); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change in selection */ -/*--------------------------------------------------------------------------*/ -static void -page_size_entry_changed_cb (GtkEntry * entry, - gpointer user_data) -{ - glMediaSelect *media_select = GL_MEDIA_SELECT (user_data); - gchar *page_size; - GList *template_names; - - /* Update template selections for new page size */ - page_size = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - template_names = gl_template_get_name_list (page_size); - gtk_combo_set_popdown_strings (GTK_COMBO (media_select->template_combo), - template_names); - gl_template_free_name_list (&template_names); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change in selection */ -/*--------------------------------------------------------------------------*/ -static void -template_entry_changed_cb (GtkEntry * entry, - gpointer user_data) -{ - glMediaSelect *media_select = GL_MEDIA_SELECT (user_data); - gchar *name; - - /* Update mini_preview canvas & details with template */ - name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - gl_mini_preview_set_label (GL_MINI_PREVIEW (media_select->mini_preview), - name); - details_update (media_select, name); - g_free (name); - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (user_data), media_select_signals[CHANGED]); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. update "details" widgets from new template. */ -/*--------------------------------------------------------------------------*/ -static void -details_update (glMediaSelect * media_select, - gchar * name) -{ - glTemplate *template; - gchar *text; - glPrefsUnits units; - const gchar *units_string; - gdouble units_per_point; - - units = gl_prefs_get_units (); - units_string = gl_prefs_get_units_string (); - units_per_point = gl_prefs_get_units_per_point (); - - /* Fetch template */ - template = gl_template_from_name (name); - - gtk_label_set_text (GTK_LABEL (media_select->desc_label), - template->description); - - gtk_label_set_text (GTK_LABEL (media_select->sheet_size_label), - template->page_size); - - text = g_strdup_printf (_("%d x %d (%d per sheet)"), - template->nx, template->ny, - template->nx * template->ny); - - gtk_label_set_text (GTK_LABEL (media_select->number_label), text); - g_free (text); - - if ( units == GL_PREFS_UNITS_INCHES ) { - gchar *xstr, *ystr; - - xstr = gl_util_fraction (template->label_height - * units_per_point); - ystr = gl_util_fraction (template->label_width - * units_per_point); - text = g_strdup_printf (_("%s x %s %s"), - xstr, ystr, units_string); - g_free (xstr); - g_free (ystr); - } else { - text = g_strdup_printf (_("%.5g x %.5g %s"), - template->label_height*units_per_point, - template->label_width*units_per_point, - units_string); - } - gtk_label_set_text (GTK_LABEL (media_select->label_size_label), text); - g_free (text); - - gl_template_free( &template ); -} - -/****************************************************************************/ -/* query selected label template name. */ -/****************************************************************************/ -gchar * -gl_media_select_get_name (glMediaSelect * media_select) -{ - return - gtk_editable_get_chars (GTK_EDITABLE (media_select->template_entry), - 0, -1); -} - -/****************************************************************************/ -/* set selected label template name. */ -/****************************************************************************/ -void -gl_media_select_set_name (glMediaSelect * media_select, - gchar * name) -{ - gint pos; - - gtk_signal_handler_block_by_func (GTK_OBJECT - (media_select->template_entry), - GTK_SIGNAL_FUNC - (template_entry_changed_cb), - media_select); - gtk_editable_delete_text (GTK_EDITABLE (media_select->template_entry), - 0, -1); - gtk_signal_handler_unblock_by_func (GTK_OBJECT - (media_select->template_entry), - GTK_SIGNAL_FUNC - (template_entry_changed_cb), - media_select); - - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (media_select->template_entry), - name, strlen (name), &pos); -} - -/****************************************************************************/ -/* query selected label template page size. */ -/****************************************************************************/ -gchar * -gl_media_select_get_page_size (glMediaSelect * media_select) -{ - return - gtk_editable_get_chars (GTK_EDITABLE - (media_select->page_size_entry), 0, -1); -} - -/****************************************************************************/ -/* set selected label template page size. */ -/****************************************************************************/ -void -gl_media_select_set_page_size (glMediaSelect * media_select, - gchar * page_size) -{ - gint pos; - - gtk_signal_handler_block_by_func (GTK_OBJECT - (media_select->page_size_entry), - GTK_SIGNAL_FUNC - (page_size_entry_changed_cb), - media_select); - gtk_editable_delete_text (GTK_EDITABLE (media_select->page_size_entry), - 0, -1); - gtk_signal_handler_unblock_by_func (GTK_OBJECT - (media_select->page_size_entry), - GTK_SIGNAL_FUNC - (page_size_entry_changed_cb), - media_select); - - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (media_select->page_size_entry), - page_size, strlen (page_size), &pos); -} diff --git a/glabels1/src/media_select.h b/glabels1/src/media_select.h deleted file mode 100644 index 4d4af21..0000000 --- a/glabels1/src/media_select.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * media_select.h: media selection widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __MEDIA_SELECT_H__ -#define __MEDIA_SELECT_H__ - -#include <gnome.h> - -#define GL_TYPE_MEDIA_SELECT (gl_media_select_get_type ()) -#define GL_MEDIA_SELECT(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_MEDIA_SELECT, glMediaSelect )) -#define GL_MEDIA_SELECT_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MEDIA_SELECT, glMediaSelectClass)) -#define GL_IS_MEDIA_SELECT(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_MEDIA_SELECT)) -#define GL_IS_MEDIA_SELECT_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MEDIA_SELECT)) - -typedef struct _glMediaSelect glMediaSelect; -typedef struct _glMediaSelectClass glMediaSelectClass; - -struct _glMediaSelect { - GtkVBox parent_widget; - - GtkWidget *page_size_entry; - GtkWidget *template_combo; - GtkWidget *template_entry; - - GtkWidget *mini_preview; - - GtkWidget *desc_label; - GtkWidget *sheet_size_label; - GtkWidget *number_label; - GtkWidget *label_size_label; -}; - -struct _glMediaSelectClass { - GtkVBoxClass parent_class; - - void (*changed) (glMediaSelect * media_select, gpointer user_data); -}; - -extern guint gl_media_select_get_type (void); - -extern GtkWidget *gl_media_select_new (void); - -extern gchar *gl_media_select_get_name (glMediaSelect * media_select); - -extern void gl_media_select_set_name (glMediaSelect * media_select, - gchar * name); - -extern gchar *gl_media_select_get_page_size (glMediaSelect * media_select); - -extern void gl_media_select_set_page_size (glMediaSelect * media_select, - gchar * page_size); - -#endif diff --git a/glabels1/src/menu.c b/glabels1/src/menu.c deleted file mode 100644 index 283e2f5..0000000 --- a/glabels1/src/menu.c +++ /dev/null @@ -1,328 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * menu.c: Menu module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "menu.h" -#include "stock.h" -#include "file.h" -#include "print_dialog.h" -#include "edit.h" -#include "prefs.h" -#include "tools.h" - -#ifdef PACKAGE_DATA_DIR -#define LOGO_PIXMAP (PACKAGE_DATA_DIR "/pixmaps/glabels/glabels-about-logo.png") -#else -#define LOGO_PIXMAP gnome_pixmap_file("glabels/glabels-about-logo.png") -#endif - -/*===========================================*/ -/* Private function prototypes. */ -/*===========================================*/ -static void about_cb (GtkWidget * widget, gpointer data); -static void nothing_cb (GtkWidget * widget, gpointer data); - -/*===========================================*/ -/* Menu definitions */ -/*===========================================*/ - -static GnomeUIInfo menu_file[] = { - GNOMEUIINFO_MENU_NEW_ITEM (N_("_New"), - N_("Make a new, empty label"), - gl_file_new_cb, NULL), - - GNOMEUIINFO_MENU_OPEN_ITEM (gl_file_open_cb, NULL), - - GNOMEUIINFO_MENU_SAVE_ITEM (gl_file_save_cb, NULL), - - GNOMEUIINFO_MENU_SAVE_AS_ITEM (gl_file_save_as_cb, NULL), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_MENU_PRINT_ITEM (gl_print_dialog_cb, NULL), - - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_MENU_CLOSE_ITEM (gl_file_close_cb, NULL), - GNOMEUIINFO_MENU_EXIT_ITEM (gl_file_exit_cb, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo menu_edit[] = { -#ifdef UNDO_REDO - GNOMEUIINFO_MENU_UNDO_ITEM (nothing_cb, NULL), - GNOMEUIINFO_MENU_REDO_ITEM (nothing_cb, NULL), - - GNOMEUIINFO_SEPARATOR, -#endif - - GNOMEUIINFO_MENU_CUT_ITEM (gl_edit_cut_cb, NULL), - GNOMEUIINFO_MENU_COPY_ITEM (gl_edit_copy_cb, NULL), - GNOMEUIINFO_MENU_PASTE_ITEM (gl_edit_paste_cb, NULL), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_MENU_SELECT_ALL_ITEM (gl_edit_select_all_cb, NULL), - GNOMEUIINFO_ITEM_NONE (N_("U_nselect All "), - N_("Remove all selections"), - gl_edit_unselect_cb), - - GNOMEUIINFO_END -}; - -static GnomeUIInfo menu_tools[] = { - - GNOMEUIINFO_ITEM_STOCK (N_("Select"), - N_("Select, move and modify objects"), - gl_tools_arrow_cb, GL_STOCK_PIXMAP_ARROW), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_NONE (N_("Text"), N_("Create text object"), - gl_tools_text_cb), - - GNOMEUIINFO_ITEM_NONE (N_("Box"), N_("Create box/rectangle object"), - gl_tools_box_cb), - - GNOMEUIINFO_ITEM_NONE (N_("Line"), N_("Create line object"), - gl_tools_line_cb), - - GNOMEUIINFO_ITEM_NONE (N_("Ellipse"), - N_("Create ellipse/circle object"), - gl_tools_ellipse_cb), - - GNOMEUIINFO_ITEM_NONE (N_("Image"), N_("Create image object"), - gl_tools_image_cb), - - GNOMEUIINFO_ITEM_NONE (N_("Barcode"), N_("Create barcode object"), - gl_tools_barcode_cb), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_NONE (N_("Zoom in"), N_("Zoom in"), - gl_tools_zoomin_cb), - - GNOMEUIINFO_ITEM_NONE (N_("Zoom out"), N_("Zoom out"), - gl_tools_zoomout_cb), - - GNOMEUIINFO_ITEM_NONE (N_("Zoom 1:1"), N_("Zoom to 1:1"), - gl_tools_zoom1to1_cb), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_NONE (N_("Merge properties"), - N_("Edit merge properties"), - gl_tools_merge_properties_cb), - - GNOMEUIINFO_END -}; - -static GnomeUIInfo menu_settings[] = { - GNOMEUIINFO_MENU_PREFERENCES_ITEM (gl_prefs_cb, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo menu_windows[] = { - GNOMEUIINFO_END -}; - -static GnomeUIInfo menu_help[] = { - GNOMEUIINFO_HELP ("glabels"), - GNOMEUIINFO_MENU_ABOUT_ITEM (about_cb, NULL), - GNOMEUIINFO_END -}; - -static GnomeUIInfo menu_main[] = { - GNOMEUIINFO_MENU_FILE_TREE (menu_file), - GNOMEUIINFO_MENU_EDIT_TREE (menu_edit), - GNOMEUIINFO_SUBTREE (N_("_Tools"), menu_tools), - GNOMEUIINFO_MENU_SETTINGS_TREE (menu_settings), - GNOMEUIINFO_MENU_WINDOWS_TREE (menu_windows), - GNOMEUIINFO_MENU_HELP_TREE (menu_help), - GNOMEUIINFO_END -}; - -/*===========================================*/ -/* Toolbar definitions */ -/*===========================================*/ -static GnomeUIInfo toolbar[] = { - GNOMEUIINFO_ITEM_STOCK (N_(" New "), N_("New Label/Card"), - gl_file_new_cb, GNOME_STOCK_PIXMAP_NEW), - GNOMEUIINFO_ITEM_STOCK (N_(" Open "), N_("Open a file"), - gl_file_open_cb, GNOME_STOCK_PIXMAP_OPEN), - GNOMEUIINFO_ITEM_STOCK (N_(" Save "), N_("Save current file"), - gl_file_save_cb, GNOME_STOCK_PIXMAP_SAVE), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_ITEM_STOCK (N_(" Print "), N_("Print current file"), - gl_print_dialog_cb, GNOME_STOCK_PIXMAP_PRINT), - GNOMEUIINFO_SEPARATOR, - GNOMEUIINFO_END -}; - -/*****************************************************************************/ -/* Drawing tools toolbar definitions */ -/*****************************************************************************/ -static GnomeUIInfo tools_toolbar[] = { - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Select, move and modify objects"), - gl_tools_arrow_cb, GL_STOCK_PIXMAP_ARROW), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create text object"), - gl_tools_text_cb, GL_STOCK_PIXMAP_TEXT), - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create box/rectangle object"), - gl_tools_box_cb, GL_STOCK_PIXMAP_BOX), - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create line object"), - gl_tools_line_cb, GL_STOCK_PIXMAP_LINE), - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create ellipse/circle object"), - gl_tools_ellipse_cb, GL_STOCK_PIXMAP_ELLIPSE), - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create image object"), - gl_tools_image_cb, GL_STOCK_PIXMAP_IMAGE), - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Create barcode object"), - gl_tools_barcode_cb, GL_STOCK_PIXMAP_BARCODE), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Zoom in"), - gl_tools_zoomin_cb, GL_STOCK_PIXMAP_ZOOMIN), - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Zoom out"), - gl_tools_zoomout_cb, GL_STOCK_PIXMAP_ZOOMOUT), - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Zoom to 1:1"), - gl_tools_zoom1to1_cb, - GL_STOCK_PIXMAP_ZOOM1TO1), - - GNOMEUIINFO_SEPARATOR, - - GNOMEUIINFO_ITEM_STOCK (NULL, N_("Merge properties"), - gl_tools_merge_properties_cb, - GL_STOCK_PIXMAP_MERGE), - - GNOMEUIINFO_END -}; - - -/****************************************************************************/ -/* Install menus templates in mdi. */ -/****************************************************************************/ -void -gl_menu_install_menus (GnomeMDI * mdi) -{ - gnome_mdi_set_menubar_template (mdi, menu_main); - gnome_mdi_set_child_list_path (mdi, GNOME_MENU_WINDOWS_PATH); -} - -/****************************************************************************/ -/* Install toolbar in application window. */ -/****************************************************************************/ -void -gl_menu_install_toolbar (GnomeMDI * mdi) -{ - gnome_mdi_set_toolbar_template (mdi, toolbar); -} - -/*****************************************************************************/ -/* Install drawing tools toolbar in application window. */ -/*****************************************************************************/ -void -gl_menu_install_tools_toolbar (GnomeMDI * mdi, - GnomeApp * app) -{ - GtkWidget *toolbar; - - toolbar = gtk_toolbar_new (GTK_ORIENTATION_VERTICAL, - GTK_TOOLBAR_ICONS); - - gnome_app_fill_toolbar_with_data (GTK_TOOLBAR (toolbar), tools_toolbar, - NULL, mdi); - gnome_app_add_toolbar (GNOME_APP (app), GTK_TOOLBAR (toolbar), - "ToolsToolbar", GNOME_DOCK_ITEM_BEH_NORMAL, - GNOME_DOCK_LEFT, 1, 1, 0); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE about menu callback. */ -/*--------------------------------------------------------------------------*/ -static void -about_cb (GtkWidget * widget, - gpointer data) -{ - static GtkWidget *dialog = NULL; - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - - if (dialog != NULL) { - g_assert (GTK_WIDGET_REALIZED (dialog)); - gdk_window_show (dialog->window); - gdk_window_raise (dialog->window); - } else { - const gchar *authors[] = { - "Jim Evins <evins@snaught.com>", - NULL - }; - gchar *copy_text = "Copyright 2001 Jim Evins"; - gchar *about_text = - _("A label and business card creation program for GNOME.\n" - " \n" - "Glabels is free software; you can redistribute it and/or modify it " - "under the terms of the GNU General Public License as published by " - "the Free Software Foundation; either version 2 of the License, or " - "(at your option) any later version.\n" " \n" - "This program is distributed in the hope that it will be useful, but " - "WITHOUT ANY WARRANTY; without even the implied warranty of " - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU " - "General Public License for more details.\n"); - - dialog = gnome_about_new ("glabels", VERSION, - copy_text, authors, about_text, - LOGO_PIXMAP); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (app)); - - gtk_signal_connect (GTK_OBJECT (dialog), "destroy", - GTK_SIGNAL_FUNC (gtk_widget_destroyed), - &dialog); - - gtk_widget_show (dialog); - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. place-holder callback. */ -/*--------------------------------------------------------------------------*/ -static void -nothing_cb (GtkWidget * widget, - gpointer data) -{ - GtkWidget *dialog; - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - - dialog = gnome_ok_dialog (_("Function is not implemented!")); - gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (app)); -} diff --git a/glabels1/src/menu.h b/glabels1/src/menu.h deleted file mode 100644 index 01e119d..0000000 --- a/glabels1/src/menu.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * menu.h: Menu module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __MENU_H__ -#define __MENU_H__ - -#include <gnome.h> - -extern void gl_menu_install_menus (GnomeMDI * mdi); -extern void gl_menu_install_toolbar (GnomeMDI * mdi); -extern void gl_menu_install_tools_toolbar (GnomeMDI * mdi, GnomeApp * app); - - -#endif diff --git a/glabels1/src/merge.c b/glabels1/src/merge.c deleted file mode 100644 index 603ae25..0000000 --- a/glabels1/src/merge.c +++ /dev/null @@ -1,460 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge.c: document merge module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <gnome.h> - -#include "merge.h" -#include "merge_text.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ -typedef struct { - gchar *short_text; - gchar *long_text; -} TypeTexts; - -typedef struct { - - glMergeInput * (*open) (glMergeType, GList *, gchar *); - void (*close) (glMergeInput *); - glMergeRecord * (*get_record) (glMergeInput *); - GList * (*get_raw_record) (glMergeInput *); - -} BackendFunctions; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static TypeTexts type_text[GL_MERGE_N_TYPES]; - -static BackendFunctions func[GL_MERGE_N_TYPES]; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - - -/*****************************************************************************/ -/* Initialize module. */ -/*****************************************************************************/ -void -gl_merge_init (void) -{ - gint i; - - /* Register backend functions and data. */ - - i = GL_MERGE_NONE; - func[i].open = NULL; - func[i].close = NULL; - func[i].get_record = NULL; - func[i].get_raw_record = NULL; - type_text[i].short_text = "None"; - type_text[i].long_text = _("None"); - - i = GL_MERGE_TEXT_TAB; - func[i].open = gl_merge_text_open; - func[i].close = gl_merge_text_close; - func[i].get_record = gl_merge_text_get_record; - func[i].get_raw_record = gl_merge_text_get_raw_record; - type_text[i].short_text = "Text/Tab"; - type_text[i].long_text = _("Text with tab separators"); - - i = GL_MERGE_TEXT_COMMA; - func[i].open = gl_merge_text_open; - func[i].close = gl_merge_text_close; - func[i].get_record = gl_merge_text_get_record; - func[i].get_raw_record = gl_merge_text_get_raw_record; - type_text[i].short_text = "Text/Comma"; - type_text[i].long_text = _("Text with comma separators (CSV)"); - - i = GL_MERGE_TEXT_COLON; - func[i].open = gl_merge_text_open; - func[i].close = gl_merge_text_close; - func[i].get_record = gl_merge_text_get_record; - func[i].get_raw_record = gl_merge_text_get_raw_record; - type_text[i].short_text = "Text/Colon"; - type_text[i].long_text = _("Text with colon separators"); - -} - -/*****************************************************************************/ -/* Lookup type from short text. */ -/*****************************************************************************/ -glMergeType -gl_merge_text_to_type (gchar * text) -{ - glMergeType type; - - for (type = 0; type < GL_MERGE_N_TYPES; type++) { - if (g_strcasecmp (text, type_text[type].short_text) == 0) { - return type; - } - } - - return GL_MERGE_NONE; - -} - -/*****************************************************************************/ -/* Lookup short text for given type. */ -/*****************************************************************************/ -gchar * -gl_merge_type_to_text (glMergeType type) -{ - return g_strdup (type_text[type].short_text); -} - -/*****************************************************************************/ -/* Lookup type from long descriptive text. */ -/*****************************************************************************/ -glMergeType -gl_merge_long_text_to_type (gchar * text) -{ - glMergeType type; - - for (type = 0; type < GL_MERGE_N_TYPES; type++) { - if (g_strcasecmp (text, type_text[type].long_text) == 0) { - return type; - } - } - - return GL_MERGE_NONE; -} - -/*****************************************************************************/ -/* Lookup longer, more descriptive text for given type. */ -/*****************************************************************************/ -gchar * -gl_merge_type_to_long_text (glMergeType type) -{ - return g_strdup (type_text[type].long_text); -} - -/*****************************************************************************/ -/* Retrieve a list of descriptive texts for all available types. */ -/*****************************************************************************/ -GList * -gl_merge_get_long_texts_list (void) -{ - glMergeType type; - GList *list = NULL; - - for (type = 0; type < GL_MERGE_N_TYPES; type++) { - - list = g_list_append (list, gl_merge_type_to_long_text (type)); - - } - - return list; -} - -/*****************************************************************************/ -/* Free list of descriptive texts. */ -/*****************************************************************************/ -void -gl_merge_free_long_texts_list (GList ** list) -{ - GList *p; - - for (p = *list; p != NULL; p = p->next) { - g_free (p->data); - p->data = NULL; - } - - g_list_free (*list); - *list = NULL; -} - -/*****************************************************************************/ -/* Free list of field definitions. */ -/*****************************************************************************/ -void -gl_merge_free_field_def_list (GList ** list) -{ - GList *p; - glMergeFieldDefinition *field_def; - - for (p = *list; p != NULL; p = p->next) { - field_def = (glMergeFieldDefinition *) p->data; - - g_free (field_def->key); - field_def->key = NULL; - g_free (field_def->loc); - field_def->loc = NULL; - - g_free (p->data); - p->data = NULL; - } - - g_list_free (*list); - *list = NULL; - -} - -/*****************************************************************************/ -/* Extract a list of valid keys from field definitions list */ -/*****************************************************************************/ -GList * -gl_merge_get_key_list (GList * field_defs) -{ - GList *p, *keys; - glMergeFieldDefinition *field_def; - - keys = NULL; - for (p = field_defs; p != NULL; p = p->next) { - field_def = (glMergeFieldDefinition *) p->data; - - keys = g_list_append (keys, g_strdup (field_def->key)); - } - - return keys; -} - -/*****************************************************************************/ -/* Free a list of keys. */ -/*****************************************************************************/ -void -gl_merge_free_key_list (GList ** keys) -{ - GList *p; - - for (p = *keys; p != NULL; p = p->next) { - g_free (p->data); - p->data = NULL; - } - - g_list_free (*keys); - *keys = NULL; -} - -/*****************************************************************************/ -/* Lookup key for given locator. */ -/*****************************************************************************/ -gchar * -gl_merge_find_key (GList * field_defs, - gchar * loc) -{ - GList *p; - glMergeFieldDefinition *field_def; - - for (p = field_defs; p != NULL; p = p->next) { - field_def = (glMergeFieldDefinition *) p->data; - - if (strcmp (loc, field_def->loc) == 0) { - return g_strdup (field_def->key); - } - - } - - return NULL; -} - -/*****************************************************************************/ -/* Open merge source front-end. */ -/*****************************************************************************/ -glMergeInput * -gl_merge_open (glMergeType type, - GList * field_defs, - gchar * src) -{ - return func[type].open (type, field_defs, src); -} - -/*****************************************************************************/ -/* Close merge source front-end. */ -/*****************************************************************************/ -void -gl_merge_close (glMergeInput * input) -{ - if ( input != NULL ) { - func[input->type].close (input); - } -} - -/*****************************************************************************/ -/* Get next record from merge source, NULL if exhausted (front-end). */ -/*****************************************************************************/ -glMergeRecord * -gl_merge_get_record (glMergeInput * input) -{ - if ( input == NULL ) { - return NULL; - } - return func[input->type].get_record (input); -} - -/*****************************************************************************/ -/* Get next record (raw) from merge source, NULL if exhausted (front-end). */ -/*****************************************************************************/ -GList * -gl_merge_get_raw_record (glMergeInput * input) -{ - if ( input == NULL ) { - return NULL; - } - return func[input->type].get_raw_record (input); -} - -/*****************************************************************************/ -/* Free a merge record (list of fields) */ -/*****************************************************************************/ -void -gl_merge_free_record (glMergeRecord ** record) -{ - GList *p; - glMergeField *field; - - for (p = (*record)->field_list; p != NULL; p = p->next) { - field = (glMergeField *) p->data; - - g_free (field->key); - field->key = NULL; - g_free (field->value); - field->value = NULL; - - g_free (p->data); - p->data = NULL; - - } - g_list_free ((*record)->field_list); - (*record)->field_list = NULL; - - g_free (*record); - *record = NULL; -} - -/*****************************************************************************/ -/* Free a merge record (list of fields) */ -/*****************************************************************************/ -void -gl_merge_free_raw_record (GList ** record) -{ - GList *p; - glMergeRawField *field; - - for (p = *record; p != NULL; p = p->next) { - field = (glMergeRawField *) p->data; - - g_free (field->loc); - field->loc = NULL; - g_free (field->value); - field->value = NULL; - - g_free (p->data); - p->data = NULL; - - } - - g_list_free (*record); - *record = NULL; -} - -/*****************************************************************************/ -/* Find key in given record and evaluate. */ -/*****************************************************************************/ -extern gchar * -gl_merge_eval_key (gchar * key, - glMergeRecord * record) -{ - GList *p; - glMergeField *field; - - if ( record != NULL ) { - for (p = record->field_list; p != NULL; p = p->next) { - field = (glMergeField *) p->data; - - if (strcmp (key, field->key) == 0) { - return g_strdup (field->value); - } - - } - } - return NULL; -} - -/*****************************************************************************/ -/* Read all records from merge source. */ -/*****************************************************************************/ -GList * -gl_merge_read_data(glMergeType type, - GList *field_defs, - gchar *src) -{ - glMergeInput *mp; - glMergeRecord *record; - GList *record_list = NULL; - - mp = gl_merge_open (type, field_defs, src); - while ( (record = gl_merge_get_record (mp)) != NULL ) { - record_list = g_list_append( record_list, record ); - } - gl_merge_close(mp); - - return record_list; -} - -/*****************************************************************************/ -/* Free a list of records. */ -/*****************************************************************************/ -void -gl_merge_free_data (GList ** record_list) -{ - GList *p; - glMergeRecord *record; - - for (p = *record_list; p != NULL; p = p->next) { - record = (glMergeRecord *) p->data; - - gl_merge_free_record( &record ); - - } - - g_list_free (*record_list); - *record_list = NULL; -} - -/*****************************************************************************/ -/* Count selected records. */ -/*****************************************************************************/ -gint -gl_merge_count_records (GList *record_list) -{ - GList *p; - glMergeRecord *record; - gint count; - - count = 0; - for ( p=record_list; p!=NULL; p=p->next ) { - record = (glMergeRecord *)p->data; - - if ( record->select_flag ) count ++; - } - return count; -} - diff --git a/glabels1/src/merge.h b/glabels1/src/merge.h deleted file mode 100644 index ce87019..0000000 --- a/glabels1/src/merge.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge.h: document merge module header file - * - * Copyright (C) 2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __MERGE_H__ -#define __MERGE_H__ - -#include <glib.h> - -typedef enum { - - GL_MERGE_NONE, - GL_MERGE_TEXT_TAB, - GL_MERGE_TEXT_COMMA, - GL_MERGE_TEXT_COLON, - - GL_MERGE_N_TYPES -} glMergeType; - -typedef struct { - glMergeType type; - GList *field_defs; - gpointer handle; -} glMergeInput; - -typedef struct { - gchar *key; - gchar *loc; -} glMergeFieldDefinition; - -typedef struct { - gchar *loc; - gchar *value; -} glMergeRawField; - -typedef struct { - gchar *key; - gchar *value; -} glMergeField; - -typedef struct { - gboolean select_flag; - GList *field_list; /* List of glMergeFields */ -} glMergeRecord; - -extern void - gl_merge_init (void); - -extern glMergeType gl_merge_text_to_type (gchar * text); -extern gchar *gl_merge_type_to_text (glMergeType type); -extern glMergeType gl_merge_long_text_to_type (gchar * text); -extern gchar *gl_merge_type_to_long_text (glMergeType type); -extern GList *gl_merge_get_long_texts_list (void); -extern void gl_merge_free_long_texts_list (GList ** list); - -extern void gl_merge_free_field_def_list (GList ** field_defs); - -extern GList *gl_merge_get_key_list (GList * field_defs); -extern void gl_merge_free_key_list (GList ** keys); - -extern gchar *gl_merge_find_key (GList * field_defs, gchar * loc); - -extern glMergeInput *gl_merge_open (glMergeType type, GList * field_defs, - gchar * src); -extern void gl_merge_close (glMergeInput * input); -extern glMergeRecord *gl_merge_get_record (glMergeInput * input); -extern GList *gl_merge_get_raw_record (glMergeInput * input); -extern void gl_merge_free_record (glMergeRecord ** record); -extern void gl_merge_free_raw_record (GList ** record); -extern gchar *gl_merge_eval_key (gchar * key, glMergeRecord * record); - -extern GList *gl_merge_read_data (glMergeType type, GList * field_defs, - gchar * src); -extern void gl_merge_free_data (GList **record_list); -extern gint gl_merge_count_records (GList *record_list); - -#endif diff --git a/glabels1/src/merge_properties.c b/glabels1/src/merge_properties.c deleted file mode 100644 index a2fc1c2..0000000 --- a/glabels1/src/merge_properties.c +++ /dev/null @@ -1,258 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge_properties.c: document merge properties dialog module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include <config.h> - -#include "mdi.h" -#include "display.h" -#include "merge.h" -#include "merge_ui.h" -#include "merge_properties.h" - -#include "debug.h" - -/*===========================================*/ -/* Private data types */ -/*===========================================*/ - -typedef struct { - GtkWidget *dialog; - - glDisplay *display; - glLabel *label; - gchar *name; - - GtkWidget *type_entry; - GtkWidget *src_entry; - GtkWidget *field_ws; - - glMergeType src_type; - gchar *field_ws_src; - -} PropertyDialogPassback; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void create_merge_dialog_widgets (GnomeDialog * dialog, - PropertyDialogPassback * data); - -static void type_changed_cb (GtkWidget * widget, PropertyDialogPassback * data); -static void src_changed_cb (GtkWidget * widget, PropertyDialogPassback * data); - -static void ok_cb (GtkWidget * widget, PropertyDialogPassback * data); - -/****************************************************************************/ -/* Launch merge properties dialog. */ -/****************************************************************************/ -void -gl_merge_properties_dialog (glDisplay * display, - gchar * basename) -{ - static PropertyDialogPassback *data = NULL; - GtkWidget *dialog; - - if (data == NULL) { - data = g_new0 (PropertyDialogPassback, 1); - } - - dialog = gnome_dialog_new (_("Edit document-merge properties"), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, NULL); - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (gl_mdi_get_active_window ())); - - data->dialog = dialog; - data->display = display; - data->label = display->label; - data->name = basename; - - data->type_entry = NULL; - data->src_entry = NULL; - data->field_ws = NULL; - - create_merge_dialog_widgets (GNOME_DIALOG (dialog), data); - - gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0, - GTK_SIGNAL_FUNC (ok_cb), data); - - gnome_dialog_button_connect_object (GNOME_DIALOG (dialog), 1, - GTK_SIGNAL_FUNC - (gtk_widget_destroy), - GTK_OBJECT (dialog)); - - gtk_widget_show_all (GTK_WIDGET (dialog)); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Create and add start page to druid. */ -/*--------------------------------------------------------------------------*/ -static void -create_merge_dialog_widgets (GnomeDialog * dialog, - PropertyDialogPassback * data) -{ - GtkWidget *wvbox, *wframe, *whbox, *wtable, *wlabel, *wcombo, *wscroll; - GList *texts; - glMergeType type; - gchar *src; - GList *fields; - - type = data->label->merge_type; - src = data->label->merge_src; - fields = data->label->merge_fields; - - wvbox = dialog->vbox; - - wframe = gtk_frame_new (_("Source")); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - whbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_add (GTK_CONTAINER (wframe), whbox); - - wtable = gtk_table_new (2, 2, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_box_pack_start (GTK_BOX (whbox), wtable, FALSE, FALSE, GNOME_PAD); - - wlabel = gtk_label_new (_("Format:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - - wcombo = gtk_combo_new (); - gtk_widget_set_usize (wcombo, 400, -1); - texts = gl_merge_get_long_texts_list (); - gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), texts); - gl_merge_free_long_texts_list (&texts); - data->type_entry = GTK_COMBO (wcombo)->entry; - gtk_entry_set_editable (GTK_ENTRY (data->type_entry), FALSE); - gtk_table_attach_defaults (GTK_TABLE (wtable), wcombo, 1, 2, 0, 1); - gtk_entry_set_text (GTK_ENTRY (data->type_entry), - gl_merge_type_to_long_text (type)); - - wlabel = gtk_label_new (_("Location:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); - - data->src_entry = gl_merge_ui_src_new (); - gtk_table_attach_defaults (GTK_TABLE (wtable), data->src_entry, 1, 2, 1, - 2); - gl_merge_ui_src_set_type (GL_MERGE_UI_SRC (data->src_entry), type); - gl_merge_ui_src_set_value (GL_MERGE_UI_SRC (data->src_entry), src); - - wframe = gtk_frame_new (_("Fields")); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wscroll = gtk_scrolled_window_new (NULL, NULL); - gtk_container_set_border_width (GTK_CONTAINER (wscroll), 5); - gtk_widget_set_usize (wscroll, 500, 300); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wscroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (wframe), wscroll); - - data->field_ws = gl_merge_ui_field_ws_new (); - gtk_container_set_border_width (GTK_CONTAINER (data->field_ws), 10); - gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS - (data->field_ws), type, src); - gl_merge_ui_field_ws_set_field_defs (GL_MERGE_UI_FIELD_WS - (data->field_ws), fields); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (wscroll), - data->field_ws); - - gtk_signal_connect (GTK_OBJECT (data->type_entry), "changed", - GTK_SIGNAL_FUNC (type_changed_cb), data); - gtk_signal_connect (GTK_OBJECT (data->src_entry), "changed", - GTK_SIGNAL_FUNC (src_changed_cb), data); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. type "changed" callback. */ -/*--------------------------------------------------------------------------*/ -static void -type_changed_cb (GtkWidget * widget, - PropertyDialogPassback * data) -{ - glMergeType type; - gchar *type_text; - - type_text = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry), - 0, -1); - type = gl_merge_long_text_to_type (type_text); - g_free (type_text); - - gl_merge_ui_src_set_type (GL_MERGE_UI_SRC (data->src_entry), type); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. source "changed" callback. */ -/*--------------------------------------------------------------------------*/ -static void -src_changed_cb (GtkWidget * widget, - PropertyDialogPassback * data) -{ - glMergeType type; - gchar *type_text, *src; - - type_text = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry), - 0, -1); - type = gl_merge_long_text_to_type (type_text); - g_free (type_text); - - src = gl_merge_ui_src_get_value (GL_MERGE_UI_SRC (data->src_entry)); - gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS - (data->field_ws), type, src); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. "OK" callback. */ -/*--------------------------------------------------------------------------*/ -static void -ok_cb (GtkWidget * widget, - PropertyDialogPassback * data) -{ - gchar *type_text; - - type_text = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry), - 0, -1); - data->label->merge_type = gl_merge_long_text_to_type (type_text); - g_free (type_text); - - data->label->merge_src = - gl_merge_ui_src_get_value (GL_MERGE_UI_SRC (data->src_entry)); - - gl_merge_free_field_def_list (&data->label->merge_fields); - data->label->merge_fields = - gl_merge_ui_field_ws_get_field_defs (GL_MERGE_UI_FIELD_WS - (data->field_ws)); - - gl_display_set_modified (data->display); - - gtk_widget_destroy (data->dialog); -} diff --git a/glabels1/src/merge_properties.h b/glabels1/src/merge_properties.h deleted file mode 100644 index ba13439..0000000 --- a/glabels1/src/merge_properties.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge_properties.h: document merge properties dialog module header file - * - * Copyright (C) 2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __MERGE_PROPERTIES_H__ -#define __MERGE_PROPERTIES_H__ - -#include <gnome.h> - -extern void gl_merge_properties_dialog (glDisplay * display, gchar * basename); - -#endif diff --git a/glabels1/src/merge_text.c b/glabels1/src/merge_text.c deleted file mode 100644 index c39b05b..0000000 --- a/glabels1/src/merge_text.c +++ /dev/null @@ -1,385 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge_text.c: text-file merge backend module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <gnome.h> - -#include "merge_text.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ -static GList * parse_line ( FILE *handle, gchar delim ); -static void free_fields( GList **fields ); - - -/****************************************************************************/ -/* Open merge source. */ -/****************************************************************************/ -glMergeInput * -gl_merge_text_open (glMergeType type, - GList * field_defs, - gchar * src) -{ - FILE *fp; - glMergeInput *input; - - fp = fopen (src, "r"); - if (fp == NULL) { - return NULL; - } - - input = g_new0 (glMergeInput, 1); - input->type = type; - input->field_defs = field_defs; - input->handle = fp; - - return input; -} - -/****************************************************************************/ -/* Close merge source. */ -/****************************************************************************/ -void -gl_merge_text_close (glMergeInput * input) -{ - if (input != NULL) { - - fclose ((FILE *) input->handle); - g_free (input); - - } -} - -/****************************************************************************/ -/* Get next record from merge source, NULL if no records left (i.e EOF) */ -/****************************************************************************/ -glMergeRecord * -gl_merge_text_get_record (glMergeInput * input) -{ - gchar *loc; - GList *fields, *p; - gint i_field; - glMergeRecord *record = NULL; - glMergeField *field; - - if (input != NULL) { - - switch (input->type) { - case GL_MERGE_TEXT_TAB: - fields = parse_line( input->handle, '\t' ); - break; - case GL_MERGE_TEXT_COLON: - fields = parse_line( input->handle, ':' ); - break; - case GL_MERGE_TEXT_COMMA: - fields = parse_line( input->handle, ',' ); - break; - default: - WARN ("Unexpected merge type"); - return NULL; - } - - if ( fields != NULL ) { - record = g_new0 (glMergeRecord, 1); - record->select_flag = TRUE; - i_field = 1; - for (p=fields; p != NULL; p=p->next) { - loc = g_strdup_printf ("%d", i_field++); - field = g_new0 (glMergeField, 1); - field->value = g_strdup (p->data); - field->key = gl_merge_find_key (input->field_defs, loc); - record->field_list = g_list_append (record->field_list, field); - g_free (loc); - } - free_fields (&fields); - return record; - } - - } - return NULL; -} - -/****************************************************************************/ -/* Retrieve a list of raw fields (columns in this case) */ -/****************************************************************************/ -GList * -gl_merge_text_get_raw_record (glMergeInput * input) -{ - GList *list = NULL; - GList *fields, *p; - gint i_field; - glMergeRawField *raw_field; - - if (input != NULL) { - - switch (input->type) { - case GL_MERGE_TEXT_TAB: - fields = parse_line( input->handle, '\t' ); - break; - case GL_MERGE_TEXT_COLON: - fields = parse_line( input->handle, ':' ); - break; - case GL_MERGE_TEXT_COMMA: - fields = parse_line( input->handle, ',' ); - break; - default: - WARN ("Unexpected merge type"); - return NULL; - } - - if ( fields != NULL ) { - i_field = 1; - for (p=fields; p != NULL; p=p->next) { - raw_field = g_new0 (glMergeRawField, 1); - raw_field->loc = g_strdup_printf ("%d", - i_field++); - raw_field->value = g_strdup (p->data); - list = g_list_append (list, raw_field); - } - free_fields (&fields); - } - - } - return list; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Parse line (quoted values may span multiple lines). */ -/*---------------------------------------------------------------------------*/ -static GList * parse_line ( FILE *handle, - gchar delim ) -{ - GList *list = NULL; - GString *string; - gint c; - enum { BEGIN, NORMAL, NORMAL_ESCAPED, - QUOTED, QUOTED_ESCAPED, QUOTED_QUOTE1, - DONE } state; - - state = BEGIN; - string = g_string_new( "" ); - while ( state != DONE ) { - c=getc (handle); - - switch (state) { - - case BEGIN: - switch (c) { - case '\\': - state = NORMAL_ESCAPED; - break; - case '"': - state = QUOTED; - break; - case '\r': - /* Strip CR. */ - state = NORMAL; - break; - case '\n': - case EOF: - state = DONE; - break; - default: - if ( c != delim ) { - string = g_string_append_c (string, c); - } else { - list = g_list_append (list, - g_strdup (string->str)); - string = g_string_assign( string, "" ); - } - state = NORMAL; - break; - } - break; - - case NORMAL: - switch (c) { - case '\\': - state = NORMAL_ESCAPED; - break; - case '"': - state = QUOTED; - break; - case '\r': - /* Strip CR. */ - break; - case '\n': - case EOF: - list = g_list_append (list, - g_strdup (string->str)); - state = DONE; - break; - default: - if ( c != delim ) { - string = g_string_append_c (string, c); - } else { - list = g_list_append (list, - g_strdup (string->str)); - string = g_string_assign( string, "" ); - } - break; - } - break; - - case NORMAL_ESCAPED: - switch (c) { - case 'n': - string = g_string_append_c (string, '\n'); - state = NORMAL; - break; - case 't': - string = g_string_append_c (string, '\t'); - state = NORMAL; - break; - case '\r': - /* Strip CR, stay ESCAPED. */ - break; - case EOF: - state = DONE; - break; - default: - string = g_string_append_c (string, c); - state = NORMAL; - break; - } - break; - - case QUOTED: - switch (c) { - case '\\': - state = QUOTED_ESCAPED; - break; - case '"': - state = QUOTED_QUOTE1; - break; - case '\r': - /* Strip CR. */ - break; - case EOF: - /* File ended mid way through quoted item */ - list = g_list_append (list, - g_strdup (string->str)); - state = DONE; - break; - default: - string = g_string_append_c (string, c); - break; - } - break; - - case QUOTED_ESCAPED: - switch (c) { - case 'n': - string = g_string_append_c (string, '\n'); - state = QUOTED; - break; - case 't': - string = g_string_append_c (string, '\t'); - state = QUOTED; - break; - case '\r': - /* Strip CR, stay ESCAPED. */ - break; - case EOF: - /* File ended mid way through quoted item */ - list = g_list_append (list, - g_strdup (string->str)); - state = DONE; - break; - default: - string = g_string_append_c (string, c); - state = QUOTED; - break; - } - break; - - case QUOTED_QUOTE1: - switch (c) { - case '"': - /* insert quotes in string, stay quoted. */ - string = g_string_append_c (string, c); - state = QUOTED; - break; - case '\r': - /* Strip CR, return to NORMAL. */ - state = NORMAL; - break; - case '\n': - case EOF: - /* line or file ended after quoted item */ - list = g_list_append (list, - g_strdup (string->str)); - state = DONE; - break; - default: - if ( c != delim ) { - string = g_string_append_c (string, c); - } else { - list = g_list_append (list, - g_strdup (string->str)); - string = g_string_assign( string, "" ); - } - state = NORMAL; - break; - } - break; - - default: - g_assert_not_reached(); - break; - } - - } - g_string_free( string, TRUE ); - - return list; -} - -/*---------------------------------------------------------------------------*/ -/* Free list of fields. */ -/*---------------------------------------------------------------------------*/ -void -free_fields (GList ** list) -{ - GList *p; - - for (p = *list; p != NULL; p = p->next) { - g_free (p->data); - p->data = NULL; - } - - g_list_free (*list); - *list = NULL; -} - diff --git a/glabels1/src/merge_text.h b/glabels1/src/merge_text.h deleted file mode 100644 index b1dddef..0000000 --- a/glabels1/src/merge_text.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge_text.h: text-file merge backend module header file - * - * Copyright (C) 2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __MERGE_TEXT_H__ -#define __MERGE_TEXT_H__ - -#include <gtk/gtk.h> - -#include "merge.h" - -extern glMergeInput *gl_merge_text_open (glMergeType type, GList * field_defs, - gchar * src); -extern void gl_merge_text_close (glMergeInput * input); -extern glMergeRecord *gl_merge_text_get_record (glMergeInput * input); -extern GList *gl_merge_text_get_raw_record (glMergeInput * input); - -#endif diff --git a/glabels1/src/merge_ui.c b/glabels1/src/merge_ui.c deleted file mode 100644 index fb42254..0000000 --- a/glabels1/src/merge_ui.c +++ /dev/null @@ -1,498 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge_ui.c: document merge user interface module - * - * Copyright (C) 2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include <config.h> - -#include "merge_ui.h" - -/* Backends */ -#include "merge_ui_text.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef struct { - - GtkWidget * (*src_new) (glMergeType); - void (*src_set_value) (); - gchar * (*src_get_value) (); - - GtkWidget * (*field_ws_new) (glMergeType, gchar *); - void (*field_ws_set_field_defs) (); - GList * (*field_ws_get_field_defs) (); - -} BackendFunctions; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint merge_ui_src_signals[LAST_SIGNAL] = { 0 }; -static gint merge_ui_field_ws_signals[LAST_SIGNAL] = { 0 }; - -static BackendFunctions func[GL_MERGE_N_TYPES]; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_merge_ui_src_class_init (glMergeUISrcClass * class); -static void gl_merge_ui_src_init (glMergeUISrc * src); -static void gl_merge_ui_src_destroy (GtkObject * object); - -static void src_changed_cb (glMergeUISrc * src); - -static void gl_merge_ui_field_ws_class_init (glMergeUIFieldWSClass * class); -static void gl_merge_ui_field_ws_init (glMergeUIFieldWS * field_ws); -static void gl_merge_ui_field_ws_destroy (GtkObject * object); - -static void field_ws_changed_cb (glMergeUIFieldWS * field_ws); - -/*****************************************************************************/ -/* Initialize module. */ -/*****************************************************************************/ -void -gl_merge_ui_init (void) -{ - gint i; - - /* Register backend functions. */ - - i = GL_MERGE_NONE; - func[i].src_new = NULL; - func[i].src_set_value = NULL; - func[i].src_get_value = NULL; - func[i].field_ws_new = NULL; - func[i].field_ws_set_field_defs = NULL; - func[i].field_ws_get_field_defs = NULL; - - i = GL_MERGE_TEXT_TAB; - func[i].src_new = gl_merge_ui_text_src_new; - func[i].src_set_value = gl_merge_ui_text_src_set_value; - func[i].src_get_value = gl_merge_ui_text_src_get_value; - func[i].field_ws_new = gl_merge_ui_text_field_ws_new; - func[i].field_ws_set_field_defs = - gl_merge_ui_text_field_ws_set_field_defs; - func[i].field_ws_get_field_defs = - gl_merge_ui_text_field_ws_get_field_defs; - - i = GL_MERGE_TEXT_COMMA; - func[i].src_new = gl_merge_ui_text_src_new; - func[i].src_set_value = gl_merge_ui_text_src_set_value; - func[i].src_get_value = gl_merge_ui_text_src_get_value; - func[i].field_ws_new = gl_merge_ui_text_field_ws_new; - func[i].field_ws_set_field_defs = - gl_merge_ui_text_field_ws_set_field_defs; - func[i].field_ws_get_field_defs = - gl_merge_ui_text_field_ws_get_field_defs; - - i = GL_MERGE_TEXT_COLON; - func[i].src_new = gl_merge_ui_text_src_new; - func[i].src_set_value = gl_merge_ui_text_src_set_value; - func[i].src_get_value = gl_merge_ui_text_src_get_value; - func[i].field_ws_new = gl_merge_ui_text_field_ws_new; - func[i].field_ws_set_field_defs = - gl_merge_ui_text_field_ws_set_field_defs; - func[i].field_ws_get_field_defs = - gl_merge_ui_text_field_ws_get_field_defs; - -} - -/*****************************************************************************/ -/* Boilerplate Object stuff. */ -/*****************************************************************************/ -guint -gl_merge_ui_src_get_type (void) -{ - static guint merge_ui_src_type = 0; - - if (!merge_ui_src_type) { - GtkTypeInfo merge_ui_src_info = { - "glMergeUISrc", - sizeof (glMergeUISrc), - sizeof (glMergeUISrcClass), - (GtkClassInitFunc) gl_merge_ui_src_class_init, - (GtkObjectInitFunc) gl_merge_ui_src_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - merge_ui_src_type = gtk_type_unique (gtk_vbox_get_type (), - &merge_ui_src_info); - } - - return merge_ui_src_type; -} - -static void -gl_merge_ui_src_class_init (glMergeUISrcClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_merge_ui_src_destroy; - - merge_ui_src_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glMergeUISrcClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, - merge_ui_src_signals, LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_merge_ui_src_init (glMergeUISrc * src) -{ - src->backend_widget = NULL; -} - -static void -gl_merge_ui_src_destroy (GtkObject * object) -{ - glMergeUISrc *src; - glMergeUISrcClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_MERGE_UI_SRC (object)); - - src = GL_MERGE_UI_SRC (object); - class = GL_MERGE_UI_SRC_CLASS (GTK_OBJECT (src)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_merge_ui_src_new (void) -{ - glMergeUISrc *src; - - src = gtk_type_new (gl_merge_ui_src_get_type ()); - - src->type = GL_MERGE_NONE; - src->backend_widget = gtk_label_new (_("N/A")); - gtk_misc_set_alignment (GTK_MISC (src->backend_widget), 0, 0.5); - gtk_box_pack_start (GTK_BOX (src), src->backend_widget, FALSE, FALSE, - 0); - - return GTK_WIDGET (src); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when our backend widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -src_changed_cb (glMergeUISrc * src) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (src), merge_ui_src_signals[CHANGED]); -} - -/*****************************************************************************/ -/* Set type. */ -/*****************************************************************************/ -void -gl_merge_ui_src_set_type (glMergeUISrc * src, - glMergeType type) -{ - - if (type != src->type) { - - gtk_widget_destroy (src->backend_widget); - - src->type = type; - - if (type != GL_MERGE_NONE) { - src->backend_widget = (func[type].src_new) (type); - } else { - src->backend_widget = gtk_label_new (_("N/A")); - gtk_misc_set_alignment (GTK_MISC (src->backend_widget), - 0, 0.5); - } - - gtk_box_pack_start (GTK_BOX (src), src->backend_widget, - FALSE, FALSE, 0); - - if (GTK_WIDGET_VISIBLE (src)) { - gtk_widget_show_all (src->backend_widget); - } - - if (type != GL_MERGE_NONE) { - gtk_signal_connect_object (GTK_OBJECT - (src->backend_widget), - "changed", - GTK_SIGNAL_FUNC - (src_changed_cb), - GTK_OBJECT (src)); - } - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (src), - merge_ui_src_signals[CHANGED]); - } - -} - -/*****************************************************************************/ -/* Set src. */ -/*****************************************************************************/ -void -gl_merge_ui_src_set_value (glMergeUISrc * src, - gchar * text) -{ - glMergeType type; - - type = src->type; - - if (type != GL_MERGE_NONE) { - func[type].src_set_value (src->backend_widget, text); - } else { - return; - } - -} - -/*****************************************************************************/ -/* Get src name. */ -/*****************************************************************************/ -gchar * -gl_merge_ui_src_get_value (glMergeUISrc * src) -{ - glMergeType type; - - type = src->type; - - if (type != GL_MERGE_NONE) { - return func[type].src_get_value (src->backend_widget); - } else { - return NULL; - } - -} - -/*****************************************************************************/ -/* Boilerplate Object stuff. */ -/*****************************************************************************/ -guint -gl_merge_ui_field_ws_get_type (void) -{ - static guint merge_ui_field_ws_type = 0; - - if (!merge_ui_field_ws_type) { - GtkTypeInfo merge_ui_field_ws_info = { - "glMergeUIFieldWS", - sizeof (glMergeUIFieldWS), - sizeof (glMergeUIFieldWSClass), - (GtkClassInitFunc) gl_merge_ui_field_ws_class_init, - (GtkObjectInitFunc) gl_merge_ui_field_ws_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - merge_ui_field_ws_type = gtk_type_unique (gtk_vbox_get_type (), - &merge_ui_field_ws_info); - } - - return merge_ui_field_ws_type; -} - -static void -gl_merge_ui_field_ws_class_init (glMergeUIFieldWSClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_merge_ui_field_ws_destroy; - - merge_ui_field_ws_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glMergeUIFieldWSClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, - merge_ui_field_ws_signals, LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_merge_ui_field_ws_init (glMergeUIFieldWS * field_ws) -{ - field_ws->type = GL_MERGE_NONE; - field_ws->src = NULL; - field_ws->backend_widget = NULL; -} - -static void -gl_merge_ui_field_ws_destroy (GtkObject * object) -{ - glMergeUIFieldWS *field_ws; - glMergeUIFieldWSClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_MERGE_UI_FIELD_WS (object)); - - field_ws = GL_MERGE_UI_FIELD_WS (object); - class = GL_MERGE_UI_FIELD_WS_CLASS (GTK_OBJECT (field_ws)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_merge_ui_field_ws_new (void) -{ - glMergeUIFieldWS *field_ws; - - field_ws = gtk_type_new (gl_merge_ui_field_ws_get_type ()); - - field_ws->type = GL_MERGE_NONE; - field_ws->backend_widget = gtk_label_new (_("N/A")); - gtk_misc_set_alignment (GTK_MISC (field_ws->backend_widget), 0, 0.5); - gtk_box_pack_start (GTK_BOX (field_ws), field_ws->backend_widget, - FALSE, FALSE, 0); - - return GTK_WIDGET (field_ws); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when our backend widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -field_ws_changed_cb (glMergeUIFieldWS * field_ws) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (field_ws), - merge_ui_field_ws_signals[CHANGED]); -} - -/*****************************************************************************/ -/* set type and src data, create appropriate backend widget. */ -/*****************************************************************************/ -void -gl_merge_ui_field_ws_set_type_src (glMergeUIFieldWS * field_ws, - glMergeType type, - gchar * src) -{ - - if (field_ws->src != NULL) - g_free (field_ws->src); - if (field_ws->backend_widget != NULL) { - gtk_widget_destroy (field_ws->backend_widget); - } - - field_ws->type = type; - field_ws->src = g_strdup (src); - - if (type != GL_MERGE_NONE) { - field_ws->backend_widget = - (func[type].field_ws_new) (type, src); - } else { - field_ws->backend_widget = gtk_label_new (_("N/A")); - gtk_misc_set_alignment (GTK_MISC (field_ws->backend_widget), 0, - 0.5); - } - - gtk_box_pack_start (GTK_BOX (field_ws), field_ws->backend_widget, - FALSE, FALSE, 0); - - if (type != GL_MERGE_NONE) { - gtk_signal_connect_object (GTK_OBJECT - (field_ws->backend_widget), - "changed", - GTK_SIGNAL_FUNC - (field_ws_changed_cb), - GTK_OBJECT (field_ws)); - } - - if (GTK_WIDGET_VISIBLE (field_ws)) { - gtk_widget_show_all (field_ws->backend_widget); - } - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (field_ws), - merge_ui_field_ws_signals[CHANGED]); - -} - -/*****************************************************************************/ -/* Set field definitions (associate ids with raw fields). */ -/*****************************************************************************/ -void -gl_merge_ui_field_ws_set_field_defs (glMergeUIFieldWS * field_ws, - GList * field_defs) -{ - glMergeType type; - - type = field_ws->type; - - if (type != GL_MERGE_NONE) { - - (func[type].field_ws_set_field_defs) (field_ws->backend_widget, - field_defs); - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (field_ws), - merge_ui_field_ws_signals[CHANGED]); - - } -} - -/*****************************************************************************/ -/* Get field definitions (associate ids with raw fields). */ -/*****************************************************************************/ -GList * -gl_merge_ui_field_ws_get_field_defs (glMergeUIFieldWS * field_ws) -{ - glMergeType type; - - type = field_ws->type; - - if (type != GL_MERGE_NONE) { - - return (func[type].field_ws_get_field_defs) (field_ws-> - backend_widget); - - } else { - - return NULL; - - } - -} diff --git a/glabels1/src/merge_ui.h b/glabels1/src/merge_ui.h deleted file mode 100644 index e5a7e71..0000000 --- a/glabels1/src/merge_ui.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge_ui.h: document merge user interface module header file - * - * Copyright (C) 2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __MERGE_UI_H__ -#define __MERGE_UI_H__ - -#include <gnome.h> - -#include "merge.h" - -extern void - gl_merge_ui_init (void); - -/*======================================================*/ -/* Merge source selection widget */ -/*======================================================*/ -#define GL_TYPE_MERGE_UI_SRC (gl_merge_ui_src_get_type ()) -#define GL_MERGE_UI_SRC(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_MERGE_UI_SRC, glMergeUISrc )) -#define GL_MERGE_UI_SRC_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_UI_SRC, glMergeUISrcClass)) -#define GL_IS_MERGE_UI_SRC(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_MERGE_UI_SRC)) -#define GL_IS_MERGE_UI_SRC_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_UI_SRC)) - -typedef struct _glMergeUISrc glMergeUISrc; -typedef struct _glMergeUISrcClass glMergeUISrcClass; - -struct _glMergeUISrc { - GtkVBox parent_widget; - - glMergeType type; - GtkWidget *backend_widget; -}; - -struct _glMergeUISrcClass { - GtkVBoxClass parent_class; - - void (*changed) (glMergeUISrc * src, gpointer user_data); -}; - -extern guint gl_merge_ui_src_get_type (void); -extern GtkWidget *gl_merge_ui_src_new (void); -extern void gl_merge_ui_src_set_type (glMergeUISrc * src, glMergeType type); -extern void gl_merge_ui_src_set_value (glMergeUISrc * src, gchar * text); -extern gchar *gl_merge_ui_src_get_value (glMergeUISrc * src); - -/*======================================================*/ -/* Merge field selection/definition widget. */ -/*======================================================*/ -#define GL_TYPE_MERGE_UI_FIELD_WS (gl_merge_ui_field_ws_get_type ()) -#define GL_MERGE_UI_FIELD_WS(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_MERGE_UI_FIELD_WS, glMergeUIFieldWS )) -#define GL_MERGE_UI_FIELD_WS_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_UI_FIELD_WS, glMergeUIFieldWSClass)) -#define GL_IS_MERGE_UI_FIELD_WS(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_MERGE_UI_FIELD_WS)) -#define GL_IS_MERGE_UI_FIELD_WS_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_UI_FIELD_WS)) - -typedef struct _glMergeUIFieldWS glMergeUIFieldWS; -typedef struct _glMergeUIFieldWSClass glMergeUIFieldWSClass; - -struct _glMergeUIFieldWS { - GtkVBox parent_widget; - - glMergeType type; - gchar *src; - GtkWidget *backend_widget; -}; - -struct _glMergeUIFieldWSClass { - GtkVBoxClass parent_class; - - void (*changed) (glMergeUIFieldWS * field_ws, gpointer user_data); -}; - -extern guint gl_merge_ui_field_ws_get_type (void); -extern GtkWidget *gl_merge_ui_field_ws_new (void); -extern void gl_merge_ui_field_ws_set_type_src (glMergeUIFieldWS * field_ws, - glMergeType type, - gchar * src); -extern void gl_merge_ui_field_ws_set_field_defs (glMergeUIFieldWS * field_ws, - GList * field_defs); -extern GList *gl_merge_ui_field_ws_get_field_defs (glMergeUIFieldWS * field_ws); - -#endif diff --git a/glabels1/src/merge_ui_text.c b/glabels1/src/merge_ui_text.c deleted file mode 100644 index 5e7954d..0000000 --- a/glabels1/src/merge_ui_text.c +++ /dev/null @@ -1,449 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge_ui_text.c: text-file document merge user interface backend module - * - * Copyright (C) 2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include <config.h> - -#include "merge_ui_text.h" -#include "merge_text.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef struct { - gchar *loc; - GtkWidget *entry; -} EntryNode; - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint merge_ui_text_src_signals[LAST_SIGNAL] = { 0 }; -static gint merge_ui_text_field_ws_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_merge_ui_text_src_class_init (glMergeUITextSrcClass * class); -static void gl_merge_ui_text_src_init (glMergeUITextSrc * src); -static void gl_merge_ui_text_src_destroy (GtkObject * object); -static void gl_merge_ui_text_src_construct (glMergeUITextSrc * src, - glMergeType type); - -static void src_changed_cb (glMergeUITextSrc * src); - -static void gl_merge_ui_text_field_ws_class_init (glMergeUITextFieldWSClass * class); -static void gl_merge_ui_text_field_ws_init (glMergeUITextFieldWS * field_ws); -static void gl_merge_ui_text_field_ws_destroy (GtkObject * object); -static void gl_merge_ui_text_field_ws_construct (glMergeUITextFieldWS * field_ws, - glMergeType type, - gchar * src); - -static void field_ws_changed_cb (glMergeUITextFieldWS * field_ws); - -/*****************************************************************************/ -/* Boilerplate Object stuff. */ -/*****************************************************************************/ -guint -gl_merge_ui_text_src_get_type (void) -{ - static guint merge_ui_text_src_type = 0; - - if (!merge_ui_text_src_type) { - GtkTypeInfo merge_ui_text_src_info = { - "glMergeUITextSrc", - sizeof (glMergeUITextSrc), - sizeof (glMergeUITextSrcClass), - (GtkClassInitFunc) gl_merge_ui_text_src_class_init, - (GtkObjectInitFunc) gl_merge_ui_text_src_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - merge_ui_text_src_type = gtk_type_unique (gtk_vbox_get_type (), - &merge_ui_text_src_info); - } - - return merge_ui_text_src_type; -} - -static void -gl_merge_ui_text_src_class_init (glMergeUITextSrcClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_merge_ui_text_src_destroy; - - merge_ui_text_src_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glMergeUITextSrcClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, - merge_ui_text_src_signals, LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_merge_ui_text_src_init (glMergeUITextSrc * src) -{ - src->type = GL_MERGE_NONE; - src->entry = NULL; -} - -static void -gl_merge_ui_text_src_destroy (GtkObject * object) -{ - glMergeUITextSrc *src; - glMergeUITextSrcClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_MERGE_UI_TEXT_SRC (object)); - - src = GL_MERGE_UI_TEXT_SRC (object); - class = GL_MERGE_UI_TEXT_SRC_CLASS (GTK_OBJECT (src)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_merge_ui_text_src_new (glMergeType type) -{ - glMergeUITextSrc *src; - - src = gtk_type_new (gl_merge_ui_text_src_get_type ()); - - gl_merge_ui_text_src_construct (src, type); - - return GTK_WIDGET (src); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*---------------------------------------------------------------------------*/ -static void -gl_merge_ui_text_src_construct (glMergeUITextSrc * src, - glMergeType type) -{ - GtkWidget *wvbox, *wentry; - - wvbox = GTK_WIDGET (src); - - src->type = type; - - src->entry = - gnome_file_entry_new (NULL, _("Select merge-database source")); - gtk_box_pack_start (GTK_BOX (wvbox), src->entry, TRUE, TRUE, 0); - - wentry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (src->entry)); - gtk_signal_connect_object (GTK_OBJECT (wentry), "changed", - GTK_SIGNAL_FUNC (src_changed_cb), - GTK_OBJECT (src)); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when our backend widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -src_changed_cb (glMergeUITextSrc * src) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (src), merge_ui_text_src_signals[CHANGED]); -} - -/*****************************************************************************/ -/* Set src name. */ -/*****************************************************************************/ -void -gl_merge_ui_text_src_set_value (glMergeUITextSrc * src, - gchar * text) -{ - GtkWidget *wentry; - - wentry = gnome_file_entry_gtk_entry (GNOME_FILE_ENTRY (src->entry)); - - gtk_entry_set_text (GTK_ENTRY (wentry), text); -} - -/*****************************************************************************/ -/* Get src name. */ -/*****************************************************************************/ -gchar * -gl_merge_ui_text_src_get_value (glMergeUITextSrc * src) -{ - return gnome_file_entry_get_full_path (GNOME_FILE_ENTRY (src->entry), - TRUE); -} - -/*****************************************************************************/ -/* Boilerplate Object stuff. */ -/*****************************************************************************/ -guint -gl_merge_ui_text_field_ws_get_type (void) -{ - static guint merge_ui_text_field_ws_type = 0; - - if (!merge_ui_text_field_ws_type) { - GtkTypeInfo merge_ui_text_field_ws_info = { - "glMergeUITextFieldWS", - sizeof (glMergeUITextFieldWS), - sizeof (glMergeUITextFieldWSClass), - (GtkClassInitFunc) gl_merge_ui_text_field_ws_class_init, - (GtkObjectInitFunc) gl_merge_ui_text_field_ws_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - merge_ui_text_field_ws_type = - gtk_type_unique (gtk_hbox_get_type (), - &merge_ui_text_field_ws_info); - } - - return merge_ui_text_field_ws_type; -} - -static void -gl_merge_ui_text_field_ws_class_init (glMergeUITextFieldWSClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_hbox_get_type ()); - - object_class->destroy = gl_merge_ui_text_field_ws_destroy; - - merge_ui_text_field_ws_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glMergeUITextFieldWSClass, - changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, - merge_ui_text_field_ws_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_merge_ui_text_field_ws_init (glMergeUITextFieldWS * field_ws) -{ - field_ws->type = GL_MERGE_NONE; - field_ws->entry_list = NULL; -} - -static void -gl_merge_ui_text_field_ws_destroy (GtkObject * object) -{ - glMergeUITextFieldWS *field_ws; - glMergeUITextFieldWSClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_MERGE_UI_TEXT_FIELD_WS (object)); - - field_ws = GL_MERGE_UI_TEXT_FIELD_WS (object); - class = GL_MERGE_UI_TEXT_FIELD_WS_CLASS (GTK_OBJECT (field_ws)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_merge_ui_text_field_ws_new (glMergeType type, - gchar * src) -{ - glMergeUITextFieldWS *field_ws; - - field_ws = gtk_type_new (gl_merge_ui_text_field_ws_get_type ()); - - gl_merge_ui_text_field_ws_construct (field_ws, type, src); - - return GTK_WIDGET (field_ws); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_merge_ui_text_field_ws_construct (glMergeUITextFieldWS * field_ws, - glMergeType type, - gchar * src) -{ - GtkWidget *whbox, *wtable, *wlabel, *whline, *wentry; - glMergeInput *mp; - glMergeRawField *sample_field; - GList *sample_field_list=NULL, *p; - gint n_fields, i; - EntryNode *entry_node; - - field_ws->type = type; - field_ws->entry_list = NULL; - - mp = gl_merge_open( type, NULL, src ); - sample_field_list = gl_merge_get_raw_record (mp); - gl_merge_close(mp); - n_fields = g_list_length( sample_field_list ); - - whbox = GTK_WIDGET (field_ws); - - wtable = gtk_table_new (n_fields + 2, 3, FALSE); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 20); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 10); - gtk_box_pack_start (GTK_BOX (whbox), wtable, FALSE, FALSE, GNOME_PAD); - - wlabel = gtk_label_new (_("Column")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 1, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - - wlabel = gtk_label_new (_("Custom field key")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 1, 2, 0, 1); - - wlabel = gtk_label_new (_("Sample data")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 2, 3, 0, 1); - - whline = gtk_hseparator_new (); - gtk_table_attach_defaults (GTK_TABLE (wtable), whline, 0, 1, 1, 2); - whline = gtk_hseparator_new (); - gtk_table_attach_defaults (GTK_TABLE (wtable), whline, 1, 2, 1, 2); - whline = gtk_hseparator_new (); - gtk_table_attach_defaults (GTK_TABLE (wtable), whline, 2, 3, 1, 2); - - for (p = sample_field_list, i = 0; p != NULL; p = p->next, i++) { - sample_field = p->data; - - wlabel = gtk_label_new (sample_field->loc); - gtk_misc_set_alignment (GTK_MISC (wlabel), 1, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, - 0, 1, i + 2, i + 3); - - wentry = gtk_entry_new (); - gtk_entry_set_text (GTK_ENTRY (wentry), sample_field->loc); - gtk_widget_set_usize (wentry, 100, 0); - gtk_table_attach_defaults (GTK_TABLE (wtable), wentry, - 1, 2, i + 2, i + 3); - - gtk_signal_connect_object (GTK_OBJECT (wentry), "changed", - GTK_SIGNAL_FUNC - (field_ws_changed_cb), - GTK_OBJECT (field_ws)); - - wlabel = gtk_label_new (sample_field->value); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL(wlabel), GTK_JUSTIFY_LEFT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, - 2, 3, i + 2, i + 3); - - entry_node = g_new0 (EntryNode, 1); - entry_node->loc = g_strdup (sample_field->loc); - entry_node->entry = wentry; - field_ws->entry_list = - g_list_append (field_ws->entry_list, entry_node); - - } - - gl_merge_free_raw_record (&sample_field_list); - -} - -/*****************************************************************************/ -/* Set field definitions. (associate key with locator) */ -/*****************************************************************************/ -void -gl_merge_ui_text_field_ws_set_field_defs (glMergeUITextFieldWS * field_ws, - GList * field_defs) -{ - GList *p_entry, *p_defs; - EntryNode *entry; - glMergeFieldDefinition *def; - - for (p_entry = field_ws->entry_list; p_entry != NULL; - p_entry = p_entry->next) { - entry = (EntryNode *) p_entry->data; - - for (p_defs = field_defs; p_defs != NULL; p_defs = p_defs->next) { - def = (glMergeFieldDefinition *) p_defs->data; - - if (strcmp (entry->loc, def->loc) == 0) { - gtk_entry_set_text (GTK_ENTRY (entry->entry), - def->key); - } - } - } - -} - -/*****************************************************************************/ -/* Get field definitions. (associate key with locator) */ -/*****************************************************************************/ -GList * -gl_merge_ui_text_field_ws_get_field_defs (glMergeUITextFieldWS * field_ws) -{ - GList *p_entry, *defs_list = NULL; - EntryNode *entry; - glMergeFieldDefinition *def; - - for (p_entry = field_ws->entry_list; p_entry != NULL; - p_entry = p_entry->next) { - entry = (EntryNode *) p_entry->data; - - def = g_new0 (glMergeFieldDefinition, 1); - - def->loc = g_strdup (entry->loc); - def->key = - gtk_editable_get_chars (GTK_EDITABLE (entry->entry), 0, -1); - - defs_list = g_list_append (defs_list, def); - - } - - return defs_list; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when our backend widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -field_ws_changed_cb (glMergeUITextFieldWS * field_ws) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (field_ws), - merge_ui_text_field_ws_signals[CHANGED]); -} diff --git a/glabels1/src/merge_ui_text.h b/glabels1/src/merge_ui_text.h deleted file mode 100644 index 42006f2..0000000 --- a/glabels1/src/merge_ui_text.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * merge_ui_text.h: text-file merge user interface backend header - * - * Copyright (C) 2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __MERGE_UI_TEXT_H__ -#define __MERGE_UI_TEXT_H__ - -#include <gnome.h> - -#include "merge.h" - -/*======================================================*/ -/* Merge source selection widget */ -/*======================================================*/ -#define GL_TYPE_MERGE_UI_TEXT_SRC (gl_merge_ui_text_src_get_type ()) -#define GL_MERGE_UI_TEXT_SRC(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_MERGE_UI_TEXT_SRC, glMergeUITextSrc )) -#define GL_MERGE_UI_TEXT_SRC_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_UI_TEXT_SRC, glMergeUITextSrcClass)) -#define GL_IS_MERGE_UI_TEXT_SRC(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_MERGE_UI_TEXT_SRC)) -#define GL_IS_MERGE_UI_TEXT_SRC_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_UI_TEXT_SRC)) - -typedef struct _glMergeUITextSrc glMergeUITextSrc; -typedef struct _glMergeUITextSrcClass glMergeUITextSrcClass; - -struct _glMergeUITextSrc { - GtkVBox parent_widget; - - glMergeType type; - GtkWidget *entry; -}; - -struct _glMergeUITextSrcClass { - GtkVBoxClass parent_class; - - void (*changed) (glMergeUITextSrc * src, gpointer user_data); -}; - -extern guint gl_merge_ui_text_src_get_type (void); -extern GtkWidget *gl_merge_ui_text_src_new (glMergeType type); -extern void gl_merge_ui_text_src_set_value (glMergeUITextSrc * src, - gchar * text); -extern gchar *gl_merge_ui_text_src_get_value (glMergeUITextSrc * src); - -/*======================================================*/ -/* Merge field selection/definition widget. */ -/*======================================================*/ -#define GL_TYPE_MERGE_UI_TEXT_FIELD_WS (gl_merge_ui_text_field_ws_get_type ()) -#define GL_MERGE_UI_TEXT_FIELD_WS(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_MERGE_UI_TEXT_FIELD_WS, glMergeUITextFieldWS )) -#define GL_MERGE_UI_TEXT_FIELD_WS_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MERGE_UI_TEXT_FIELD_WS, glMergeUITextFieldWSClass)) -#define GL_IS_MERGE_UI_TEXT_FIELD_WS(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_MERGE_UI_TEXT_FIELD_WS)) -#define GL_IS_MERGE_UI_TEXT_FIELD_WS_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MERGE_UI_TEXT_FIELD_WS)) - -typedef struct _glMergeUITextFieldWS glMergeUITextFieldWS; -typedef struct _glMergeUITextFieldWSClass glMergeUITextFieldWSClass; - -struct _glMergeUITextFieldWS { - GtkHBox parent_widget; - - glMergeType type; - GList *entry_list; -}; - -struct _glMergeUITextFieldWSClass { - GtkHBoxClass parent_class; - - void (*changed) (glMergeUITextFieldWS * field_ws, gpointer user_data); -}; - -extern guint gl_merge_ui_text_field_ws_get_type (void); -extern GtkWidget *gl_merge_ui_text_field_ws_new (glMergeType type, - gchar * src); -extern void gl_merge_ui_text_field_ws_set_field_defs (glMergeUITextFieldWS * field_ws, - GList * field_defs); -extern GList *gl_merge_ui_text_field_ws_get_field_defs (glMergeUITextFieldWS * - field_ws); - -#endif diff --git a/glabels1/src/mini_preview.c b/glabels1/src/mini_preview.c deleted file mode 100644 index 21e61fa..0000000 --- a/glabels1/src/mini_preview.c +++ /dev/null @@ -1,498 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * mini_preview.c: mini preview widget module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "mini_preview.h" - -#include "debug.h" - -#define MINI_PREVIEW_MAX_PIXELS 175 - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CLICKED, - PRESSED, - LAST_SIGNAL -}; - - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint mini_preview_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_mini_preview_class_init (glMiniPreviewClass * class); -static void gl_mini_preview_init (glMiniPreview * preview); -static void gl_mini_preview_destroy (GtkObject * object); - -static void gl_mini_preview_construct (glMiniPreview * preview, - gint height, gint width); - -static GList *mini_outline_list_new (GnomeCanvas *canvas, - glTemplate *template); -static void mini_outline_list_free (GList ** list); - -static gint canvas_event_cb (GnomeCanvas * canvas, GdkEvent * event, - gpointer data); - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_mini_preview_get_type (void) -{ - static guint mini_preview_type = 0; - - if (!mini_preview_type) { - GtkTypeInfo mini_preview_info = { - "glMiniPreview", - sizeof (glMiniPreview), - sizeof (glMiniPreviewClass), - (GtkClassInitFunc) gl_mini_preview_class_init, - (GtkObjectInitFunc) gl_mini_preview_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - mini_preview_type = gtk_type_unique (gtk_hbox_get_type (), - &mini_preview_info); - } - - return mini_preview_type; -} - -static void -gl_mini_preview_class_init (glMiniPreviewClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_hbox_get_type ()); - - object_class->destroy = gl_mini_preview_destroy; - - mini_preview_signals[CLICKED] = - gtk_signal_new ("clicked", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glMiniPreviewClass, clicked), - gtk_marshal_NONE__INT, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - mini_preview_signals[PRESSED] = - gtk_signal_new ("pressed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glMiniPreviewClass, pressed), - gtk_marshal_NONE__INT_INT, - GTK_TYPE_NONE, 2, GTK_TYPE_INT, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, mini_preview_signals, - LAST_SIGNAL); - - class->clicked = NULL; - class->pressed = NULL; -} - -static void -gl_mini_preview_init (glMiniPreview * preview) -{ - preview->canvas = NULL; - preview->label_items = NULL; -} - -static void -gl_mini_preview_destroy (GtkObject * object) -{ - glMiniPreview *preview; - glMiniPreviewClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_MINI_PREVIEW (object)); - - preview = GL_MINI_PREVIEW (object); - class = GL_MINI_PREVIEW_CLASS (GTK_OBJECT (preview)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_mini_preview_new (gint height, - gint width) -{ - glMiniPreview *preview; - - preview = gtk_type_new (gl_mini_preview_get_type ()); - - gl_mini_preview_construct (preview, height, width); - - return GTK_WIDGET (preview); -} - -/*--------------------------------------------------------------------------*/ -/* Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_mini_preview_construct (glMiniPreview * preview, - gint height, - gint width) -{ - GtkWidget *whbox; - GnomeCanvasGroup *group; - - whbox = GTK_WIDGET (preview); - - preview->height = height; - preview->width = width; - - /* create canvas */ - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - preview->canvas = gnome_canvas_new_aa (); - gtk_widget_pop_colormap (); - gtk_widget_pop_visual (); - gtk_box_pack_start (GTK_BOX (whbox), preview->canvas, TRUE, TRUE, 0); - gtk_widget_set_usize (preview->canvas, width, height); - gnome_canvas_set_scroll_region (GNOME_CANVAS (preview->canvas), - 0.0, 0.0, width, height); - - /* draw an initial paper outline */ - gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (preview->canvas), 1.0); - group = gnome_canvas_root (GNOME_CANVAS (preview->canvas)); - preview->paper_item = - gnome_canvas_item_new (group, - gnome_canvas_rect_get_type (), - "x1", 0.0, - "y1", 0.0, - "x2", (gdouble)width, - "y2", (gdouble)height, - "width_pixels", 1, - "outline_color", "black", - "fill_color", "white", NULL); - - /* create empty list of label canvas items */ - preview->label_items = NULL; - preview->labels_per_sheet = 0; - - /* Event handler */ - gtk_signal_connect (GTK_OBJECT (preview->canvas), "event", - GTK_SIGNAL_FUNC (canvas_event_cb), preview); - -} - -/****************************************************************************/ -/* Set label for mini-preview to determine geometry. */ -/****************************************************************************/ -void gl_mini_preview_set_label (glMiniPreview * preview, - gchar *name) -{ - glTemplate *template; - const GnomePaper *paper = NULL; - gdouble paper_width, paper_height; - gdouble canvas_scale; - gdouble w, h; - - /* Fetch template */ - template = gl_template_from_name (name); - - /* get paper size and set scale */ - paper = gnome_paper_with_name (template->page_size); - paper_width = gnome_paper_pswidth (paper); - paper_height = gnome_paper_psheight (paper); - w = preview->width - 4; - h = preview->height - 4; - if ( (w/paper_width) > (h/paper_height) ) { - canvas_scale = h / paper_height; - } else { - canvas_scale = w / paper_width; - } - gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (preview->canvas), - canvas_scale); - gnome_canvas_set_scroll_region (GNOME_CANVAS (preview->canvas), - 0.0, 0.0, paper_width, paper_height); - - /* update paper outline */ - gnome_canvas_item_set (preview->paper_item, - "x1", 0.0, - "y1", 0.0, - "x2", paper_width, - "y2", paper_height, - NULL); - - /* update label items */ - mini_outline_list_free (&preview->label_items); - preview->label_items = - mini_outline_list_new (GNOME_CANVAS(preview->canvas), - template); - - gl_template_free( &template ); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Draw label outlines and return canvas item list. */ -/*--------------------------------------------------------------------------*/ -static GList * -mini_outline_list_new (GnomeCanvas * canvas, - glTemplate * template) -{ - GnomeCanvasGroup *group = NULL; - GnomeCanvasItem *item = NULL; - GList *list = NULL; - gint i, ix, iy; - gdouble x1, y1, x2, y2, y_temp; - const GnomePaper *paper = NULL; - gdouble paper_height; - - /* get paper height */ - paper = gnome_paper_with_name (template->page_size); - paper_height = gnome_paper_psheight (paper); - - group = gnome_canvas_root (canvas); - - /* draw mini label outlines */ - i = 1; - for (iy = (template->ny - 1); iy >= 0; iy--) { - for (ix = 0; ix < template->nx; ix++, i++) { - - x1 = ix * (template->dx) + template->x0; - y1 = iy * (template->dy) + template->y0; - x2 = x1 + template->label_width; - y2 = y1 + template->label_height; - - /* transform origin from lower left to upper left */ - /* and swap y's so that (y1 < y2) */ - y_temp = y2; - y2 = paper_height - y1; - y1 = paper_height - y_temp; - - switch (template->style) { - case GL_TEMPLATE_STYLE_RECT: - item = gnome_canvas_item_new (group, - gnome_canvas_rect_get_type(), - "x1", x1, - "y1", y1, - "x2", x2, - "y2", y2, - "width_pixels", 1, - "outline_color", "black", - "fill_color", "white", - NULL); - break; - case GL_TEMPLATE_STYLE_ROUND: - case GL_TEMPLATE_STYLE_CD: - item = gnome_canvas_item_new (group, - gnome_canvas_ellipse_get_type(), - "x1", x1, - "y1", y1, - "x2", x2, - "y2", y2, - "width_pixels", 1, - "outline_color", "black", - "fill_color", "white", - NULL); - break; - default: - WARN ("Unknown label style"); - return list; - break; - } - gtk_object_set_data (GTK_OBJECT (item), "i", - GINT_TO_POINTER (i)); - - list = g_list_append (list, item); - } - } - - return list; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Draw label outlines and return canvas item list. */ -/*--------------------------------------------------------------------------*/ -static void -mini_outline_list_free (GList ** list) -{ - GnomeCanvasItem *item; - GList *p; - - if ( *list != NULL ) { - - for (p = *list; p != NULL; p = p->next) { - item = GNOME_CANVAS_ITEM (p->data); - gtk_object_destroy (GTK_OBJECT (item)); - } - - g_list_free (*list); - *list = NULL; - - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Canvas event handler, select first and last items. */ -/*--------------------------------------------------------------------------*/ -static gint -canvas_event_cb (GnomeCanvas * canvas, - GdkEvent * event, - gpointer data) -{ - glMiniPreview *preview = GL_MINI_PREVIEW (data); - GnomeCanvasItem *item; - static gboolean dragging = FALSE; - static gint prev_i = 0, first, last; - gint i; - gdouble x, y; - - switch (event->type) { - - case GDK_BUTTON_PRESS: - gnome_canvas_window_to_world (canvas, - event->button.x, event->button.y, - &x, &y); - switch (event->button.button) { - case 1: - /* Get item at cursor and make sure - it's a label object ("i" is valid) */ - item = gnome_canvas_get_item_at (GNOME_CANVAS (canvas), - x, y); - if (item == NULL) - break; - i = GPOINTER_TO_INT (gtk_object_get_data - (GTK_OBJECT (item), "i")); - if (i == 0) - break; - /* Go into dragging mode while remains pressed. */ - dragging = TRUE; - gdk_pointer_grab (GTK_WIDGET (canvas)->window, - FALSE, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, NULL, NULL, - event->button.time); - gtk_signal_emit (GTK_OBJECT(preview), - mini_preview_signals[CLICKED], - i); - first = i; - last = i; - gtk_signal_emit (GTK_OBJECT(preview), - mini_preview_signals[PRESSED], - first, last); - prev_i = i; - break; - - default: - break; - } - break; - - case GDK_BUTTON_RELEASE: - gnome_canvas_window_to_world (canvas, - event->button.x, event->button.y, - &x, &y); - switch (event->button.button) { - case 1: - /* Exit dragging mode */ - dragging = FALSE; - gdk_pointer_ungrab (event->button.time); - break; - - default: - break; - } - break; - - case GDK_MOTION_NOTIFY: - gnome_canvas_window_to_world (canvas, - event->motion.x, event->motion.y, - &x, &y); - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - /* Get item at cursor and - make sure it's a label object ("i" is valid) */ - item = gnome_canvas_get_item_at (GNOME_CANVAS (canvas), - x, y); - if (item == NULL) - break; - i = GPOINTER_TO_INT (gtk_object_get_data - (GTK_OBJECT (item), "i")); - if (i == 0) - break; - if (prev_i != i) { - /* Entered into a new item */ - last = i; - gtk_signal_emit (GTK_OBJECT(preview), - mini_preview_signals[PRESSED], - MIN (first, last), - MAX (first, last)); - prev_i = i; - } - } - break; - - default: - break; - } - - return FALSE; - -} - -/****************************************************************************/ -/* Highlight given label outlines. */ -/****************************************************************************/ -void -gl_mini_preview_highlight_range (glMiniPreview * preview, - gint first_label, - gint last_label) -{ - GnomeCanvasItem *item = NULL; - GList *p = NULL; - gint i; - - for (p = preview->label_items, i = 1; p != NULL; i++, p = p->next) { - - item = GNOME_CANVAS_ITEM (p->data); - - if ((i >= first_label) && (i <= last_label)) { - gnome_canvas_item_set (item, - "fill_color", "light blue", - NULL); - } else { - gnome_canvas_item_set (item, - "fill_color", "white", NULL); - } - - } - -} - diff --git a/glabels1/src/mini_preview.h b/glabels1/src/mini_preview.h deleted file mode 100644 index 5c08dea..0000000 --- a/glabels1/src/mini_preview.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * mini_preview.h: mini-preview widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __MINI_PREVIEW_H__ -#define __MINI_PREVIEW_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_MINI_PREVIEW (gl_mini_preview_get_type ()) -#define GL_MINI_PREVIEW(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_MINI_PREVIEW, glMiniPreview )) -#define GL_MINI_PREVIEW_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_MINI_PREVIEW, glMiniPreviewClass)) -#define GL_IS_MINI_PREVIEW(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_MINI_PREVIEW)) -#define GL_IS_MINI_PREVIEW_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_MINI_PREVIEW)) - -typedef struct _glMiniPreview glMiniPreview; -typedef struct _glMiniPreviewClass glMiniPreviewClass; - -struct _glMiniPreview { - GtkHBox parent_widget; - - gint height; - gint width; - - GtkWidget *canvas; - GnomeCanvasItem *paper_item; - - gint labels_per_sheet; - GList *label_items; -}; - -struct _glMiniPreviewClass { - GtkHBoxClass parent_class; - - void (*clicked) (glMiniPreview *preview, - gint index, gpointer user_data); - void (*pressed) (glMiniPreview *preview, - gint index1, gint index2, - gpointer user_data); -}; - -extern guint gl_mini_preview_get_type (void); - -extern GtkWidget *gl_mini_preview_new (gint height, gint width); - -extern void gl_mini_preview_set_label (glMiniPreview * preview, - gchar * name); - -extern void gl_mini_preview_highlight_range (glMiniPreview * preview, - gint first_label, - gint last_label); - -#endif diff --git a/glabels1/src/pixmaps/Makefile.am b/glabels1/src/pixmaps/Makefile.am deleted file mode 100644 index 3d19710..0000000 --- a/glabels1/src/pixmaps/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -EXTRA_DIST = \ - arrow.xpm \ - text.xpm \ - box.xpm \ - line.xpm \ - ellipse.xpm \ - image.xpm \ - barcode.xpm \ - zoomin.xpm \ - zoomout.xpm \ - zoom1to1.xpm \ - merge.xpm \ - collate.xpm \ - nocollate.xpm \ - checkerboard.xpm \ - cursor_text.xbm \ - cursor_text_mask.xbm \ - cursor_box.xbm \ - cursor_box_mask.xbm \ - cursor_line.xbm \ - cursor_line_mask.xbm \ - cursor_ellipse.xbm \ - cursor_ellipse_mask.xbm \ - cursor_image.xbm \ - cursor_image_mask.xbm \ - cursor_barcode.xbm \ - cursor_barcode_mask.xbm \ - cursor_zoomin.xbm \ - cursor_zoomin_mask.xbm \ - cursor_zoomout.xbm \ - cursor_zoomout_mask.xbm - diff --git a/glabels1/src/pixmaps/arrow.xpm b/glabels1/src/pixmaps/arrow.xpm deleted file mode 100644 index 60e9e66..0000000 --- a/glabels1/src/pixmaps/arrow.xpm +++ /dev/null @@ -1,29 +0,0 @@ -/* XPM */ -static char *arrow_xpm[]={ -"24 24 2 1", -". c None", -"# c #000000", -"........................", -"........................", -"........................", -".......#................", -".......##...............", -".......###..............", -".......####.............", -".......#####............", -".......######...........", -".......#######..........", -".......########.........", -".......#####............", -".......##.##............", -".......#...##...........", -"...........##...........", -"............##..........", -"............##..........", -"........................", -"........................", -"........................", -"........................", -"........................", -"........................", -"........................"}; diff --git a/glabels1/src/pixmaps/barcode.xpm b/glabels1/src/pixmaps/barcode.xpm deleted file mode 100644 index 9ac1581..0000000 --- a/glabels1/src/pixmaps/barcode.xpm +++ /dev/null @@ -1,29 +0,0 @@ -/* XPM */ -static char *barcode_xpm[]={ -"24 24 2 1", -". c None", -"# c #000000", -"........................", -"........................", -"........................", -"........................", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"...#.##.##.#.#.#.##.#...", -"........................", -"........................", -"........................", -"........................"}; diff --git a/glabels1/src/pixmaps/box.xpm b/glabels1/src/pixmaps/box.xpm deleted file mode 100644 index b744068..0000000 --- a/glabels1/src/pixmaps/box.xpm +++ /dev/null @@ -1,30 +0,0 @@ -/* XPM */ -static char *box_xpm[]={ -"24 24 3 1", -". c None", -"# c #000000", -"a c #ede5cf", -"........................", -"........................", -"........................", -"........................", -"...##################...", -"...##################...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##################...", -"...##################...", -"........................", -"........................", -"........................", -"........................"}; diff --git a/glabels1/src/pixmaps/checkerboard.xpm b/glabels1/src/pixmaps/checkerboard.xpm deleted file mode 100644 index 33ab7b5..0000000 --- a/glabels1/src/pixmaps/checkerboard.xpm +++ /dev/null @@ -1,29 +0,0 @@ -/* XPM */ -static char * checkerboard_xpm[] = { -"24 24 2 1", -" c #CCCCCC", -". c #000000", -".. .. .. .. .. .. ", -".. .. .. .. .. .. ", -" .. .. .. .. .. ..", -" .. .. .. .. .. ..", -".. .. .. .. .. .. ", -".. .. .. .. .. .. ", -" .. .. .. .. .. ..", -" .. .. .. .. .. ..", -".. .. .. .. .. .. ", -".. .. .. .. .. .. ", -" .. .. .. .. .. ..", -" .. .. .. .. .. ..", -".. .. .. .. .. .. ", -".. .. .. .. .. .. ", -" .. .. .. .. .. ..", -" .. .. .. .. .. ..", -".. .. .. .. .. .. ", -".. .. .. .. .. .. ", -" .. .. .. .. .. ..", -" .. .. .. .. .. ..", -".. .. .. .. .. .. ", -".. .. .. .. .. .. ", -" .. .. .. .. .. ..", -" .. .. .. .. .. .."}; diff --git a/glabels1/src/pixmaps/collate.xpm b/glabels1/src/pixmaps/collate.xpm deleted file mode 100644 index a781151..0000000 --- a/glabels1/src/pixmaps/collate.xpm +++ /dev/null @@ -1,34 +0,0 @@ -/* XPM */ -static char *collate_xpm[]={ -"58 28 3 1", -". c None", -"# c #000000", -"a c #ffffff", -"..........................................................", -".###################..###################.................", -".#aaaaaaaaaaaaaaaaa#..#aaaaaaaaaaaaaaaaa#.................", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaa##aaaaaaaa#.................", -".#aaaaaaa##aaaaaaaa#..#aaaaaa#aa#aaaaaaa#.................", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaaaa#aaaaaaa#..##..##..##.....", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaaa#aaaaaaaa#..##..##..##.....", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaa#aaaaaaaaa#.................", -".#aaaaaaaa#aaaaaaaa#..#aaaaaa#aaaaaaaaaa#.................", -".#aaaaaaa###aaaaaaa#..#aaaaaa####aaaaaaa#.................", -".#aaaaaaaaaaaaaaaaa#..#aaaaaaaaaaaaaaaaa#.................", -".###################..###################.................", -"..........................................................", -"..........................................................", -"..........................................................", -".................###################..###################.", -".................#aaaaaaaaaaaaaaaaa#..#aaaaaaaaaaaaaaaaa#.", -".................#aaaaaaaa#aaaaaaaa#..#aaaaaaa##aaaaaaaa#.", -".................#aaaaaaa##aaaaaaaa#..#aaaaaa#aa#aaaaaaa#.", -"....##..##..##...#aaaaaaaa#aaaaaaaa#..#aaaaaaaaa#aaaaaaa#.", -"....##..##..##...#aaaaaaaa#aaaaaaaa#..#aaaaaaaa#aaaaaaaa#.", -".................#aaaaaaaa#aaaaaaaa#..#aaaaaaa#aaaaaaaaa#.", -".................#aaaaaaaa#aaaaaaaa#..#aaaaaa#aaaaaaaaaa#.", -".................#aaaaaaa###aaaaaaa#..#aaaaaa####aaaaaaa#.", -".................#aaaaaaaaaaaaaaaaa#..#aaaaaaaaaaaaaaaaa#.", -".................###################..###################.", -"..........................................................", -".........................................................."}; diff --git a/glabels1/src/pixmaps/cursor_barcode.xbm b/glabels1/src/pixmaps/cursor_barcode.xbm deleted file mode 100644 index 6e8d1d6..0000000 --- a/glabels1/src/pixmaps/cursor_barcode.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_barcode_width 32 -#define cursor_barcode_height 32 -#define cursor_barcode_x_hot 7 -#define cursor_barcode_y_hot 7 -static unsigned char cursor_barcode_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, - 0x00, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, - 0x00, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, - 0x00, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, - 0x00, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, 0x00, 0xa0, 0xad, 0x5a, - 0x00, 0xa0, 0xad, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_barcode_mask.xbm b/glabels1/src/pixmaps/cursor_barcode_mask.xbm deleted file mode 100644 index 52ed3ba..0000000 --- a/glabels1/src/pixmaps/cursor_barcode_mask.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_barcode_mask_width 32 -#define cursor_barcode_mask_height 32 -#define cursor_barcode_mask_x_hot 7 -#define cursor_barcode_mask_y_hot 7 -static unsigned char cursor_barcode_mask_bits[] = { - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0xf1, 0xff, 0xff, 0xc0, 0xf1, 0xff, 0xff, 0xc0, 0xf1, 0xff, 0xff, - 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, - 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, - 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, - 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, - 0x00, 0xf0, 0xff, 0xff, 0x00, 0xf0, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_box.xbm b/glabels1/src/pixmaps/cursor_box.xbm deleted file mode 100644 index 48ae4ea..0000000 --- a/glabels1/src/pixmaps/cursor_box.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_box_width 32 -#define cursor_box_height 32 -#define cursor_box_x_hot 7 -#define cursor_box_y_hot 7 -static unsigned char cursor_box_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x80, 0xff, 0x7f, 0x00, 0x80, 0xff, 0x7f, 0x00, 0x80, 0x01, 0x60, - 0x00, 0x80, 0x01, 0x60, 0x00, 0x80, 0x01, 0x60, 0x00, 0x80, 0x01, 0x60, - 0x00, 0x80, 0x01, 0x60, 0x00, 0x80, 0x01, 0x60, 0x00, 0x80, 0x01, 0x60, - 0x00, 0x80, 0x01, 0x60, 0x00, 0x80, 0x01, 0x60, 0x00, 0x80, 0x01, 0x60, - 0x00, 0x80, 0x01, 0x60, 0x00, 0x80, 0x01, 0x60, 0x00, 0x80, 0xff, 0x7f, - 0x00, 0x80, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_box_mask.xbm b/glabels1/src/pixmaps/cursor_box_mask.xbm deleted file mode 100644 index b41e055..0000000 --- a/glabels1/src/pixmaps/cursor_box_mask.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_box_mask_width 32 -#define cursor_box_mask_height 32 -#define cursor_box_mask_x_hot 7 -#define cursor_box_mask_y_hot 7 -static unsigned char cursor_box_mask_bits[] = { - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0xc1, 0xff, 0xff, - 0x00, 0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, - 0x00, 0xc0, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, - 0x00, 0xc0, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, - 0x00, 0xc0, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, 0x00, 0xc0, 0x03, 0xf0, - 0x00, 0xc0, 0x03, 0xf0, 0x00, 0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff, - 0x00, 0xc0, 0xff, 0xff, 0x00, 0xc0, 0xff, 0xff}; diff --git a/glabels1/src/pixmaps/cursor_ellipse.xbm b/glabels1/src/pixmaps/cursor_ellipse.xbm deleted file mode 100644 index 946af9a..0000000 --- a/glabels1/src/pixmaps/cursor_ellipse.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_ellipse_width 32 -#define cursor_ellipse_height 32 -#define cursor_ellipse_x_hot 7 -#define cursor_ellipse_y_hot 7 -static unsigned char cursor_ellipse_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x7c, 0x00, 0x80, 0x00, 0xef, 0x01, 0x00, 0x80, 0x01, 0x03, - 0x00, 0xc0, 0x00, 0x06, 0x00, 0x60, 0x00, 0x0c, 0x00, 0x20, 0x00, 0x08, - 0x00, 0x30, 0x00, 0x18, 0x00, 0x30, 0x00, 0x18, 0x00, 0x10, 0x00, 0x10, - 0x00, 0x30, 0x00, 0x18, 0x00, 0x30, 0x00, 0x18, 0x00, 0x20, 0x00, 0x08, - 0x00, 0x60, 0x00, 0x0c, 0x00, 0xc0, 0x00, 0x06, 0x00, 0x80, 0x01, 0x03, - 0x00, 0x00, 0xef, 0x01, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_ellipse_mask.xbm b/glabels1/src/pixmaps/cursor_ellipse_mask.xbm deleted file mode 100644 index 22fb544..0000000 --- a/glabels1/src/pixmaps/cursor_ellipse_mask.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_ellipse_mask_width 32 -#define cursor_ellipse_mask_height 32 -#define cursor_ellipse_mask_x_hot 7 -#define cursor_ellipse_mask_y_hot 7 -static unsigned char cursor_ellipse_mask_bits[] = { - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0xfe, 0x00, - 0xc0, 0x81, 0xff, 0x03, 0xc0, 0xc1, 0xff, 0x07, 0xc0, 0xe1, 0xff, 0x0f, - 0x00, 0xf0, 0x83, 0x1f, 0x00, 0xf0, 0x01, 0x1f, 0x00, 0xf8, 0x00, 0x3e, - 0x00, 0x78, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x3c, - 0x00, 0x78, 0x00, 0x3c, 0x00, 0x78, 0x00, 0x3c, 0x00, 0xf8, 0x00, 0x3e, - 0x00, 0xf0, 0x01, 0x1f, 0x00, 0xf0, 0x83, 0x1f, 0x00, 0xe0, 0xff, 0x0f, - 0x00, 0xc0, 0xff, 0x07, 0x00, 0x80, 0xff, 0x03, 0x00, 0x00, 0xfe, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_image.xbm b/glabels1/src/pixmaps/cursor_image.xbm deleted file mode 100644 index 3230836..0000000 --- a/glabels1/src/pixmaps/cursor_image.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_image_width 32 -#define cursor_image_height 32 -#define cursor_image_x_hot 7 -#define cursor_image_y_hot 7 -static unsigned char cursor_image_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0xf0, 0xff, 0x7f, 0x80, 0x10, 0x00, 0x40, 0x00, 0x10, 0x00, 0x40, - 0x00, 0x10, 0x00, 0x4c, 0x00, 0x10, 0x00, 0x52, 0x00, 0x10, 0x08, 0x4c, - 0x00, 0x10, 0x14, 0x40, 0x00, 0x10, 0x22, 0x40, 0x00, 0x10, 0x41, 0x40, - 0x00, 0x90, 0xc1, 0x40, 0x00, 0x10, 0x41, 0x40, 0x00, 0xf0, 0xc1, 0x7f, - 0x00, 0x10, 0x41, 0x40, 0x00, 0x10, 0x41, 0x40, 0x00, 0x10, 0x41, 0x40, - 0x00, 0x10, 0x7f, 0x40, 0x00, 0x10, 0x00, 0x40, 0x00, 0x10, 0x00, 0x40, - 0x00, 0xf0, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_image_mask.xbm b/glabels1/src/pixmaps/cursor_image_mask.xbm deleted file mode 100644 index 9c79e82..0000000 --- a/glabels1/src/pixmaps/cursor_image_mask.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_image_mask_width 32 -#define cursor_image_mask_height 32 -#define cursor_image_mask_x_hot 7 -#define cursor_image_mask_y_hot 7 -static unsigned char cursor_image_mask_bits[] = { - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0xf9, 0xff, 0xff, - 0xc0, 0xf9, 0xff, 0xff, 0xc0, 0xf9, 0xff, 0xff, 0xc0, 0xf9, 0xff, 0xff, - 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, - 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, - 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, - 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, - 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff, - 0x00, 0xf8, 0xff, 0xff, 0x00, 0xf8, 0xff, 0xff}; diff --git a/glabels1/src/pixmaps/cursor_line.xbm b/glabels1/src/pixmaps/cursor_line.xbm deleted file mode 100644 index f5e2636..0000000 --- a/glabels1/src/pixmaps/cursor_line.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_line_width 32 -#define cursor_line_height 32 -#define cursor_line_x_hot 7 -#define cursor_line_y_hot 7 -static unsigned char cursor_line_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x08, - 0x80, 0x00, 0x00, 0x0c, 0x80, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x60, 0x00, - 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x0c, 0x00, - 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x01, 0x00, - 0x00, 0xc0, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, - 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_line_mask.xbm b/glabels1/src/pixmaps/cursor_line_mask.xbm deleted file mode 100644 index a9359d5..0000000 --- a/glabels1/src/pixmaps/cursor_line_mask.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_line_mask_width 32 -#define cursor_line_mask_height 32 -#define cursor_line_mask_x_hot 7 -#define cursor_line_mask_y_hot 7 -static unsigned char cursor_line_mask_bits[] = { - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x08, 0xc0, 0x01, 0x00, 0x1c, - 0xc0, 0x01, 0x00, 0x1e, 0xc0, 0x01, 0x00, 0x0f, 0xc0, 0x01, 0x80, 0x07, - 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0xf0, 0x00, - 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x1e, 0x00, - 0x00, 0x00, 0x0f, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0xc0, 0x03, 0x00, - 0x00, 0xe0, 0x01, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, - 0x00, 0x3c, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_text.xbm b/glabels1/src/pixmaps/cursor_text.xbm deleted file mode 100644 index 4378c1a..0000000 --- a/glabels1/src/pixmaps/cursor_text.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_text_width 32 -#define cursor_text_height 32 -#define cursor_text_x_hot 7 -#define cursor_text_y_hot 7 -static unsigned char cursor_text_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0xfe, 0x3f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x01, - 0x00, 0xc0, 0x9c, 0x01, 0x00, 0x40, 0x1c, 0x01, 0x00, 0x00, 0x1c, 0x00, - 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, - 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, - 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3e, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_text_mask.xbm b/glabels1/src/pixmaps/cursor_text_mask.xbm deleted file mode 100644 index 543c2b7..0000000 --- a/glabels1/src/pixmaps/cursor_text_mask.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_text_mask_width 32 -#define cursor_text_mask_height 32 -#define cursor_text_mask_x_hot 7 -#define cursor_text_mask_y_hot 7 -static unsigned char cursor_text_mask_bits[] = { - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, - 0xc0, 0x01, 0x00, 0x00, 0xc0, 0xe1, 0xff, 0x03, 0xc0, 0xe1, 0xff, 0x03, - 0x00, 0xe0, 0xff, 0x03, 0x00, 0xe0, 0xbe, 0x03, 0x00, 0x60, 0x3e, 0x03, - 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, - 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, - 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x00, - 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_zoomin.xbm b/glabels1/src/pixmaps/cursor_zoomin.xbm deleted file mode 100644 index beb1545..0000000 --- a/glabels1/src/pixmaps/cursor_zoomin.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_zoomin_width 32 -#define cursor_zoomin_height 32 -#define cursor_zoomin_x_hot 8 -#define cursor_zoomin_y_hot 8 -static unsigned char cursor_zoomin_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, - 0x30, 0x0c, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x88, 0x31, 0x00, 0x00, - 0x84, 0x21, 0x00, 0x00, 0xe4, 0x27, 0x00, 0x00, 0xe4, 0x27, 0x00, 0x00, - 0x84, 0x21, 0x00, 0x00, 0x8c, 0x11, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, - 0x30, 0x0c, 0x00, 0x00, 0xe0, 0x37, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0xe0, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x03, 0x00, - 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1c, 0x00, - 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_zoomin_mask.xbm b/glabels1/src/pixmaps/cursor_zoomin_mask.xbm deleted file mode 100644 index cada016..0000000 --- a/glabels1/src/pixmaps/cursor_zoomin_mask.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_zoomin_mask_width 32 -#define cursor_zoomin_mask_height 32 -#define cursor_zoomin_mask_x_hot 8 -#define cursor_zoomin_mask_y_hot 8 -static unsigned char cursor_zoomin_mask_bits[] = { - 0xc0, 0x03, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, - 0xfc, 0x3f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, - 0xfc, 0x3f, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, - 0xc0, 0xf3, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, - 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3e, 0x00, - 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_zoomout.xbm b/glabels1/src/pixmaps/cursor_zoomout.xbm deleted file mode 100644 index c8fac13..0000000 --- a/glabels1/src/pixmaps/cursor_zoomout.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_zoomout_width 32 -#define cursor_zoomout_height 32 -#define cursor_zoomout_x_hot 8 -#define cursor_zoomout_y_hot 8 -static unsigned char cursor_zoomout_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, - 0x30, 0x0c, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, 0x08, 0x30, 0x00, 0x00, - 0x04, 0x20, 0x00, 0x00, 0xe4, 0x27, 0x00, 0x00, 0xe4, 0x27, 0x00, 0x00, - 0x04, 0x20, 0x00, 0x00, 0x0c, 0x10, 0x00, 0x00, 0x08, 0x10, 0x00, 0x00, - 0x30, 0x0c, 0x00, 0x00, 0xe0, 0x37, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, - 0x00, 0xe0, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x03, 0x00, - 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x1c, 0x00, - 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/cursor_zoomout_mask.xbm b/glabels1/src/pixmaps/cursor_zoomout_mask.xbm deleted file mode 100644 index aadc97d..0000000 --- a/glabels1/src/pixmaps/cursor_zoomout_mask.xbm +++ /dev/null @@ -1,16 +0,0 @@ -#define cursor_zoomout_mask_width 32 -#define cursor_zoomout_mask_height 32 -#define cursor_zoomout_mask_x_hot 8 -#define cursor_zoomout_mask_y_hot 8 -static unsigned char cursor_zoomout_mask_bits[] = { - 0xc0, 0x03, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0xf8, 0x1f, 0x00, 0x00, - 0xfc, 0x3f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, - 0xff, 0xff, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, - 0xfc, 0x3f, 0x00, 0x00, 0xf8, 0x7f, 0x00, 0x00, 0xf0, 0xff, 0x00, 0x00, - 0xc0, 0xf3, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x07, 0x00, - 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x3e, 0x00, - 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/glabels1/src/pixmaps/ellipse.xpm b/glabels1/src/pixmaps/ellipse.xpm deleted file mode 100644 index f186186..0000000 --- a/glabels1/src/pixmaps/ellipse.xpm +++ /dev/null @@ -1,30 +0,0 @@ -/* XPM */ -static char *ellipse_xpm[]={ -"24 24 3 1", -". c None", -"# c #000000", -"a c #ede5cf", -"........................", -"........................", -"........................", -".........######.........", -".......##########.......", -"......###aaaaaa###......", -".....##aaaaaaaaa###.....", -"....###aaaaaaaaaaa##....", -"....##aaaaaaaaaaaa##....", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"...##aaaaaaaaaaaaaa##...", -"....##aaaaaaaaaaaa##....", -"....##aaaaaaaaaaa###....", -".....###aaaaaaaaa##.....", -"......###aaaaaa###......", -".......##########.......", -".........######.........", -"........................", -"........................", -"........................"}; diff --git a/glabels1/src/pixmaps/image.xpm b/glabels1/src/pixmaps/image.xpm deleted file mode 100644 index 116c20d..0000000 --- a/glabels1/src/pixmaps/image.xpm +++ /dev/null @@ -1,42 +0,0 @@ -/* XPM */ -static char *image_xpm[]={ -"24 24 15 1", -". c None", -"# c #000000", -"i c #004000", -"f c #008000", -"e c #00c000", -"d c #00ff00", -"k c #404000", -"a c #58a8ff", -"h c #a0a0a0", -"g c #a8dcff", -"j c #c0ffff", -"l c #ff0000", -"b c #ffff00", -"c c #ffffc0", -"m c #ffffff", -"........................", -"........................", -"..####################..", -"..#aaaaaaaaaaaaaaaaaa#..", -"..#aaaaaaaaaaaabbaaaa#..", -"..#aaaaaa#aaaabbbbaaa#..", -"..#aaaaa#c#aaaabbaaaa#..", -"..#aaaa#ccc#aaaaaadef#..", -"..#aga#cchcc#agagdeei#..", -"..#ga##cchcc##agaeefi#..", -"..#ggg#ccccc#gggggfii#..", -"..#jjj#ccccc#jjjjjjij#..", -"..#####chchc#######k##..", -"..#eee#chchc#eeeeeeke#..", -"..#eee#chccc#eeelelke#..", -"..#ffe#chccc#eleieike#..", -"..#eee#######eeieilei#..", -"..#feeeemeeeeeieeeeie#..", -"..#eeeeemmmmmmmmmeeee#..", -"..#eeeeeeeeeeeeemmeee#..", -"..#eeeeeeeeeeeeeemeee#..", -"..####################..", -"........................", -"........................"}; diff --git a/glabels1/src/pixmaps/line.xpm b/glabels1/src/pixmaps/line.xpm deleted file mode 100644 index 37a24c9..0000000 --- a/glabels1/src/pixmaps/line.xpm +++ /dev/null @@ -1,29 +0,0 @@ -/* XPM */ -static char *line_xpm[]={ -"24 24 2 1", -". c None", -"# c #000000", -"........................", -"........................", -"........................", -"........................", -"...................#....", -"..................##....", -".................##.....", -"................##......", -"...............##.......", -"..............##........", -".............##.........", -"............##..........", -"...........##...........", -"..........##............", -".........##.............", -"........##..............", -".......##...............", -"......##................", -".....##.................", -"....##..................", -"....#...................", -"........................", -"........................", -"........................"}; diff --git a/glabels1/src/pixmaps/merge.xpm b/glabels1/src/pixmaps/merge.xpm deleted file mode 100644 index 6fd5f8f..0000000 --- a/glabels1/src/pixmaps/merge.xpm +++ /dev/null @@ -1,34 +0,0 @@ -/* XPM */ -static char *merge_xpm[]={ -"24 24 7 1", -". c None", -"# c #000000", -"c c #585858", -"d c #a0a0a0", -"a c #c0c000", -"b c #ffffc0", -"e c #ffffff", -"........................", -"........................", -"....##########..........", -"...##abbbbbbb#c.........", -"..#d#dbbbbbbb#c.........", -".####acdbcbcb#c.........", -".#adadbbbbbbe#c.........", -".#bccbcbcdecb#c.........", -".#bbbbbebebbe#c.........", -".#bcb##############.....", -".#bbb#eeeeeeeeeeee#.....", -".#bcd#e##############...", -".#bbb#e#eeeeeeeeeeee#...", -".#bcb#e#e##############.", -".#bbb#e#e#eeeeeeeeeeee#.", -".#bcb###e#eeeeeeeeeeee#.", -".#bbebb#e#eeeeeeeeeeee#.", -".#bccbb###eeeeeeeeeeee#.", -".#bbbebeb#eeeeeeeeeeee#.", -".#bcbbcce##############.", -".#ebebebebeee#c.........", -".#############c.........", -"..ccccccccccccc.........", -"........................"}; diff --git a/glabels1/src/pixmaps/nocollate.xpm b/glabels1/src/pixmaps/nocollate.xpm deleted file mode 100644 index a67cc13..0000000 --- a/glabels1/src/pixmaps/nocollate.xpm +++ /dev/null @@ -1,34 +0,0 @@ -/* XPM */ -static char *nocollate_xpm[]={ -"58 28 3 1", -". c None", -"# c #000000", -"a c #ffffff", -"..........................................................", -".###################..###################.................", -".#aaaaaaaaaaaaaaaaa#..#aaaaaaaaaaaaaaaaa#.................", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaaa#aaaaaaaa#.................", -".#aaaaaaa##aaaaaaaa#..#aaaaaaa##aaaaaaaa#.................", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaaa#aaaaaaaa#..##..##..##.....", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaaa#aaaaaaaa#..##..##..##.....", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaaa#aaaaaaaa#.................", -".#aaaaaaaa#aaaaaaaa#..#aaaaaaaa#aaaaaaaa#.................", -".#aaaaaaa###aaaaaaa#..#aaaaaaa###aaaaaaa#.................", -".#aaaaaaaaaaaaaaaaa#..#aaaaaaaaaaaaaaaaa#.................", -".###################..###################.................", -"..........................................................", -"..........................................................", -"..........................................................", -".................###################..###################.", -".................#aaaaaaaaaaaaaaaaa#..#aaaaaaaaaaaaaaaaa#.", -".................#aaaaaaaa##aaaaaaa#..#aaaaaaaa##aaaaaaa#.", -".................#aaaaaaa#aa#aaaaaa#..#aaaaaaa#aa#aaaaaa#.", -"....##..##..##...#aaaaaaaaaa#aaaaaa#..#aaaaaaaaaa#aaaaaa#.", -"....##..##..##...#aaaaaaaaa#aaaaaaa#..#aaaaaaaaa#aaaaaaa#.", -".................#aaaaaaaa#aaaaaaaa#..#aaaaaaaa#aaaaaaaa#.", -".................#aaaaaaa#aaaaaaaaa#..#aaaaaaa#aaaaaaaaa#.", -".................#aaaaaaa####aaaaaa#..#aaaaaaa####aaaaaa#.", -".................#aaaaaaaaaaaaaaaaa#..#aaaaaaaaaaaaaaaaa#.", -".................###################..###################.", -"..........................................................", -".........................................................."}; diff --git a/glabels1/src/pixmaps/text.xpm b/glabels1/src/pixmaps/text.xpm deleted file mode 100644 index 499d740..0000000 --- a/glabels1/src/pixmaps/text.xpm +++ /dev/null @@ -1,29 +0,0 @@ -/* XPM */ -static char *text_xpm[]={ -"24 24 2 1", -". c None", -"# c #000000", -"........................", -"........................", -"........................", -"........................", -"........................", -"......###########.......", -"......##..###..##.......", -"......#...###...#.......", -"..........###...........", -"..........###...........", -"..........###...........", -"..........###...........", -"..........###...........", -"..........###...........", -"..........###...........", -"..........###...........", -"..........###...........", -".........#####..........", -"........................", -"........................", -"........................", -"........................", -"........................", -"........................"}; diff --git a/glabels1/src/pixmaps/zoom1to1.xpm b/glabels1/src/pixmaps/zoom1to1.xpm deleted file mode 100644 index 956f402..0000000 --- a/glabels1/src/pixmaps/zoom1to1.xpm +++ /dev/null @@ -1,30 +0,0 @@ -/* XPM */ -static char *zoom1to1_xpm[]={ -"24 24 3 1", -". c None", -"# c #000000", -"a c #00ff00", -"........................", -"........................", -"........................", -"........................", -"......###.......###.....", -".....#aa#......#aa#.....", -".....#aa#......#aa#.....", -".....##a#......##a#.....", -"......#a#.......#a#.....", -"......#a#..###..#a#.....", -"......#a#..#a#..#a#.....", -"......#a#..#a#..#a#.....", -"......#a#..###..#a#.....", -"......#a#.......#a#.....", -"......#a#.......#a#.....", -"......#a#.......#a#.....", -"......#a#..###..#a#.....", -"......#a#..#a#..#a#.....", -"......#a#..#a#..#a#.....", -"......###..###..###.....", -"........................", -"........................", -"........................", -"........................"}; diff --git a/glabels1/src/pixmaps/zoomin.xpm b/glabels1/src/pixmaps/zoomin.xpm deleted file mode 100644 index 88f8b4d..0000000 --- a/glabels1/src/pixmaps/zoomin.xpm +++ /dev/null @@ -1,38 +0,0 @@ -/* XPM */ -static char *zoomin_xpm[]={ -"24 24 11 1", -". c None", -"# c #000000", -"c c #0058c0", -"e c #00ff00", -"i c #404000", -"g c #58a8ff", -"f c #a8dcff", -"h c #c0c000", -"a c #c0ffff", -"b c #ffffc0", -"d c #ffffff", -"........................", -"........................", -"........................", -".......######...........", -"......##aaaaa##.........", -".....#aaaaaaaa##........", -"....##aab###aaac#.......", -"....#aabd#e#aafa##......", -"...#aaddd#e#faffa#......", -"...#aa####e####ga#......", -"...#ad#eeeeeee#ga#......", -"...#ad####e####ga#......", -"...#aaaff#e#fffga#......", -"...##aaaf#e#fgga#.......", -"....#aaff###ggaa#.......", -".....##afggggaa####.....", -"......##aaaaa##.#hb#....", -"........######..#ihb#...", -"................d#ihb#..", -".................d#ihb#.", -"..................d#ihb.", -"...................d#i..", -"....................d...", -"........................"}; diff --git a/glabels1/src/pixmaps/zoomout.xpm b/glabels1/src/pixmaps/zoomout.xpm deleted file mode 100644 index a1f8e86..0000000 --- a/glabels1/src/pixmaps/zoomout.xpm +++ /dev/null @@ -1,37 +0,0 @@ -/* XPM */ -static char *zoomout_xpm[]={ -"24 24 10 1", -". c None", -"# c #000000", -"f c #00ff00", -"h c #404000", -"e c #58a8ff", -"c c #a8dcff", -"g c #c0c000", -"a c #c0ffff", -"b c #ffffc0", -"d c #ffffff", -"........................", -"........................", -"........................", -".......######...........", -"......##aaaaa##.........", -".....#aaaaaaaa##........", -"....##aabbacaaaa#.......", -"....#aabdcacaaca##......", -"...#aadddccccacca#......", -"...#aa#########ea#......", -"...#ad#fffffff#ea#......", -"...#ad#########ea#......", -"...#aaaccccccccea#......", -"...##aaaccccceea#.......", -"....#aaccccceeaa#.......", -".....##aceeeeaa####.....", -"......##aaaaa##.#gb#....", -"........######..#hgb#...", -"................d#hgb#..", -".................d#hgb#.", -"..................d#hgb.", -"...................d#h..", -"....................d...", -"........................"}; diff --git a/glabels1/src/prefs.c b/glabels1/src/prefs.c deleted file mode 100644 index 8e76eec..0000000 --- a/glabels1/src/prefs.c +++ /dev/null @@ -1,470 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prefs.c: Application preferences module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include <config.h> - -#include "mdi.h" -#include "propertybox.h" -#include "prefs.h" - -#include "debug.h" - -/*============================================*/ -/* Private types. */ -/*============================================*/ - -typedef struct { - glPrefsUnits default_units; - gchar *default_page_size; -} Prefs; - -/*============================================*/ -/* Private globals. */ -/*============================================*/ -static GtkWidget *dialog = NULL; - -static Prefs *prefs = NULL; - -static GtkWidget *unit_pts_radio, *unit_inches_radio, *unit_mm_radio; -static GtkWidget *page_size_us_letter_radio, *page_size_a4_radio; - -/*============================================*/ -/* Private function prototypes. */ -/*============================================*/ -static void apply_cb (glPropertyBox * propertybox, gint arg1, gpointer user_data); - -static void prefs_destroy_cb (void); - -static void prefs_changed_cb (void); - -static Prefs *read_prefs (void); - -static void sync_prefs (Prefs * p); - -static void free_prefs (Prefs * p); - -static void add_general_page (GtkWidget * dialog); - -static void set_general_page_from_prefs (Prefs * p); - -static void set_prefs_from_general_page (Prefs * p); - -/****************************************************************************/ -/* Create and display preferences dialog. */ -/****************************************************************************/ -void -gl_prefs_cb (GtkWidget * widget, - gpointer data) -{ - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - - if (prefs == NULL) { - prefs = read_prefs (); - } - - if (dialog == NULL) { - dialog = gl_property_box_new (); - gtk_window_set_title (GTK_WINDOW (dialog), - _("Glabels: Preferences")); - gtk_window_set_transient_for (GTK_WINDOW (dialog), - GTK_WINDOW (app)); - - add_general_page (dialog); - - gtk_signal_connect (GTK_OBJECT (dialog), "destroy", - GTK_SIGNAL_FUNC (prefs_destroy_cb), NULL); - - gtk_signal_connect (GTK_OBJECT (dialog), "delete_event", - GTK_SIGNAL_FUNC (prefs_destroy_cb), NULL); - - gtk_signal_connect (GTK_OBJECT (dialog), "apply", - GTK_SIGNAL_FUNC (apply_cb), NULL); - - gtk_widget_show_all (GTK_WIDGET (dialog)); - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. "Apply" button callback. */ -/*--------------------------------------------------------------------------*/ -static void -apply_cb (glPropertyBox * propertybox, - gint arg1, - gpointer user_data) -{ - set_prefs_from_general_page (prefs); - sync_prefs (prefs); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback to finish cleaning up after tearing down dialog. */ -/*--------------------------------------------------------------------------*/ -static void -prefs_destroy_cb (void) -{ - dialog = NULL; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the dialog has changed. */ -/*--------------------------------------------------------------------------*/ -static void -prefs_changed_cb (void) -{ - gl_property_box_changed (GL_PROPERTY_BOX (dialog)); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Read and set preferences from disk. */ -/*--------------------------------------------------------------------------*/ -static Prefs * -read_prefs (void) -{ - Prefs *p; - gchar *string; - gboolean dflt; - - p = g_new0 (Prefs, 1); - - gnome_config_push_prefix ("/glabels/General/"); - - string = gnome_config_get_string_with_default ("Units=Inches", &dflt); - if (dflt) - gnome_config_set_string ("Units", "Inches"); - if (g_strcasecmp (string, "Points") == 0) { - p->default_units = GL_PREFS_UNITS_PTS; - } else if (g_strcasecmp (string, "Inches") == 0) { - p->default_units = GL_PREFS_UNITS_INCHES; - } else if (g_strcasecmp (string, "Millimeters") == 0) { - p->default_units = GL_PREFS_UNITS_MM; - } - g_free (string); - - p->default_page_size = - gnome_config_get_string_with_default ("Page_size=US-Letter", &dflt); - if (dflt) - gnome_config_set_string ("Page_size", "US-Letter"); - - gnome_config_pop_prefix (); - - return p; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Sync preferences with disk. */ -/*--------------------------------------------------------------------------*/ -static void -sync_prefs (Prefs * p) -{ - gnome_config_push_prefix ("/glabels/General/"); - switch (p->default_units) { - case GL_PREFS_UNITS_PTS: - gnome_config_set_string ("Units", "Points"); - break; - case GL_PREFS_UNITS_INCHES: - gnome_config_set_string ("Units", "Inches"); - break; - case GL_PREFS_UNITS_MM: - gnome_config_set_string ("Units", "Millimeters"); - break; - default: - WARN ("Illegal units"); - break; - } - gnome_config_set_string ("Page_size", p->default_page_size); - gnome_config_pop_prefix (); - gnome_config_sync (); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Free previously allocated preferences structure. */ -/*--------------------------------------------------------------------------*/ -static void -free_prefs (Prefs * p) -{ - g_free (p); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Create and add the general page tab with controls to the dialog.*/ -/*--------------------------------------------------------------------------*/ -static void -add_general_page (GtkWidget * dialog) -{ - GtkWidget *wframe, *wlabel, *wvbox, *wvbox1; - GSList *radio_group = NULL; - - wlabel = gtk_label_new (_("General")); - - wvbox = gtk_vbox_new (FALSE, 0); - - /* ----- Display Units Frame ------------------------------------ */ - wframe = gtk_frame_new (_("Display units")); - gtk_container_set_border_width (GTK_CONTAINER (wframe), 10); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wvbox1 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox1), 10); - gtk_container_add (GTK_CONTAINER (wframe), wvbox1); - - radio_group = NULL; - - unit_pts_radio = - gtk_radio_button_new_with_label (radio_group, _("Points")); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (unit_pts_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), unit_pts_radio, FALSE, FALSE, 0); - - unit_inches_radio = - gtk_radio_button_new_with_label (radio_group, _("Inches")); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (unit_inches_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), unit_inches_radio, FALSE, FALSE, - 0); - - unit_mm_radio = - gtk_radio_button_new_with_label (radio_group, _("Millimeters")); - radio_group = gtk_radio_button_group (GTK_RADIO_BUTTON (unit_mm_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), unit_mm_radio, FALSE, FALSE, 0); - - /* ----- Display Units Frame ------------------------------------ */ - wframe = gtk_frame_new (_("Default page size")); - gtk_container_set_border_width (GTK_CONTAINER (wframe), 10); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wvbox1 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox1), 10); - gtk_container_add (GTK_CONTAINER (wframe), wvbox1); - - radio_group = NULL; - - page_size_us_letter_radio = - gtk_radio_button_new_with_label (radio_group, "US-Letter"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON - (page_size_us_letter_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), page_size_us_letter_radio, FALSE, - FALSE, 0); - - page_size_a4_radio = - gtk_radio_button_new_with_label (radio_group, "A4"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (page_size_a4_radio)); - gtk_box_pack_start (GTK_BOX (wvbox1), page_size_a4_radio, - FALSE, FALSE, 0); - - gl_property_box_append_page (GL_PROPERTY_BOX (dialog), wvbox, wlabel); - - set_general_page_from_prefs (prefs); - - gtk_signal_connect (GTK_OBJECT (unit_pts_radio), "toggled", - GTK_SIGNAL_FUNC (prefs_changed_cb), NULL); - gtk_signal_connect (GTK_OBJECT (unit_inches_radio), "toggled", - GTK_SIGNAL_FUNC (prefs_changed_cb), NULL); - gtk_signal_connect (GTK_OBJECT (unit_mm_radio), "toggled", - GTK_SIGNAL_FUNC (prefs_changed_cb), NULL); - - gtk_signal_connect (GTK_OBJECT (page_size_us_letter_radio), "toggled", - GTK_SIGNAL_FUNC (prefs_changed_cb), NULL); - gtk_signal_connect (GTK_OBJECT (page_size_a4_radio), "toggled", - GTK_SIGNAL_FUNC (prefs_changed_cb), NULL); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Initialize general tab controls from current prefs. */ -/*--------------------------------------------------------------------------*/ -static void -set_general_page_from_prefs (Prefs * p) -{ - switch (p->default_units) { - case GL_PREFS_UNITS_PTS: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (unit_pts_radio), TRUE); - break; - case GL_PREFS_UNITS_INCHES: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (unit_inches_radio), TRUE); - break; - case GL_PREFS_UNITS_MM: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (unit_mm_radio), - TRUE); - break; - default: - WARN ("Illegal units"); - break; - } - - if (g_strcasecmp (p->default_page_size, "US-Letter") == 0) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (page_size_us_letter_radio), - TRUE); - } else if (g_strcasecmp (p->default_page_size, "A4") == 0) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (page_size_a4_radio), TRUE); - } else { - WARN ("Illegal page size: %s", p->default_page_size); - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Set current preferences based on general controls. */ -/*--------------------------------------------------------------------------*/ -static void -set_prefs_from_general_page (Prefs * p) -{ - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (unit_pts_radio))) { - p->default_units = GL_PREFS_UNITS_PTS; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (unit_inches_radio))) { - p->default_units = GL_PREFS_UNITS_INCHES; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (unit_mm_radio))) { - p->default_units = GL_PREFS_UNITS_MM; - } - - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (page_size_us_letter_radio))) { - g_free (p->default_page_size); - p->default_page_size = g_strdup ("US-Letter"); - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (page_size_a4_radio))) { - g_free (p->default_page_size); - p->default_page_size = g_strdup ("A4"); - } - -} - -/****************************************************************************/ -/* Get desired units. */ -/****************************************************************************/ -glPrefsUnits -gl_prefs_get_units(void) -{ - return prefs->default_units; -} - -/****************************************************************************/ -/* Get desired units per point. */ -/****************************************************************************/ -gdouble -gl_prefs_get_units_per_point (void) -{ - if (prefs == NULL) { - prefs = read_prefs (); - } - - switch (prefs->default_units) { - case GL_PREFS_UNITS_PTS: - return 1.0; /* points */ - case GL_PREFS_UNITS_INCHES: - return 1.0 / 72.0; /* inches */ - case GL_PREFS_UNITS_MM: - return 0.35277778; /* mm */ - default: - WARN ("Illegal units"); /* Should not happen */ - return 1.0; - } -} - -/****************************************************************************/ -/* Get precision for desired units. */ -/****************************************************************************/ -gint -gl_prefs_get_units_precision (void) -{ - if (prefs == NULL) { - prefs = read_prefs (); - } - - switch (prefs->default_units) { - case GL_PREFS_UNITS_PTS: - return 1; /* points */ - case GL_PREFS_UNITS_INCHES: - return 3; /* inches */ - case GL_PREFS_UNITS_MM: - return 1; /* mm */ - default: - WARN ("Illegal units"); /* Should not happen */ - return 1.0; - } -} - -/****************************************************************************/ -/* Get step size for desired units. */ -/****************************************************************************/ -gdouble -gl_prefs_get_units_step_size (void) -{ - if (prefs == NULL) { - prefs = read_prefs (); - } - - switch (prefs->default_units) { - case GL_PREFS_UNITS_PTS: - return 0.1; /* points */ - case GL_PREFS_UNITS_INCHES: - return 0.001; /* inches */ - case GL_PREFS_UNITS_MM: - return 0.1; /* mm */ - default: - WARN ("Illegal units"); /* Should not happen */ - return 1.0; - } -} - -/****************************************************************************/ -/* Get string representing desired units. */ -/****************************************************************************/ -const gchar * -gl_prefs_get_units_string (void) -{ - if (prefs == NULL) { - prefs = read_prefs (); - } - - switch (prefs->default_units) { - case GL_PREFS_UNITS_PTS: - return _("points"); - case GL_PREFS_UNITS_INCHES: - return _("inches"); - case GL_PREFS_UNITS_MM: - return _("mm"); - default: - WARN ("Illegal units"); /* Should not happen */ - return _("points"); - } -} - -/****************************************************************************/ -/* Get default page size. */ -/****************************************************************************/ -const gchar * -gl_prefs_get_page_size (void) -{ - if (prefs == NULL) { - prefs = read_prefs (); - } - - return prefs->default_page_size; -} diff --git a/glabels1/src/prefs.h b/glabels1/src/prefs.h deleted file mode 100644 index a279d58..0000000 --- a/glabels1/src/prefs.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prefs.h: Application preferences module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PREFS_H__ -#define __PREFS_H__ - -#include <gnome.h> - -typedef enum { - GL_PREFS_UNITS_PTS, - GL_PREFS_UNITS_INCHES, - GL_PREFS_UNITS_MM, -} glPrefsUnits; - -extern void gl_prefs_cb (GtkWidget * widget, gpointer data); - -extern glPrefsUnits gl_prefs_get_units(void); - -extern gdouble gl_prefs_get_units_per_point (void); - -extern gint gl_prefs_get_units_precision (void); - -extern gdouble gl_prefs_get_units_step_size (void); - -extern const gchar *gl_prefs_get_units_string (void); - -extern const gchar *gl_prefs_get_page_size (void); - -#endif /* __PREFS_H__ */ diff --git a/glabels1/src/print.c b/glabels1/src/print.c deleted file mode 100644 index 29e8aa7..0000000 --- a/glabels1/src/print.c +++ /dev/null @@ -1,869 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print.c: Print module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include <config.h> - -#include <math.h> -#include <time.h> -#include <ctype.h> -#include <libgnome/gnome-paper.h> -#include <libgnomeprint/gnome-printer.h> - -#include "print.h" -#include "label.h" -#include "bc.h" -#include "template.h" -#include "hack.h" - -#include "debug.h" - -#define GL_PRINT_DEFAULT_PAPER "US-Letter" - -#define RED(x) ( (((x)>>24) & 0xff) / 255.0 ) -#define GREEN(x) ( (((x)>>16) & 0xff) / 255.0 ) -#define BLUE(x) ( (((x)>>8) & 0xff) / 255.0 ) -#define ALPHA(x) ( ( (x) & 0xff) / 255.0 ) - -/*===========================================*/ -/* Private types. */ -/*===========================================*/ -typedef struct _PrintInfo { - /* gnome print context */ - GnomePrintContext *pc; - - /* gLabels Template */ - glTemplate *template; - gboolean label_rotate_flag; - -} PrintInfo; - -/*===========================================*/ -/* Private function prototypes. */ -/*===========================================*/ -static PrintInfo *print_info_new (GnomePrintMaster * master, glLabel * label); -static void print_info_free (PrintInfo ** pi); - -static void print_label (PrintInfo * pi, glLabel * label, gint i, - glMergeRecord * record, gboolean outline_flag, - gboolean reverse_flag); - -static void draw_label (PrintInfo * pi, glLabel * label, - glMergeRecord * record); - -static void draw_text_object (PrintInfo * pi, glLabelObject * object, - glMergeRecord * record); -static void draw_box_object (PrintInfo * pi, glLabelObject * object); -static void draw_line_object (PrintInfo * pi, glLabelObject * object); -static void draw_ellipse_object (PrintInfo * pi, glLabelObject * object); -static void draw_image_object (PrintInfo * pi, glLabelObject * object); -static void draw_barcode_object (PrintInfo * pi, glLabelObject * object, - glMergeRecord * record); - -static void draw_outline (PrintInfo * pi, glLabel * label); -#ifdef CLIP_LABEL -static void clip_to_outline (PrintInfo * pi, glLabel * label); -#endif - -static void create_rectangle_path (GnomePrintContext * pc, - gdouble x0, gdouble y0, - gdouble w, gdouble h); -static void create_ellipse_path (GnomePrintContext * pc, - gdouble x0, gdouble y0, - gdouble rx, gdouble ry); -static void create_rounded_rectangle_path (GnomePrintContext * pc, - gdouble x0, gdouble y0, - gdouble w, gdouble h, gdouble r); - -/*****************************************************************************/ -/* Simple (no merge data) print command. */ -/*****************************************************************************/ -void -gl_print_simple (GnomePrintMaster * master, - glLabel * label, - gint n_sheets, - gint first, - gint last, - gboolean outline_flag, - gboolean reverse_flag) -{ - PrintInfo *pi; - gint i_sheet, i_label; - gchar *page_str = NULL; - - pi = print_info_new (master, label); - - for (i_sheet = 0; i_sheet < n_sheets; i_sheet++) { - - page_str = g_strdup_printf ("sheet %d", i_sheet + 1); - gnome_print_beginpage (pi->pc, page_str); - g_free (page_str); - - for (i_label = first - 1; i_label < last; i_label++) { - - print_label (pi, label, i_label, NULL, - outline_flag, reverse_flag); - - } - - gnome_print_showpage (pi->pc); - } - - print_info_free (&pi); -} - -/*****************************************************************************/ -/* Merge print command (collated copies) */ -/*****************************************************************************/ -void -gl_print_merge_collated (GnomePrintMaster * master, - glLabel * label, - GList * record_list, - gint n_copies, - gint first, - gboolean outline_flag, - gboolean reverse_flag) -{ - PrintInfo *pi; - gint i_sheet, i_label, n_labels_per_page, i_copy; - gchar *str = NULL; - glMergeRecord *record; - GList *p; - - pi = print_info_new (master, label); - - n_labels_per_page = (pi->template->nx) * (pi->template->ny); - - i_sheet = 0; - i_label = first - 1; - - for ( p=record_list; p!=NULL; p=p->next ) { - record = (glMergeRecord *)p->data; - - if ( record->select_flag ) { - for (i_copy = 0; i_copy < n_copies; i_copy++) { - - if ((i_label == 0) || (i_sheet == 0)) { - str = g_strdup_printf ("sheet %d", - ++i_sheet); - gnome_print_beginpage (pi->pc, str); - g_free (str); - } - - print_label (pi, label, i_label, record, - outline_flag, reverse_flag); - - i_label = (i_label + 1) % n_labels_per_page; - if (i_label == 0) { - gnome_print_showpage (pi->pc); - } - } - } - } - - if (i_label != 0) { - gnome_print_showpage (pi->pc); - } - - print_info_free (&pi); -} - -/*****************************************************************************/ -/* Merge print command (uncollated copies) */ -/*****************************************************************************/ -void -gl_print_merge_uncollated (GnomePrintMaster * master, - glLabel * label, - GList * record_list, - gint n_copies, - gint first, - gboolean outline_flag, - gboolean reverse_flag) -{ - PrintInfo *pi; - gint i_sheet, i_label, n_labels_per_page, i_copy; - gchar *str = NULL; - glMergeRecord *record; - GList *p; - - pi = print_info_new (master, label); - - n_labels_per_page = (pi->template->nx) * (pi->template->ny); - - i_sheet = 0; - i_label = first - 1; - - for (i_copy = 0; i_copy < n_copies; i_copy++) { - - for ( p=record_list; p!=NULL; p=p->next ) { - record = (glMergeRecord *)p->data; - - if ( record->select_flag ) { - - - if ((i_label == 0) || (i_sheet == 0)) { - str = g_strdup_printf ("sheet %d", - ++i_sheet); - gnome_print_beginpage (pi->pc, str); - g_free (str); - } - - print_label (pi, label, i_label, record, - outline_flag, reverse_flag); - - i_label = (i_label + 1) % n_labels_per_page; - if (i_label == 0) { - gnome_print_showpage (pi->pc); - } - } - } - - } - if (i_label != 0) { - gnome_print_showpage (pi->pc); - } - - print_info_free (&pi); -} - -/*****************************************************************************/ -/* Batch print. Call appropriate function above. */ -/*****************************************************************************/ -void -gl_print_batch (GnomePrintMaster * master, glLabel * label, - gint n_sheets, gint n_copies, - gboolean outline_flag, gboolean reverse_flag) -{ - gint n_per_page; - GList *record_list = NULL; - - if ( label->merge_type == GL_MERGE_NONE ) { - n_per_page = (label->template->nx)*(label->template->ny); - - gl_print_simple (master, label, n_sheets, 1, n_per_page, - outline_flag, reverse_flag); - } else { - record_list = gl_merge_read_data (label->merge_type, - label->merge_fields, - label->merge_src); - - gl_print_merge_collated (master, label, record_list, - n_copies, 1, - outline_flag, reverse_flag); - } -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. new print info structure */ -/*---------------------------------------------------------------------------*/ -static PrintInfo * -print_info_new (GnomePrintMaster * master, - glLabel * label) -{ - const GnomePaper *paper; - PrintInfo *pi = g_new0 (PrintInfo, 1); - glTemplate *template = label->template; - - if (template == NULL) { - WARN ("Undefined template \"%s\"", label->template_name); - return NULL; - } - - pi->pc = gnome_print_master_get_context (master); - - if ((template != NULL) && (template->page_size != NULL)) { - paper = gnome_paper_with_name (template->page_size); - } else { - paper = gnome_paper_with_name (GL_PRINT_DEFAULT_PAPER); - } - gnome_print_master_set_paper (master, paper); - - pi->template = template; - pi->label_rotate_flag = label->rotate_flag; - - return pi; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. free print info structure */ -/*---------------------------------------------------------------------------*/ -static void -print_info_free (PrintInfo ** pi) -{ - gnome_print_context_close ((*pi)->pc); - - g_free (*pi); - *pi = NULL; -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Print i'th label. */ -/*---------------------------------------------------------------------------*/ -static void -print_label (PrintInfo * pi, - glLabel * label, - gint i_label, - glMergeRecord * record, - gboolean outline_flag, - gboolean reverse_flag) -{ - gdouble a[6]; - gint ix, iy; - - ix = i_label % (pi->template->nx); - iy = ((pi->template->ny) - 1) - (i_label / (pi->template->nx)); - - gnome_print_gsave (pi->pc); - - /* Transform coordinate system to be relative to upper corner */ - /* of the current label */ - gnome_print_translate (pi->pc, - ix * (pi->template->dx) + pi->template->x0, - iy * (pi->template->dy) + pi->template->y0); - if (!label->rotate_flag) { - art_affine_scale (a, 1.0, -1.0); - a[5] = label->height; - gnome_print_concat (pi->pc, a); - } else { - gnome_print_rotate (pi->pc, 90.0); - gnome_print_scale (pi->pc, 1.0, -1.0); - } - if ( reverse_flag ) { - gnome_print_translate (pi->pc, label->width, 0.0); - art_affine_scale (a, -1.0, 1.0); - gnome_print_concat (pi->pc, a); - } - if (outline_flag) { - draw_outline (pi, label); - } -#ifdef CLIP_LABEL /* FIXME: this may be causing problems for some people. */ - clip_to_outline (pi, label); -#endif - draw_label (pi, label, record); - - gnome_print_grestore (pi->pc); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw label. */ -/*---------------------------------------------------------------------------*/ -static void -draw_label (PrintInfo * pi, - glLabel * label, - glMergeRecord * record) -{ - GList *p_obj; - glLabelObject *object; - - for (p_obj = label->objects; p_obj != NULL; p_obj = p_obj->next) { - object = (glLabelObject *) p_obj->data; - - if (object->type == GL_LABEL_OBJECT_TEXT) { - draw_text_object (pi, object, record); - } else if (object->type == GL_LABEL_OBJECT_BOX) { - draw_box_object (pi, object); - } else if (object->type == GL_LABEL_OBJECT_LINE) { - draw_line_object (pi, object); - } else if (object->type == GL_LABEL_OBJECT_ELLIPSE) { - draw_ellipse_object (pi, object); - } else if (object->type == GL_LABEL_OBJECT_IMAGE) { - draw_image_object (pi, object); - } else if (object->type == GL_LABEL_OBJECT_BARCODE) { - draw_barcode_object (pi, object, record); - } - - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw text object. */ -/*---------------------------------------------------------------------------*/ -static void -draw_text_object (PrintInfo * pi, - glLabelObject * object, - glMergeRecord * record) -{ - GnomeFont *font; - gchar **line; - gint i; - gdouble w; - gdouble x_offset, y_offset; - gdouble x, y; - gchar *text, *utf8_text; - - font = gnome_font_new_closest (object->arg.text.font_family, - object->arg.text.font_weight, - object->arg.text.font_italic_flag, - object->arg.text.font_size); - gnome_print_setfont (pi->pc, font); - - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.text.color), - GREEN (object->arg.text.color), - BLUE (object->arg.text.color)); - gnome_print_setopacity (pi->pc, ALPHA (object->arg.text.color)); - - text = gl_text_node_lines_expand (object->arg.text.lines, record); - line = g_strsplit (text, "\n", -1); - g_free (text); - - for (i = 0; line[i] != NULL; i++) { - - utf8_text = gl_hack_text_to_utf8 (line[i]); - - w = gl_hack_get_width_string (font, line[i]); - - switch (object->arg.text.just) { - case GTK_JUSTIFY_LEFT: - x_offset = 0.0; - break; - case GTK_JUSTIFY_CENTER: - x_offset = -w / 2.0; - break; - case GTK_JUSTIFY_RIGHT: - x_offset = -w; - break; - default: - x_offset = 0.0; - break; /* shouldn't happen */ - } - - y_offset = (i + 1) * object->arg.text.font_size - - gnome_font_get_descender (font); - - x = object->x + x_offset; - y = object->y + y_offset; - gnome_print_moveto (pi->pc, x, y); - - gnome_print_gsave (pi->pc); - gnome_print_scale (pi->pc, 1.0, -1.0); - gnome_print_show (pi->pc, utf8_text); - gnome_print_grestore (pi->pc); - - g_free (utf8_text); - } - - g_strfreev (line); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw box object. */ -/*---------------------------------------------------------------------------*/ -static void -draw_box_object (PrintInfo * pi, - glLabelObject * object) -{ - gdouble x, y, w, h; - - x = object->x; - y = object->y; - w = object->arg.box.w; - h = object->arg.box.h; - - /* Paint fill color */ - create_rectangle_path (pi->pc, x, y, w, h); - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.box.fill_color), - GREEN (object->arg.box.fill_color), - BLUE (object->arg.box.fill_color)); - gnome_print_setopacity (pi->pc, ALPHA (object->arg.box.fill_color)); - gnome_print_fill (pi->pc); - - /* Draw outline */ - create_rectangle_path (pi->pc, x, y, w, h); - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.box.line_color), - GREEN (object->arg.box.line_color), - BLUE (object->arg.box.line_color)); - gnome_print_setopacity (pi->pc, ALPHA (object->arg.box.line_color)); - gnome_print_setlinewidth (pi->pc, object->arg.box.line_width); - gnome_print_stroke (pi->pc); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw line object. */ -/*---------------------------------------------------------------------------*/ -static void -draw_line_object (PrintInfo * pi, - glLabelObject * object) -{ - gdouble x, y, dx, dy; - - x = object->x; - y = object->y; - dx = object->arg.line.dx; - dy = object->arg.line.dy; - - gnome_print_moveto (pi->pc, x, y); - gnome_print_lineto (pi->pc, x + dx, y + dy); - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.line.line_color), - GREEN (object->arg.line.line_color), - BLUE (object->arg.line.line_color)); - gnome_print_setopacity (pi->pc, ALPHA (object->arg.line.line_color)); - gnome_print_setlinewidth (pi->pc, object->arg.line.line_width); - gnome_print_stroke (pi->pc); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw ellipse object. */ -/*---------------------------------------------------------------------------*/ -static void -draw_ellipse_object (PrintInfo * pi, - glLabelObject * object) -{ - gdouble x0, y0, rx, ry; - - rx = object->arg.ellipse.w / 2.0; - ry = object->arg.ellipse.h / 2.0; - x0 = object->x + rx; - y0 = object->y + ry; - - /* Paint fill color */ - create_ellipse_path (pi->pc, x0, y0, rx, ry); - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.ellipse.fill_color), - GREEN (object->arg.ellipse.fill_color), - BLUE (object->arg.ellipse.fill_color)); - gnome_print_setopacity (pi->pc, ALPHA (object->arg.ellipse.fill_color)); - gnome_print_fill (pi->pc); - - /* Draw outline */ - create_ellipse_path (pi->pc, x0, y0, rx, ry); - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.ellipse.line_color), - GREEN (object->arg.ellipse.line_color), - BLUE (object->arg.ellipse.line_color)); - gnome_print_setopacity (pi->pc, ALPHA (object->arg.ellipse.line_color)); - gnome_print_setlinewidth (pi->pc, object->arg.ellipse.line_width); - gnome_print_stroke (pi->pc); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw image object. */ -/*---------------------------------------------------------------------------*/ -static void -draw_image_object (PrintInfo * pi, - glLabelObject * object) -{ - gdouble x, y, w, h; - GdkPixbuf *pixbuf; - - x = object->x; - y = object->y; - w = object->arg.image.w; - h = object->arg.image.h; - - pixbuf = object->arg.image.image; - - gnome_print_gsave (pi->pc); - gnome_print_translate (pi->pc, x, y + h); - gnome_print_scale (pi->pc, w, -h); - gnome_print_pixbuf (pi->pc, pixbuf); - gnome_print_grestore (pi->pc); - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw box object. */ -/*---------------------------------------------------------------------------*/ -static void -draw_barcode_object (PrintInfo * pi, - glLabelObject * object, - glMergeRecord * record) -{ - glBarcode *gbc; - glBarcodeLine *line; - glBarcodeChar *bchar; - GList *li; - gdouble x, y, y_offset; - GnomeFont *font; - gchar *text, *cstring; - - x = object->x; - y = object->y; - - text = gl_text_node_expand (object->arg.barcode.text_node, record); - gbc = gl_barcode (object->arg.barcode.style, - object->arg.barcode.text_flag, - object->arg.barcode.scale, text); - g_free (text); - - if (gbc == NULL) { - - font = gnome_font_new_closest (GL_BARCODE_FONT_FAMILY, - GL_BARCODE_FONT_WEIGHT, - FALSE, 12.0); - gnome_print_setfont (pi->pc, font); - - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.barcode.color), - GREEN (object->arg.barcode.color), - BLUE (object->arg.barcode.color)); - gnome_print_setopacity (pi->pc, - ALPHA (object->arg.barcode.color)); - - y_offset = 12.0 - gnome_font_get_descender (font); - gnome_print_moveto (pi->pc, x, y + y_offset); - - gnome_print_gsave (pi->pc); - gnome_print_scale (pi->pc, 1.0, -1.0); - gnome_print_show (pi->pc, _("Invalid barcode")); - gnome_print_grestore (pi->pc); - - } else { - - for (li = gbc->lines; li != NULL; li = li->next) { - line = (glBarcodeLine *) li->data; - - gnome_print_moveto (pi->pc, x + line->x, y + line->y); - gnome_print_lineto (pi->pc, x + line->x, - y + line->y + line->length); - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.barcode. - color), - GREEN (object->arg.barcode. - color), - BLUE (object->arg.barcode. - color)); - gnome_print_setopacity (pi->pc, - ALPHA (object->arg.barcode. - color)); - gnome_print_setlinewidth (pi->pc, line->width); - gnome_print_stroke (pi->pc); - } - - for (li = gbc->chars; li != NULL; li = li->next) { - bchar = (glBarcodeChar *) li->data; - - font = gnome_font_new_closest (GL_BARCODE_FONT_FAMILY, - GL_BARCODE_FONT_WEIGHT, - FALSE, bchar->fsize); - gnome_print_setfont (pi->pc, font); - - gnome_print_setrgbcolor (pi->pc, - RED (object->arg.barcode. - color), - GREEN (object->arg.barcode. - color), - BLUE (object->arg.barcode. - color)); - gnome_print_setopacity (pi->pc, - ALPHA (object->arg.barcode. - color)); - - y_offset = - bchar->y + bchar->fsize - - gnome_font_get_descender (font); - gnome_print_moveto (pi->pc, x + bchar->x, y + y_offset); - - cstring = g_strdup_printf ("%c", bchar->c); - gnome_print_gsave (pi->pc); - gnome_print_scale (pi->pc, 1.0, -1.0); - gnome_print_show (pi->pc, cstring); - gnome_print_grestore (pi->pc); - g_free (cstring); - - } - - gl_barcode_free (&gbc); - - } - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Draw outline. */ -/*---------------------------------------------------------------------------*/ -static void -draw_outline (PrintInfo * pi, - glLabel * label) -{ - gdouble w, h, r; - gdouble r1, r2; - - gnome_print_setrgbcolor (pi->pc, 0.25, 0.25, 0.25); - gnome_print_setopacity (pi->pc, 1.0); - gnome_print_setlinewidth (pi->pc, 0.25); - - switch (label->template->style) { - - case GL_TEMPLATE_STYLE_RECT: - w = label->width; - h = label->height; - r = label->template->label_round; - if (r == 0.0) { - /* simple rectangle */ - create_rectangle_path (pi->pc, 0.0, 0.0, w, h); - } else { - /* rectangle with rounded corners */ - create_rounded_rectangle_path (pi->pc, 0.0, 0.0, - w, h, r); - } - gnome_print_stroke (pi->pc); - break; - - case GL_TEMPLATE_STYLE_ROUND: - /* Round style */ - r1 = label->template->label_radius; - create_ellipse_path (pi->pc, r1, r1, r1, r1); - gnome_print_stroke (pi->pc); - break; - - case GL_TEMPLATE_STYLE_CD: - /* CD style, round label w/ concentric round hole */ - r1 = label->template->label_radius; - r2 = label->template->label_hole; - create_ellipse_path (pi->pc, r1, r1, r1, r1); - gnome_print_stroke (pi->pc); - create_ellipse_path (pi->pc, r1, r1, r2, r2); - gnome_print_stroke (pi->pc); - break; - - default: - WARN ("Unknown template label style"); - break; - } - -} - -#ifdef CLIP_LABEL -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Clip to outline. */ -/*---------------------------------------------------------------------------*/ -static void -clip_to_outline (PrintInfo * pi, - glLabel * label) -{ - gdouble w, h, r; - gdouble r1; - - switch (label->template->style) { - - case GL_TEMPLATE_STYLE_RECT: - w = label->width; - h = label->height; - r = label->template->label_round; - if (r == 0.0) { - /* simple rectangle */ - create_rectangle_path (pi->pc, 0.0, 0.0, w, h); - } else { - /* rectangle with rounded corners */ - create_rounded_rectangle_path (pi->pc, 0.0, 0.0, - w, h, r); - } - gnome_print_clip (pi->pc); - break; - - case GL_TEMPLATE_STYLE_ROUND: - case GL_TEMPLATE_STYLE_CD: - r1 = label->template->label_radius; - create_ellipse_path (pi->pc, r1, r1, r1, r1); - gnome_print_clip (pi->pc); - break; - - default: - WARN ("Unknown template label style"); - break; - } - -} -#endif - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Path creation utilities. */ -/*---------------------------------------------------------------------------*/ -static void -create_rectangle_path (GnomePrintContext * pc, - gdouble x0, - gdouble y0, - gdouble w, - gdouble h) -{ - gnome_print_newpath (pc); - gnome_print_moveto (pc, x0, y0); - gnome_print_lineto (pc, x0 + w, y0); - gnome_print_lineto (pc, x0 + w, y0 + h); - gnome_print_lineto (pc, x0, y0 + h); - gnome_print_lineto (pc, x0, y0); - gnome_print_closepath (pc); -} - -static void -create_ellipse_path (GnomePrintContext * pc, - gdouble x0, - gdouble y0, - gdouble rx, - gdouble ry) -{ - gdouble x, y; - gint i_theta; - - gnome_print_newpath (pc); - gnome_print_moveto (pc, x0 + rx, y0); - for (i_theta = 2; i_theta <= 360; i_theta += 2) { - x = x0 + rx * cos (i_theta * M_PI / 180.0); - y = y0 + ry * sin (i_theta * M_PI / 180.0); - gnome_print_lineto (pc, x, y); - } - gnome_print_closepath (pc); -} - -static void -create_rounded_rectangle_path (GnomePrintContext * pc, - gdouble x0, - gdouble y0, - gdouble w, - gdouble h, - gdouble r) -{ - gdouble x, y; - gint i_theta; - - gnome_print_newpath (pc); - - gnome_print_moveto (pc, x0 + r, y0); - for (i_theta = 5; i_theta <= 90; i_theta += 5) { - x = x0 + r - r * sin (i_theta * M_PI / 180.0); - y = y0 + r - r * cos (i_theta * M_PI / 180.0); - gnome_print_lineto (pc, x, y); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - x = x0 + r - r * cos (i_theta * M_PI / 180.0); - y = y0 + (h - r) + r * sin (i_theta * M_PI / 180.0); - gnome_print_lineto (pc, x, y); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - x = x0 + (w - r) + r * sin (i_theta * M_PI / 180.0); - y = y0 + (h - r) + r * cos (i_theta * M_PI / 180.0); - gnome_print_lineto (pc, x, y); - } - for (i_theta = 0; i_theta <= 90; i_theta += 5) { - x = x0 + (w - r) + r * cos (i_theta * M_PI / 180.0); - y = y0 + r - r * sin (i_theta * M_PI / 180.0); - gnome_print_lineto (pc, x, y); - } - gnome_print_lineto (pc, x0 + r, y0); - - gnome_print_closepath (pc); -} diff --git a/glabels1/src/print.h b/glabels1/src/print.h deleted file mode 100644 index 25aec93..0000000 --- a/glabels1/src/print.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print.h: Print module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __PRINT_H__ -#define __PRINT_H__ - -#include <gnome.h> -#include <libgnomeprint/gnome-print-master.h> -#include <libgnomeprint/gnome-print-master-preview.h> -#include "label.h" - -extern void gl_print_simple (GnomePrintMaster * master, glLabel * label, - gint n_sheets, gint first, gint last, - gboolean outline_flag, gboolean reverse_flag); - -extern void gl_print_merge_collated (GnomePrintMaster * master, - glLabel * label, - GList *record_list, - gint n_copies, gint first, - gboolean outline_flag, - gboolean reverse_flag); - -extern void gl_print_merge_uncollated (GnomePrintMaster * master, - glLabel * label, - GList *record_list, - gint n_copies, gint first, - gboolean outline_flag, - gboolean reverse_flag); - -extern void gl_print_batch (GnomePrintMaster * master, glLabel * label, - gint n_sheets, gint n_copies, - gboolean outline_flag, gboolean reverse_flag); - - -#endif diff --git a/glabels1/src/print_copies.c b/glabels1/src/print_copies.c deleted file mode 100644 index 4d8d625..0000000 --- a/glabels1/src/print_copies.c +++ /dev/null @@ -1,387 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print_copies.c: custom print copies widget module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "print_copies.h" -#include "mini_preview.h" - -#include "debug.h" - -#define MINI_PREVIEW_HEIGHT 175 -#define MINI_PREVIEW_WIDTH 150 - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_print_copies_class_init (glPrintCopiesClass * class); -static void gl_print_copies_init (glPrintCopies * copies); -static void gl_print_copies_destroy (GtkObject * object); - -static void gl_print_copies_construct (glPrintCopies * copies, glLabel * label); - -static void sheets_radio_cb (GtkToggleButton * togglebutton, gpointer user_data); -static void first_spin_cb (GtkSpinButton * spinbutton, gpointer user_data); -static void last_spin_cb (GtkSpinButton * spinbutton, gpointer user_data); - -static void -preview_pressed (glMiniPreview *mini_preview, - gint first, gint last, gpointer user_data); - - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_print_copies_get_type (void) -{ - static guint print_copies_type = 0; - - if (!print_copies_type) { - GtkTypeInfo print_copies_info = { - "glPrintCopies", - sizeof (glPrintCopies), - sizeof (glPrintCopiesClass), - (GtkClassInitFunc) gl_print_copies_class_init, - (GtkObjectInitFunc) gl_print_copies_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - print_copies_type = gtk_type_unique (gtk_hbox_get_type (), - &print_copies_info); - } - - return print_copies_type; -} - -static void -gl_print_copies_class_init (glPrintCopiesClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_hbox_get_type ()); - - object_class->destroy = gl_print_copies_destroy; -} - -static void -gl_print_copies_init (glPrintCopies * copies) -{ - copies->labels_per_sheet = 0; - - copies->mini_preview = NULL; - - copies->sheets_radio = NULL; - copies->sheets_spin = NULL; - - copies->labels_radio = NULL; - copies->first_spin = NULL; - copies->last_spin = NULL; -} - -static void -gl_print_copies_destroy (GtkObject * object) -{ - glPrintCopies *copies; - glPrintCopiesClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PRINT_COPIES (object)); - - copies = GL_PRINT_COPIES (object); - class = GL_PRINT_COPIES_CLASS (GTK_OBJECT (copies)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_print_copies_new (glLabel * label) -{ - glPrintCopies *copies; - - copies = gtk_type_new (gl_print_copies_get_type ()); - - gl_print_copies_construct (copies, label); - - return GTK_WIDGET (copies); -} - -/*--------------------------------------------------------------------------*/ -/* Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_print_copies_construct (glPrintCopies * copies, - glLabel * label) -{ - GtkWidget *whbox, *wvbox, *whbox1; - GSList *radio_group = NULL; - GtkObject *adjust; - - whbox = GTK_WIDGET (copies); - - copies->labels_per_sheet = label->template->nx * label->template->ny; - - /* mini_preview canvas */ - copies->mini_preview = gl_mini_preview_new (MINI_PREVIEW_HEIGHT, - MINI_PREVIEW_WIDTH); - gl_mini_preview_set_label (GL_MINI_PREVIEW(copies->mini_preview), - label->template->name->data); - gtk_box_pack_start (GTK_BOX (whbox), copies->mini_preview, - TRUE, TRUE, GNOME_PAD); - - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (whbox), wvbox, TRUE, TRUE, GNOME_PAD); - - /* Sheet controls */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (wvbox), whbox1, FALSE, FALSE, GNOME_PAD); - copies->sheets_radio = - gtk_radio_button_new_with_label (radio_group, _("Sheets:")); - gtk_box_pack_start (GTK_BOX (whbox1), copies->sheets_radio, - FALSE, FALSE, 0); - adjust = gtk_adjustment_new (1, 1.0, 10.0, 1.0, 10.0, 10.0); - copies->sheets_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_box_pack_start (GTK_BOX (whbox1), copies->sheets_spin, - FALSE, FALSE, 0); - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - 1, copies->labels_per_sheet); - - /* Label controls */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (wvbox), whbox1, FALSE, FALSE, GNOME_PAD); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (copies->sheets_radio)); - copies->labels_radio = - gtk_radio_button_new_with_label (radio_group, _("Labels")); - gtk_box_pack_start (GTK_BOX (whbox1), copies->labels_radio, - FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (whbox1), gtk_label_new (_("from:")), - FALSE, FALSE, 0); - adjust = gtk_adjustment_new (1, 1.0, copies->labels_per_sheet, - 1.0, 10.0, 10.0); - copies->first_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_box_pack_start (GTK_BOX (whbox1), copies->first_spin, - FALSE, FALSE, 0); - gtk_box_pack_start (GTK_BOX (whbox1), gtk_label_new (_("to:")), - FALSE, FALSE, 0); - adjust = gtk_adjustment_new (copies->labels_per_sheet, - 1.0, copies->labels_per_sheet, - 1.0, 10.0, 10.0); - copies->last_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_box_pack_start (GTK_BOX (whbox1), copies->last_spin, - FALSE, FALSE, 0); - gtk_widget_set_sensitive (copies->first_spin, FALSE); - gtk_widget_set_sensitive (copies->last_spin, FALSE); - - /* Connect signals to controls */ - gtk_signal_connect (GTK_OBJECT (copies->mini_preview), "pressed", - GTK_SIGNAL_FUNC (preview_pressed), copies); - gtk_signal_connect (GTK_OBJECT (copies->sheets_radio), "toggled", - GTK_SIGNAL_FUNC (sheets_radio_cb), copies); - gtk_signal_connect (GTK_OBJECT (copies->first_spin), "changed", - GTK_SIGNAL_FUNC (first_spin_cb), copies); - gtk_signal_connect (GTK_OBJECT (copies->last_spin), "changed", - GTK_SIGNAL_FUNC (last_spin_cb), copies); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Enable/Disable appropriate controls due to radio button toggle.*/ -/*--------------------------------------------------------------------------*/ -static void -sheets_radio_cb (GtkToggleButton * togglebutton, - gpointer user_data) -{ - glPrintCopies *copies = GL_PRINT_COPIES (user_data); - gint first, last; - - if (gtk_toggle_button_get_active (togglebutton)) { - - gtk_widget_set_sensitive (copies->sheets_spin, TRUE); - gtk_widget_set_sensitive (copies->first_spin, FALSE); - gtk_widget_set_sensitive (copies->last_spin, FALSE); - - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - 1, copies->labels_per_sheet); - - } else { - - gtk_widget_set_sensitive (copies->sheets_spin, FALSE); - gtk_widget_set_sensitive (copies->first_spin, TRUE); - gtk_widget_set_sensitive (copies->last_spin, TRUE); - - first = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - last = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->last_spin)); - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - first, last); - - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change of first spin button */ -/*--------------------------------------------------------------------------*/ -static void -first_spin_cb (GtkSpinButton * spinbutton, - gpointer user_data) -{ - glPrintCopies *copies = GL_PRINT_COPIES (user_data); - gint first, last; - - first = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - last = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->last_spin)); - - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (copies->last_spin))-> - lower = first; - - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - first, last); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change of last spin button */ -/*--------------------------------------------------------------------------*/ -static void -last_spin_cb (GtkSpinButton * spinbutton, - gpointer user_data) -{ - glPrintCopies *copies = GL_PRINT_COPIES (user_data); - gint first, last; - - first = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - last = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->last_spin)); - - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (copies->first_spin))-> - upper = last; - - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(copies->mini_preview), - first, last); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Canvas event handler, select first and last items. */ -/*--------------------------------------------------------------------------*/ -static void -preview_pressed (glMiniPreview *mini_preview, - gint first, gint last, gpointer user_data) -{ - glPrintCopies *copies = GL_PRINT_COPIES (user_data); - - gl_print_copies_set_range (copies, 1, first, last); -} - -/****************************************************************************/ -/* query selected range of labels within sheet or number of sheets. */ -/****************************************************************************/ -void -gl_print_copies_get_range (glPrintCopies * copies, - gint * n_sheets, - gint * first_label, - gint * last_label) -{ - gboolean sheets_active; - - sheets_active = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (copies->sheets_radio)); - - if (sheets_active) { - *n_sheets = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->sheets_spin)); - *first_label = 1; - *last_label = copies->labels_per_sheet; - } else { - *n_sheets = 1; - *first_label = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - *last_label = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->last_spin)); - } -} - -/****************************************************************************/ -/* set range of labels within sheet or number of sheets */ -/****************************************************************************/ -void -gl_print_copies_set_range (glPrintCopies * copies, - gint n_sheets, - gint first_label, - gint last_label) -{ - gint old_first_label; - - old_first_label = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (copies->first_spin)); - - if (first_label > old_first_label) { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (copies->last_spin), - last_label); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (copies->first_spin), - first_label); - } else { - gtk_spin_button_set_value (GTK_SPIN_BUTTON (copies->first_spin), - first_label); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (copies->last_spin), - last_label); - } - if ((first_label == 1) && (last_label == copies->labels_per_sheet)) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (copies->sheets_radio), TRUE); - gtk_spin_button_set_value (GTK_SPIN_BUTTON - (copies->sheets_spin), n_sheets); - } else { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (copies->labels_radio), TRUE); - gtk_spin_button_set_value (GTK_SPIN_BUTTON - (copies->sheets_spin), 1.0); - } -} diff --git a/glabels1/src/print_copies.h b/glabels1/src/print_copies.h deleted file mode 100644 index 124c5a2..0000000 --- a/glabels1/src/print_copies.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print_copies.h: custom print copies widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PRINT_COPIES_H__ -#define __PRINT_COPIES_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_PRINT_COPIES (gl_print_copies_get_type ()) -#define GL_PRINT_COPIES(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PRINT_COPIES, glPrintCopies )) -#define GL_PRINT_COPIES_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PRINT_COPIES, glPrintCopiesClass)) -#define GL_IS_PRINT_COPIES(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PRINT_COPIES)) -#define GL_IS_PRINT_COPIES_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PRINT_COPIES)) - -typedef struct _glPrintCopies glPrintCopies; -typedef struct _glPrintCopiesClass glPrintCopiesClass; - -struct _glPrintCopies { - GtkHBox parent_widget; - - gint labels_per_sheet; - - GtkWidget *mini_preview; - - GtkWidget *sheets_radio; - GtkWidget *sheets_spin; - - GtkWidget *labels_radio; - GtkWidget *first_spin; - GtkWidget *last_spin; -}; - -struct _glPrintCopiesClass { - GtkHBoxClass parent_class; -}; - -extern guint gl_print_copies_get_type (void); - -extern GtkWidget *gl_print_copies_new (glLabel * label); - -extern void gl_print_copies_get_range (glPrintCopies * copies, - gint * n_sheets, - gint * first_label, - gint * last_label); - -extern void gl_print_copies_set_range (glPrintCopies * copies, - gint n_sheets, - gint first_label, - gint last_label); - -#endif diff --git a/glabels1/src/print_dialog.c b/glabels1/src/print_dialog.c deleted file mode 100644 index 97aa0a3..0000000 --- a/glabels1/src/print_dialog.c +++ /dev/null @@ -1,288 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print.c: Print module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include <config.h> - -#include <math.h> -#include <time.h> -#include <ctype.h> -#include <libgnome/gnome-paper.h> -#include <libgnomeprint/gnome-printer.h> -#include <libgnomeprint/gnome-print-dialog.h> -#include <libgnomeprint/gnome-print-master.h> -#include <libgnomeprint/gnome-print-master-preview.h> - -#include "print_dialog.h" -#include "print.h" -#include "label.h" -#include "bc.h" -#include "template.h" -#include "mdi.h" -#include "hack.h" - -#include "print_copies.h" -#include "print_merge.h" - -#include "debug.h" - -#define RED(x) ( (((x)>>24) & 0xff) / 255.0 ) -#define GREEN(x) ( (((x)>>16) & 0xff) / 255.0 ) -#define BLUE(x) ( (((x)>>8) & 0xff) / 255.0 ) -#define ALPHA(x) ( ( (x) & 0xff) / 255.0 ) - -/*===========================================*/ -/* Private types. */ -/*===========================================*/ - -/*===========================================*/ -/* Private function prototypes. */ -/*===========================================*/ -static void print_sheets (GtkWidget * dlg, glLabel * label, - gboolean preview_flag, - gint n_sheets, gint first, gint last, - gboolean outline_flag, gboolean reverse_flag); - -static void print_sheets_merge (GtkWidget * dlg, glLabel * label, - GList *record_list, - gboolean preview_flag, - gint n_copies, gint first, - gboolean collate_flag, - gboolean outline_flag, gboolean reverse_flag); - - -/*****************************************************************************/ -/* "Print" menu item callback. */ -/*****************************************************************************/ -void -gl_print_dialog_cb (GtkWidget * widget, gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - GnomeApp *app = gnome_mdi_get_active_window (GNOME_MDI (data)); - GtkWidget *dlg = NULL; - GtkWidget *copies = NULL; - GtkWidget *merge = NULL; - GtkWidget *outline_check = NULL; - GtkWidget *reverse_check = NULL; - GtkWidget *wframe, *wvbox; - glLabel *label; - gint ret; - static gboolean outline_flag = FALSE; - static gboolean reverse_flag = FALSE; - static gboolean collate_flag = FALSE; - static gint first = 1, last = 1, n_sheets = 0, n_copies = 1; - GList *record_list = NULL; - gint n_records; - - g_return_if_fail (child != NULL); - g_return_if_fail (app != NULL); - - label = gl_mdi_get_label (child); - - dlg = gnome_print_dialog_new (_("Print"), 0); - - if (label->merge_type == GL_MERGE_NONE) { - - /* ----------- Add simple-copies widget ------------ */ - wframe = gtk_frame_new (_("Copies")); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), wframe, - FALSE, FALSE, 0); - - copies = gl_print_copies_new (label); - gtk_container_set_border_width (GTK_CONTAINER (copies), - GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (wframe), copies); - - if (n_sheets) { - gl_print_copies_set_range (GL_PRINT_COPIES (copies), - n_sheets, first, last); - } - - } else { - - /* -------Otherwise add merge control widget ------------ */ - wframe = gtk_frame_new (_("Document merge control")); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), wframe, - FALSE, FALSE, 0); - - merge = gl_print_merge_new (label); - gtk_container_set_border_width (GTK_CONTAINER (merge), - GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (wframe), merge); - - record_list = gl_merge_read_data (label->merge_type, - label->merge_fields, - label->merge_src); - n_records = gl_merge_count_records( record_list ); - gl_print_merge_set_copies (GL_PRINT_MERGE(merge), - n_copies, first, n_records, - collate_flag); - } - gtk_widget_show_all (wframe); - - /* ----------- Add custom print options area ------------ */ - wframe = gtk_frame_new (_("Options")); - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dlg)->vbox), wframe, - FALSE, FALSE, 0); - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), - GNOME_PAD_SMALL); - gtk_container_add (GTK_CONTAINER (wframe), wvbox); - - /* add Outline check button */ - outline_check = - gtk_check_button_new_with_label ( - _("print outlines (to test printer alignment)")); - gtk_box_pack_start (GTK_BOX (wvbox), outline_check, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (outline_check), - outline_flag); - - /* add Reverse check button */ - reverse_check = - gtk_check_button_new_with_label ( - _("print in reverse (i.e. a mirror image)")); - gtk_box_pack_start (GTK_BOX (wvbox), reverse_check, FALSE, FALSE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (reverse_check), - reverse_flag); - - gtk_widget_show_all (wframe); - - gtk_signal_connect (GTK_OBJECT (dlg), "destroy", - GTK_SIGNAL_FUNC (gtk_widget_destroyed), &dlg); - - gtk_window_set_transient_for (GTK_WINDOW (dlg), GTK_WINDOW (app)); - - /* ----------- Now run the dialog and act ---------------- */ - ret = gnome_dialog_run (GNOME_DIALOG (dlg)); - - switch (ret) { - - case GNOME_PRINT_PRINT: - case GNOME_PRINT_PREVIEW: - outline_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (outline_check)); - reverse_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (reverse_check)); - - if (label->merge_type == GL_MERGE_NONE) { - - gl_print_copies_get_range (GL_PRINT_COPIES (copies), - &n_sheets, &first, &last); - print_sheets (dlg, label, - (ret == GNOME_PRINT_PREVIEW), - n_sheets, first, last, - outline_flag, reverse_flag); - - } else { - - gl_print_merge_get_copies (GL_PRINT_MERGE (merge), - &n_copies, &first, - &collate_flag); - print_sheets_merge (dlg, label, record_list, - (ret == GNOME_PRINT_PREVIEW), - n_copies, first, - collate_flag, - outline_flag, - reverse_flag); - } - break; - - default: - break; - - } - - if (dlg) gtk_widget_destroy (GTK_WIDGET (dlg)); - - -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. print the sheets */ -/*---------------------------------------------------------------------------*/ -static void -print_sheets (GtkWidget * dlg, - glLabel * label, - gboolean preview_flag, - gint n_sheets, - gint first, - gint last, - gboolean outline_flag, - gboolean reverse_flag) -{ - GnomePrintMaster *master; - - master = gnome_print_master_new_from_dialog (GNOME_PRINT_DIALOG (dlg)); - gl_print_simple (master, label, n_sheets, first, last, - outline_flag, reverse_flag); - gnome_print_master_close (master); - - if (preview_flag) { - GnomePrintMasterPreview *preview_widget = - gnome_print_master_preview_new (master, _("Print preview")); - gtk_widget_show (GTK_WIDGET (preview_widget)); - } else { - gnome_print_master_print (master); - } - - gtk_object_unref (GTK_OBJECT (master)); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. print the sheets with merge data */ -/*---------------------------------------------------------------------------*/ -static void -print_sheets_merge (GtkWidget * dlg, - glLabel * label, - GList * record_list, - gboolean preview_flag, - gint n_copies, - gint first, - gboolean collate_flag, - gboolean outline_flag, - gboolean reverse_flag) -{ - GnomePrintMaster *master; - - master = gnome_print_master_new_from_dialog (GNOME_PRINT_DIALOG (dlg)); - if ( collate_flag ) { - gl_print_merge_collated (master, label, record_list, - n_copies, first, - outline_flag, reverse_flag); - } else { - gl_print_merge_uncollated (master, label, record_list, - n_copies, first, - outline_flag, reverse_flag); - } - gnome_print_master_close (master); - - if (preview_flag) { - GnomePrintMasterPreview *preview_widget = - gnome_print_master_preview_new (master, _("Print preview")); - gtk_widget_show (GTK_WIDGET (preview_widget)); - } else { - gnome_print_master_print (master); - } - - gtk_object_unref (GTK_OBJECT (master)); -} - diff --git a/glabels1/src/print_dialog.h b/glabels1/src/print_dialog.h deleted file mode 100644 index a55b6e5..0000000 --- a/glabels1/src/print_dialog.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print_dialog.h: Print dialog module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __PRINT_DIALOG_H__ -#define __PRINT_DIALOG_H__ - -#include <gnome.h> -#include "label.h" - -extern void gl_print_dialog_cb (GtkWidget * widget, gpointer data); - -#endif diff --git a/glabels1/src/print_merge.c b/glabels1/src/print_merge.c deleted file mode 100644 index 3ef0033..0000000 --- a/glabels1/src/print_merge.c +++ /dev/null @@ -1,324 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print_merge.c: print merge widget module - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "print_merge.h" -#include "mini_preview.h" - -#include "pixmaps/collate.xpm" -#include "pixmaps/nocollate.xpm" - -#include "debug.h" - -#define MINI_PREVIEW_HEIGHT 175 -#define MINI_PREVIEW_WIDTH 150 - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_print_merge_class_init (glPrintMergeClass * class); -static void gl_print_merge_init (glPrintMerge * merge); -static void gl_print_merge_destroy (GtkObject * object); - -static void gl_print_merge_construct (glPrintMerge * merge, - glLabel * label); - -static void preview_clicked (glMiniPreview *mini_preview, - gint i_label, gpointer user_data); - -static void collate_check_cb (GtkToggleButton * togglebutton, - gpointer user_data); -static void spin_cb (GtkSpinButton * spinbutton, gpointer user_data); - - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_print_merge_get_type (void) -{ - static guint print_merge_type = 0; - - if (!print_merge_type) { - GtkTypeInfo print_merge_info = { - "glPrintMerge", - sizeof (glPrintMerge), - sizeof (glPrintMergeClass), - (GtkClassInitFunc) gl_print_merge_class_init, - (GtkObjectInitFunc) gl_print_merge_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - print_merge_type = gtk_type_unique (gtk_hbox_get_type (), - &print_merge_info); - } - - return print_merge_type; -} - -static void -gl_print_merge_class_init (glPrintMergeClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_hbox_get_type ()); - - object_class->destroy = gl_print_merge_destroy; -} - -static void -gl_print_merge_init (glPrintMerge * merge) -{ - merge->mini_preview = NULL; - - merge->copies_spin = NULL; - merge->first_spin = NULL; - merge->collate_image = NULL; - merge->collate_check = NULL; -} - -static void -gl_print_merge_destroy (GtkObject * object) -{ - glPrintMerge *merge; - glPrintMergeClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PRINT_MERGE (object)); - - merge = GL_PRINT_MERGE (object); - class = GL_PRINT_MERGE_CLASS (GTK_OBJECT (merge)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_print_merge_new (glLabel * label) -{ - glPrintMerge *merge; - - merge = gtk_type_new (gl_print_merge_get_type ()); - - gl_print_merge_construct (merge, label); - - return GTK_WIDGET (merge); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_print_merge_construct (glPrintMerge * merge, - glLabel * label) -{ - GtkWidget *whbox, *wvbox, *whbox1; - GtkObject *adjust; - - whbox = GTK_WIDGET (merge); - - merge->labels_per_sheet = label->template->nx * label->template->ny; - - /* mini_preview canvas */ - merge->mini_preview = gl_mini_preview_new (MINI_PREVIEW_HEIGHT, - MINI_PREVIEW_WIDTH); - gl_mini_preview_set_label( GL_MINI_PREVIEW (merge->mini_preview), - label->template->name->data ); - gtk_box_pack_start (GTK_BOX (whbox), merge->mini_preview, - TRUE, TRUE, GNOME_PAD); - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(merge->mini_preview), - 1, 1); - - wvbox = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (whbox), wvbox, TRUE, TRUE, GNOME_PAD); - - /* First Label controls */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (wvbox), whbox1, FALSE, FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (whbox1), - gtk_label_new (_("Start on label")), FALSE, FALSE, - 0); - adjust = - gtk_adjustment_new (1, 1.0, merge->labels_per_sheet, 1.0, 10.0, - 10.0); - merge->first_spin = - gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 1.0, 0); - gtk_box_pack_start (GTK_BOX (whbox1), merge->first_spin, FALSE, FALSE, - 0); - gtk_box_pack_start (GTK_BOX (whbox1), gtk_label_new (_("on 1st sheet")), - FALSE, FALSE, 0); - - /* Collate controls */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_end (GTK_BOX (wvbox), whbox1, FALSE, FALSE, GNOME_PAD); - merge->collate_image = gnome_pixmap_new_from_xpm_d (nocollate_xpm); - gtk_box_pack_start (GTK_BOX (whbox1), merge->collate_image, - FALSE, FALSE, 0); - merge->collate_check = gtk_check_button_new_with_label (_("Collate")); - gtk_box_pack_start (GTK_BOX (whbox1), merge->collate_check, - FALSE, FALSE, 0); - - /* Copy controls */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_end (GTK_BOX (wvbox), whbox1, FALSE, FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (whbox1), gtk_label_new (_("Copies:")), - FALSE, FALSE, 0); - adjust = gtk_adjustment_new (1, 1.0, 10.0, 1.0, 10.0, 10.0); - merge->copies_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - 1.0, 0); - gtk_box_pack_start (GTK_BOX (whbox1), merge->copies_spin, - FALSE, FALSE, 0); - - /* Connect signals to controls */ - gtk_signal_connect (GTK_OBJECT (merge->mini_preview), "clicked", - GTK_SIGNAL_FUNC (preview_clicked), merge); - gtk_signal_connect (GTK_OBJECT (merge->collate_check), "toggled", - GTK_SIGNAL_FUNC (collate_check_cb), merge); - gtk_signal_connect (GTK_OBJECT (merge->copies_spin), "changed", - GTK_SIGNAL_FUNC (spin_cb), merge); - gtk_signal_connect (GTK_OBJECT (merge->first_spin), "changed", - GTK_SIGNAL_FUNC (spin_cb), merge); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Enable/Disable appropriate controls due to radio button toggle.*/ -/*--------------------------------------------------------------------------*/ -static void -collate_check_cb (GtkToggleButton * togglebutton, - gpointer user_data) -{ - glPrintMerge *merge = GL_PRINT_MERGE (user_data); - - if (gtk_toggle_button_get_active (togglebutton)) { - - gnome_pixmap_load_xpm_d (GNOME_PIXMAP (merge->collate_image), - (char **) collate_xpm); - - } else { - - gnome_pixmap_load_xpm_d (GNOME_PIXMAP (merge->collate_image), - (char **) nocollate_xpm); - - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change of first spin button */ -/*--------------------------------------------------------------------------*/ -static void -spin_cb (GtkSpinButton * spinbutton, - gpointer user_data) -{ - glPrintMerge *merge = GL_PRINT_MERGE (user_data); - gint first, last, n_copies; - - first = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->first_spin)); - - n_copies = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->copies_spin)); - last = first + (n_copies * merge->n_records) - 1; - gl_mini_preview_highlight_range (GL_MINI_PREVIEW(merge->mini_preview), - first, last ); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Canvas event handler, select first and last items. */ -/*--------------------------------------------------------------------------*/ -static void -preview_clicked (glMiniPreview *mini_preview, - gint first, gpointer user_data) -{ - glPrintMerge *merge = GL_PRINT_MERGE (user_data); - gint n_copies, last; - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (merge->first_spin), - first); - - n_copies = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->copies_spin)); - last = first + (n_copies * merge->n_records) - 1; - gl_mini_preview_highlight_range (GL_MINI_PREVIEW (merge->mini_preview), - first, last); - -} - -/****************************************************************************/ -/* query selected range of labels within sheet or number of sheets. */ -/****************************************************************************/ -void -gl_print_merge_get_copies (glPrintMerge * merge, - gint * n_copies, - gint * first_label, - gboolean * collate_flag) -{ - *n_copies = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->copies_spin)); - *first_label = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (merge->first_spin)); - *collate_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (merge->collate_check)); -} - -/****************************************************************************/ -/* set range of labels within sheet or number of sheets */ -/****************************************************************************/ -void -gl_print_merge_set_copies (glPrintMerge * merge, - gint n_copies, - gint first_label, - gint n_records, - gboolean collate_flag) -{ - gint last_label; - - merge->n_records = n_records; - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (merge->copies_spin), - n_copies); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (merge->first_spin), - first_label); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (merge->collate_check), - collate_flag); - - last_label = first_label + (n_copies * n_records) - 1; - gl_mini_preview_highlight_range (GL_MINI_PREVIEW (merge->mini_preview), - first_label, last_label ); -} diff --git a/glabels1/src/print_merge.h b/glabels1/src/print_merge.h deleted file mode 100644 index a2a6ef8..0000000 --- a/glabels1/src/print_merge.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * print_merge.h: print merge widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PRINT_MERGE_H__ -#define __PRINT_MERGE_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_PRINT_MERGE (gl_print_merge_get_type ()) -#define GL_PRINT_MERGE(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PRINT_MERGE, glPrintMerge )) -#define GL_PRINT_MERGE_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PRINT_MERGE, glPrintMergeClass)) -#define GL_IS_PRINT_MERGE(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PRINT_MERGE)) -#define GL_IS_PRINT_MERGE_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PRINT_MERGE)) - -typedef struct _glPrintMerge glPrintMerge; -typedef struct _glPrintMergeClass glPrintMergeClass; - -struct _glPrintMerge { - GtkHBox parent_widget; - - gint labels_per_sheet; - GtkWidget *mini_preview; - - gint n_records; - - GtkWidget *copies_spin; - GtkWidget *first_spin; - GtkWidget *collate_image; - GtkWidget *collate_check; -}; - -struct _glPrintMergeClass { - GtkHBoxClass parent_class; -}; - -extern guint gl_print_merge_get_type (void); - -extern GtkWidget *gl_print_merge_new (glLabel * label); - -extern void gl_print_merge_get_copies (glPrintMerge * merge, - gint * n_copies, - gint * first_label, - gboolean * collate_flag); - -extern void gl_print_merge_set_copies (glPrintMerge * merge, - gint n_copies, - gint first_label, - gint n_records, - gboolean collate_flag); - -#endif diff --git a/glabels1/src/prop_bc.c b/glabels1/src/prop_bc.c deleted file mode 100644 index 0b0e817..0000000 --- a/glabels1/src/prop_bc.c +++ /dev/null @@ -1,249 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_bc.c: barcode properties widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_bc.h" - -#include "debug.h" - -#define RED(x) ( ((x)>>24) & 0xff ) -#define GREEN(x) ( ((x)>>16) & 0xff ) -#define BLUE(x) ( ((x)>>8) & 0xff ) -#define ALPHA(x) ( (x) & 0xff ) - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropBCSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_bc_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_bc_class_init (glPropBCClass * class); -static void gl_prop_bc_init (glPropBC * prop); -static void gl_prop_bc_destroy (GtkObject * object); -static void gl_prop_bc_construct (glPropBC * prop, gchar * label); -static void changed_cb (glPropBC * prop); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_bc_get_type (void) -{ - static guint prop_bc_type = 0; - - if (!prop_bc_type) { - GtkTypeInfo prop_bc_info = { - "glPropBC", - sizeof (glPropBC), - sizeof (glPropBCClass), - (GtkClassInitFunc) gl_prop_bc_class_init, - (GtkObjectInitFunc) gl_prop_bc_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_bc_type = gtk_type_unique (gtk_vbox_get_type (), - &prop_bc_info); - } - - return prop_bc_type; -} - -static void -gl_prop_bc_class_init (glPropBCClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_bc_destroy; - - prop_bc_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropBCClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, prop_bc_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_bc_init (glPropBC * prop) -{ - prop->scale_spin = NULL; - prop->color_picker = NULL; -} - -static void -gl_prop_bc_destroy (GtkObject * object) -{ - glPropBC *prop; - glPropBCClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_BC (object)); - - prop = GL_PROP_BC (object); - class = GL_PROP_BC_CLASS (GTK_OBJECT (prop)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_bc_new (gchar * label) -{ - glPropBC *prop; - - prop = gtk_type_new (gl_prop_bc_get_type ()); - - gl_prop_bc_construct (prop, label); - - return GTK_WIDGET (prop); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_bc_construct (glPropBC * prop, - gchar * label) -{ - GtkWidget *wvbox, *wframe, *wtable, *wlabel; - GtkObject *adjust; - - wvbox = GTK_WIDGET (prop); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 3, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* Scale Label */ - wlabel = gtk_label_new (_("Scale:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - /* Scale widget */ - adjust = gtk_adjustment_new (100.0, 50.0, 200.0, 10.0, 10.0, 10.0); - prop->scale_spin = - gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 10.0, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->scale_spin), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - gtk_table_attach_defaults (GTK_TABLE (wtable), prop->scale_spin, 1, 2, - 0, 1); - /* % Label */ - wlabel = gtk_label_new (_("%")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 2, 3, 0, 1); - - /* Line Color Label */ - wlabel = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); - /* Line Color picker widget */ - prop->color_picker = gnome_color_picker_new (); - gtk_signal_connect_object (GTK_OBJECT (prop->color_picker), "color_set", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - gtk_table_attach_defaults (GTK_TABLE (wtable), prop->color_picker, 1, 3, - 1, 2); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropBC * prop) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (prop), prop_bc_signals[CHANGED]); -} - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ -void -gl_prop_bc_get_params (glPropBC * prop, - gdouble * scale, - guint * color) -{ - guint8 r, g, b, a; - - /* ------- Get updated scale ------ */ - *scale = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (prop->scale_spin)); - *scale /= 100.0; - - /* ------- Get updated line color ------ */ - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (prop->color_picker), - &r, &g, &b, &a); - *color = GNOME_CANVAS_COLOR_A (r, g, b, a); - -} - -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ -void -gl_prop_bc_set_params (glPropBC * prop, - gdouble scale, - guint color) -{ - scale *= 100.0; - gtk_spin_button_set_value (GTK_SPIN_BUTTON (prop->scale_spin), scale); - - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (prop->color_picker), - RED (color), GREEN (color), BLUE (color), - ALPHA (color)); - -} diff --git a/glabels1/src/prop_bc.h b/glabels1/src/prop_bc.h deleted file mode 100644 index f009b1f..0000000 --- a/glabels1/src/prop_bc.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_bc.h: barcode properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_BC_H__ -#define __PROP_BC_H__ - -#include <gnome.h> -#include "bc.h" - -#define GL_TYPE_PROP_BC (gl_prop_bc_get_type ()) -#define GL_PROP_BC(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_BC, glPropBC )) -#define GL_PROP_BC_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_BC, glPropBCClass)) -#define GL_IS_PROP_BC(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_BC)) -#define GL_IS_PROP_BC_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_BC)) - -typedef struct _glPropBC glPropBC; -typedef struct _glPropBCClass glPropBCClass; - -struct _glPropBC { - GtkVBox parent_widget; - - GtkWidget *scale_spin; - GtkWidget *color_picker; -}; - -struct _glPropBCClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropBC * prop, gpointer user_data); -}; - -extern guint gl_prop_bc_get_type (void); - -extern GtkWidget *gl_prop_bc_new (gchar * label); - -extern void gl_prop_bc_get_params (glPropBC * prop, - gdouble * scale, - guint * color); - -extern void gl_prop_bc_set_params (glPropBC * prop, - gdouble scale, - guint color); - -#endif diff --git a/glabels1/src/prop_bc_data.c b/glabels1/src/prop_bc_data.c deleted file mode 100644 index 7464bea..0000000 --- a/glabels1/src/prop_bc_data.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_bc_data.c: barcode data widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_bc_data.h" -#include "merge.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropBCDataSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_bc_data_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_bc_data_class_init (glPropBCDataClass * class); -static void gl_prop_bc_data_init (glPropBCData * bc_data); -static void gl_prop_bc_data_destroy (GtkObject * object); -static void gl_prop_bc_data_construct (glPropBCData * bc_data, - gchar * label, GList * field_defs); - -static void changed_cb (glPropBCData * bc_data); -static void radio_toggled_cb (GtkToggleButton * togglebutton, - glPropBCData * bc_data); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_bc_data_get_type (void) -{ - static guint prop_bc_data_type = 0; - - if (!prop_bc_data_type) { - GtkTypeInfo prop_bc_data_info = { - "glPropBCData", - sizeof (glPropBCData), - sizeof (glPropBCDataClass), - (GtkClassInitFunc) gl_prop_bc_data_class_init, - (GtkObjectInitFunc) gl_prop_bc_data_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_bc_data_type = gtk_type_unique (gtk_vbox_get_type (), - &prop_bc_data_info); - } - - return prop_bc_data_type; -} - -static void -gl_prop_bc_data_class_init (glPropBCDataClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_bc_data_destroy; - - prop_bc_data_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropBCDataClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, - prop_bc_data_signals, LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_bc_data_init (glPropBCData * bc_data) -{ - bc_data->literal_radio = NULL; - bc_data->literal_entry = NULL; - - bc_data->key_radio = NULL; - bc_data->key_entry = NULL; -} - -static void -gl_prop_bc_data_destroy (GtkObject * object) -{ - glPropBCData *bc_data; - glPropBCDataClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_BC_DATA (object)); - - bc_data = GL_PROP_BC_DATA (object); - class = GL_PROP_BC_DATA_CLASS (GTK_OBJECT (bc_data)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_bc_data_new (gchar * label, - GList * field_defs) -{ - glPropBCData *bc_data; - - bc_data = gtk_type_new (gl_prop_bc_data_get_type ()); - - gl_prop_bc_data_construct (bc_data, label, field_defs); - - return GTK_WIDGET (bc_data); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_bc_data_construct (glPropBCData * bc_data, - gchar * label, - GList * field_defs) -{ - GtkWidget *wvbox, *wframe, *wtable, *wcombo; - GSList *radio_group = NULL; - GList *keys; - - wvbox = GTK_WIDGET (bc_data); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 2, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* Literal radio */ - bc_data->literal_radio = gtk_radio_button_new_with_label (radio_group, - _ - ("Literal:")); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (bc_data->literal_radio)); - gtk_signal_connect (GTK_OBJECT (bc_data->literal_radio), "toggled", - GTK_SIGNAL_FUNC (radio_toggled_cb), - GTK_OBJECT (bc_data)); - gtk_table_attach_defaults (GTK_TABLE (wtable), bc_data->literal_radio, - 0, 1, 0, 1); - - /* Literal entry widget */ - bc_data->literal_entry = gtk_entry_new (); - gtk_widget_set_usize (bc_data->literal_entry, 200, 0); - gtk_signal_connect_object (GTK_OBJECT (bc_data->literal_entry), - "changed", GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (bc_data)); - gtk_table_attach_defaults (GTK_TABLE (wtable), bc_data->literal_entry, - 1, 2, 0, 1); - - /* Key radio */ - bc_data->key_radio = gtk_radio_button_new_with_label (radio_group, - _("Key:")); - gtk_signal_connect (GTK_OBJECT (bc_data->key_radio), "toggled", - GTK_SIGNAL_FUNC (radio_toggled_cb), - GTK_OBJECT (bc_data)); - gtk_table_attach_defaults (GTK_TABLE (wtable), bc_data->key_radio, - 0, 1, 1, 2); - - /* Key entry widget */ - wcombo = gtk_combo_new (); - keys = gl_merge_get_key_list (field_defs); - if (keys != NULL) - gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), keys); - gl_merge_free_key_list (&keys); - bc_data->key_entry = GTK_COMBO (wcombo)->entry; - gtk_entry_set_editable (GTK_ENTRY (bc_data->key_entry), FALSE); - gtk_widget_set_usize (wcombo, 200, 0); - gtk_signal_connect_object (GTK_OBJECT (bc_data->key_entry), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (bc_data)); - gtk_table_attach_defaults (GTK_TABLE (wtable), wcombo, 1, 2, 1, 2); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropBCData * bc_data) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (bc_data), prop_bc_data_signals[CHANGED]); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback to handle toggling of radio buttons */ -/*--------------------------------------------------------------------------*/ -static void -radio_toggled_cb (GtkToggleButton * togglebutton, - glPropBCData * bc_data) -{ - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (bc_data->literal_radio))) { - gtk_widget_set_sensitive (bc_data->literal_entry, TRUE); - gtk_widget_set_sensitive (bc_data->key_entry, FALSE); - } else { - gtk_widget_set_sensitive (bc_data->literal_entry, FALSE); - gtk_widget_set_sensitive (bc_data->key_entry, TRUE); - } - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (bc_data), prop_bc_data_signals[CHANGED]); -} - -/*--------------------------------------------------------------------------*/ -/* Get widget data. */ -/*--------------------------------------------------------------------------*/ -void -gl_prop_bc_data_get_data (glPropBCData * bc_data, - gboolean * field_flag, - gchar ** data, - gchar ** key) -{ - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (bc_data->literal_radio))) { - *field_flag = FALSE; - *data = - gtk_editable_get_chars (GTK_EDITABLE - (bc_data->literal_entry), 0, -1); - *key = NULL; - } else { - *field_flag = TRUE; - *data = NULL; - *key = - gtk_editable_get_chars (GTK_EDITABLE (bc_data->key_entry), - 0, -1); - } -} - -/*--------------------------------------------------------------------------*/ -/* Set widget data. */ -/*--------------------------------------------------------------------------*/ -void -gl_prop_bc_data_set_data (glPropBCData * bc_data, - gboolean merge_flag, - gboolean field_flag, - gchar * data, - gchar * key) -{ - gint pos; - - gtk_widget_set_sensitive (bc_data->key_radio, merge_flag); - - if (!field_flag) { - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (bc_data->literal_radio), TRUE); - - gtk_widget_set_sensitive (bc_data->literal_entry, TRUE); - gtk_widget_set_sensitive (bc_data->key_entry, FALSE); - - gtk_signal_handler_block_by_func (GTK_OBJECT - (bc_data->literal_entry), - GTK_SIGNAL_FUNC (changed_cb), - bc_data); - gtk_editable_delete_text (GTK_EDITABLE (bc_data->literal_entry), - 0, -1); - gtk_signal_handler_unblock_by_func (GTK_OBJECT - (bc_data->literal_entry), - GTK_SIGNAL_FUNC - (changed_cb), bc_data); - - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (bc_data->literal_entry), - data, strlen (data), &pos); - } else { - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (bc_data->key_radio), TRUE); - - gtk_widget_set_sensitive (bc_data->literal_entry, FALSE); - gtk_widget_set_sensitive (bc_data->key_entry, TRUE); - - gtk_signal_handler_block_by_func (GTK_OBJECT - (bc_data->key_entry), - GTK_SIGNAL_FUNC (changed_cb), - bc_data); - gtk_editable_delete_text (GTK_EDITABLE (bc_data->key_entry), 0, - -1); - gtk_signal_handler_unblock_by_func (GTK_OBJECT - (bc_data->key_entry), - GTK_SIGNAL_FUNC - (changed_cb), bc_data); - - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (bc_data->key_entry), - data, strlen (data), &pos); - } - -} diff --git a/glabels1/src/prop_bc_data.h b/glabels1/src/prop_bc_data.h deleted file mode 100644 index 0f59e3d..0000000 --- a/glabels1/src/prop_bc_data.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_bc_data.h: barcode data widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_BC_DATA_H__ -#define __PROP_BC_DATA_H__ - -#include <gnome.h> - -#define GL_TYPE_PROP_BC_DATA (gl_prop_bc_data_get_type ()) -#define GL_PROP_BC_DATA(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_BC_DATA, glPropBCData )) -#define GL_PROP_BC_DATA_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_BC_DATA, glPropBCDataClass)) -#define GL_IS_PROP_BC_DATA(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_BC_DATA)) -#define GL_IS_PROP_BC_DATA_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_BC_DATA)) - -typedef struct _glPropBCData glPropBCData; -typedef struct _glPropBCDataClass glPropBCDataClass; - -struct _glPropBCData { - GtkVBox parent_widget; - - GtkWidget *literal_radio; - GtkWidget *literal_entry; - - GtkWidget *key_radio; - GtkWidget *key_entry; -}; - -struct _glPropBCDataClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropBCData * bc_data, gpointer user_data); -}; - -extern guint gl_prop_bc_data_get_type (void); - -extern GtkWidget *gl_prop_bc_data_new (gchar * label, GList * field_defs); - -extern void gl_prop_bc_data_get_data (glPropBCData * bc_data, - gboolean * field_flag, - gchar ** data, - gchar ** key); - -extern void gl_prop_bc_data_set_data (glPropBCData * bc_data, - gboolean merge_flag, - gboolean field_flag, - gchar * data, - gchar * key); - -#endif diff --git a/glabels1/src/prop_bc_style.c b/glabels1/src/prop_bc_style.c deleted file mode 100644 index 07432ef..0000000 --- a/glabels1/src/prop_bc_style.c +++ /dev/null @@ -1,460 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_bc_style.c: barcode style selection widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_bc_style.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropBCStyleSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_bc_style_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_bc_style_class_init (glPropBCStyleClass * class); -static void gl_prop_bc_style_init (glPropBCStyle * prop_style); -static void gl_prop_bc_style_destroy (GtkObject * object); -static void gl_prop_bc_style_construct (glPropBCStyle * prop_style, - gchar * label); -static void changed_cb (glPropBCStyle * prop_style); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_bc_style_get_type (void) -{ - static guint prop_bc_style_type = 0; - - if (!prop_bc_style_type) { - GtkTypeInfo prop_bc_style_info = { - "glPropBCStyle", - sizeof (glPropBCStyle), - sizeof (glPropBCStyleClass), - (GtkClassInitFunc) gl_prop_bc_style_class_init, - (GtkObjectInitFunc) gl_prop_bc_style_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_bc_style_type = gtk_type_unique (gtk_vbox_get_type (), - &prop_bc_style_info); - } - - return prop_bc_style_type; -} - -static void -gl_prop_bc_style_class_init (glPropBCStyleClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_bc_style_destroy; - - prop_bc_style_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropBCStyleClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, prop_bc_style_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_bc_style_init (glPropBCStyle * prop_style) -{ - prop_style->postnet_radio = NULL; - prop_style->ean_radio = NULL; - prop_style->upc_radio = NULL; - prop_style->isbn_radio = NULL; - prop_style->code39_radio = NULL; - prop_style->code128_radio = NULL; - prop_style->code128c_radio = NULL; - prop_style->code128b_radio = NULL; - prop_style->i25_radio = NULL; - prop_style->cbr_radio = NULL; - prop_style->msi_radio = NULL; - prop_style->pls_radio = NULL; -} - -static void -gl_prop_bc_style_destroy (GtkObject * object) -{ - glPropBCStyle *prop_style; - glPropBCStyleClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_BC_STYLE (object)); - - prop_style = GL_PROP_BC_STYLE (object); - class = GL_PROP_BC_STYLE_CLASS (GTK_OBJECT (prop_style)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_bc_style_new (gchar * label) -{ - glPropBCStyle *prop_style; - - prop_style = gtk_type_new (gl_prop_bc_style_get_type ()); - - gl_prop_bc_style_construct (prop_style, label); - - return GTK_WIDGET (prop_style); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_bc_style_construct (glPropBCStyle * prop, - gchar * label) -{ - GtkWidget *wvbox, *wframe, *wvbox1, *whbox2, *wvbox2; - GSList *radio_group = NULL; - - wvbox = GTK_WIDGET (prop); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wvbox1 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox1), 10); - gtk_container_add (GTK_CONTAINER (wframe), wvbox1); - - whbox2 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_container_add (GTK_CONTAINER (wvbox1), whbox2); - - /* ... Start column ... */ - wvbox2 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox2), 10); - gtk_box_pack_start (GTK_BOX (whbox2), wvbox2, FALSE, FALSE, 0); - - /* POSTNET button */ - prop->postnet_radio = - gtk_radio_button_new_with_label (radio_group, "POSTNET"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->postnet_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->postnet_radio, - FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->postnet_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* EAN button */ - prop->ean_radio = gtk_radio_button_new_with_label (radio_group, "EAN"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->ean_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->ean_radio, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->ean_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* UPC button */ - prop->upc_radio = gtk_radio_button_new_with_label (radio_group, "UPC"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->upc_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->upc_radio, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->upc_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* ISBN button */ - prop->isbn_radio = - gtk_radio_button_new_with_label (radio_group, "ISBN"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->isbn_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->isbn_radio, - FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->isbn_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* CODE39 button */ - prop->code39_radio = - gtk_radio_button_new_with_label (radio_group, "Code 39"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->code39_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->code39_radio, - FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->code39_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* CODE128 button */ - prop->code128_radio = - gtk_radio_button_new_with_label (radio_group, "Code 128"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->code128_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->code128_radio, - FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->code128_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* ... Start column ... */ - wvbox2 = gtk_vbox_new (FALSE, GNOME_PAD); - gtk_container_set_border_width (GTK_CONTAINER (wvbox2), 10); - gtk_box_pack_start (GTK_BOX (whbox2), wvbox2, FALSE, FALSE, 0); - - /* CODE128B button */ - prop->code128b_radio = - gtk_radio_button_new_with_label (radio_group, "Code 128-B"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->code128b_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->code128b_radio, - FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->code128b_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* CODE128C button */ - prop->code128c_radio = - gtk_radio_button_new_with_label (radio_group, "Code 128-C"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->code128c_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->code128c_radio, - FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->code128c_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* I25 button */ - prop->i25_radio = - gtk_radio_button_new_with_label (radio_group, "Interleaved 2 of 5"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->i25_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->i25_radio, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->i25_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* CBR button */ - prop->cbr_radio = - gtk_radio_button_new_with_label (radio_group, "Codabar"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->cbr_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->cbr_radio, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->cbr_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* MSI button */ - prop->msi_radio = gtk_radio_button_new_with_label (radio_group, "MSI"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->msi_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->msi_radio, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->msi_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* PLS button */ - prop->pls_radio = - gtk_radio_button_new_with_label (radio_group, "Plessey"); - radio_group = - gtk_radio_button_group (GTK_RADIO_BUTTON (prop->pls_radio)); - gtk_box_pack_start (GTK_BOX (wvbox2), prop->pls_radio, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->pls_radio), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - - /* ... Separator ... */ - gtk_box_pack_start (GTK_BOX (wvbox1), gtk_hseparator_new (), FALSE, - FALSE, 0); - - /* Text checkbox widget */ - prop->text_check = - gtk_check_button_new_with_label (_("Show text with barcode")); - gtk_box_pack_start (GTK_BOX (wvbox1), prop->text_check, - FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (prop->text_check), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (prop)); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropBCStyle * prop_style) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (prop_style), - prop_bc_style_signals[CHANGED]); -} - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ -void -gl_prop_bc_style_get_params (glPropBCStyle * prop, - glBarcodeStyle * style, - gboolean * text_flag) -{ - *text_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (prop->text_check)); - - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->postnet_radio))) { - *style = GL_BARCODE_STYLE_POSTNET; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->ean_radio))) { - *style = GL_BARCODE_STYLE_EAN; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->upc_radio))) { - *style = GL_BARCODE_STYLE_UPC; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->isbn_radio))) { - *style = GL_BARCODE_STYLE_ISBN; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->code39_radio))) { - *style = GL_BARCODE_STYLE_39; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->code128_radio))) { - *style = GL_BARCODE_STYLE_128; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->code128c_radio))) { - *style = GL_BARCODE_STYLE_128C; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->code128b_radio))) { - *style = GL_BARCODE_STYLE_128B; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->i25_radio))) { - *style = GL_BARCODE_STYLE_I25; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->cbr_radio))) { - *style = GL_BARCODE_STYLE_CBR; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->msi_radio))) { - *style = GL_BARCODE_STYLE_MSI; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (prop->pls_radio))) { - *style = GL_BARCODE_STYLE_PLS; - } - -} - -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ -void -gl_prop_bc_style_set_params (glPropBCStyle * prop, - glBarcodeStyle style, - gboolean text_flag) -{ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prop->text_check), - text_flag); - - switch (style) { - case GL_BARCODE_STYLE_POSTNET: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->postnet_radio), TRUE); - break; - case GL_BARCODE_STYLE_EAN: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->ean_radio), TRUE); - break; - case GL_BARCODE_STYLE_UPC: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->upc_radio), TRUE); - break; - case GL_BARCODE_STYLE_ISBN: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->isbn_radio), TRUE); - break; - case GL_BARCODE_STYLE_39: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->code39_radio), TRUE); - break; - case GL_BARCODE_STYLE_128: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->code128_radio), TRUE); - break; - case GL_BARCODE_STYLE_128C: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->code128c_radio), TRUE); - break; - case GL_BARCODE_STYLE_128B: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->code128b_radio), TRUE); - break; - case GL_BARCODE_STYLE_I25: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->i25_radio), TRUE); - break; - case GL_BARCODE_STYLE_CBR: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->cbr_radio), TRUE); - break; - case GL_BARCODE_STYLE_MSI: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->msi_radio), TRUE); - break; - case GL_BARCODE_STYLE_PLS: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->pls_radio), TRUE); - break; - default: - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (prop->postnet_radio), TRUE); - break; - } -} diff --git a/glabels1/src/prop_bc_style.h b/glabels1/src/prop_bc_style.h deleted file mode 100644 index 13065e4..0000000 --- a/glabels1/src/prop_bc_style.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_bc_style.h: barcode style selection widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_BC_STYLE_H__ -#define __PROP_BC_STYLE_H__ - -#include <gnome.h> -#include "bc.h" - -#define GL_TYPE_PROP_BC_STYLE (gl_prop_bc_style_get_type ()) -#define GL_PROP_BC_STYLE(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_BC_STYLE, glPropBCStyle )) -#define GL_PROP_BC_STYLE_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_BC_STYLE, glPropBCStyleClass)) -#define GL_IS_PROP_BC_STYLE(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_BC_STYLE)) -#define GL_IS_PROP_BC_STYLE_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_BC_STYLE)) - -typedef struct _glPropBCStyle glPropBCStyle; -typedef struct _glPropBCStyleClass glPropBCStyleClass; - -struct _glPropBCStyle { - GtkVBox parent_widget; - - GtkWidget *postnet_radio; - GtkWidget *ean_radio; - GtkWidget *upc_radio; - GtkWidget *isbn_radio; - GtkWidget *code39_radio; - GtkWidget *code128_radio; - GtkWidget *code128c_radio; - GtkWidget *code128b_radio; - GtkWidget *i25_radio; - GtkWidget *cbr_radio; - GtkWidget *msi_radio; - GtkWidget *pls_radio; - - GtkWidget *text_check; -}; - -struct _glPropBCStyleClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropBCStyle * prop, gpointer user_data); -}; - -extern guint gl_prop_bc_style_get_type (void); - -extern GtkWidget *gl_prop_bc_style_new (gchar * label); - -extern void gl_prop_bc_style_get_params (glPropBCStyle * prop_style, - glBarcodeStyle * style, - gboolean * text_flag); - -extern void gl_prop_bc_style_set_params (glPropBCStyle * prop_style, - glBarcodeStyle style, - gboolean text_flag); - -#endif diff --git a/glabels1/src/prop_fill.c b/glabels1/src/prop_fill.c deleted file mode 100644 index f9f5151..0000000 --- a/glabels1/src/prop_fill.c +++ /dev/null @@ -1,215 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_fill.c: fill properties widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_fill.h" - -#include "debug.h" - -#define RED(x) ( ((x)>>24) & 0xff ) -#define GREEN(x) ( ((x)>>16) & 0xff ) -#define BLUE(x) ( ((x)>>8) & 0xff ) -#define ALPHA(x) ( (x) & 0xff ) - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropFillSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_fill_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_fill_class_init (glPropFillClass * class); -static void gl_prop_fill_init (glPropFill * fill); -static void gl_prop_fill_destroy (GtkObject * object); -static void gl_prop_fill_construct (glPropFill * fill, gchar * label); -static void changed_cb (glPropFill * fill); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_fill_get_type (void) -{ - static guint prop_fill_type = 0; - - if (!prop_fill_type) { - GtkTypeInfo prop_fill_info = { - "glPropFill", - sizeof (glPropFill), - sizeof (glPropFillClass), - (GtkClassInitFunc) gl_prop_fill_class_init, - (GtkObjectInitFunc) gl_prop_fill_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_fill_type = - gtk_type_unique (gtk_vbox_get_type (), &prop_fill_info); - } - - return prop_fill_type; -} - -static void -gl_prop_fill_class_init (glPropFillClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_fill_destroy; - - prop_fill_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropFillClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, prop_fill_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_fill_init (glPropFill * fill) -{ - fill->color_picker = NULL; -} - -static void -gl_prop_fill_destroy (GtkObject * object) -{ - glPropFill *fill; - glPropFillClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_FILL (object)); - - fill = GL_PROP_FILL (object); - class = GL_PROP_FILL_CLASS (GTK_OBJECT (fill)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_fill_new (gchar * label) -{ - glPropFill *fill; - - fill = gtk_type_new (gl_prop_fill_get_type ()); - - gl_prop_fill_construct (fill, label); - - return GTK_WIDGET (fill); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_fill_construct (glPropFill * fill, - gchar * label) -{ - GtkWidget *wvbox, *wframe, *wtable, *wlabel; - - wvbox = GTK_WIDGET (fill); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (1, 3, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* Fill Color Label */ - wlabel = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - - /* Fill Color picker widget */ - fill->color_picker = gnome_color_picker_new (); - gtk_signal_connect_object (GTK_OBJECT (fill->color_picker), "color_set", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (fill)); - gtk_table_attach_defaults (GTK_TABLE (wtable), fill->color_picker, 1, 3, - 0, 1); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropFill * fill) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (fill), prop_fill_signals[CHANGED]); -} - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ -void -gl_prop_fill_get_params (glPropFill * fill, - guint * color) -{ - guint8 r, g, b, a; - - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (fill->color_picker), - &r, &g, &b, &a); - *color = GNOME_CANVAS_COLOR_A (r, g, b, a); -} - -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ -void -gl_prop_fill_set_params (glPropFill * fill, - guint color) -{ - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (fill->color_picker), - RED (color), GREEN (color), BLUE (color), - ALPHA (color)); -} diff --git a/glabels1/src/prop_fill.h b/glabels1/src/prop_fill.h deleted file mode 100644 index 0605e20..0000000 --- a/glabels1/src/prop_fill.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_fill.h: fill properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_FILL_H__ -#define __PROP_FILL_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_PROP_FILL (gl_prop_fill_get_type ()) -#define GL_PROP_FILL(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_FILL, glPropFill )) -#define GL_PROP_FILL_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_FILL, glPropFillClass)) -#define GL_IS_PROP_FILL(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_FILL)) -#define GL_IS_PROP_FILL_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_FILL)) - -typedef struct _glPropFill glPropFill; -typedef struct _glPropFillClass glPropFillClass; - -struct _glPropFill { - GtkVBox parent_widget; - - GtkWidget *color_picker; -}; - -struct _glPropFillClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropFill * fill, gpointer user_data); -}; - -extern guint gl_prop_fill_get_type (void); - -extern GtkWidget *gl_prop_fill_new (gchar * label); - -extern void gl_prop_fill_get_params (glPropFill * fill, guint * color); - -extern void gl_prop_fill_set_params (glPropFill * fill, guint color); - -#endif diff --git a/glabels1/src/prop_line.c b/glabels1/src/prop_line.c deleted file mode 100644 index a73811e..0000000 --- a/glabels1/src/prop_line.c +++ /dev/null @@ -1,244 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_line.c: line properties widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_line.h" - -#include "debug.h" - -#define RED(x) ( ((x)>>24) & 0xff ) -#define GREEN(x) ( ((x)>>16) & 0xff ) -#define BLUE(x) ( ((x)>>8) & 0xff ) -#define ALPHA(x) ( (x) & 0xff ) - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropLineSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_line_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_line_class_init (glPropLineClass * class); -static void gl_prop_line_init (glPropLine * line); -static void gl_prop_line_destroy (GtkObject * object); -static void gl_prop_line_construct (glPropLine * line, gchar * label); -static void changed_cb (glPropLine * line); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_line_get_type (void) -{ - static guint prop_line_type = 0; - - if (!prop_line_type) { - GtkTypeInfo prop_line_info = { - "glPropLine", - sizeof (glPropLine), - sizeof (glPropLineClass), - (GtkClassInitFunc) gl_prop_line_class_init, - (GtkObjectInitFunc) gl_prop_line_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_line_type = - gtk_type_unique (gtk_vbox_get_type (), &prop_line_info); - } - - return prop_line_type; -} - -static void -gl_prop_line_class_init (glPropLineClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_line_destroy; - - prop_line_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropLineClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, prop_line_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_line_init (glPropLine * line) -{ - line->width_spin = NULL; - line->color_picker = NULL; - line->units_label = NULL; -} - -static void -gl_prop_line_destroy (GtkObject * object) -{ - glPropLine *line; - glPropLineClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_LINE (object)); - - line = GL_PROP_LINE (object); - class = GL_PROP_LINE_CLASS (GTK_OBJECT (line)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_line_new (gchar * label) -{ - glPropLine *line; - - line = gtk_type_new (gl_prop_line_get_type ()); - - gl_prop_line_construct (line, label); - - return GTK_WIDGET (line); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_line_construct (glPropLine * line, - gchar * label) -{ - GtkWidget *wvbox, *wframe, *wtable, *wlabel; - GtkObject *adjust; - - wvbox = GTK_WIDGET (line); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 3, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* Line Width Label */ - wlabel = gtk_label_new (_("Width:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - /* Line Width widget */ - adjust = gtk_adjustment_new (1.0, 0.25, 4.0, 0.25, 1.0, 1.0); - line->width_spin = - gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 0.25, 2); - gtk_signal_connect_object (GTK_OBJECT (line->width_spin), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (line)); - gtk_table_attach_defaults (GTK_TABLE (wtable), line->width_spin, 1, 2, - 0, 1); - /* Line Width units */ - line->units_label = gtk_label_new (_("points")); - gtk_misc_set_alignment (GTK_MISC (line->units_label), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), line->units_label, - 2, 3, 0, 1); - - /* Line Color Label */ - wlabel = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); - /* Line Color picker widget */ - line->color_picker = gnome_color_picker_new (); - gtk_signal_connect_object (GTK_OBJECT (line->color_picker), "color_set", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (line)); - gtk_table_attach_defaults (GTK_TABLE (wtable), line->color_picker, 1, 3, - 1, 2); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropLine * line) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (line), prop_line_signals[CHANGED]); -} - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ -void -gl_prop_line_get_params (glPropLine * line, - gdouble * width, - guint * color) -{ - guint8 r, g, b, a; - - *width = - gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON - (line->width_spin)); - - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (line->color_picker), - &r, &g, &b, &a); - *color = GNOME_CANVAS_COLOR_A (r, g, b, a); -} - -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ -void -gl_prop_line_set_params (glPropLine * line, - gdouble width, - guint color) -{ - gtk_spin_button_set_value (GTK_SPIN_BUTTON (line->width_spin), width); - - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (line->color_picker), - RED (color), GREEN (color), BLUE (color), - ALPHA (color)); -} diff --git a/glabels1/src/prop_line.h b/glabels1/src/prop_line.h deleted file mode 100644 index 1350fac..0000000 --- a/glabels1/src/prop_line.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_line.h: line properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_LINE_H__ -#define __PROP_LINE_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_PROP_LINE (gl_prop_line_get_type ()) -#define GL_PROP_LINE(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_LINE, glPropLine )) -#define GL_PROP_LINE_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_LINE, glPropLineClass)) -#define GL_IS_PROP_LINE(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_LINE)) -#define GL_IS_PROP_LINE_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_LINE)) - -typedef struct _glPropLine glPropLine; -typedef struct _glPropLineClass glPropLineClass; - -struct _glPropLine { - GtkVBox parent_widget; - - GtkWidget *width_spin; - GtkWidget *color_picker; - GtkWidget *units_label; -}; - -struct _glPropLineClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropLine * line, gpointer user_data); -}; - -extern guint gl_prop_line_get_type (void); - -extern GtkWidget *gl_prop_line_new (gchar * label); - -extern void gl_prop_line_get_params (glPropLine * line, - gdouble * width, - guint * color); - -extern void gl_prop_line_set_params (glPropLine * line, - gdouble width, - guint color); - -#endif diff --git a/glabels1/src/prop_position.c b/glabels1/src/prop_position.c deleted file mode 100644 index 039afe6..0000000 --- a/glabels1/src/prop_position.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_position.c: position properties widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_position.h" -#include "prefs.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropPositionSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_position_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_position_class_init (glPropPositionClass * class); -static void gl_prop_position_init (glPropPosition * position); -static void gl_prop_position_destroy (GtkObject * object); -static void gl_prop_position_construct (glPropPosition * position, - gchar * label); -static void changed_cb (glPropPosition * position); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_position_get_type (void) -{ - static guint prop_position_type = 0; - - if (!prop_position_type) { - GtkTypeInfo prop_position_info = { - "glPropPosition", - sizeof (glPropPosition), - sizeof (glPropPositionClass), - (GtkClassInitFunc) gl_prop_position_class_init, - (GtkObjectInitFunc) gl_prop_position_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_position_type = gtk_type_unique (gtk_vbox_get_type (), - &prop_position_info); - } - - return prop_position_type; -} - -static void -gl_prop_position_class_init (glPropPositionClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_position_destroy; - - prop_position_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropPositionClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, prop_position_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_position_init (glPropPosition * position) -{ - position->x_spin = NULL; - position->y_spin = NULL; -} - -static void -gl_prop_position_destroy (GtkObject * object) -{ - glPropPosition *position; - glPropPositionClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_POSITION (object)); - - position = GL_PROP_POSITION (object); - class = GL_PROP_POSITION_CLASS (GTK_OBJECT (position)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_position_new (gchar * label) -{ - glPropPosition *position; - - position = gtk_type_new (gl_prop_position_get_type ()); - - gl_prop_position_construct (position, label); - - return GTK_WIDGET (position); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_position_construct (glPropPosition * position, - gchar * label) -{ - GtkWidget *wvbox, *wframe, *wtable, *wlabel; - GtkObject *x_adjust, *y_adjust; - const gchar *units_string; - gdouble units_per_point, climb_rate; - gint digits; - - units_string = gl_prefs_get_units_string (); - units_per_point = gl_prefs_get_units_per_point (); - climb_rate = gl_prefs_get_units_step_size (); - digits = gl_prefs_get_units_precision (); - - wvbox = GTK_WIDGET (position); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 3, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* X label */ - wlabel = gtk_label_new (_("X:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - /* X spin */ - x_adjust = gtk_adjustment_new (0.0, 0.0, 100.0, climb_rate, 10.0, 10.0); - position->x_spin = gtk_spin_button_new (GTK_ADJUSTMENT (x_adjust), - climb_rate, digits); - gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (position->x_spin), - TRUE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (position->x_spin), TRUE); - gtk_signal_connect_object (GTK_OBJECT (position->x_spin), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (position)); - gtk_table_attach_defaults (GTK_TABLE (wtable), position->x_spin, - 1, 2, 0, 1); - - /* Y label */ - wlabel = gtk_label_new (_("Y:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); - /* Y spin */ - y_adjust = gtk_adjustment_new (0.0, 0.0, 100.0, climb_rate, 10.0, 10.0); - position->y_spin = gtk_spin_button_new (GTK_ADJUSTMENT (y_adjust), - climb_rate, digits); - gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (position->y_spin), - TRUE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (position->y_spin), TRUE); - gtk_signal_connect_object (GTK_OBJECT (position->y_spin), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (position)); - gtk_table_attach_defaults (GTK_TABLE (wtable), position->y_spin, - 1, 2, 1, 2); - - /* Units */ - position->units_label = gtk_label_new (units_string); - gtk_misc_set_alignment (GTK_MISC (position->units_label), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), - position->units_label, 2, 3, 1, 2); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropPosition * position) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (position), prop_position_signals[CHANGED]); -} - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ -void -gl_prop_position_get_position (glPropPosition * position, - gdouble * x, - gdouble * y) -{ - gdouble units_per_point; - - units_per_point = gl_prefs_get_units_per_point (); - - *x = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (position->x_spin)); - *y = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (position->y_spin)); - - /* convert everything back to our internal units (points) */ - *x /= units_per_point; - *y /= units_per_point; -} - -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ -void -gl_prop_position_set_params (glPropPosition * position, - gdouble x, - gdouble y, - gdouble x_max, - gdouble y_max) -{ - GtkObject *x_adjust, *y_adjust; - const gchar *units_string; - gdouble units_per_point, climb_rate; - gint digits; - - units_string = gl_prefs_get_units_string (); - units_per_point = gl_prefs_get_units_per_point (); - climb_rate = gl_prefs_get_units_step_size (); - digits = gl_prefs_get_units_precision (); - - /* Put everything into our display units */ - x *= units_per_point; - y *= units_per_point; - x_max *= units_per_point; - y_max *= units_per_point; - - /* update X/Y spin controls */ - x_adjust = gtk_adjustment_new (x, 0.0, x_max, climb_rate, 10.0, 10.0); - gtk_spin_button_configure (GTK_SPIN_BUTTON (position->x_spin), - GTK_ADJUSTMENT (x_adjust), climb_rate, - digits); - y_adjust = gtk_adjustment_new (y, 0.0, y_max, climb_rate, 10.0, 10.0); - gtk_spin_button_configure (GTK_SPIN_BUTTON (position->y_spin), - GTK_ADJUSTMENT (y_adjust), climb_rate, - digits); - - /* Units */ - gtk_label_set_text (GTK_LABEL (position->units_label), units_string); - -} diff --git a/glabels1/src/prop_position.h b/glabels1/src/prop_position.h deleted file mode 100644 index c0637a5..0000000 --- a/glabels1/src/prop_position.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_position.h: position properties widget module header file - * - * Copyright (C) 2000, 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_POSITION_H__ -#define __PROP_POSITION_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_PROP_POSITION (gl_prop_position_get_type ()) -#define GL_PROP_POSITION(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_POSITION, glPropPosition )) -#define GL_PROP_POSITION_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_POSITION, glPropPositionClass)) -#define GL_IS_PROP_POSITION(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_POSITION)) -#define GL_IS_PROP_POSITION_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_POSITION)) - -typedef struct _glPropPosition glPropPosition; -typedef struct _glPropPositionClass glPropPositionClass; - -struct _glPropPosition { - GtkVBox parent_widget; - - GtkWidget *x_spin; - GtkWidget *y_spin; - GtkWidget *units_label; -}; - -struct _glPropPositionClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropPosition * prop, gpointer user_data); -}; - -extern guint gl_prop_position_get_type (void); - -extern GtkWidget *gl_prop_position_new (gchar * label); - -extern void gl_prop_position_get_position (glPropPosition * position, - gdouble * x, gdouble * y); - -extern void gl_prop_position_set_params (glPropPosition * position, - gdouble x, gdouble y, - gdouble x_max, gdouble y_max); - -#endif diff --git a/glabels1/src/prop_size.c b/glabels1/src/prop_size.c deleted file mode 100644 index 1f8d094..0000000 --- a/glabels1/src/prop_size.c +++ /dev/null @@ -1,459 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_size.c: size properties widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_size.h" -#include "prefs.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropSizeSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_size_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_size_class_init (glPropSizeClass * class); -static void gl_prop_size_init (glPropSize * size); -static void gl_prop_size_destroy (GtkObject * object); -static void gl_prop_size_construct (glPropSize * size, gchar * label); - -static void aspect_toggle_cb (GtkToggleButton * togglebutton, - gpointer user_data); -static void w_spin_cb (GtkSpinButton * spinbutton, gpointer user_data); -static void h_spin_cb (GtkSpinButton * spinbutton, gpointer user_data); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_size_get_type (void) -{ - static guint prop_size_type = 0; - - if (!prop_size_type) { - GtkTypeInfo prop_size_info = { - "glPropSize", - sizeof (glPropSize), - sizeof (glPropSizeClass), - (GtkClassInitFunc) gl_prop_size_class_init, - (GtkObjectInitFunc) gl_prop_size_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_size_type = - gtk_type_unique (gtk_vbox_get_type (), &prop_size_info); - } - - return prop_size_type; -} - -static void -gl_prop_size_class_init (glPropSizeClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_size_destroy; - - prop_size_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropSizeClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, prop_size_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_size_init (glPropSize * size) -{ - size->aspect_ratio = 1.0; - - size->w_spin = NULL; - size->h_spin = NULL; - - size->units_label = NULL; - - size->aspect_checkbox = NULL; -} - -static void -gl_prop_size_destroy (GtkObject * object) -{ - glPropSize *size; - glPropSizeClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_SIZE (object)); - - size = GL_PROP_SIZE (object); - class = GL_PROP_SIZE_CLASS (GTK_OBJECT (size)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_size_new (gchar * label) -{ - glPropSize *size; - - size = gtk_type_new (gl_prop_size_get_type ()); - - gl_prop_size_construct (size, label); - - return GTK_WIDGET (size); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_size_construct (glPropSize * size, - gchar * label) -{ - GtkWidget *wvbox, *wframe, *wtable, *wlabel; - GtkObject *w_adjust, *h_adjust; - const gchar *units_string; - gdouble units_per_point, climb_rate; - gint digits; - - units_string = gl_prefs_get_units_string (); - units_per_point = gl_prefs_get_units_per_point (); - climb_rate = gl_prefs_get_units_step_size (); - digits = gl_prefs_get_units_precision (); - - wvbox = GTK_WIDGET (size); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (3, 3, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* W Label */ - wlabel = gtk_label_new (_("Width:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - /* W spin */ - w_adjust = gtk_adjustment_new (climb_rate, climb_rate, 100.0, - climb_rate, 10.0, 10.0); - size->w_spin = gtk_spin_button_new (GTK_ADJUSTMENT (w_adjust), - climb_rate, digits); - gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (size->w_spin), - TRUE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (size->w_spin), TRUE); - gtk_table_attach_defaults (GTK_TABLE (wtable), size->w_spin, - 1, 2, 0, 1); - - /* H label */ - wlabel = gtk_label_new (_("Height:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); - /* H spin */ - h_adjust = gtk_adjustment_new (climb_rate, climb_rate, - 100.0, climb_rate, 10.0, 10.0); - size->h_spin = gtk_spin_button_new (GTK_ADJUSTMENT (h_adjust), - climb_rate, digits); - gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (size->h_spin), - TRUE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (size->h_spin), TRUE); - gtk_table_attach_defaults (GTK_TABLE (wtable), size->h_spin, - 1, 2, 1, 2); - - /* Units */ - size->units_label = gtk_label_new (units_string); - gtk_misc_set_alignment (GTK_MISC (size->units_label), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), - size->units_label, 2, 3, 1, 2); - - /* Maintain aspect ratio checkbox */ - size->aspect_checkbox = - gtk_check_button_new_with_label (_ - ("Maintain current aspect ratio")); - gtk_table_attach_defaults (GTK_TABLE (wtable), size->aspect_checkbox, 0, - 3, 2, 3); - - /* Connect signals to controls */ - gtk_signal_connect (GTK_OBJECT (size->aspect_checkbox), "toggled", - GTK_SIGNAL_FUNC (aspect_toggle_cb), size); - gtk_signal_connect (GTK_OBJECT (size->w_spin), "changed", - GTK_SIGNAL_FUNC (w_spin_cb), size); - gtk_signal_connect (GTK_OBJECT (size->h_spin), "changed", - GTK_SIGNAL_FUNC (h_spin_cb), size); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Maintain aspect ratio checkbox callback. */ -/*--------------------------------------------------------------------------*/ -static void -aspect_toggle_cb (GtkToggleButton * togglebutton, - gpointer user_data) -{ - glPropSize *size = GL_PROP_SIZE (user_data); - GtkAdjustment *w_adjust, *h_adjust; - - if (gtk_toggle_button_get_active (togglebutton)) { - - size->w = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (size->w_spin)); - size->h = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (size->h_spin)); - - size->aspect_ratio = size->h / size->w; - - /* We have a new aspect ratio, adjust one of the maxes accordingly */ - if ((size->h_max_orig / size->w_max_orig) < size->aspect_ratio) { - size->w_max = size->h_max_orig / size->aspect_ratio; - size->h_max = size->h_max_orig; - } else { - size->w_max = size->w_max_orig; - size->h_max = size->w_max_orig * size->aspect_ratio; - } - - } else { - - /* Reset maximums */ - size->w_max = size->w_max_orig; - size->h_max = size->h_max_orig; - - } - - gtk_signal_handler_block_by_func (GTK_OBJECT (size->w_spin), - GTK_SIGNAL_FUNC (w_spin_cb), - user_data); - gtk_signal_handler_block_by_func (GTK_OBJECT (size->h_spin), - GTK_SIGNAL_FUNC (h_spin_cb), - user_data); - w_adjust = - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (size->w_spin)); - w_adjust->upper = size->w_max; - gtk_spin_button_update (GTK_SPIN_BUTTON (size->w_spin)); - h_adjust = - gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (size->h_spin)); - h_adjust->upper = size->h_max; - gtk_spin_button_update (GTK_SPIN_BUTTON (size->h_spin)); - gtk_signal_handler_unblock_by_func (GTK_OBJECT (size->w_spin), - GTK_SIGNAL_FUNC (w_spin_cb), - user_data); - gtk_signal_handler_unblock_by_func (GTK_OBJECT (size->h_spin), - GTK_SIGNAL_FUNC (h_spin_cb), - user_data); - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (size), prop_size_signals[CHANGED]); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. W spin button changed callback. */ -/*--------------------------------------------------------------------------*/ -static void -w_spin_cb (GtkSpinButton * spinbutton, - gpointer user_data) -{ - glPropSize *size = GL_PROP_SIZE (user_data); - GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (size->aspect_checkbox); - - size->w = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (size->w_spin)); - - if (gtk_toggle_button_get_active (toggle)) { - - size->h = size->w * size->aspect_ratio; - - /* Update our sibling control, blocking recursion. */ - gtk_signal_handler_block_by_func (GTK_OBJECT (size->h_spin), - GTK_SIGNAL_FUNC (h_spin_cb), - user_data); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (size->h_spin), - size->h); - gtk_signal_handler_unblock_by_func (GTK_OBJECT (size->h_spin), - GTK_SIGNAL_FUNC (h_spin_cb), - user_data); - } - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (size), prop_size_signals[CHANGED]); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. H spin button changed callback. */ -/*--------------------------------------------------------------------------*/ -static void -h_spin_cb (GtkSpinButton * spinbutton, - gpointer user_data) -{ - glPropSize *size = GL_PROP_SIZE (user_data); - GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (size->aspect_checkbox); - - size->h = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON (size->h_spin)); - - if (gtk_toggle_button_get_active (toggle)) { - - size->w = size->h / size->aspect_ratio; - - /* Update our sibling control, blocking recursion. */ - gtk_signal_handler_block_by_func (GTK_OBJECT (size->w_spin), - GTK_SIGNAL_FUNC (w_spin_cb), - user_data); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (size->w_spin), - size->w); - gtk_signal_handler_unblock_by_func (GTK_OBJECT (size->w_spin), - GTK_SIGNAL_FUNC (w_spin_cb), - user_data); - } - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (size), prop_size_signals[CHANGED]); - -} - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ -void -gl_prop_size_get_size (glPropSize * size, - gdouble * w, - gdouble * h, - gboolean * keep_aspect_ratio_flag) -{ - gdouble units_per_point; - - units_per_point = gl_prefs_get_units_per_point (); - - *w = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (size->w_spin)); - *h = gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (size->h_spin)); - - *keep_aspect_ratio_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (size->aspect_checkbox)); - - /* convert everything back to our internal units (points) */ - *w /= units_per_point; - *h /= units_per_point; -} - -/*====================================================================*/ -/* set values and ranges for controls. */ -/*====================================================================*/ -void -gl_prop_size_set_params (glPropSize * size, - gdouble w, - gdouble h, - gboolean keep_aspect_ratio_flag, - gdouble w_max, - gdouble h_max) -{ - GtkObject *w_adjust, *h_adjust; - const gchar *units_string; - gdouble units_per_point, climb_rate; - gint digits; - - units_string = gl_prefs_get_units_string (); - units_per_point = gl_prefs_get_units_per_point (); - climb_rate = gl_prefs_get_units_step_size (); - digits = gl_prefs_get_units_precision (); - - /* Put everything into our display units */ - size->w = w * units_per_point; - size->h = h * units_per_point; - size->w_max = w_max * units_per_point; - size->h_max = h_max * units_per_point; - - /* Squirrel away copies of our original maximums */ - size->w_max_orig = size->w_max; - size->h_max_orig = size->h_max; - - size->aspect_ratio = size->h / size->w; - if (keep_aspect_ratio_flag) { - - /* When tracking aspect ratio, adjust one of the maxes */ - if ((size->h_max / size->w_max) < size->aspect_ratio) { - size->w_max = size->h_max / size->aspect_ratio; - } else { - size->h_max = size->w_max * size->aspect_ratio; - } - - /* before adjusting w & h, limit to max values */ - if (size->w > size->w_max) - size->w = size->w_max; - if (size->h > size->h_max) - size->h = size->h_max; - - } - - /* update W/H spin controls */ - w_adjust = gtk_adjustment_new (size->w, climb_rate, size->w_max, - climb_rate, 10.0, 10.0); - gtk_spin_button_configure (GTK_SPIN_BUTTON (size->w_spin), - GTK_ADJUSTMENT (w_adjust), climb_rate, - digits); - h_adjust = - gtk_adjustment_new (size->h, climb_rate, size->h_max, climb_rate, - 10.0, 10.0); - gtk_spin_button_configure (GTK_SPIN_BUTTON (size->h_spin), - GTK_ADJUSTMENT (h_adjust), climb_rate, - digits); - - gtk_label_set_text (GTK_LABEL (size->units_label), units_string); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (size->aspect_checkbox), - keep_aspect_ratio_flag); - -} diff --git a/glabels1/src/prop_size.h b/glabels1/src/prop_size.h deleted file mode 100644 index 550e93f..0000000 --- a/glabels1/src/prop_size.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_size.h: size properties widget module header file - * - * Copyright (C) 2000, 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_SIZE_H__ -#define __PROP_SIZE_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_PROP_SIZE (gl_prop_size_get_type ()) -#define GL_PROP_SIZE(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_SIZE, glPropSize )) -#define GL_PROP_SIZE_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_SIZE, glPropSizeClass)) -#define GL_IS_PROP_SIZE(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_SIZE)) -#define GL_IS_PROP_SIZE_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_SIZE)) - -typedef struct _glPropSize glPropSize; -typedef struct _glPropSizeClass glPropSizeClass; - -struct _glPropSize { - GtkVBox parent_widget; - - gdouble w, h; - gdouble aspect_ratio; - gdouble w_max, h_max; - gdouble w_max_orig, h_max_orig; - - GtkWidget *w_spin; - GtkWidget *h_spin; - GtkWidget *units_label; - GtkWidget *aspect_checkbox; -}; - -struct _glPropSizeClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropSize * size, gpointer user_data); -}; - -extern guint gl_prop_size_get_type (void); - -extern GtkWidget *gl_prop_size_new (gchar * label); - -extern void gl_prop_size_get_size (glPropSize * size, - gdouble * w, gdouble * h, - gboolean * keep_aspect_ratio_flag); - -extern void gl_prop_size_set_params (glPropSize * size, - gdouble w, gdouble h, - gboolean keep_aspect_ratio_flag, - gdouble w_max, gdouble h_max); - -#endif diff --git a/glabels1/src/prop_text.c b/glabels1/src/prop_text.c deleted file mode 100644 index c7f6a2a..0000000 --- a/glabels1/src/prop_text.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_text.c: text properties widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_text.h" - -#include "debug.h" - -#define RED(x) ( ((x)>>24) & 0xff ) -#define GREEN(x) ( ((x)>>16) & 0xff ) -#define BLUE(x) ( ((x)>>8) & 0xff ) -#define ALPHA(x) ( (x) & 0xff ) - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropTextSignal) (GtkObject * object, - gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_text_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_text_class_init (glPropTextClass * class); -static void gl_prop_text_init (glPropText * text); -static void gl_prop_text_destroy (GtkObject * object); -static void gl_prop_text_construct (glPropText * text, gchar * label); - -static void changed_cb (glPropText * text); -static void just_toggled_cb (GtkToggleButton * togglebutton, - gpointer user_data); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_text_get_type (void) -{ - static guint prop_text_type = 0; - - if (!prop_text_type) { - GtkTypeInfo prop_text_info = { - "glPropText", - sizeof (glPropText), - sizeof (glPropTextClass), - (GtkClassInitFunc) gl_prop_text_class_init, - (GtkObjectInitFunc) gl_prop_text_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_text_type = - gtk_type_unique (gtk_vbox_get_type (), &prop_text_info); - } - - return prop_text_type; -} - -static void -gl_prop_text_class_init (glPropTextClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_text_destroy; - - prop_text_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropTextClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, prop_text_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_text_init (glPropText * text) -{ - text->font_family_entry = NULL; - text->font_size_spin = NULL; - text->font_b_button = NULL; - text->font_i_button = NULL; - - text->color_picker = NULL; - - text->left_button = NULL; - text->right_button = NULL; - text->center_button = NULL; -} - -static void -gl_prop_text_destroy (GtkObject * object) -{ - glPropText *text; - glPropTextClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_TEXT (object)); - - text = GL_PROP_TEXT (object); - class = GL_PROP_TEXT_CLASS (GTK_OBJECT (text)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_text_new (gchar * label) -{ - glPropText *text; - - text = gtk_type_new (gl_prop_text_get_type ()); - - gl_prop_text_construct (text, label); - - return GTK_WIDGET (text); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_text_construct (glPropText * text, - gchar * label) -{ - GtkWidget *wvbox, *wframe, *wtable, *wlabel, *whbox1, *wcombo; - GList *family_names = NULL; - GtkObject *adjust; - - wvbox = GTK_WIDGET (text); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (3, 3, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* Font label */ - wlabel = gtk_label_new (_("Font:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - - /* Pack these widgets into an inner hbox */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_table_attach_defaults (GTK_TABLE (wtable), whbox1, 1, 3, 0, 1); - - /* Font family entry widget */ - wcombo = gtk_combo_new (); - family_names = gnome_font_family_list (); - gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), family_names); - gnome_font_family_list_free (family_names); - text->font_family_entry = GTK_COMBO (wcombo)->entry; - gtk_entry_set_editable (GTK_ENTRY (text->font_family_entry), FALSE); - gtk_widget_set_usize (wcombo, 200, 0); - gtk_box_pack_start (GTK_BOX (whbox1), wcombo, FALSE, FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (text->font_family_entry), - "changed", GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (text)); - - /* Font size entry widget */ - adjust = gtk_adjustment_new (1.0, 1.0, 250.0, 1.0, 10.0, 10.0); - text->font_size_spin = - gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 1.0, 0); - gtk_box_pack_start (GTK_BOX (whbox1), text->font_size_spin, FALSE, - FALSE, 0); - gtk_signal_connect_object (GTK_OBJECT (text->font_size_spin), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (text)); - - /* Font weight/italic button widgets */ - text->font_b_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->font_b_button), - gnome_stock_new_with_icon - (GNOME_STOCK_PIXMAP_TEXT_BOLD)); - gtk_box_pack_start (GTK_BOX (whbox1), text->font_b_button, FALSE, FALSE, - 0); - gtk_signal_connect_object (GTK_OBJECT (text->font_b_button), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (text)); - text->font_i_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->font_i_button), - gnome_stock_new_with_icon - (GNOME_STOCK_PIXMAP_TEXT_ITALIC)); - gtk_box_pack_start (GTK_BOX (whbox1), text->font_i_button, FALSE, FALSE, - 0); - gtk_signal_connect_object (GTK_OBJECT (text->font_i_button), "toggled", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (text)); - - /* Text Color Label */ - wlabel = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); - - /* Text Color picker widget */ - text->color_picker = gnome_color_picker_new (); - gtk_signal_connect_object (GTK_OBJECT (text->color_picker), "color_set", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (text)); - gtk_table_attach_defaults (GTK_TABLE (wtable), text->color_picker, 1, 2, - 1, 2); - - /* Alignment label */ - wlabel = gtk_label_new (_("Alignment:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 2, 3); - - /* Pack these widgets into an inner hbox */ - whbox1 = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_table_attach_defaults (GTK_TABLE (wtable), whbox1, 1, 2, 2, 3); - - /* Justification entry widget */ - text->left_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->left_button), - gnome_stock_new_with_icon - (GNOME_STOCK_PIXMAP_ALIGN_LEFT)); - gtk_box_pack_start (GTK_BOX (whbox1), text->left_button, FALSE, FALSE, - 0); - text->center_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->center_button), - gnome_stock_new_with_icon - (GNOME_STOCK_PIXMAP_ALIGN_CENTER)); - gtk_box_pack_start (GTK_BOX (whbox1), text->center_button, FALSE, FALSE, - 0); - text->right_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->right_button), - gnome_stock_new_with_icon - (GNOME_STOCK_PIXMAP_ALIGN_RIGHT)); - gtk_box_pack_start (GTK_BOX (whbox1), text->right_button, FALSE, FALSE, - 0); - - /* Now connect a callback that makes these toggles mutually exclusive */ - gtk_signal_connect (GTK_OBJECT (text->left_button), "toggled", - GTK_SIGNAL_FUNC (just_toggled_cb), text); - gtk_signal_connect (GTK_OBJECT (text->center_button), "toggled", - GTK_SIGNAL_FUNC (just_toggled_cb), text); - gtk_signal_connect (GTK_OBJECT (text->right_button), "toggled", - GTK_SIGNAL_FUNC (just_toggled_cb), text); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropText * text) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (text), prop_text_signals[CHANGED]); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Justify toggle button callback. */ -/*--------------------------------------------------------------------------*/ -static void -just_toggled_cb (GtkToggleButton * togglebutton, - gpointer user_data) -{ - glPropText *text = GL_PROP_TEXT (user_data); - - if (gtk_toggle_button_get_active (togglebutton)) { - - if (GTK_WIDGET (togglebutton) == GTK_WIDGET (text->left_button)) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (text->center_button), - FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (text->right_button), - FALSE); - } else if (GTK_WIDGET (togglebutton) == - GTK_WIDGET (text->center_button)) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (text->left_button), - FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (text->right_button), - FALSE); - } else if (GTK_WIDGET (togglebutton) == - GTK_WIDGET (text->right_button)) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (text->left_button), - FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (text->center_button), - FALSE); - } - - } - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (text), prop_text_signals[CHANGED]); -} - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ -void -gl_prop_text_get_params (glPropText * text, - gchar ** font_family, - gdouble * font_size, - GnomeFontWeight * font_weight, - gboolean * font_italic_flag, - guint * color, - GtkJustification * just) -{ - guint8 r, g, b, a; - - /* ------ Get updated font information ------ */ - *font_family = - gtk_editable_get_chars (GTK_EDITABLE (text->font_family_entry), 0, - -1); - *font_size = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (text->font_size_spin)); - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (text->font_b_button))) { - *font_weight = GNOME_FONT_BOLD; - } else { - *font_weight = GNOME_FONT_BOOK; - } - *font_italic_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (text->font_i_button)); - - /* ------ Get updated color ------ */ - gnome_color_picker_get_i8 (GNOME_COLOR_PICKER (text->color_picker), - &r, &g, &b, &a); - *color = GNOME_CANVAS_COLOR_A (r, g, b, a); - - /* ------- Get updated justification ------ */ - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (text->left_button))) { - *just = GTK_JUSTIFY_LEFT; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (text->right_button))) { - *just = GTK_JUSTIFY_RIGHT; - } else - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (text->center_button))) { - *just = GTK_JUSTIFY_CENTER; - } else { - *just = GTK_JUSTIFY_LEFT; /* Should not happen. */ - } - -} - -/*====================================================================*/ -/* fill in values and ranges for controls. */ -/*====================================================================*/ -void -gl_prop_text_set_params (glPropText * text, - gchar * font_family, - gdouble font_size, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - guint color, - GtkJustification just) -{ - gtk_entry_set_text (GTK_ENTRY (text->font_family_entry), font_family); - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (text->font_size_spin), - font_size); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text->font_b_button), - (font_weight == GNOME_FONT_BOLD)); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text->font_i_button), - font_italic_flag); - - gnome_color_picker_set_i8 (GNOME_COLOR_PICKER (text->color_picker), - RED (color), GREEN (color), BLUE (color), - ALPHA (color)); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text->left_button), - (just == GTK_JUSTIFY_LEFT)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text->center_button), - (just == GTK_JUSTIFY_CENTER)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (text->right_button), - (just == GTK_JUSTIFY_RIGHT)); -} diff --git a/glabels1/src/prop_text.h b/glabels1/src/prop_text.h deleted file mode 100644 index 8d3b02a..0000000 --- a/glabels1/src/prop_text.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_text.h: text properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_TEXT_H__ -#define __PROP_TEXT_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_PROP_TEXT (gl_prop_text_get_type ()) -#define GL_PROP_TEXT(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_TEXT, glPropText )) -#define GL_PROP_TEXT_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_TEXT, glPropTextClass)) -#define GL_IS_PROP_TEXT(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_TEXT)) -#define GL_IS_PROP_TEXT_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_TEXT)) - -typedef struct _glPropText glPropText; -typedef struct _glPropTextClass glPropTextClass; - -struct _glPropText { - GtkVBox parent_widget; - - GtkWidget *font_family_entry; - GtkWidget *font_size_spin; - GtkWidget *font_b_button; - GtkWidget *font_i_button; - - GtkWidget *color_picker; - - GtkWidget *left_button, *right_button, *center_button; -}; - -struct _glPropTextClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropText * text, gpointer user_data); -}; - -extern guint gl_prop_text_get_type (void); - -extern GtkWidget *gl_prop_text_new (gchar * label); - -extern void gl_prop_text_get_params (glPropText * text, - gchar ** font_family, - gdouble * font_size, - GnomeFontWeight * font_weight, - gboolean * font_italic_flag, - guint * color, - GtkJustification * just); - -extern void gl_prop_text_set_params (glPropText * text, - gchar * font_family, - gdouble font_size, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - guint color, - GtkJustification just); - -#endif diff --git a/glabels1/src/prop_text_entry.c b/glabels1/src/prop_text_entry.c deleted file mode 100644 index e82e6d1..0000000 --- a/glabels1/src/prop_text_entry.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_text_entry.c: text entry widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_text_entry.h" -#include "merge.h" -#include "text_node.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropTextEntrySignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_text_entry_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_text_entry_class_init (glPropTextEntryClass * class); -static void gl_prop_text_entry_init (glPropTextEntry * text_entry); -static void gl_prop_text_entry_destroy (GtkObject * object); -static void gl_prop_text_entry_construct (glPropTextEntry * text_entry, - gchar * label, GList * field_defs); - -static void changed_cb (glPropTextEntry * text_entry); -static void insert_cb (glPropTextEntry * text_entry); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_text_entry_get_type (void) -{ - static guint prop_text_entry_type = 0; - - if (!prop_text_entry_type) { - GtkTypeInfo prop_text_entry_info = { - "glPropTextEntry", - sizeof (glPropTextEntry), - sizeof (glPropTextEntryClass), - (GtkClassInitFunc) gl_prop_text_entry_class_init, - (GtkObjectInitFunc) gl_prop_text_entry_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_text_entry_type = gtk_type_unique (gtk_vbox_get_type (), - &prop_text_entry_info); - } - - return prop_text_entry_type; -} - -static void -gl_prop_text_entry_class_init (glPropTextEntryClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_text_entry_destroy; - - prop_text_entry_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropTextEntryClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, - prop_text_entry_signals, LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_text_entry_init (glPropTextEntry * text_entry) -{ - text_entry->text_entry = NULL; - text_entry->key_entry = NULL; - text_entry->insert_button = NULL; -} - -static void -gl_prop_text_entry_destroy (GtkObject * object) -{ - glPropTextEntry *text_entry; - glPropTextEntryClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_TEXT_ENTRY (object)); - - text_entry = GL_PROP_TEXT_ENTRY (object); - class = GL_PROP_TEXT_ENTRY_CLASS (GTK_OBJECT (text_entry)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_text_entry_new (gchar * label, - GList * field_defs) -{ - glPropTextEntry *text_entry; - - text_entry = gtk_type_new (gl_prop_text_entry_get_type ()); - - gl_prop_text_entry_construct (text_entry, label, field_defs); - - return GTK_WIDGET (text_entry); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_text_entry_construct (glPropTextEntry * text_entry, - gchar * label, - GList * field_defs) -{ - GtkWidget *wvbox, *wframe, *wtable, *wlabel, *wcombo; - GList *keys; - - wvbox = GTK_WIDGET (text_entry); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 3, FALSE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* Actual text entry widget */ - text_entry->text_entry = gtk_text_new (NULL, NULL); - gtk_text_set_editable (GTK_TEXT (text_entry->text_entry), TRUE); - gtk_signal_connect_object (GTK_OBJECT (text_entry->text_entry), - "changed", GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (text_entry)); - gtk_table_attach_defaults (GTK_TABLE (wtable), text_entry->text_entry, - 0, 3, 0, 1); - - /* Insert merge field label */ - wlabel = gtk_label_new (_("Key:")); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); - - /* Key entry widget */ - wcombo = gtk_combo_new (); - keys = gl_merge_get_key_list (field_defs); - if (keys != NULL) - gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), keys); - gl_merge_free_key_list (&keys); - text_entry->key_entry = GTK_COMBO (wcombo)->entry; - gtk_entry_set_editable (GTK_ENTRY (text_entry->key_entry), FALSE); - gtk_widget_set_usize (wcombo, 200, 0); - gtk_table_attach_defaults (GTK_TABLE (wtable), wcombo, 1, 2, 1, 2); - - /* Insert button */ - text_entry->insert_button = - gtk_button_new_with_label (_("Insert merge field")); - gtk_signal_connect_object (GTK_OBJECT (text_entry->insert_button), - "clicked", GTK_SIGNAL_FUNC (insert_cb), - GTK_OBJECT (text_entry)); - gtk_table_attach_defaults (GTK_TABLE (wtable), - text_entry->insert_button, 2, 3, 1, 2); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropTextEntry * text_entry) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (text_entry), - prop_text_entry_signals[CHANGED]); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -insert_cb (glPropTextEntry * text_entry) -{ - gchar *key, *field; - gint pos; - - key = - gtk_editable_get_chars (GTK_EDITABLE (text_entry->key_entry), 0, - -1); - field = g_strdup_printf ("FIELD{%s}", key); - - pos = gtk_editable_get_position (GTK_EDITABLE (text_entry->text_entry)); - gtk_editable_insert_text (GTK_EDITABLE (text_entry->text_entry), - field, strlen (field), &pos); - - g_free (field); - g_free (key); - -} - -/*--------------------------------------------------------------------------*/ -/* Get widget data. */ -/*--------------------------------------------------------------------------*/ -GList * -gl_prop_text_entry_get_text (glPropTextEntry * text_entry) -{ - gchar *text; - GList *lines; - - text = - gtk_editable_get_chars (GTK_EDITABLE (text_entry->text_entry), 0, - -1); - - lines = gl_text_node_lines_new_from_text (text); - - g_free (text); - return lines; -} - -/*--------------------------------------------------------------------------*/ -/* Set widget data. */ -/*--------------------------------------------------------------------------*/ -void -gl_prop_text_entry_set_text (glPropTextEntry * text_entry, - gboolean merge_flag, - GList * lines) -{ - gint pos; - gchar *text; - - gtk_widget_set_sensitive (text_entry->key_entry, merge_flag); - gtk_widget_set_sensitive (text_entry->insert_button, merge_flag); - - gtk_signal_handler_block_by_func (GTK_OBJECT (text_entry->text_entry), - GTK_SIGNAL_FUNC (changed_cb), - text_entry); - gtk_editable_delete_text (GTK_EDITABLE (text_entry->text_entry), 0, -1); - gtk_signal_handler_unblock_by_func (GTK_OBJECT (text_entry->text_entry), - GTK_SIGNAL_FUNC (changed_cb), - text_entry); - - text = gl_text_node_lines_expand (lines, NULL); - - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (text_entry->text_entry), - text, strlen (text), &pos); - -} diff --git a/glabels1/src/prop_text_entry.h b/glabels1/src/prop_text_entry.h deleted file mode 100644 index 06c5dee..0000000 --- a/glabels1/src/prop_text_entry.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_text_entry.h: text entry widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_TEXT_ENTRY_H__ -#define __PROP_TEXT_ENTRY_H__ - -#include <gnome.h> - -#include "merge.h" - -#define GL_TYPE_PROP_TEXT_ENTRY (gl_prop_text_entry_get_type ()) -#define GL_PROP_TEXT_ENTRY(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_TEXT_ENTRY, glPropTextEntry )) -#define GL_PROP_TEXT_ENTRY_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_TEXT_ENTRY, glPropTextEntryClass)) -#define GL_IS_PROP_TEXT_ENTRY(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_TEXT_ENTRY)) -#define GL_IS_PROP_TEXT_ENTRY_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_TEXT_ENTRY)) - -typedef struct _glPropTextEntry glPropTextEntry; -typedef struct _glPropTextEntryClass glPropTextEntryClass; - -struct _glPropTextEntry { - GtkVBox parent_widget; - - GtkWidget *text_entry; - GtkWidget *key_entry; - GtkWidget *insert_button; -}; - -struct _glPropTextEntryClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropTextEntry * text_entry, gpointer user_data); -}; - -extern guint gl_prop_text_entry_get_type (void); - -extern GtkWidget *gl_prop_text_entry_new (gchar * label, GList * field_defs); - -extern GList *gl_prop_text_entry_get_text (glPropTextEntry * text_entry); - -extern void gl_prop_text_entry_set_text (glPropTextEntry * text_entry, - gboolean merge_flag, - GList * lines); - -#endif diff --git a/glabels1/src/prop_vector.c b/glabels1/src/prop_vector.c deleted file mode 100644 index 303aefa..0000000 --- a/glabels1/src/prop_vector.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_vector.c: vector properties widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "prop_vector.h" -#include "prefs.h" - -#include "debug.h" - -#include <math.h> - -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif - -#define LENGTH(x,y) sqrt( (x)*(x) + (y)*(y) ) -#define ANGLE(x,y) ( (180.0/M_PI)*atan2( -(y), (x) ) ) -#define COMP_X(l,a) ( (l) * cos( (M_PI/180.0)*(a) ) ) -#define COMP_Y(l,a) ( -(l) * sin( (M_PI/180.0)*(a) ) ) - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glPropVectorSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint prop_vector_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_prop_vector_class_init (glPropVectorClass * class); -static void gl_prop_vector_init (glPropVector * vector); -static void gl_prop_vector_destroy (GtkObject * object); -static void gl_prop_vector_construct (glPropVector * vector, gchar * label); -static void changed_cb (glPropVector * vector); - -/*================================================================*/ -/* Boilerplate Object stuff. */ -/*================================================================*/ -guint -gl_prop_vector_get_type (void) -{ - static guint prop_vector_type = 0; - - if (!prop_vector_type) { - GtkTypeInfo prop_vector_info = { - "glPropVector", - sizeof (glPropVector), - sizeof (glPropVectorClass), - (GtkClassInitFunc) gl_prop_vector_class_init, - (GtkObjectInitFunc) gl_prop_vector_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - prop_vector_type = gtk_type_unique (gtk_vbox_get_type (), - &prop_vector_info); - } - - return prop_vector_type; -} - -static void -gl_prop_vector_class_init (glPropVectorClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_vbox_get_type ()); - - object_class->destroy = gl_prop_vector_destroy; - - prop_vector_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glPropVectorClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, prop_vector_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_prop_vector_init (glPropVector * vector) -{ - vector->len_spin = NULL; - vector->angle_spin = NULL; -} - -static void -gl_prop_vector_destroy (GtkObject * object) -{ - glPropVector *vector; - glPropVectorClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROP_VECTOR (object)); - - vector = GL_PROP_VECTOR (object); - class = GL_PROP_VECTOR_CLASS (GTK_OBJECT (vector)->klass); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_prop_vector_new (gchar * label) -{ - glPropVector *vector; - - vector = gtk_type_new (gl_prop_vector_get_type ()); - - gl_prop_vector_construct (vector, label); - - return GTK_WIDGET (vector); -} - -/*============================================================*/ -/* Construct composite widget. */ -/*============================================================*/ -static void -gl_prop_vector_construct (glPropVector * vector, - gchar * label) -{ - GtkWidget *wvbox, *wframe, *wtable, *wlabel; - GtkObject *adjust; - const gchar *units_string; - gdouble units_per_point, climb_rate; - gint digits; - - units_string = gl_prefs_get_units_string (); - units_per_point = gl_prefs_get_units_per_point (); - climb_rate = gl_prefs_get_units_step_size (); - digits = gl_prefs_get_units_precision (); - - wvbox = GTK_WIDGET (vector); - - wframe = gtk_frame_new (label); - gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0); - - wtable = gtk_table_new (2, 3, TRUE); - gtk_container_set_border_width (GTK_CONTAINER (wtable), 10); - gtk_table_set_row_spacings (GTK_TABLE (wtable), 5); - gtk_table_set_col_spacings (GTK_TABLE (wtable), 5); - gtk_container_add (GTK_CONTAINER (wframe), wtable); - - /* Length label */ - wlabel = gtk_label_new (_("Length:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_label_set_justify (GTK_LABEL (wlabel), GTK_JUSTIFY_RIGHT); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1); - /* Length spin */ - adjust = gtk_adjustment_new (climb_rate, climb_rate, 100.0, climb_rate, - 10.0, 10.0); - vector->len_spin = gtk_spin_button_new (GTK_ADJUSTMENT (adjust), - climb_rate, digits); - gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (vector->len_spin), - TRUE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vector->len_spin), TRUE); - gtk_signal_connect_object (GTK_OBJECT (vector->len_spin), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (vector)); - gtk_table_attach_defaults (GTK_TABLE (wtable), vector->len_spin, 1, 2, - 0, 1); - /* Length units label */ - vector->len_units_label = gtk_label_new (units_string); - gtk_misc_set_alignment (GTK_MISC (vector->len_units_label), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), vector->len_units_label, - 2, 3, 0, 1); - - /* Angle label */ - wlabel = gtk_label_new (_("Angle:")); - gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2); - /* Angle spin */ - adjust = gtk_adjustment_new (0.0, -180.0, +180.0, 1.0, 10.0, 10.0); - vector->angle_spin = - gtk_spin_button_new (GTK_ADJUSTMENT (adjust), 1.0, 0); - gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (vector->angle_spin), - TRUE); - gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (vector->angle_spin), - TRUE); - gtk_signal_connect_object (GTK_OBJECT (vector->angle_spin), "changed", - GTK_SIGNAL_FUNC (changed_cb), - GTK_OBJECT (vector)); - gtk_table_attach_defaults (GTK_TABLE (wtable), vector->angle_spin, 1, 2, - 1, 2); - /* Angle units label */ - vector->angle_units_label = gtk_label_new (_("degrees")); - gtk_misc_set_alignment (GTK_MISC (vector->angle_units_label), 0, 0.5); - gtk_table_attach_defaults (GTK_TABLE (wtable), - vector->angle_units_label, 2, 3, 1, 2); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glPropVector * vector) -{ - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (vector), prop_vector_signals[CHANGED]); -} - -/*====================================================================*/ -/* query values from controls. */ -/*====================================================================*/ -void -gl_prop_vector_get_params (glPropVector * vector, - gdouble * dx, - gdouble * dy) -{ - gdouble length, angle; - gdouble units_per_point; - - units_per_point = gl_prefs_get_units_per_point (); - - length = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (vector->len_spin)); - angle = - gtk_spin_button_get_value_as_float (GTK_SPIN_BUTTON - (vector->angle_spin)); - - length /= units_per_point; - - *dx = COMP_X (length, angle); - *dy = COMP_Y (length, angle); -} - -/*====================================================================*/ -/* set values and ranges for controls. */ -/*====================================================================*/ -void -gl_prop_vector_set_params (glPropVector * vector, - gdouble dx, - gdouble dy, - gdouble x_max, - gdouble y_max) -{ - GtkObject *length_adjust; - gdouble length, angle; - const gchar *units_string; - gdouble units_per_point, climb_rate; - gint digits; - - units_string = gl_prefs_get_units_string (); - units_per_point = gl_prefs_get_units_per_point (); - climb_rate = gl_prefs_get_units_step_size (); - digits = gl_prefs_get_units_precision (); - - /* Put everything into our display units */ - dx *= units_per_point; - dy *= units_per_point; - x_max *= units_per_point; - y_max *= units_per_point; - - length = LENGTH (dx, dy); - angle = ANGLE (dx, dy); - - length_adjust = gtk_adjustment_new (length, 0.0, LENGTH (x_max, y_max), - climb_rate, 10.0, 10.0); - gtk_spin_button_configure (GTK_SPIN_BUTTON (vector->len_spin), - GTK_ADJUSTMENT (length_adjust), - climb_rate, digits); - gtk_spin_button_update (GTK_SPIN_BUTTON (vector->len_spin)); - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (vector->angle_spin), angle); -} diff --git a/glabels1/src/prop_vector.h b/glabels1/src/prop_vector.h deleted file mode 100644 index e8197ad..0000000 --- a/glabels1/src/prop_vector.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * prop_vector.h: vector properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __PROP_VECTOR_H__ -#define __PROP_VECTOR_H__ - -#include <gnome.h> -#include "label.h" - -#define GL_TYPE_PROP_VECTOR (gl_prop_vector_get_type ()) -#define GL_PROP_VECTOR(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_PROP_VECTOR, glPropVector )) -#define GL_PROP_VECTOR_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROP_VECTOR, glPropVectorClass)) -#define GL_IS_PROP_VECTOR(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_PROP_VECTOR)) -#define GL_IS_PROP_VECTOR_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROP_VECTOR)) - -typedef struct _glPropVector glPropVector; -typedef struct _glPropVectorClass glPropVectorClass; - -struct _glPropVector { - GtkVBox parent_widget; - - GtkWidget *len_spin; - GtkWidget *len_units_label; - GtkWidget *angle_spin; - GtkWidget *angle_units_label; -}; - -struct _glPropVectorClass { - GtkVBoxClass parent_class; - - void (*changed) (glPropVector * vector, gpointer user_data); -}; - -extern guint gl_prop_vector_get_type (void); - -extern GtkWidget *gl_prop_vector_new (gchar * label); - -extern void gl_prop_vector_get_params (glPropVector * vector, - gdouble * dx, gdouble * dy); - -extern void gl_prop_vector_set_params (glPropVector * vector, - gdouble dx, gdouble dy, - gdouble x_max, gdouble y_max); - -#endif diff --git a/glabels1/src/propertybox.c b/glabels1/src/propertybox.c deleted file mode 100644 index b8fe294..0000000 --- a/glabels1/src/propertybox.c +++ /dev/null @@ -1,428 +0,0 @@ -/* Modified version of gnome-propertybox from gnome-libs-1.4 */ -/* Primarily removed the "help" button and changed the names.*/ -/* -Jim Evins 11/25/2001 */ - -/* gnome-propertybox.c - Property dialog box. - - Copyright (C) 1998 Tom Tromey - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -/* Note that the property box is constructed so that we could later - change how the buttons work. For instance, we could put an Apply - button inside each page; this kind of Apply button would only - affect the current page. Please do not change the API in a way - that would violate this goal. */ - -#include <config.h> - -#include "propertybox.h" -#include <libgnome/gnome-util.h> -#include <libgnomeui/gnome-stock.h> -#include <libgnome/gnome-config.h> -#include <gtk/gtk.h> -#include <libgnomeui/gnome-preferences.h> - -enum { - APPLY, - LAST_SIGNAL -}; - -typedef void (*glPropertyBoxSignal) (GtkObject * object, - gint arg, - gpointer data); - -static void gl_property_box_class_init (glPropertyBoxClass * klass); -static void gl_property_box_init (glPropertyBox * property_box); -static void gl_property_box_marshal_signal (GtkObject * object, - GtkSignalFunc func, - gpointer func_data, - GtkArg * args); -static void gl_property_box_destroy (GtkObject * object); - -/* - * These four are called from dialog_clicked_cb(), depending - * on which button was clicked. - */ -static void global_apply (glPropertyBox * property_box); -static void apply_and_close (glPropertyBox * property_box); -static void just_close (glPropertyBox * property_box); - -static void dialog_clicked_cb (GnomeDialog * dialog, - gint button, - gpointer data); - -static GnomeDialogClass *parent_class = NULL; - -static gint property_box_signals[LAST_SIGNAL] = { 0 }; - -/** - * gl_property_box_get_type: - * - * Internal routine that returns the GtkType of the - * glPropertyBox widget - */ -guint -gl_property_box_get_type (void) -{ - static guint property_box_type = 0; - - if (!property_box_type) { - GtkTypeInfo property_box_info = { - "glPropertyBox", - sizeof (glPropertyBox), - sizeof (glPropertyBoxClass), - (GtkClassInitFunc) gl_property_box_class_init, - (GtkObjectInitFunc) gl_property_box_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL - }; - - property_box_type = gtk_type_unique (gnome_dialog_get_type (), - &property_box_info); - } - - return property_box_type; -} - -static void -gl_property_box_class_init (glPropertyBoxClass * klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkWindowClass *window_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - window_class = (GtkWindowClass *) klass; - - object_class->destroy = gl_property_box_destroy; - - parent_class = gtk_type_class (gnome_dialog_get_type ()); - - property_box_signals[APPLY] = - gtk_signal_new ("apply", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (glPropertyBoxClass, - apply), - gl_property_box_marshal_signal, - GTK_TYPE_NONE, 1, GTK_TYPE_INT); - - gtk_object_class_add_signals (object_class, property_box_signals, - LAST_SIGNAL); - - klass->apply = NULL; -} - -static void -gl_property_box_marshal_signal (GtkObject * object, - GtkSignalFunc func, - gpointer func_data, - GtkArg * args) -{ - glPropertyBoxSignal rfunc; - - rfunc = (glPropertyBoxSignal) func; - (*rfunc) (object, GTK_VALUE_INT (args[0]), func_data); -} - -static void -gl_property_box_init (glPropertyBox * property_box) -{ - GList *button_list; - - property_box->notebook = gtk_notebook_new (); - - if (gnome_preferences_get_property_box_apply ()) { - gnome_dialog_append_buttons (GNOME_DIALOG (property_box), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_APPLY, - GNOME_STOCK_BUTTON_CLOSE, NULL); - } else { - gnome_dialog_append_buttons (GNOME_DIALOG (property_box), - GNOME_STOCK_BUTTON_OK, - GNOME_STOCK_BUTTON_CANCEL, NULL); - } - - gnome_dialog_set_default (GNOME_DIALOG (property_box), 0); - - /* This is sort of unattractive */ - - button_list = GNOME_DIALOG (property_box)->buttons; - - property_box->ok_button = GTK_WIDGET (button_list->data); - button_list = button_list->next; - - if (gnome_preferences_get_property_box_apply ()) { - property_box->apply_button = GTK_WIDGET (button_list->data); - button_list = button_list->next; - gtk_widget_set_sensitive (property_box->apply_button, FALSE); - } else - property_box->apply_button = 0; - - property_box->cancel_button = GTK_WIDGET (button_list->data); - button_list = button_list->next; - - gtk_signal_connect (GTK_OBJECT (property_box), "clicked", - GTK_SIGNAL_FUNC (dialog_clicked_cb), NULL); - - gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (property_box)->vbox), - property_box->notebook, TRUE, TRUE, 0); - - gtk_widget_show (property_box->notebook); -} - -static void -gl_property_box_destroy (GtkObject * object) -{ - glPropertyBox *property_box; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_PROPERTY_BOX (object)); - - property_box = GL_PROPERTY_BOX (object); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -/** - * gl_property_box_new: [constructor] - * - * Creates a new glPropertyBox widget. The PropertyBox widget - * is useful for making consistent configuration dialog boxes. - * - * When a setting has been made to a property in the PropertyBox - * your program needs to invoke the gl_property_box_changed to signal - * a change (this will enable the Ok/Apply buttons). - * - * Returns a newly created glPropertyBox widget. - */ -GtkWidget * -gl_property_box_new (void) -{ - return gtk_type_new (gl_property_box_get_type ()); -} - -static void -dialog_clicked_cb (GnomeDialog * dialog, - gint button, - gpointer data) -{ - glPropertyBox *pbox; - GtkWidget *page; - GList *list; - gboolean dirty = FALSE; - - g_return_if_fail (dialog != NULL); - g_return_if_fail (GL_IS_PROPERTY_BOX (dialog)); - - pbox = GL_PROPERTY_BOX (dialog); - - if (GTK_NOTEBOOK (pbox->notebook)->cur_page != NULL) { - - for (list = GTK_NOTEBOOK (pbox->notebook)->children; - list != NULL; list = list->next) { - GtkNotebookPage *page = list->data; - g_assert (page != NULL); - - dirty = - GPOINTER_TO_INT (gtk_object_get_data - (GTK_OBJECT (page->child), - GL_PROPERTY_BOX_DIRTY)); - - if (dirty) - break; - } - } else { - page = NULL; - dirty = FALSE; - } - - /* Choose which style we did */ - if (pbox->apply_button) { - switch (button) { - case 0: - if (dirty) - apply_and_close (GL_PROPERTY_BOX (dialog)); - else - just_close (GL_PROPERTY_BOX (dialog)); - break; - case 1: - global_apply (GL_PROPERTY_BOX (dialog)); - break; - case 2: - just_close (GL_PROPERTY_BOX (dialog)); - break; - default: - g_assert_not_reached (); - } - } else { - switch (button) { - case 0: - if (dirty) - apply_and_close (GL_PROPERTY_BOX (dialog)); - else - just_close (GL_PROPERTY_BOX (dialog)); - break; - case 1: - just_close (GL_PROPERTY_BOX (dialog)); - break; - default: - g_assert_not_reached (); - } - } -} - -static void -set_sensitive (glPropertyBox * property_box, - gint dirty) -{ - if (property_box->apply_button) - gtk_widget_set_sensitive (property_box->apply_button, dirty); -} - -/** - * gl_property_box_changed: - * @property_box: The glPropertyBox that contains the changed data - * - * When a setting has changed, the code needs to invoke this routine - * to make the Ok/Apply buttons sensitive. - */ -void -gl_property_box_changed (glPropertyBox * property_box) -{ - GtkWidget *page; - - g_return_if_fail (property_box != NULL); - g_return_if_fail (GL_IS_PROPERTY_BOX (property_box)); - g_return_if_fail (property_box->notebook); - g_return_if_fail (GTK_NOTEBOOK (property_box->notebook)->cur_page); - - page = GTK_NOTEBOOK (property_box->notebook)->cur_page->child; - g_assert (page != NULL); - - gtk_object_set_data (GTK_OBJECT (page), - GL_PROPERTY_BOX_DIRTY, GINT_TO_POINTER (1)); - - set_sensitive (property_box, 1); -} - -/** - * gl_property_box_set_modified: - * @property_box: The glPropertyBox that contains the changed data - * @state: The state. TRUE means modified, FALSE means unmodified. - * - * This sets the modified flag of the glPropertyBox to the value in @state. - * Affects whether the OK/Apply buttons are sensitive. - */ -void -gl_property_box_set_modified (glPropertyBox * property_box, - gboolean state) -{ - GtkWidget *page; - - g_return_if_fail (property_box != NULL); - g_return_if_fail (GL_IS_PROPERTY_BOX (property_box)); - g_return_if_fail (property_box->notebook); - g_return_if_fail (GTK_NOTEBOOK (property_box->notebook)->cur_page); - - page = GTK_NOTEBOOK (property_box->notebook)->cur_page->child; - g_assert (page != NULL); - - gtk_object_set_data (GTK_OBJECT (page), - GL_PROPERTY_BOX_DIRTY, - GINT_TO_POINTER (state ? 1 : 0)); - - set_sensitive (property_box, state); -} - -static void -global_apply (glPropertyBox * property_box) -{ - GList *list; - gint n; - - g_return_if_fail (GTK_NOTEBOOK (property_box->notebook)->children != - NULL); - - for (list = GTK_NOTEBOOK (property_box->notebook)->children, n = 0; - list != NULL; list = g_list_next (list), n++) { - /* FIXME: there should be a way to report an error - during Apply. That way we could prevent closing - the window if there were a problem. */ - GtkNotebookPage *page = list->data; - if (gtk_object_get_data (GTK_OBJECT (page->child), - GL_PROPERTY_BOX_DIRTY)) { - gtk_signal_emit (GTK_OBJECT (property_box), - property_box_signals[APPLY], n); - gtk_object_set_data (GTK_OBJECT (page->child), - GL_PROPERTY_BOX_DIRTY, - GINT_TO_POINTER (0)); - } - } - - /* Emit an apply signal with a button of -1. This means we - just finished a global apply. Is this a hack? */ - gtk_signal_emit (GTK_OBJECT (property_box), - property_box_signals[APPLY], (gint) - 1); - - /* Doesn't matter which item we use. */ - set_sensitive (property_box, 0); -} - -static void -just_close (glPropertyBox * property_box) -{ - gnome_dialog_close (GNOME_DIALOG (property_box)); -} - -static void -apply_and_close (glPropertyBox * property_box) -{ - global_apply (property_box); - just_close (property_box); -} - -/** - * gl_property_box_append_page: - * @property_box: The property box where we are inserting a new page - * @child: The widget that is being inserted - * @tab_label: The widget used as the label for this confiugration page - * - * Appends a new page to the glPropertyBox. - * - * Returns the assigned index of the page inside the glPropertyBox or - * -1 if one of the arguments is invalid. - */ -gint -gl_property_box_append_page (glPropertyBox * property_box, - GtkWidget * child, - GtkWidget * tab_label) -{ - g_return_val_if_fail (property_box != NULL, -1); - g_return_val_if_fail (GL_IS_PROPERTY_BOX (property_box), -1); - g_return_val_if_fail (child != NULL, -1); - g_return_val_if_fail (GTK_IS_WIDGET (child), -1); - g_return_val_if_fail (tab_label != NULL, -1); - g_return_val_if_fail (GTK_IS_WIDGET (tab_label), -1); - - gtk_notebook_append_page (GTK_NOTEBOOK (property_box->notebook), - child, tab_label); - - return g_list_length (GTK_NOTEBOOK (property_box->notebook)->children) - - 1; -} diff --git a/glabels1/src/propertybox.h b/glabels1/src/propertybox.h deleted file mode 100644 index 403ebf0..0000000 --- a/glabels1/src/propertybox.h +++ /dev/null @@ -1,74 +0,0 @@ -/* Modified version of gnome-propertybox from gnome-libs-1.4 */ -/* Primarily removed the "help" button and changed the names.*/ -/* -Jim Evins 11/25/2001 */ - -/* gnome-propertybox.h - Property dialog box. - - Copyright (C) 1998 Tom Tromey - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License - as published by the Free Software Foundation; either version 2, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. */ - -#ifndef __PROPERTY_BOX_H__ -#define __PROPERTY_BOX_H__ - -#include <libgnomeui/gnome-dialog.h> -#include <libgnome/gnome-defs.h> - -BEGIN_GNOME_DECLS -#define GL_TYPE_PROPERTY_BOX (gl_property_box_get_type ()) -#define GL_PROPERTY_BOX(obj) (GTK_CHECK_CAST ((obj), GL_TYPE_PROPERTY_BOX, glPropertyBox)) -#define GL_PROPERTY_BOX_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_PROPERTY_BOX, glPropertyBoxClass)) -#define GL_IS_PROPERTY_BOX(obj) (GTK_CHECK_TYPE ((obj), GL_TYPE_PROPERTY_BOX)) -#define GL_IS_PROPERTY_BOX_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_PROPERTY_BOX)) -/*the flag used on the notebook pages to see if a change happened on a certain page or not*/ -#define GL_PROPERTY_BOX_DIRTY "gl_property_box_dirty" -typedef struct _glPropertyBox glPropertyBox; -typedef struct _glPropertyBoxClass glPropertyBoxClass; - -struct _glPropertyBox { - GnomeDialog dialog; - - GtkWidget *notebook; /* The notebook widget. */ - GtkWidget *ok_button; /* OK button. */ - GtkWidget *apply_button; /* Apply button. */ - GtkWidget *cancel_button; /* Cancel/Close button. */ -}; - -struct _glPropertyBoxClass { - GnomeDialogClass parent_class; - - void (*apply) (glPropertyBox * propertybox, - gint page_num); -}; - -guint gl_property_box_get_type (void); -GtkWidget *gl_property_box_new (void); - -/* - * Call this when the user changes something in the current page of - * the notebook. - */ -void gl_property_box_changed (glPropertyBox * property_box); - -void gl_property_box_set_modified (glPropertyBox * property_box, - gboolean state); - -gint gl_property_box_append_page (glPropertyBox * property_box, - GtkWidget * child, - GtkWidget * tab_label); - -END_GNOME_DECLS -#endif /* __PROPERTY_BOX_H__ */ diff --git a/glabels1/src/rotate_select.c b/glabels1/src/rotate_select.c deleted file mode 100644 index 29e0a9e..0000000 --- a/glabels1/src/rotate_select.c +++ /dev/null @@ -1,348 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * rotate_select.c: label rotate selection widget module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "rotate_select.h" -#include "template.h" - -#include "debug.h" - -#define MINI_PREVIEW_MAX_PIXELS 48 - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glRotateSelectSignal) (GtkObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint rotate_select_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_rotate_select_class_init (glRotateSelectClass * class); -static void gl_rotate_select_init (glRotateSelect * rotate_select); -static void gl_rotate_select_destroy (GtkObject * object); - -static void gl_rotate_select_construct (glRotateSelect * rotate_select); - -static void entry_changed_cb (GtkToggleButton * toggle, gpointer user_data); - -static GtkWidget *mini_preview_canvas_new (void); - -static void mini_preview_canvas_update (GnomeCanvas * canvas, - glTemplate * template, - gboolean rotate_flag); - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_rotate_select_get_type (void) -{ - static guint rotate_select_type = 0; - - if (!rotate_select_type) { - GtkTypeInfo rotate_select_info = { - "glRotateSelect", - sizeof (glRotateSelect), - sizeof (glRotateSelectClass), - (GtkClassInitFunc) gl_rotate_select_class_init, - (GtkObjectInitFunc) gl_rotate_select_init, - (GtkArgSetFunc) NULL, - (GtkArgGetFunc) NULL, - }; - - rotate_select_type = gtk_type_unique (gtk_hbox_get_type (), - &rotate_select_info); - } - - return rotate_select_type; -} - -static void -gl_rotate_select_class_init (glRotateSelectClass * class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) class; - widget_class = (GtkWidgetClass *) class; - - parent_class = gtk_type_class (gtk_hbox_get_type ()); - - object_class->destroy = gl_rotate_select_destroy; - - rotate_select_signals[CHANGED] = - gtk_signal_new ("changed", GTK_RUN_LAST, object_class->type, - GTK_SIGNAL_OFFSET (glRotateSelectClass, changed), - gtk_signal_default_marshaller, GTK_TYPE_NONE, 0); - gtk_object_class_add_signals (object_class, rotate_select_signals, - LAST_SIGNAL); - - class->changed = NULL; -} - -static void -gl_rotate_select_init (glRotateSelect * rotate_select) -{ - rotate_select->rotate_check = NULL; - - rotate_select->canvas = NULL; - - rotate_select->template = NULL; -} - -static void -gl_rotate_select_destroy (GtkObject * object) -{ - glRotateSelect *rotate_select; - glRotateSelectClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_ROTATE_SELECT (object)); - - rotate_select = GL_ROTATE_SELECT (object); - class = GL_ROTATE_SELECT_CLASS (GTK_OBJECT (rotate_select)->klass); - - gl_template_free (&rotate_select->template); - - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -GtkWidget * -gl_rotate_select_new (void) -{ - glRotateSelect *rotate_select; - - rotate_select = gtk_type_new (gl_rotate_select_get_type ()); - - gl_rotate_select_construct (rotate_select); - - return GTK_WIDGET (rotate_select); -} - -/*--------------------------------------------------------------------------*/ -/* Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_rotate_select_construct (glRotateSelect * rotate_select) -{ - GtkWidget *whbox; - - whbox = GTK_WIDGET (rotate_select); - - /* Actual selection control */ - rotate_select->rotate_check = - gtk_check_button_new_with_label (_("Rotate")); - gtk_box_pack_start (GTK_BOX (whbox), rotate_select->rotate_check, TRUE, - TRUE, GNOME_PAD); - - /* mini_preview canvas */ - rotate_select->canvas = mini_preview_canvas_new (); - gtk_box_pack_start (GTK_BOX (whbox), rotate_select->canvas, - TRUE, TRUE, GNOME_PAD); - - /* Connect signals to controls */ - gtk_signal_connect (GTK_OBJECT (rotate_select->rotate_check), "toggled", - GTK_SIGNAL_FUNC (entry_changed_cb), rotate_select); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change of check button */ -/*--------------------------------------------------------------------------*/ -static void -entry_changed_cb (GtkToggleButton * toggle, - gpointer user_data) -{ - glRotateSelect *rotate_select = GL_ROTATE_SELECT (user_data); - - if (rotate_select->template != NULL) { - /* Update mini_preview canvas & details with template */ - mini_preview_canvas_update (GNOME_CANVAS - (rotate_select->canvas), - rotate_select->template, - gtk_toggle_button_get_active - (toggle)); - } - - /* Emit our "changed" signal */ - gtk_signal_emit (GTK_OBJECT (user_data), - rotate_select_signals[CHANGED]); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Draw a mini-preview canvas. */ -/*--------------------------------------------------------------------------*/ -static GtkWidget * -mini_preview_canvas_new (void) -{ - GtkWidget *wcanvas = NULL; - - /* Create a canvas */ - gtk_widget_push_visual (gdk_rgb_get_visual ()); - gtk_widget_push_colormap (gdk_rgb_get_cmap ()); - wcanvas = gnome_canvas_new_aa (); - gtk_widget_pop_colormap (); - gtk_widget_pop_visual (); - - gtk_widget_set_usize (GTK_WIDGET (wcanvas), - MINI_PREVIEW_MAX_PIXELS + 4, - MINI_PREVIEW_MAX_PIXELS + 4); - - gtk_object_set_data (GTK_OBJECT (wcanvas), "label_item", NULL); - - return wcanvas; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Update mini-preview canvas from new template. */ -/*--------------------------------------------------------------------------*/ -static void -mini_preview_canvas_update (GnomeCanvas * canvas, - glTemplate * template, - gboolean rotate_flag) -{ - gdouble canvas_scale; - GnomeCanvasGroup *group = NULL; - GnomeCanvasItem *label_item = NULL; - gdouble m, w, h; - - /* Fetch our data from canvas */ - label_item = gtk_object_get_data (GTK_OBJECT (canvas), "label_item"); - - m = MAX (template->label_width, template->label_height); - canvas_scale = (MINI_PREVIEW_MAX_PIXELS) / m; - - /* scale and size canvas */ - gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (canvas), canvas_scale); - group = gnome_canvas_root (GNOME_CANVAS (canvas)); - gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas), - -m / 2.0, -m / 2.0, +m / 2.0, +m / 2.0); - - /* remove old label outline */ - if (label_item != NULL) { - gtk_object_destroy (GTK_OBJECT (label_item)); - } - - /* draw mini label outline */ - if (!rotate_flag) { - w = template->label_width; - h = template->label_height; - } else { - w = template->label_height; - h = template->label_width; - } - switch (template->style) { - case GL_TEMPLATE_STYLE_RECT: - label_item = gnome_canvas_item_new (group, - gnome_canvas_rect_get_type(), - "x1", -w / 2.0, - "y1", -h / 2.0, - "x2", +w / 2.0, - "y2", +h / 2.0, - "width_pixels", 1, - "outline_color", "black", - "fill_color", "white", - NULL); - break; - case GL_TEMPLATE_STYLE_ROUND: - case GL_TEMPLATE_STYLE_CD: - label_item = gnome_canvas_item_new (group, - gnome_canvas_ellipse_get_type(), - "x1", -w / 2.0, - "y1", -h / 2.0, - "x2", +w / 2.0, - "y2", +h / 2.0, - "width_pixels", 1, - "outline_color", "black", - "fill_color", "white", - NULL); - break; - default: - WARN ("Unknown label style"); - break; - } - - gtk_object_set_data (GTK_OBJECT (canvas), "label_item", label_item); - -} - -/****************************************************************************/ -/* query state of widget. */ -/****************************************************************************/ -gboolean -gl_rotate_select_get_state (glRotateSelect * rotate_select) -{ - return - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON - (rotate_select->rotate_check)); -} - -/****************************************************************************/ -/* set state of widget. */ -/****************************************************************************/ -void -gl_rotate_select_set_state (glRotateSelect * rotate_select, - gboolean state) -{ - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (rotate_select->rotate_check), state); -} - -/****************************************************************************/ -/* set template for widget. */ -/****************************************************************************/ -void -gl_rotate_select_set_template_name (glRotateSelect * rotate_select, - gchar * name) -{ - glTemplate *template; - - template = gl_template_from_name (name); - rotate_select->template = template; - - if (template->label_width != template->label_height) { - gtk_widget_set_sensitive (rotate_select->rotate_check, TRUE); - } else { - gtk_widget_set_sensitive (rotate_select->rotate_check, FALSE); - } - - mini_preview_canvas_update (GNOME_CANVAS (rotate_select->canvas), - template, FALSE); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON - (rotate_select->rotate_check), FALSE); -} diff --git a/glabels1/src/rotate_select.h b/glabels1/src/rotate_select.h deleted file mode 100644 index 7204c83..0000000 --- a/glabels1/src/rotate_select.h +++ /dev/null @@ -1,70 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * rotate_select.h: label rotate selection widget module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __ROTATE_SELECT_H__ -#define __ROTATE_SELECT_H__ - -#include <gnome.h> -#include "template.h" - -#define GL_TYPE_ROTATE_SELECT (gl_rotate_select_get_type ()) -#define GL_ROTATE_SELECT(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_ROTATE_SELECT, glRotateSelect )) -#define GL_ROTATE_SELECT_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_ROTATE_SELECT, glRotateSelectClass)) -#define GL_IS_ROTATE_SELECT(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_ROTATE_SELECT)) -#define GL_IS_ROTATE_SELECT_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_ROTATE_SELECT)) - -typedef struct _glRotateSelect glRotateSelect; -typedef struct _glRotateSelectClass glRotateSelectClass; - -struct _glRotateSelect { - GtkHBox parent_widget; - - GtkWidget *rotate_check; - - GtkWidget *canvas; - - glTemplate *template; -}; - -struct _glRotateSelectClass { - GtkHBoxClass parent_class; - - void (*changed) (glRotateSelect * rotate_select, gpointer user_data); -}; - -extern guint gl_rotate_select_get_type (void); - -extern GtkWidget *gl_rotate_select_new (void); - -extern gboolean gl_rotate_select_get_state (glRotateSelect * rotate_select); - -extern void gl_rotate_select_set_state (glRotateSelect * rotate_select, - gboolean state); - -extern void gl_rotate_select_set_template_name (glRotateSelect * rotate_select, - gchar * name); - -#endif diff --git a/glabels1/src/splash.c b/glabels1/src/splash.c deleted file mode 100644 index 92bb9aa..0000000 --- a/glabels1/src/splash.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * splash.c: Splash screen module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#include <gnome.h> - -#include "debug.h" -#include "splash.h" - -#ifdef PACKAGE_DATA_DIR -#define SPLASH_PIXMAP (PACKAGE_DATA_DIR "/pixmaps/glabels/glabels-logo.png") -#else -#define SPLASH_PIXMAP gnome_pixmap_file("glabels/glabels-logo.png") -#endif - -#define SPLASH_TIMEOUT 2000 - -static GtkWidget *splash = NULL; - -static gint splash_timeout (gpointer not_used); - - -/***************************************************************************/ -/* Create splash screen. */ -/***************************************************************************/ -void -gl_splash (void) -{ - GtkWidget *wpixmap, *wvbox, *whbox, *wframe1, *wframe2; - gchar *label; - - if (splash) - return; - - splash = gtk_window_new (GTK_WINDOW_POPUP); - gtk_window_set_position (GTK_WINDOW (splash), GTK_WIN_POS_CENTER); - - wframe1 = gtk_frame_new (NULL); - gtk_frame_set_shadow_type (GTK_FRAME (wframe1), GTK_SHADOW_OUT); - wframe2 = gtk_frame_new (NULL); - - wvbox = gtk_vbox_new (FALSE, 5); - gtk_container_set_border_width (GTK_CONTAINER (wvbox), 2); - - whbox = gtk_hbox_new (FALSE, 5); - - if (!g_file_exists (SPLASH_PIXMAP)) { - WARN ("Could not find %s", SPLASH_PIXMAP); - } - wpixmap = gnome_pixmap_new_from_file (SPLASH_PIXMAP); - if (!wpixmap) { - WARN ("can't find splash pixmap"); - gtk_widget_destroy (splash); - return; - } - - gtk_container_add (GTK_CONTAINER (splash), wframe1); - gtk_container_add (GTK_CONTAINER (wframe1), wframe2); - gtk_container_add (GTK_CONTAINER (wframe2), wvbox); - - gtk_box_pack_start (GTK_BOX (wvbox), wpixmap, TRUE, TRUE, 0); - - label = g_strdup_printf ("Version %s", VERSION); - gtk_box_pack_start (GTK_BOX (wvbox), - gtk_label_new (label), TRUE, TRUE, 0); - g_free (label); - - gtk_widget_show_all (splash); - - gtk_timeout_add (SPLASH_TIMEOUT, splash_timeout, NULL); - - while (gtk_events_pending ()) { - gtk_main_iteration (); - } -} - -/*-------------------------------------------------------------------------*/ -/* PRIVATE. Callback to tear-down splash screen once timer has expired. */ -/*-------------------------------------------------------------------------*/ -static gint -splash_timeout (gpointer not_used) -{ - if (splash) { - gtk_widget_destroy (splash); - splash = NULL; - } - - return FALSE; -} - diff --git a/glabels1/src/splash.h b/glabels1/src/splash.h deleted file mode 100644 index 25cd5b6..0000000 --- a/glabels1/src/splash.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * splash.c: Splash screen module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __SPLASH_H__ -#define __SPLASH_H__ - -void gl_splash (void); - -#endif diff --git a/glabels1/src/stock.c b/glabels1/src/stock.c deleted file mode 100644 index f352300..0000000 --- a/glabels1/src/stock.c +++ /dev/null @@ -1,121 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * stock.h: Stock image module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> -#include <gnome.h> -#include "stock.h" -#include "pixmaps/arrow.xpm" -#include "pixmaps/text.xpm" -#include "pixmaps/line.xpm" -#include "pixmaps/box.xpm" -#include "pixmaps/ellipse.xpm" -#include "pixmaps/image.xpm" -#include "pixmaps/barcode.xpm" -#include "pixmaps/zoomin.xpm" -#include "pixmaps/zoomout.xpm" -#include "pixmaps/zoom1to1.xpm" -#include "pixmaps/merge.xpm" - -void -gl_stock_init (void) -{ - static GnomeStockPixmapEntry entries[11]; - - entries[0].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[0].data.width = 24; - entries[0].data.height = 24; - entries[0].data.xpm_data = arrow_xpm; - - entries[1].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[1].data.width = 24; - entries[1].data.height = 24; - entries[1].data.xpm_data = text_xpm; - - entries[2].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[2].data.width = 24; - entries[2].data.height = 24; - entries[2].data.xpm_data = line_xpm; - - entries[3].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[3].data.width = 24; - entries[3].data.height = 24; - entries[3].data.xpm_data = box_xpm; - - entries[4].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[4].data.width = 24; - entries[4].data.height = 24; - entries[4].data.xpm_data = ellipse_xpm; - - entries[5].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[5].data.width = 24; - entries[5].data.height = 24; - entries[5].data.xpm_data = image_xpm; - - entries[6].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[6].data.width = 24; - entries[6].data.height = 24; - entries[6].data.xpm_data = barcode_xpm; - - entries[7].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[7].data.width = 24; - entries[7].data.height = 24; - entries[7].data.xpm_data = zoomin_xpm; - - entries[8].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[8].data.width = 24; - entries[8].data.height = 24; - entries[8].data.xpm_data = zoomout_xpm; - - entries[9].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[9].data.width = 24; - entries[9].data.height = 24; - entries[9].data.xpm_data = zoom1to1_xpm; - - entries[10].data.type = GNOME_STOCK_PIXMAP_TYPE_DATA; - entries[10].data.width = 24; - entries[10].data.height = 24; - entries[10].data.xpm_data = merge_xpm; - - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_ARROW, - GNOME_STOCK_PIXMAP_REGULAR, &entries[0]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_TEXT, - GNOME_STOCK_PIXMAP_REGULAR, &entries[1]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_LINE, - GNOME_STOCK_PIXMAP_REGULAR, &entries[2]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_BOX, - GNOME_STOCK_PIXMAP_REGULAR, &entries[3]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_ELLIPSE, - GNOME_STOCK_PIXMAP_REGULAR, &entries[4]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_IMAGE, - GNOME_STOCK_PIXMAP_REGULAR, &entries[5]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_BARCODE, - GNOME_STOCK_PIXMAP_REGULAR, &entries[6]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_ZOOMIN, - GNOME_STOCK_PIXMAP_REGULAR, &entries[7]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_ZOOMOUT, - GNOME_STOCK_PIXMAP_REGULAR, &entries[8]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_ZOOM1TO1, - GNOME_STOCK_PIXMAP_REGULAR, &entries[9]); - gnome_stock_pixmap_register (GL_STOCK_PIXMAP_MERGE, - GNOME_STOCK_PIXMAP_REGULAR, &entries[10]); - -} diff --git a/glabels1/src/stock.h b/glabels1/src/stock.h deleted file mode 100644 index 4b2b20c..0000000 --- a/glabels1/src/stock.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * stock.h: Stock image module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __STOCK_H__ -#define __STOCK_H__ - -/* Stock names */ - -#define GL_STOCK_PIXMAP_ARROW "GL_stock_arrow" -#define GL_STOCK_PIXMAP_TEXT "GL_stock_text" -#define GL_STOCK_PIXMAP_LINE "GL_stock_line" -#define GL_STOCK_PIXMAP_BOX "GL_stock_box" -#define GL_STOCK_PIXMAP_ELLIPSE "GL_stock_ellipse" -#define GL_STOCK_PIXMAP_IMAGE "GL_stock_image" -#define GL_STOCK_PIXMAP_BARCODE "GL_stock_barcode" -#define GL_STOCK_PIXMAP_ZOOMIN "GL_stock_zoomin" -#define GL_STOCK_PIXMAP_ZOOMOUT "GL_stock_zoomout" -#define GL_STOCK_PIXMAP_ZOOM1TO1 "GL_stock_zoom1to1" -#define GL_STOCK_PIXMAP_MERGE "GL_stock_merge" - -void gl_stock_init (void); - -#endif diff --git a/glabels1/src/template.c b/glabels1/src/template.c deleted file mode 100644 index aae0a89..0000000 --- a/glabels1/src/template.c +++ /dev/null @@ -1,584 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * template.c: template module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <sys/stat.h> -#include <sys/types.h> -#include <dirent.h> -#include <fcntl.h> -#include <unistd.h> - - -#include "template.h" - -#include "debug.h" - -#ifdef PACKAGE_DATA_DIR -#define GL_DATA_DIR (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "glabels") -#else -#define GL_DATA_DIR gnome_datadir_file("glabels") -#endif - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GList *templates = NULL; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ -static GList *read_templates (void); - -static gchar *get_home_data_dir (void); -static GList *read_template_files_from_dir (GList * templates, - const gchar * dirname); -static GList *read_templates_from_file (GList * templates, - gchar * xml_filename); - -static void xml_parse_label (xmlNodePtr label_node, glTemplate * template); -static void xml_parse_layout (xmlNodePtr layout_node, glTemplate * template); -static void xml_parse_alias (xmlNodePtr alias_node, glTemplate * template); - -static void xml_add_label (glTemplate *template, xmlNodePtr root, xmlNsPtr ns); -static void xml_add_layout (glTemplate *template, xmlNodePtr root, xmlNsPtr ns); -static void xml_add_alias (gchar *name, xmlNodePtr root, xmlNsPtr ns); - -/*****************************************************************************/ -/* Initialize module. */ -/*****************************************************************************/ -void -gl_template_init (void) -{ - templates = read_templates (); -} - -/*****************************************************************************/ -/* Get a list of valid template names for given page size */ -/*****************************************************************************/ -GList * -gl_template_get_name_list (const gchar * page_size) -{ - GList *p_tmplt, *p_name; - glTemplate *template; - gchar *str; - GList *names = NULL; - - for (p_tmplt = templates; p_tmplt != NULL; p_tmplt = p_tmplt->next) { - template = (glTemplate *) p_tmplt->data; - if (g_strcasecmp (page_size, template->page_size) == 0) { - for (p_name = template->name; p_name != NULL; - p_name = p_name->next) { - str = g_strdup_printf("%s: %s", - (gchar *) p_name->data, - template->description); - names = g_list_insert_sorted (names, str, - (GCompareFunc)g_strcasecmp); - } - } - } - - return names; -} - -/*****************************************************************************/ -/* Free a list of template names. */ -/*****************************************************************************/ -void -gl_template_free_name_list (GList ** names) -{ - GList *p_name; - - for (p_name = *names; p_name != NULL; p_name = p_name->next) { - g_free (p_name->data); - p_name->data = NULL; - } - - g_list_free (*names); - *names = NULL; -} - -/*****************************************************************************/ -/* Return a template structure from a name. */ -/*****************************************************************************/ -glTemplate * -gl_template_from_name (const gchar * name) -{ - GList *p_tmplt, *p_name; - glTemplate *template; - gchar **split_name; - - if (name == NULL) { - /* If no name, return first template as a default */ - return (glTemplate *) templates->data; - } - - split_name = g_strsplit (name, ":", 2); - - for (p_tmplt = templates; p_tmplt != NULL; p_tmplt = p_tmplt->next) { - template = (glTemplate *) p_tmplt->data; - for (p_name = template->name; p_name != NULL; - p_name = p_name->next) { - if (g_strcasecmp (p_name->data, split_name[0]) == 0) { - g_strfreev (split_name); - return gl_template_copy(template); - } - } - } - - g_strfreev (split_name); - - return NULL; -} - -/*****************************************************************************/ -/* Copy a template. */ -/*****************************************************************************/ -glTemplate *gl_template_copy (const glTemplate *orig_template) -{ - glTemplate *template; - GList *p; - - template = g_new0 (glTemplate,1); - - /* Shallow copy first */ - *template = *orig_template; - - /* Now the deep stuff */ - template->name = NULL; - for ( p=orig_template->name; p != NULL; p=p->next ) { - template->name = g_list_append (template->name, - g_strdup (p->data)); - } - template->description = g_strdup (orig_template->description); - template->page_size = g_strdup (orig_template->page_size); - - return template; -} - -/*****************************************************************************/ -/* Free up a template. */ -/*****************************************************************************/ -void gl_template_free (glTemplate **template) -{ - GList *p; - - for ( p=(*template)->name; p != NULL; p=p->next ) { - g_free (p->data); - p->data = NULL; - } - g_list_free ((*template)->name); - (*template)->name = NULL; - - g_free ((*template)->description); - (*template)->description = NULL; - - g_free ((*template)->page_size); - (*template)->page_size = NULL; - - g_free (*template); - *template = NULL; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Read templates from various files. */ -/*--------------------------------------------------------------------------*/ -static GList * -read_templates (void) -{ - gchar *home_data_dir = get_home_data_dir (); - GList *templates = NULL; - - LIBXML_TEST_VERSION; - - templates = read_template_files_from_dir (templates, GL_DATA_DIR); - templates = read_template_files_from_dir (templates, home_data_dir); - - g_free (home_data_dir); - - if (templates == NULL) { - WARN (_("No template files found!")); - } - - return templates; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. get '~/.glabels' directory path. */ -/*--------------------------------------------------------------------------*/ -static gchar * -get_home_data_dir (void) -{ - gchar *dir = gnome_util_prepend_user_home (".glabels"); - - /* Try to create ~/.glabels directory. If it exists, no problem. */ - mkdir (dir, 0775); - - return dir; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Read all template files from given directory. Append to list. */ -/*--------------------------------------------------------------------------*/ -static GList * -read_template_files_from_dir (GList * templates, - const gchar * dirname) -{ - DIR *dp; - struct dirent *d_entry; - gchar *filename, *extension; - gchar *full_filename = NULL; - - if (dirname == NULL) - return templates; - - dp = opendir (dirname); - if (dp == NULL) - return templates; - - while ((d_entry = readdir (dp)) != NULL) { - - filename = d_entry->d_name; - extension = strrchr (filename, '.'); - - if (extension != NULL) { - - if (strcasecmp (extension, ".template") == 0) { - - full_filename = - g_concat_dir_and_file (dirname, filename); - templates = - read_templates_from_file (templates, - full_filename); - g_free (full_filename); - - } - - } - - } - - closedir (dp); - - return templates; -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Read templates from template file. */ -/*--------------------------------------------------------------------------*/ -static GList * -read_templates_from_file (GList * templates, - gchar * xml_filename) -{ - xmlDocPtr doc; - xmlNodePtr root, node; - glTemplate *template; - - doc = xmlParseFile (xml_filename); - if (!doc) { - WARN ("\"%s\" is not a glabels template file (not XML)", - xml_filename); - return templates; - } - - root = xmlDocGetRootElement (doc); - if (!root || !root->name) { - WARN ("\"%s\" is not a glabels template file (no root node)", - xml_filename); - xmlFreeDoc (doc); - return templates; - } - if (g_strcasecmp (root->name, "glabels-templates") != 0) { - WARN ("\"%s\" is not a glabels template file (wrong root node)", - xml_filename); - xmlFreeDoc (doc); - return templates; - } - - for (node = root->xmlChildrenNode; node != NULL; node = node->next) { - - if (g_strcasecmp (node->name, "Sheet") == 0) { - template = g_new0 (glTemplate, 1); - gl_template_xml_parse_sheet (template, node); - templates = g_list_append (templates, template); - } else { - if (g_strcasecmp (node->name, "text") != 0) { - WARN ("bad node = \"%s\"", node->name); - } - } - } - - xmlFreeDoc (doc); - - return templates; -} - -/*****************************************************************************/ -/* Parse XML template Node. */ -/*****************************************************************************/ -void -gl_template_xml_parse_sheet (glTemplate * template, - xmlNodePtr sheet_node) -{ - xmlNodePtr node; - - template->name = g_list_append (template->name, - xmlGetProp (sheet_node, "name")); - template->page_size = xmlGetProp (sheet_node, "size"); - template->description = xmlGetProp (sheet_node, "description"); - - for (node = sheet_node->xmlChildrenNode; node != NULL; - node = node->next) { - if (g_strcasecmp (node->name, "Label") == 0) { - xml_parse_label (node, template); - } else if (g_strcasecmp (node->name, "Alias") == 0) { - xml_parse_alias (node, template); - } else { - if (g_strcasecmp (node->name, "text") != 0) { - WARN ("bad node = \"%s\"", node->name); - } - } - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Sheet->Label Node. */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_label (xmlNodePtr label_node, - glTemplate * template) -{ - xmlNodePtr node; - gchar *style; - - style = xmlGetProp (label_node, "style"); - if (g_strcasecmp (style, "rectangle") == 0) { - template->style = GL_TEMPLATE_STYLE_RECT; - } else if (g_strcasecmp (style, "round") == 0) { - template->style = GL_TEMPLATE_STYLE_ROUND; - } else if (g_strcasecmp (style, "cd") == 0) { - template->style = GL_TEMPLATE_STYLE_CD; - } else { - WARN ("Unknown label style in template"); - } - - if (template->style == GL_TEMPLATE_STYLE_RECT) { - template->label_width = - g_strtod (xmlGetProp (label_node, "width"), NULL); - template->label_height = - g_strtod (xmlGetProp (label_node, "height"), NULL); - template->label_round = - g_strtod (xmlGetProp (label_node, "round"), NULL); - } else if (template->style == GL_TEMPLATE_STYLE_ROUND) { - template->label_radius = - g_strtod (xmlGetProp (label_node, "radius"), NULL); - template->label_width = 2.0 * template->label_radius; - template->label_height = 2.0 * template->label_radius; - } else if (template->style == GL_TEMPLATE_STYLE_CD) { - template->label_radius = - g_strtod (xmlGetProp (label_node, "radius"), NULL); - template->label_hole = - g_strtod (xmlGetProp (label_node, "hole"), NULL); - template->label_width = 2.0 * template->label_radius; - template->label_height = 2.0 * template->label_radius; - } - - template->label_margin = - g_strtod (xmlGetProp (label_node, "margin"), NULL); - - for (node = label_node->xmlChildrenNode; node != NULL; - node = node->next) { - if (g_strcasecmp (node->name, "Layout") == 0) { - xml_parse_layout (node, template); - } else { - if (g_strcasecmp (node->name, "text") != 0) { - WARN ("bad node = \"%s\"", node->name); - } - } - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Sheet->Label->Layout Node. */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_layout (xmlNodePtr layout_node, - glTemplate * template) -{ - xmlNodePtr node; - - sscanf (xmlGetProp (layout_node, "nx"), "%d", &(template->nx)); - sscanf (xmlGetProp (layout_node, "ny"), "%d", &(template->ny)); - template->x0 = g_strtod (xmlGetProp (layout_node, "x0"), NULL); - template->y0 = g_strtod (xmlGetProp (layout_node, "y0"), NULL); - template->dx = g_strtod (xmlGetProp (layout_node, "dx"), NULL); - template->dy = g_strtod (xmlGetProp (layout_node, "dy"), NULL); - - for (node = layout_node->xmlChildrenNode; node != NULL; - node = node->next) { - if (g_strcasecmp (node->name, "text") != 0) { - WARN ("bad node = \"%s\"", node->name); - } - } - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Parse XML Sheet->Alias Node. */ -/*--------------------------------------------------------------------------*/ -static void -xml_parse_alias (xmlNodePtr alias_node, - glTemplate * template) -{ - template->name = g_list_append (template->name, - xmlGetProp (alias_node, "name")); -} - -/****************************************************************************/ -/* Add XML Template Node */ -/****************************************************************************/ -void -gl_template_xml_add_sheet (glTemplate * template, - xmlNodePtr root, - xmlNsPtr ns) -{ - xmlNodePtr node; - GList *p; - - node = xmlNewChild (root, ns, "Sheet", NULL); - - xmlSetProp (node, "name", template->name->data); - xmlSetProp (node, "size", template->page_size); - xmlSetProp (node, "description", template->description); - - xml_add_label (template, node, ns); - - for ( p=template->name->next; p != NULL; p=p->next ) { - xml_add_alias( p->data, node, ns ); - } -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Sheet->Label Node. */ -/*--------------------------------------------------------------------------*/ -static void -xml_add_label (glTemplate *template, - xmlNodePtr root, - xmlNsPtr ns) -{ - xmlNodePtr node; - gchar *string; - - node = xmlNewChild(root, ns, "Label", NULL); - string = g_strdup_printf ("%g", template->label_margin); - xmlSetProp (node, "margin", string); - g_free (string); - switch (template->style) { - case GL_TEMPLATE_STYLE_RECT: - xmlSetProp (node, "style", "rectangle"); - string = g_strdup_printf ("%g", template->label_width); - xmlSetProp (node, "width", string); - g_free (string); - string = g_strdup_printf ("%g", template->label_height); - xmlSetProp (node, "height", string); - g_free (string); - string = g_strdup_printf ("%g", template->label_round); - xmlSetProp (node, "round", string); - g_free (string); - break; - case GL_TEMPLATE_STYLE_ROUND: - xmlSetProp (node, "style", "round"); - string = g_strdup_printf ("%g", template->label_radius); - xmlSetProp (node, "radius", string); - g_free (string); - break; - case GL_TEMPLATE_STYLE_CD: - xmlSetProp (node, "style", "cd"); - string = g_strdup_printf ("%g", template->label_radius); - xmlSetProp (node, "radius", string); - g_free (string); - string = g_strdup_printf ("%g", template->label_hole); - xmlSetProp (node, "hole", string); - g_free (string); - break; - default: - WARN ("Unknown label style"); - break; - } - - xml_add_layout (template, node, ns); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Sheet->Label->Layout Node. */ -/*--------------------------------------------------------------------------*/ -static void -xml_add_layout (glTemplate *template, - xmlNodePtr root, - xmlNsPtr ns) -{ - xmlNodePtr node; - gchar *string; - - node = xmlNewChild(root, ns, "Layout", NULL); - string = g_strdup_printf ("%d", template->nx); - xmlSetProp (node, "nx", string); - g_free (string); - string = g_strdup_printf ("%d", template->ny); - xmlSetProp (node, "ny", string); - g_free (string); - string = g_strdup_printf ("%g", template->x0); - xmlSetProp (node, "x0", string); - g_free (string); - string = g_strdup_printf ("%g", template->y0); - xmlSetProp (node, "y0", string); - g_free (string); - string = g_strdup_printf ("%g", template->dx); - xmlSetProp (node, "dx", string); - g_free (string); - string = g_strdup_printf ("%g", template->dy); - xmlSetProp (node, "dy", string); - g_free (string); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Add XML Sheet->Alias Node. */ -/*--------------------------------------------------------------------------*/ -static void -xml_add_alias (gchar *name, - xmlNodePtr root, - xmlNsPtr ns) -{ - xmlNodePtr node; - - node = xmlNewChild (root, ns, "Alias", NULL); - xmlSetProp (node, "name", name); -} - diff --git a/glabels1/src/template.h b/glabels1/src/template.h deleted file mode 100644 index 9e72c6b..0000000 --- a/glabels1/src/template.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * template.h: template module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __TEMPLATE_H__ -#define __TEMPLATE_H__ - -#include <gnome.h> - -/* LibXML */ -#include <tree.h> -#include <parser.h> - -typedef enum { - GL_TEMPLATE_STYLE_RECT, - GL_TEMPLATE_STYLE_ROUND, - GL_TEMPLATE_STYLE_CD, -} glTemplateStyle; - -typedef struct { - GList *name; - gchar *description; - gchar *page_size; - glTemplateStyle style; - - /* Suggested margin */ - gdouble label_margin; - - /* Simple and rounded rectangles. */ - gdouble label_width, label_height, label_round; - - /* CD/DVD labels */ - gdouble label_radius, label_hole; - - /* Layout */ - gint nx, ny; - gdouble x0, y0, dx, dy; -} glTemplate; - -extern void gl_template_init (void); - -extern GList *gl_template_get_name_list (const gchar * page_size); -extern void gl_template_free_name_list (GList ** names); - -extern glTemplate *gl_template_from_name (const gchar * name); - -extern glTemplate *gl_template_copy(const glTemplate *orig_template); -extern void gl_template_free(glTemplate **template); - -extern void gl_template_xml_parse_sheet (glTemplate * template, - xmlNodePtr sheet_node); -extern void gl_template_xml_add_sheet (glTemplate * template, - xmlNodePtr root, xmlNsPtr ns); -#endif diff --git a/glabels1/src/text_node.c b/glabels1/src/text_node.c deleted file mode 100644 index c32ab72..0000000 --- a/glabels1/src/text_node.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * text_node.c: text node module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "text_node.h" - -#include "merge.h" - -#include "debug.h" - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static glTextNode *extract_text_node (gchar * text, gint * n); - - -/*--------------------------------------------------------------------------*/ -/* Expand single node into representative string. */ -/*--------------------------------------------------------------------------*/ -gchar * -gl_text_node_expand (glTextNode * text_node, - glMergeRecord * record) -{ - gchar *text; - - if (text_node->field_flag) { - text = gl_merge_eval_key (text_node->data, record); - if (text != NULL) { - return text; - } else { - return g_strdup_printf ("FIELD{%s}", text_node->data); - } - } else { - return g_strdup (text_node->data); - } -} - -/*--------------------------------------------------------------------------*/ -/* Create a single text node from given text. */ -/*--------------------------------------------------------------------------*/ -glTextNode * -gl_text_node_new_from_text (gchar * text) -{ - gint n; - - return extract_text_node (text, &n); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Create a single text node from given text. n = characters used */ -/*--------------------------------------------------------------------------*/ -static glTextNode * -extract_text_node (gchar * text, - gint * n) -{ - glTextNode *text_node; - gchar *p; - gint m; - - text_node = g_new0 (glTextNode, 1); - - if (strncmp (text, "FIELD{", strlen ("FIELD{")) == 0) { - /* We are at the beginning of a "FIELD" node */ - text_node->field_flag = TRUE; - *n = strlen ("FIELD{"); - text += *n; - for (p = text, m = 0; *p != 0; p++, m++, (*n)++) { - if (*p == '}') { - (*n)++; - break; - } - } - text_node->data = g_strndup (text, m); - } else { - /* We are at the beginning of a literal node */ - text_node->field_flag = FALSE; - for (p = text, *n = 0; *p != 0; p++, (*n)++) { - if (strncmp (p, "FIELD{", strlen ("FIELD{")) == 0) - break; - if (*p == '\n') - break; - } - text_node->data = g_strndup (text, *n); - } - - return text_node; -} - -/*--------------------------------------------------------------------------*/ -/* Free a single text node. */ -/*--------------------------------------------------------------------------*/ -void -gl_text_node_free (glTextNode ** text_node) -{ - g_free ((*text_node)->data); - (*text_node)->data = NULL; - g_free (*text_node); - *text_node = NULL; -} - -/*--------------------------------------------------------------------------*/ -/* Expand text lines into single string. */ -/*--------------------------------------------------------------------------*/ -gchar * -gl_text_node_lines_expand (GList * lines, - glMergeRecord * record) -{ - GList *p_line, *p_node; - glTextNode *text_node; - gchar *text, *old_text, *expanded_node; - - text = g_strdup (""); /* prime pointer for concatenation */ - for (p_line = lines; p_line != NULL; p_line = p_line->next) { - for (p_node = (GList *) p_line->data; p_node != NULL; - p_node = p_node->next) { - text_node = (glTextNode *) p_node->data; - old_text = text; - expanded_node = gl_text_node_expand (text_node, record); - text = g_strconcat (text, expanded_node, NULL); - g_free (old_text); - g_free (expanded_node); - } - old_text = text; - text = g_strconcat (text, "\n", NULL); - g_free (old_text); - } - - return text; -} - -/*--------------------------------------------------------------------------*/ -/* Parse a string back into text lines. */ -/*--------------------------------------------------------------------------*/ -GList * -gl_text_node_lines_new_from_text (gchar * text) -{ - GList *lines, *nodes; - glTextNode *text_node; - gchar *p; - gint n; - - lines = NULL; - nodes = NULL; - for (p = text; *p != 0; p += n) { - if (*p != '\n') { - text_node = extract_text_node (p, &n); - nodes = g_list_append (nodes, text_node); - } else { - n = 1; - lines = g_list_append (lines, nodes); - nodes = NULL; - } - } - if (*(p - 1) != '\n') { - lines = g_list_append (lines, nodes); - } - - return lines; -} - -/*--------------------------------------------------------------------------*/ -/* Free a list of text lines. */ -/*--------------------------------------------------------------------------*/ -void -gl_text_node_lines_free (GList ** lines) -{ - GList *p_line, *p_node; - - for (p_line = *lines; p_line != NULL; p_line = p_line->next) { - for (p_node = (GList *) p_line->data; p_node != NULL; - p_node = p_node->next) { - gl_text_node_free ( (glTextNode **) &(p_node->data) ); - } - g_list_free ((GList *) p_line->data); - p_line->data = NULL; - } - - g_list_free (*lines); - *lines = NULL; -} - -/****************************************************************************/ -/* For debugging: descend and print lines list. */ -/****************************************************************************/ -void -gl_text_node_lines_print (GList * lines ) -{ - GList *p_line, *p_node; - glTextNode *text_node; - gint i_line, i_node; - - for (p_line=lines, i_line=0; p_line != NULL; p_line=p_line->next, i_line++) { - for (p_node = (GList *) p_line->data, i_node=0; p_node != NULL; - p_node = p_node->next, i_node++) { - text_node = (glTextNode *) p_node->data; - g_print( "LINE[%d], NODE[%d] = { %d, \"%s\" }\n", - i_line, i_node, - text_node->field_flag, text_node->data ); - - } - } - -} - diff --git a/glabels1/src/text_node.h b/glabels1/src/text_node.h deleted file mode 100644 index 97adbf0..0000000 --- a/glabels1/src/text_node.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * text_node.h: text node module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __TEXT_NODE_H__ -#define __TEXT_NODE_H__ - -#include <gnome.h> -#include "merge.h" - -typedef struct { - gboolean field_flag; - gchar *data; -} glTextNode; - -extern gchar *gl_text_node_expand (glTextNode * text_node, - glMergeRecord * record); -extern glTextNode *gl_text_node_new_from_text (gchar * text); -extern void gl_text_node_free (glTextNode ** text_node); - -extern gchar *gl_text_node_lines_expand (GList * lines, - glMergeRecord * record); -extern GList *gl_text_node_lines_new_from_text (gchar * text); -extern void gl_text_node_lines_free (GList ** lines); - -/* debug function */ -extern void gl_text_node_lines_print (GList * lines ); - -#endif diff --git a/glabels1/src/tools.c b/glabels1/src/tools.c deleted file mode 100644 index ede7625..0000000 --- a/glabels1/src/tools.c +++ /dev/null @@ -1,221 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * tools.c: toolbar module - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include "tools.h" -#include "mdi.h" -#include "display.h" -#include "merge_properties.h" - -/*===========================================*/ -/* Private types. */ -/*===========================================*/ - -/*===========================================*/ -/* Private globals. */ -/*===========================================*/ - -/*===========================================*/ -/* Private function prototypes. */ -/*===========================================*/ - - - -/*****************************************************************************/ -/* arrow callback. */ -/*****************************************************************************/ -void -gl_tools_arrow_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_arrow_mode (display); - } -} - -/*****************************************************************************/ -/* text callback. */ -/*****************************************************************************/ -void -gl_tools_text_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_object_create_mode (display, GL_LABEL_OBJECT_TEXT); - } -} - -/*****************************************************************************/ -/* box callback. */ -/*****************************************************************************/ -void -gl_tools_box_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_object_create_mode (display, GL_LABEL_OBJECT_BOX); - } -} - -/*****************************************************************************/ -/* line callback. */ -/*****************************************************************************/ -void -gl_tools_line_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_object_create_mode (display, GL_LABEL_OBJECT_LINE); - } -} - -/*****************************************************************************/ -/* ellipse callback. */ -/*****************************************************************************/ -void -gl_tools_ellipse_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_object_create_mode (display, - GL_LABEL_OBJECT_ELLIPSE); - } -} - -/*****************************************************************************/ -/* image callback. */ -/*****************************************************************************/ -void -gl_tools_image_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_object_create_mode (display, GL_LABEL_OBJECT_IMAGE); - } -} - -/*****************************************************************************/ -/* barcode callback. */ -/*****************************************************************************/ -void -gl_tools_barcode_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_object_create_mode (display, - GL_LABEL_OBJECT_BARCODE); - } -} - -/*****************************************************************************/ -/* zoom in callback. */ -/*****************************************************************************/ -void -gl_tools_zoomin_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_zoom_in (display); - } -} - -/*****************************************************************************/ -/* zoom out callback. */ -/*****************************************************************************/ -void -gl_tools_zoomout_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_zoom_out (display); - } -} - -/*****************************************************************************/ -/* zoom 1:1 callback. */ -/*****************************************************************************/ -void -gl_tools_zoom1to1_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_display_set_zoom (display, 1.0); - } -} - -/*****************************************************************************/ -/* edit merge properties callback. */ -/*****************************************************************************/ -void -gl_tools_merge_properties_cb (GtkWidget * widget, - gpointer data) -{ - GnomeMDIChild *child = gnome_mdi_get_active_child (GNOME_MDI (data)); - glDisplay *display; - - display = gl_mdi_get_display (child); - if (display != NULL) { - gl_merge_properties_dialog (display, child->name); - } -} - diff --git a/glabels1/src/tools.h b/glabels1/src/tools.h deleted file mode 100644 index 814c4dd..0000000 --- a/glabels1/src/tools.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * tools.h: toolbar module header file - * - * Copyright (C) 2001-2002 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef __TOOLS_H__ -#define __TOOLS_H__ - -#include <gnome.h> - -extern void gl_tools_arrow_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_text_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_box_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_line_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_ellipse_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_image_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_barcode_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_zoomin_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_zoomout_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_zoom1to1_cb (GtkWidget * widget, gpointer data); -extern void gl_tools_merge_properties_cb (GtkWidget * widget, gpointer data); - -#endif diff --git a/glabels1/src/util.c b/glabels1/src/util.c deleted file mode 100644 index 9e75110..0000000 --- a/glabels1/src/util.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * util.c: various small utility functions - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> - -#include <string.h> -#include <glib.h> -#include <math.h> - -#include "util.h" - -#define FRAC_DELTA 0.00005 - - -/****************************************************************************/ -/* Append ".glabels" extension to filename if needed. */ -/****************************************************************************/ -gchar * -gl_util_add_extension (const gchar * orig_filename) -{ - gchar *new_filename, *extension; - - extension = strrchr (orig_filename, '.'); - if (extension == NULL) { - new_filename = g_strconcat (orig_filename, ".glabels", NULL); - } else { - if (g_strcasecmp (extension, ".glabels") != 0) { - new_filename = - g_strconcat (orig_filename, ".glabels", NULL); - } else { - new_filename = g_strdup (orig_filename); - } - } - - return new_filename; -} - -/****************************************************************************/ -/* Make sure we have an absolute path to filename. */ -/****************************************************************************/ -gchar * -gl_util_make_absolute (const gchar * filename) -{ - gchar *pwd, *absolute_filename; - - if (g_path_is_absolute (filename)) { - absolute_filename = g_strdup (filename); - } else { - pwd = g_get_current_dir (); - absolute_filename = - g_strjoin (G_DIR_SEPARATOR_S, pwd, filename, NULL); - g_free (pwd); - } - - return absolute_filename; -} - -/****************************************************************************/ -/* Create fractional representation of number, if possible. */ -/****************************************************************************/ -gchar * -gl_util_fraction( gdouble x ) -{ - static gdouble denom[] = { 1., 2., 3., 4., 8., 16., 32., 0. }; - gint i; - gdouble product, remainder; - gint n, d; - - for ( i=0; denom[i] != 0.0; i++ ) { - product = x * denom[i]; - remainder = fabs(product - ((gint)(product+0.5))); - if ( remainder < FRAC_DELTA ) break; - } - - if ( denom[i] == 0.0 ) { - /* None of our denominators work. */ - return g_strdup_printf ("%.5g", x); - } - if ( denom[i] == 1.0 ) { - /* Simple integer. */ - return g_strdup_printf ("%d", (gint)x); - } - n = (gint)( x * denom[i] + 0.5 ); - d = (gint)denom[i]; - if ( n > d ) { - return g_strdup_printf ("%d_%d/%d", (n/d), (n%d), d); - } else { - return g_strdup_printf ("%d/%d", (n%d), d); - } -} - diff --git a/glabels1/src/util.h b/glabels1/src/util.h deleted file mode 100644 index b3e188d..0000000 --- a/glabels1/src/util.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * util.h: various small utility functions - * - * Copyright (C) 2001 Jim Evins <evins@snaught.com>. - * - * 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 - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __UTIL_H__ -#define __UTIL_H__ - -#include <glib.h> - -gchar *gl_util_add_extension (const gchar * orig_filename); - -gchar *gl_util_make_absolute (const gchar * filename); - -gchar *gl_util_fraction( gdouble x ); - -#endif /* __UTIL_H__ */ |