From 5f79a4f719b16e37880857730df9f5b65e4fbe17 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Mon, 24 Nov 2003 03:44:28 +0000 Subject: [PATCH] Changed object property dialogs to a single object property editor sidebar. Added zoom to fit command. Converted object property editor and preferences dialog to use libglade and removed un-needed widgets. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@348 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/src/Makefile.am | 45 +- glabels2/src/debug.c | 2 + glabels2/src/debug.h | 3 + glabels2/src/glabels-ui.xml | 45 +- glabels2/src/glabels.c | 5 +- glabels2/src/object-editor-bc-page.c | 292 +++ glabels2/src/object-editor-data-page.c | 225 ++ glabels2/src/object-editor-edit-page.c | 132 ++ glabels2/src/object-editor-fill-page.c | 137 ++ glabels2/src/object-editor-image-page.c | 221 ++ glabels2/src/object-editor-line-page.c | 195 ++ glabels2/src/object-editor-lsize-page.c | 215 ++ glabels2/src/object-editor-position-page.c | 218 ++ glabels2/src/object-editor-private.h | 146 ++ glabels2/src/object-editor-size-page.c | 376 +++ glabels2/src/object-editor-text-page.c | 499 ++++ glabels2/src/object-editor.c | 458 ++++ glabels2/src/object-editor.glade | 2083 +++++++++++++++++ glabels2/src/object-editor.h | 247 ++ glabels2/src/prefs-dialog.c | 653 ++++-- glabels2/src/prefs-dialog.glade | 1132 +++++++++ glabels2/src/prefs-dialog.h | 2 +- glabels2/src/stock-pixmaps/Makefile.am | 2 + .../src/stock-pixmaps/stock_properties_24.png | Bin 0 -> 495 bytes glabels2/src/stock.c | 4 +- glabels2/src/tools.c | 20 +- glabels2/src/tools.h | 4 +- glabels2/src/ui-sidebar.c | 248 ++ glabels2/src/ui-sidebar.h | 71 + glabels2/src/ui.c | 5 +- glabels2/src/view-barcode.c | 495 +--- glabels2/src/view-box.c | 463 +--- glabels2/src/view-ellipse.c | 493 ++-- glabels2/src/view-image.c | 446 +--- glabels2/src/view-line.c | 413 +--- glabels2/src/view-object.c | 39 +- glabels2/src/view-object.h | 4 +- glabels2/src/view-text.c | 432 ++-- glabels2/src/view.c | 129 +- glabels2/src/view.h | 4 +- glabels2/src/wdgt-bc-data.c | 417 ---- glabels2/src/wdgt-bc-data.h | 80 - glabels2/src/wdgt-bc-props.c | 237 -- glabels2/src/wdgt-bc-props.h | 73 - glabels2/src/wdgt-bc-style.c | 323 --- glabels2/src/wdgt-bc-style.h | 80 - glabels2/src/wdgt-fill.c | 238 -- glabels2/src/wdgt-fill.h | 73 - glabels2/src/wdgt-line.c | 274 --- glabels2/src/wdgt-line.h | 79 - glabels2/src/wdgt-position.c | 338 --- glabels2/src/wdgt-position.h | 86 - glabels2/src/wdgt-size.c | 507 ---- glabels2/src/wdgt-size.h | 95 - glabels2/src/wdgt-text-entry.c | 295 --- glabels2/src/wdgt-text-entry.h | 80 - glabels2/src/wdgt-text-props.c | 479 ---- glabels2/src/wdgt-text-props.h | 93 - glabels2/src/wdgt-vector.c | 318 --- glabels2/src/wdgt-vector.h | 82 - glabels2/src/window.c | 5 +- glabels2/src/window.h | 2 + 62 files changed, 8294 insertions(+), 6563 deletions(-) create mode 100644 glabels2/src/object-editor-bc-page.c create mode 100644 glabels2/src/object-editor-data-page.c create mode 100644 glabels2/src/object-editor-edit-page.c create mode 100644 glabels2/src/object-editor-fill-page.c create mode 100644 glabels2/src/object-editor-image-page.c create mode 100644 glabels2/src/object-editor-line-page.c create mode 100644 glabels2/src/object-editor-lsize-page.c create mode 100644 glabels2/src/object-editor-position-page.c create mode 100644 glabels2/src/object-editor-private.h create mode 100644 glabels2/src/object-editor-size-page.c create mode 100644 glabels2/src/object-editor-text-page.c create mode 100644 glabels2/src/object-editor.c create mode 100644 glabels2/src/object-editor.glade create mode 100644 glabels2/src/object-editor.h create mode 100644 glabels2/src/prefs-dialog.glade create mode 100644 glabels2/src/stock-pixmaps/stock_properties_24.png create mode 100644 glabels2/src/ui-sidebar.c create mode 100644 glabels2/src/ui-sidebar.h delete mode 100644 glabels2/src/wdgt-bc-data.c delete mode 100644 glabels2/src/wdgt-bc-data.h delete mode 100644 glabels2/src/wdgt-bc-props.c delete mode 100644 glabels2/src/wdgt-bc-props.h delete mode 100644 glabels2/src/wdgt-bc-style.c delete mode 100644 glabels2/src/wdgt-bc-style.h delete mode 100644 glabels2/src/wdgt-fill.c delete mode 100644 glabels2/src/wdgt-fill.h delete mode 100644 glabels2/src/wdgt-line.c delete mode 100644 glabels2/src/wdgt-line.h delete mode 100644 glabels2/src/wdgt-position.c delete mode 100644 glabels2/src/wdgt-position.h delete mode 100644 glabels2/src/wdgt-size.c delete mode 100644 glabels2/src/wdgt-size.h delete mode 100644 glabels2/src/wdgt-text-entry.c delete mode 100644 glabels2/src/wdgt-text-entry.h delete mode 100644 glabels2/src/wdgt-text-props.c delete mode 100644 glabels2/src/wdgt-text-props.h delete mode 100644 glabels2/src/wdgt-vector.c delete mode 100644 glabels2/src/wdgt-vector.h diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index 3581fefd..e6e10aa2 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -54,6 +54,8 @@ glabels_SOURCES = \ ui.c \ ui-property-bar.h \ ui-property-bar.c \ + ui-sidebar.h \ + ui-sidebar.c \ ui-util.h \ ui-util.c \ commands.h \ @@ -90,6 +92,29 @@ glabels_SOURCES = \ view-highlight.h \ merge-properties-dialog.c \ merge-properties-dialog.h \ + object-editor.c \ + object-editor.h \ + object-editor-private.h \ + object-editor-position-page.c \ + object-editor-position-page.h \ + object-editor-size-page.c \ + object-editor-size-page.h \ + object-editor-lsize-page.c \ + object-editor-lsize-page.h \ + object-editor-line-page.c \ + object-editor-line-page.h \ + object-editor-fill-page.c \ + object-editor-fill-page.h \ + object-editor-image-page.c \ + object-editor-image-page.h \ + object-editor-text-page.c \ + object-editor-text-page.h \ + object-editor-edit-page.c \ + object-editor-edit-page.h \ + object-editor-bc-page.c \ + object-editor-bc-page.h \ + object-editor-data-page.c \ + object-editor-data-page.h \ print.c \ print.h \ print-dialog.c \ @@ -144,28 +169,8 @@ glabels_SOURCES = \ merge-text.h \ text-node.c \ text-node.h \ - wdgt-text-props.c \ - wdgt-text-props.h \ - wdgt-text-entry.c \ - wdgt-text-entry.h \ - wdgt-position.c \ - wdgt-position.h \ - wdgt-size.c \ - wdgt-size.h \ - wdgt-line.c \ - wdgt-line.h \ - wdgt-fill.c \ - wdgt-fill.h \ - wdgt-vector.c \ - wdgt-vector.h \ wdgt-image-select.c \ wdgt-image-select.h \ - wdgt-bc-props.c \ - wdgt-bc-props.h \ - wdgt-bc-style.c \ - wdgt-bc-style.h \ - wdgt-bc-data.c \ - wdgt-bc-data.h \ wdgt-print-copies.c \ wdgt-print-copies.h \ wdgt-print-merge.c \ diff --git a/glabels2/src/debug.c b/glabels2/src/debug.c index d5492eab..581c069d 100644 --- a/glabels2/src/debug.c +++ b/glabels2/src/debug.c @@ -52,6 +52,7 @@ gint gl_debug_property_bar = 0; gint gl_debug_media_select = 0; gint gl_debug_mini_preview = 0; gint gl_debug_pixbuf_cache = 0; +gint gl_debug_editor = 0; gint gl_debug_wdgt = 0; /****************************************************************************/ @@ -94,6 +95,7 @@ gl_debug (gint section, (gl_debug_media_select && section == GL_DEBUG_MEDIA_SELECT) || (gl_debug_mini_preview && section == GL_DEBUG_MINI_PREVIEW) || (gl_debug_pixbuf_cache && section == GL_DEBUG_PIXBUF_CACHE) || + (gl_debug_editor && section == GL_DEBUG_EDITOR) || (gl_debug_wdgt && section == GL_DEBUG_WDGT) ) g_print ("%s:%d (%s) %s\n", file, line, function, msg); diff --git a/glabels2/src/debug.h b/glabels2/src/debug.h index 5e15577f..809d6f98 100644 --- a/glabels2/src/debug.h +++ b/glabels2/src/debug.h @@ -52,6 +52,7 @@ typedef enum { GL_DEBUG_MEDIA_SELECT, GL_DEBUG_MINI_PREVIEW, GL_DEBUG_PIXBUF_CACHE, + GL_DEBUG_EDITOR, GL_DEBUG_WDGT, } glDebugSection; @@ -75,6 +76,7 @@ extern gint gl_debug_property_bar; extern gint gl_debug_media_select; extern gint gl_debug_mini_preview; extern gint gl_debug_pixbuf_cache; +extern gint gl_debug_editor; extern gint gl_debug_wdgt; #ifndef __GNUC__ @@ -100,6 +102,7 @@ extern gint gl_debug_wdgt; #define DEBUG_MEDIA_SELECT GL_DEBUG_MEDIA_SELECT, __FILE__, __LINE__, __FUNCTION__ #define DEBUG_MINI_PREVIEW GL_DEBUG_MINI_PREVIEW, __FILE__, __LINE__, __FUNCTION__ #define DEBUG_PIXBUF_CACHE GL_DEBUG_PIXBUF_CACHE, __FILE__, __LINE__, __FUNCTION__ +#define DEBUG_EDITOR GL_DEBUG_EDITOR, __FILE__, __LINE__, __FUNCTION__ #define DEBUG_WDGT GL_DEBUG_WDGT, __FILE__, __LINE__, __FUNCTION__ void gl_debug (gint section, gchar *file, diff --git a/glabels2/src/glabels-ui.xml b/glabels2/src/glabels-ui.xml index 01ea61ea..b519b737 100644 --- a/glabels2/src/glabels-ui.xml +++ b/glabels2/src/glabels-ui.xml @@ -246,16 +246,16 @@ pixtype="stock" pixname="gtk-zoom-100" /> + + - - + + + + @@ -741,13 +749,6 @@ - - - - + + + + + + + + + + diff --git a/glabels2/src/glabels.c b/glabels2/src/glabels.c index 6709da6c..8ae50f1e 100644 --- a/glabels2/src/glabels.c +++ b/glabels2/src/glabels.c @@ -105,9 +105,12 @@ static const struct poptOption options [] = { "debug-pixbuf-cache", '\0', POPT_ARG_NONE, &gl_debug_pixbuf_cache, 0, N_("Show pixbuf cache debugging messages."), NULL }, - { "debug-wdgt", '\0', POPT_ARG_NONE, &gl_debug_wdgt, 0, + { "debug-editor", '\0', POPT_ARG_NONE, &gl_debug_editor, 0, N_("Show widget debugging messages."), NULL }, + { "debug-wdgt", '\0', POPT_ARG_NONE, &gl_debug_wdgt, 0, + N_("Show object editor debugging messages."), NULL }, + { "debug", '\0', POPT_ARG_NONE, &gl_debug_all, 0, N_("Turn on all debugging messages."), NULL }, diff --git a/glabels2/src/object-editor-bc-page.c b/glabels2/src/object-editor-bc-page.c new file mode 100644 index 00000000..a4659e9d --- /dev/null +++ b/glabels2/src/object-editor-bc-page.c @@ -0,0 +1,292 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" +#include "mygal/widget-color-combo.h" +#include "color.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static void style_changed_cb (glObjectEditor *editor); + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare size page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_bc_page (glObjectEditor *editor) +{ + GList *styles = NULL; + GtkSizeGroup *label_size_group; + GtkWidget *label; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->bc_page_vbox = + glade_xml_get_widget (editor->priv->gui, "bc_page_vbox"); + editor->priv->bc_style_entry = + glade_xml_get_widget (editor->priv->gui, "bc_style_entry"); + editor->priv->bc_style_combo = + glade_xml_get_widget (editor->priv->gui, "bc_style_combo"); + editor->priv->bc_text_check = + glade_xml_get_widget (editor->priv->gui, "bc_text_check"); + editor->priv->bc_cs_check = + glade_xml_get_widget (editor->priv->gui, "bc_cs_check"); + editor->priv->bc_color_combo = + glade_xml_get_widget (editor->priv->gui, "bc_color_combo"); + + /* Load barcode styles */ + styles = gl_barcode_get_styles_list (); + gtk_combo_set_popdown_strings (GTK_COMBO(editor->priv->bc_style_combo), styles); + gl_barcode_free_styles_list (styles); + + /* Align label widths */ + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + label = glade_xml_get_widget (editor->priv->gui, "bc_style_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "bc_color_label"); + gtk_size_group_add_widget (label_size_group, label); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->bc_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->bc_style_entry), + "changed", + G_CALLBACK (style_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->bc_text_check), + "toggled", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->bc_cs_check), + "toggled", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->bc_color_combo), + "color_changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Callback for when style has changed. */ +/*--------------------------------------------------------------------------*/ +static void +style_changed_cb (glObjectEditor *editor) +{ + gchar *style_string; + glBarcodeStyle style; + + style_string = + gtk_editable_get_chars (GTK_EDITABLE(editor->priv->bc_style_entry), 0, -1); + + /* Don't emit if entry is empty. */ + if ( *style_string != 0 ) { + style = gl_barcode_text_to_style (style_string); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(editor->priv->bc_text_check), + gl_barcode_can_text (style)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(editor->priv->bc_cs_check), + gl_barcode_can_csum (style)); + + gtk_widget_set_sensitive (editor->priv->bc_text_check, + gl_barcode_text_optional (style)); + gtk_widget_set_sensitive (editor->priv->bc_cs_check, + gl_barcode_csum_optional (style)); + + + /* Emit our "changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + } + + g_free (style_string); +} + +/*****************************************************************************/ +/* Set barcode style. */ +/*****************************************************************************/ +void +gl_object_editor_set_bc_style (glObjectEditor *editor, + glBarcodeStyle style, + gboolean text_flag, + gboolean checksum_flag) +{ + const gchar *style_string; + gint pos; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->bc_style_entry), + G_CALLBACK (style_changed_cb), + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->bc_text_check), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->bc_cs_check), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + + style_string = gl_barcode_style_to_text (style); + + gtk_editable_delete_text (GTK_EDITABLE (editor->priv->bc_style_entry), + 0, -1); + + pos = 0; + gtk_editable_insert_text (GTK_EDITABLE (editor->priv->bc_style_entry), + style_string, + strlen (style_string), + &pos); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check), + text_flag); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->bc_cs_check), + checksum_flag); + + gtk_widget_set_sensitive (editor->priv->bc_text_check, + gl_barcode_text_optional (style)); + gtk_widget_set_sensitive (editor->priv->bc_cs_check, + gl_barcode_csum_optional (style)); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->bc_style_entry), + G_CALLBACK (style_changed_cb), + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->bc_text_check), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->bc_cs_check), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query barcode style. */ +/*****************************************************************************/ +void +gl_object_editor_get_bc_style (glObjectEditor *editor, + glBarcodeStyle *style, + gboolean *text_flag, + gboolean *checksum_flag) +{ + gchar *style_string; + + gl_debug (DEBUG_EDITOR, "START"); + + style_string = + gtk_editable_get_chars (GTK_EDITABLE(editor->priv->bc_style_entry), + 0, -1); + *style = gl_barcode_text_to_style (style_string); + + *text_flag = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check)); + + *checksum_flag = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->bc_cs_check)); + + g_free (style_string); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set bc color. */ +/*****************************************************************************/ +void +gl_object_editor_set_bc_color (glObjectEditor *editor, + guint bc_color) +{ + GdkColor *gdk_color; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->bc_color_combo), + gl_object_editor_changed_cb, + editor); + + gdk_color = gl_color_to_gdk_color (bc_color); + color_combo_set_color (COLOR_COMBO(editor->priv->bc_color_combo), gdk_color); + g_free (gdk_color); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->bc_color_combo), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query bc color. */ +/*****************************************************************************/ +guint +gl_object_editor_get_bc_color (glObjectEditor *editor) +{ + GdkColor *gdk_color; + guint color; + gboolean is_default; + + gl_debug (DEBUG_EDITOR, "START"); + + gdk_color = color_combo_get_color (COLOR_COMBO(editor->priv->bc_color_combo), + &is_default); + + if (is_default) { + color = gl_prefs->default_line_color; + } else { + color = gl_color_from_gdk_color (gdk_color); + } + + + gl_debug (DEBUG_EDITOR, "END"); + + return color; +} + + diff --git a/glabels2/src/object-editor-data-page.c b/glabels2/src/object-editor-data-page.c new file mode 100644 index 00000000..1fac8c7a --- /dev/null +++ b/glabels2/src/object-editor-data-page.c @@ -0,0 +1,225 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static void data_radio_toggled_cb (glObjectEditor *editor); + + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare data page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_data_page (glObjectEditor *editor) +{ + GdkColor *gdk_color; + GtkSizeGroup *label_size_group; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->data_page_vbox = glade_xml_get_widget (editor->priv->gui, + "data_page_vbox"); + editor->priv->data_literal_radio = glade_xml_get_widget (editor->priv->gui, + "data_literal_radio"); + editor->priv->data_key_radio = glade_xml_get_widget (editor->priv->gui, + "data_key_radio"); + editor->priv->data_text_entry = glade_xml_get_widget (editor->priv->gui, + "data_text_entry"); + editor->priv->data_key_combo = glade_xml_get_widget (editor->priv->gui, + "data_key_combo"); + editor->priv->data_key_entry = glade_xml_get_widget (editor->priv->gui, + "data_key_entry"); + + /* Align label widths */ + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + gtk_size_group_add_widget (label_size_group, editor->priv->data_literal_radio); + gtk_size_group_add_widget (label_size_group, editor->priv->data_key_radio); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->data_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->data_text_entry), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->data_key_entry), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->data_literal_radio), + "toggled", + G_CALLBACK (data_radio_toggled_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->data_key_radio), + "toggled", + G_CALLBACK (data_radio_toggled_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. data radio callback. */ +/*--------------------------------------------------------------------------*/ +static void +data_radio_toggled_cb (glObjectEditor *editor) +{ + gl_debug (DEBUG_WDGT, "START"); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->data_literal_radio))) { + gtk_widget_set_sensitive (editor->priv->data_text_entry, TRUE); + gtk_widget_set_sensitive (editor->priv->data_key_combo, FALSE); + } else { + gtk_widget_set_sensitive (editor->priv->data_text_entry, FALSE); + gtk_widget_set_sensitive (editor->priv->data_key_combo, TRUE); + } + + /* Emit our "changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + + gl_debug (DEBUG_WDGT, "END"); +} + +/*****************************************************************************/ +/* Set data. */ +/*****************************************************************************/ +void +gl_object_editor_set_data (glObjectEditor *editor, + gboolean merge_flag, + glTextNode *text_node) +{ + gint pos; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->data_text_entry), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->data_key_entry), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + + gtk_widget_set_sensitive (editor->priv->data_key_radio, merge_flag); + + if (!text_node->field_flag) { + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->data_literal_radio), TRUE); + gtk_widget_set_sensitive (editor->priv->data_text_entry, TRUE); + gtk_widget_set_sensitive (editor->priv->data_key_combo, FALSE); + + gtk_editable_delete_text (GTK_EDITABLE (editor->priv->data_text_entry), 0, -1); + pos = 0; + if (text_node->data != NULL ) { + gtk_editable_insert_text (GTK_EDITABLE (editor->priv->data_text_entry), + text_node->data, + strlen (text_node->data), + &pos); + } + + } else { + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->data_key_radio), TRUE); + + gtk_widget_set_sensitive (editor->priv->data_text_entry, FALSE); + gtk_widget_set_sensitive (editor->priv->data_key_combo, TRUE); + + gtk_editable_delete_text (GTK_EDITABLE (editor->priv->data_key_entry), 0, -1); + pos = 0; + gtk_editable_insert_text (GTK_EDITABLE (editor->priv->data_key_entry), + text_node->data, + strlen (text_node->data), + &pos); + } + + + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->data_text_entry), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->data_key_entry), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query data. */ +/*****************************************************************************/ +glTextNode * +gl_object_editor_get_data (glObjectEditor *editor) +{ + glTextNode *text_node; + + gl_debug (DEBUG_EDITOR, "START"); + + text_node = g_new0(glTextNode,1); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->data_literal_radio))) { + text_node->field_flag = FALSE; + text_node->data = + gtk_editable_get_chars (GTK_EDITABLE (editor->priv->data_text_entry), + 0, -1); + } else { + text_node->field_flag = TRUE; + text_node->data = + gtk_editable_get_chars (GTK_EDITABLE (editor->priv->data_key_entry), + 0, -1); + } + + gl_debug (DEBUG_EDITOR, "text_node: field_flag=%d, data=%s", + text_node->field_flag, text_node->data); + + gl_debug (DEBUG_EDITOR, "END"); + + return text_node; +} + diff --git a/glabels2/src/object-editor-edit-page.c b/glabels2/src/object-editor-edit-page.c new file mode 100644 index 00000000..4e010711 --- /dev/null +++ b/glabels2/src/object-editor-edit-page.c @@ -0,0 +1,132 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" +#include "mygal/widget-color-combo.h" +#include "color.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static void insert_button_cb (glObjectEditor *editor); + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare size page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_edit_page (glObjectEditor *editor) +{ + GList *family_names = NULL; + GtkSizeGroup *label_size_group; + GtkWidget *label; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->edit_page_vbox = + glade_xml_get_widget (editor->priv->gui, "edit_page_vbox"); + editor->priv->edit_text_view = + glade_xml_get_widget (editor->priv->gui, "edit_text_view"); + editor->priv->edit_key_label = + glade_xml_get_widget (editor->priv->gui, "edit_key_label"); + editor->priv->edit_key_entry = + glade_xml_get_widget (editor->priv->gui, "edit_key_entry"); + editor->priv->edit_key_combo = + glade_xml_get_widget (editor->priv->gui, "edit_key_combo"); + editor->priv->edit_insert_field_button = + glade_xml_get_widget (editor->priv->gui, "edit_insert_field_button"); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->edit_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->edit_insert_field_button), + "clicked", + G_CALLBACK (insert_button_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Alignment togglebutton callback. */ +/*--------------------------------------------------------------------------*/ +static void +insert_button_cb (glObjectEditor *editor) +{ + GtkTextBuffer *buffer; + gchar *key, *field; + + gl_debug (DEBUG_EDITOR, "START"); + + key = + gtk_editable_get_chars (GTK_EDITABLE (editor->priv->edit_key_entry), 0, -1); + field = g_strdup_printf ("${%s}", key); + gl_debug (DEBUG_WDGT, "Inserting %s", field); + + buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->priv->edit_text_view)); + gtk_text_buffer_insert_at_cursor (buffer, field, -1); + + g_free (field); + g_free (key); + + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set text buffer as model for text view/editor. */ +/*****************************************************************************/ +void +gl_object_editor_set_text_buffer (glObjectEditor *editor, + GtkTextBuffer *buffer) +{ + gl_debug (DEBUG_EDITOR, "START"); + + gtk_text_view_set_buffer (GTK_TEXT_VIEW(editor->priv->edit_text_view), buffer); + + gl_debug (DEBUG_EDITOR, "END"); +} + diff --git a/glabels2/src/object-editor-fill-page.c b/glabels2/src/object-editor-fill-page.c new file mode 100644 index 00000000..b5a33af8 --- /dev/null +++ b/glabels2/src/object-editor-fill-page.c @@ -0,0 +1,137 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" +#include "mygal/widget-color-combo.h" +#include "color.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare fill page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_fill_page (glObjectEditor *editor) +{ + GdkColor *gdk_color; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->fill_page_vbox = glade_xml_get_widget (editor->priv->gui, + "fill_page_vbox"); + editor->priv->fill_color_combo = glade_xml_get_widget (editor->priv->gui, + "fill_color_combo"); + + /* Modify widgets based on configuration */ + gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color); + color_combo_set_color (COLOR_COMBO(editor->priv->fill_color_combo), gdk_color); + g_free (gdk_color); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->fill_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->fill_color_combo), + "color_changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set fill color. */ +/*****************************************************************************/ +void +gl_object_editor_set_fill_color (glObjectEditor *editor, + guint color) +{ + GdkColor *gdk_color; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->fill_color_combo), + gl_object_editor_changed_cb, + editor); + + gdk_color = gl_color_to_gdk_color (color); + color_combo_set_color (COLOR_COMBO(editor->priv->fill_color_combo), gdk_color); + g_free (gdk_color); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->fill_color_combo), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query fill color. */ +/*****************************************************************************/ +guint +gl_object_editor_get_fill_color (glObjectEditor *editor) +{ + GdkColor *gdk_color; + gboolean is_default; + guint color; + + gl_debug (DEBUG_EDITOR, "START"); + + gdk_color = color_combo_get_color (COLOR_COMBO(editor->priv->fill_color_combo), + &is_default); + + if (is_default) { + color = GL_COLOR_NONE; + } else { + color = gl_color_from_gdk_color (gdk_color); + } + + gl_debug (DEBUG_EDITOR, "END"); + + return color; +} + diff --git a/glabels2/src/object-editor-image-page.c b/glabels2/src/object-editor-image-page.c new file mode 100644 index 00000000..550f6f0c --- /dev/null +++ b/glabels2/src/object-editor-image-page.c @@ -0,0 +1,221 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static void img_radio_toggled_cb (glObjectEditor *editor); + + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare image page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_image_page (glObjectEditor *editor) +{ + GdkColor *gdk_color; + GtkSizeGroup *label_size_group; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->img_page_vbox = glade_xml_get_widget (editor->priv->gui, + "img_page_vbox"); + editor->priv->img_file_radio = glade_xml_get_widget (editor->priv->gui, + "img_file_radio"); + editor->priv->img_key_radio = glade_xml_get_widget (editor->priv->gui, + "img_key_radio"); + editor->priv->img_pixmap_entry = glade_xml_get_widget (editor->priv->gui, + "img_pixmap_entry"); + editor->priv->img_key_combo = glade_xml_get_widget (editor->priv->gui, + "img_key_combo"); + editor->priv->img_key_entry = glade_xml_get_widget (editor->priv->gui, + "img_key_entry"); + + /* Align label widths */ + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + gtk_size_group_add_widget (label_size_group, editor->priv->img_file_radio); + gtk_size_group_add_widget (label_size_group, editor->priv->img_key_radio); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->img_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->img_pixmap_entry), + "activate", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->img_key_entry), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->img_file_radio), + "toggled", + G_CALLBACK (img_radio_toggled_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->img_key_radio), + "toggled", + G_CALLBACK (img_radio_toggled_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. image radio callback. */ +/*--------------------------------------------------------------------------*/ +static void +img_radio_toggled_cb (glObjectEditor *editor) +{ + gl_debug (DEBUG_WDGT, "START"); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->img_file_radio))) { + gtk_widget_set_sensitive (editor->priv->img_pixmap_entry, TRUE); + gtk_widget_set_sensitive (editor->priv->img_key_combo, FALSE); + } else { + gtk_widget_set_sensitive (editor->priv->img_pixmap_entry, FALSE); + gtk_widget_set_sensitive (editor->priv->img_key_combo, TRUE); + } + + /* Emit our "changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + + gl_debug (DEBUG_WDGT, "END"); +} + +/*****************************************************************************/ +/* Set image. */ +/*****************************************************************************/ +void +gl_object_editor_set_image (glObjectEditor *editor, + gboolean merge_flag, + glTextNode *text_node) +{ + gint pos; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->img_pixmap_entry), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->img_key_entry), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + + gtk_widget_set_sensitive (editor->priv->img_key_radio, merge_flag); + + if (!text_node->field_flag) { + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->img_file_radio), TRUE); + gtk_widget_set_sensitive (editor->priv->img_pixmap_entry, TRUE); + gtk_widget_set_sensitive (editor->priv->img_key_combo, FALSE); + + if (text_node->data != NULL ) { + gnome_file_entry_set_filename (GNOME_FILE_ENTRY(editor->priv->img_pixmap_entry), + text_node->data); + } else { + gnome_file_entry_set_filename (GNOME_FILE_ENTRY(editor->priv->img_pixmap_entry), + ""); + } + } else { + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->img_key_radio), TRUE); + + gtk_widget_set_sensitive (editor->priv->img_pixmap_entry, FALSE); + gtk_widget_set_sensitive (editor->priv->img_key_combo, TRUE); + + gtk_editable_delete_text (GTK_EDITABLE (editor->priv->img_key_entry), 0, -1); + pos = 0; + gtk_editable_insert_text (GTK_EDITABLE (editor->priv->img_key_entry), + text_node->data, + strlen (text_node->data), + &pos); + } + + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->img_pixmap_entry), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->img_key_entry), + G_CALLBACK (gl_object_editor_changed_cb), + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query image. */ +/*****************************************************************************/ +glTextNode * +gl_object_editor_get_image (glObjectEditor *editor) +{ + glTextNode *text_node; + + gl_debug (DEBUG_EDITOR, "START"); + + text_node = g_new0(glTextNode,1); + + if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->img_file_radio))) { + text_node->field_flag = FALSE; + text_node->data = + gnome_pixmap_entry_get_filename (GNOME_PIXMAP_ENTRY(editor->priv->img_pixmap_entry)); + } else { + text_node->field_flag = TRUE; + text_node->data = + gtk_editable_get_chars (GTK_EDITABLE (editor->priv->img_key_entry), + 0, -1); + } + + gl_debug (DEBUG_EDITOR, "text_node: field_flag=%d, data=%s", + text_node->field_flag, text_node->data); + + gl_debug (DEBUG_EDITOR, "END"); + + return text_node; +} + diff --git a/glabels2/src/object-editor-line-page.c b/glabels2/src/object-editor-line-page.c new file mode 100644 index 00000000..78df8da4 --- /dev/null +++ b/glabels2/src/object-editor-line-page.c @@ -0,0 +1,195 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" +#include "mygal/widget-color-combo.h" +#include "color.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare line page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_line_page (glObjectEditor *editor) +{ + GdkColor *gdk_color; + GtkSizeGroup *label_size_group; + GtkWidget *label; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->line_page_vbox = glade_xml_get_widget (editor->priv->gui, + "line_page_vbox"); + editor->priv->line_width_spin = glade_xml_get_widget (editor->priv->gui, + "line_width_spin"); + editor->priv->line_color_combo = glade_xml_get_widget (editor->priv->gui, + "line_color_combo"); + + /* Modify widgets based on configuration */ + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->line_width_spin), + gl_prefs->default_line_width); + gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); + color_combo_set_color (COLOR_COMBO(editor->priv->line_color_combo), gdk_color); + g_free (gdk_color); + + /* Align label widths */ + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + label = glade_xml_get_widget (editor->priv->gui, "line_w_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "line_color_label"); + gtk_size_group_add_widget (label_size_group, label); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->line_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->line_width_spin), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->line_color_combo), + "color_changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set line width. */ +/*****************************************************************************/ +void +gl_object_editor_set_line_width (glObjectEditor *editor, + gdouble width) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->line_width_spin), + gl_object_editor_changed_cb, + editor); + + /* Set widget values */ + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->line_width_spin), + width); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->line_width_spin), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query line width. */ +/*****************************************************************************/ +gdouble +gl_object_editor_get_line_width (glObjectEditor *editor) +{ + gdouble w; + + gl_debug (DEBUG_EDITOR, "START"); + + w = gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->line_width_spin)); + + gl_debug (DEBUG_EDITOR, "END"); + + return w; +} + +/*****************************************************************************/ +/* Set line color. */ +/*****************************************************************************/ +void +gl_object_editor_set_line_color (glObjectEditor *editor, + guint color) +{ + GdkColor *gdk_color; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->line_color_combo), + gl_object_editor_changed_cb, + editor); + + gdk_color = gl_color_to_gdk_color (color); + color_combo_set_color (COLOR_COMBO(editor->priv->line_color_combo), gdk_color); + g_free (gdk_color); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->line_color_combo), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query line color. */ +/*****************************************************************************/ +guint +gl_object_editor_get_line_color (glObjectEditor *editor) +{ + GdkColor *gdk_color; + gboolean is_default; + guint color; + + gl_debug (DEBUG_EDITOR, "START"); + + gdk_color = color_combo_get_color (COLOR_COMBO(editor->priv->line_color_combo), + &is_default); + + if (is_default) { + color = GL_COLOR_NONE; + } else { + color = gl_color_from_gdk_color (gdk_color); + } + + gl_debug (DEBUG_EDITOR, "END"); + + return color; +} + diff --git a/glabels2/src/object-editor-lsize-page.c b/glabels2/src/object-editor-lsize-page.c new file mode 100644 index 00000000..aef106d9 --- /dev/null +++ b/glabels2/src/object-editor-lsize-page.c @@ -0,0 +1,215 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +#define LENGTH(x,y) sqrt( (x)*(x) + (y)*(y) ) +#define ANGLE(x,y) ( (180.0/G_PI)*atan2( -(y), (x) ) ) +#define COMP_X(l,a) ( (l) * cos( (G_PI/180.0)*(a) ) ) +#define COMP_Y(l,a) ( -(l) * sin( (G_PI/180.0)*(a) ) ) + + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare line size page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_lsize_page (glObjectEditor *editor) +{ + const gchar *units_string; + gdouble climb_rate; + gint digits; + GtkSizeGroup *label_size_group; + GtkWidget *label; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->lsize_page_vbox = + glade_xml_get_widget (editor->priv->gui, "lsize_page_vbox"); + editor->priv->lsize_r_spin = + glade_xml_get_widget (editor->priv->gui, "lsize_r_spin"); + editor->priv->lsize_theta_spin = + glade_xml_get_widget (editor->priv->gui, "lsize_theta_spin"); + editor->priv->lsize_r_units_label = + glade_xml_get_widget (editor->priv->gui, "lsize_r_units_label"); + + /* Get configuration information */ + units_string = gl_prefs_get_units_string (); + editor->priv->units_per_point = gl_prefs_get_units_per_point (); + climb_rate = gl_prefs_get_units_step_size (); + digits = gl_prefs_get_units_precision (); + + /* Modify widgets based on configuration */ + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->lsize_r_spin), digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(editor->priv->lsize_r_spin), + climb_rate, 10.0*climb_rate); + gtk_label_set_text (GTK_LABEL(editor->priv->lsize_r_units_label), units_string); + + /* Align label widths */ + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + label = glade_xml_get_widget (editor->priv->gui, "lsize_r_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "lsize_theta_label"); + gtk_size_group_add_widget (label_size_group, label); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->lsize_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->lsize_r_spin), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->lsize_theta_spin), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set line size. */ +/*****************************************************************************/ +void +gl_object_editor_set_lsize (glObjectEditor *editor, + gdouble dx, + gdouble dy) +{ + gdouble r, theta; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->lsize_r_spin), + gl_object_editor_changed_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->lsize_theta_spin), + gl_object_editor_changed_cb, + editor); + + /* convert internal units to displayed units */ + gl_debug (DEBUG_EDITOR, "internal dx,dy = %g, %g", dx, dy); + dx *= editor->priv->units_per_point; + dy *= editor->priv->units_per_point; + gl_debug (DEBUG_EDITOR, "display dx,dy = %g, %g", dx, dy); + + r = LENGTH (dx, dy); + theta = ANGLE (dx, dy); + + /* Set widget values */ + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->lsize_r_spin), r); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->lsize_theta_spin), + theta); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->lsize_r_spin), + gl_object_editor_changed_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->lsize_theta_spin), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set maximum line size. */ +/*****************************************************************************/ +void +gl_object_editor_set_max_lsize (glObjectEditor *editor, + gdouble dx_max, + gdouble dy_max) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->lsize_r_spin), + gl_object_editor_changed_cb, + editor); + + /* convert internal units to displayed units */ + gl_debug (DEBUG_EDITOR, "internal dx_max,dy_max = %g, %g", dx_max, dy_max); + dx_max *= editor->priv->units_per_point; + dy_max *= editor->priv->units_per_point; + gl_debug (DEBUG_EDITOR, "display dx_max,dy_max = %g, %g", dx_max, dy_max); + + /* Set widget values */ + gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->lsize_r_spin), + 0.0, LENGTH (dx_max, dy_max)); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->lsize_r_spin), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query line size. */ +/*****************************************************************************/ +void +gl_object_editor_get_lsize (glObjectEditor *editor, + gdouble *dx, + gdouble *dy) +{ + gdouble r, theta; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Get values from widgets */ + r = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->lsize_r_spin)); + theta = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->lsize_theta_spin)); + + /* convert everything back to our internal units (points) */ + r /= editor->priv->units_per_point; + + *dx = COMP_X (r, theta); + *dy = COMP_Y (r, theta); + + gl_debug (DEBUG_EDITOR, "END"); +} + diff --git a/glabels2/src/object-editor-position-page.c b/glabels2/src/object-editor-position-page.c new file mode 100644 index 00000000..a79e19e3 --- /dev/null +++ b/glabels2/src/object-editor-position-page.c @@ -0,0 +1,218 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare position page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_position_page (glObjectEditor *editor) +{ + const gchar *units_string; + gdouble climb_rate; + gint digits; + GtkSizeGroup *label_size_group; + GtkWidget *label; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->pos_page_vbox = glade_xml_get_widget (editor->priv->gui, + "pos_page_vbox"); + editor->priv->pos_x_spin = glade_xml_get_widget (editor->priv->gui, + "pos_x_spin"); + editor->priv->pos_y_spin = glade_xml_get_widget (editor->priv->gui, + "pos_y_spin"); + editor->priv->pos_x_units_label = glade_xml_get_widget (editor->priv->gui, + "pos_x_units_label"); + editor->priv->pos_y_units_label = glade_xml_get_widget (editor->priv->gui, + "pos_y_units_label"); + + /* Get configuration information */ + units_string = gl_prefs_get_units_string (); + editor->priv->units_per_point = gl_prefs_get_units_per_point (); + climb_rate = gl_prefs_get_units_step_size (); + digits = gl_prefs_get_units_precision (); + + /* Modify widgets based on configuration */ + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->pos_x_spin), digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(editor->priv->pos_x_spin), + climb_rate, 10.0*climb_rate); + gtk_label_set_text (GTK_LABEL(editor->priv->pos_x_units_label), units_string); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->pos_y_spin), digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(editor->priv->pos_y_spin), + climb_rate, 10.0*climb_rate); + gtk_label_set_text (GTK_LABEL(editor->priv->pos_y_units_label), units_string); + + /* Align label widths */ + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + label = glade_xml_get_widget (editor->priv->gui, "pos_x_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "pos_y_label"); + gtk_size_group_add_widget (label_size_group, label); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->pos_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->pos_x_spin), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->pos_y_spin), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set position. */ +/*****************************************************************************/ +void +gl_object_editor_set_position (glObjectEditor *editor, + gdouble x, + gdouble y) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->pos_x_spin), + gl_object_editor_changed_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->pos_y_spin), + gl_object_editor_changed_cb, + editor); + + /* convert internal units to displayed units */ + gl_debug (DEBUG_EDITOR, "internal x,y = %g, %g", x, y); + x *= editor->priv->units_per_point; + y *= editor->priv->units_per_point; + gl_debug (DEBUG_EDITOR, "display x,y = %g, %g", x, y); + + /* Set widget values */ + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->pos_x_spin), x); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->pos_y_spin), y); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->pos_x_spin), + gl_object_editor_changed_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->pos_y_spin), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set maximum position. */ +/*****************************************************************************/ +void +gl_object_editor_set_max_position (glObjectEditor *editor, + gdouble x_max, + gdouble y_max) +{ + gdouble tmp; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->pos_x_spin), + gl_object_editor_changed_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->pos_y_spin), + gl_object_editor_changed_cb, + editor); + + /* convert internal units to displayed units */ + gl_debug (DEBUG_EDITOR, "internal x_max,y_max = %g, %g", x_max, y_max); + x_max *= editor->priv->units_per_point; + y_max *= editor->priv->units_per_point; + gl_debug (DEBUG_EDITOR, "display x_max,y_max = %g, %g", x_max, y_max); + + /* Set widget values */ + tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->pos_x_spin)); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->pos_x_spin), + 0.0, x_max); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->pos_x_spin), tmp); + tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->pos_y_spin)); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->pos_y_spin), + 0.0, y_max); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->pos_y_spin), tmp); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->pos_x_spin), + gl_object_editor_changed_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->pos_y_spin), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query position. */ +/*****************************************************************************/ +void +gl_object_editor_get_position (glObjectEditor *editor, + gdouble *x, + gdouble *y) +{ + gl_debug (DEBUG_EDITOR, "START"); + + /* Get values from widgets */ + *x = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->pos_x_spin)); + *y = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->pos_y_spin)); + + /* convert everything back to our internal units (points) */ + *x /= editor->priv->units_per_point; + *y /= editor->priv->units_per_point; + + gl_debug (DEBUG_EDITOR, "END"); +} + diff --git a/glabels2/src/object-editor-private.h b/glabels2/src/object-editor-private.h new file mode 100644 index 00000000..46d90f5c --- /dev/null +++ b/glabels2/src/object-editor-private.h @@ -0,0 +1,146 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor-private.h: object properties editor module private header file + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 __OBJECT_EDITOR_PRIVATE_H__ +#define __OBJECT_EDITOR_PRIVATE_H__ + +#include +#include + +G_BEGIN_DECLS + +struct _glObjectEditorPrivate { + + GladeXML *gui; + GtkWidget *editor_vbox; + + gdouble units_per_point; + + GtkWidget *title_image; + GtkWidget *title_label; + GtkWidget *notebook; + + GtkWidget *pos_page_vbox; + GtkWidget *pos_x_spin; + GtkWidget *pos_y_spin; + GtkWidget *pos_x_units_label; + GtkWidget *pos_y_units_label; + + GtkWidget *size_page_vbox; + GtkWidget *size_w_spin; + GtkWidget *size_h_spin; + GtkWidget *size_w_units_label; + GtkWidget *size_h_units_label; + GtkWidget *size_aspect_checkbutton; + GtkWidget *size_reset_image_button; + gdouble size_aspect_ratio; + gdouble w_base; + gdouble h_base; + + GtkWidget *lsize_page_vbox; + GtkWidget *lsize_r_spin; + GtkWidget *lsize_theta_spin; + GtkWidget *lsize_r_units_label; + + GtkWidget *fill_page_vbox; + GtkWidget *fill_color_combo; + + GtkWidget *line_page_vbox; + GtkWidget *line_width_spin; + GtkWidget *line_color_combo; + + GtkWidget *img_page_vbox; + GtkWidget *img_file_radio; + GtkWidget *img_key_radio; + GtkWidget *img_pixmap_entry; + GtkWidget *img_key_combo; + GtkWidget *img_key_entry; + + GtkWidget *text_page_vbox; + GtkWidget *text_family_entry; + GtkWidget *text_family_combo; + GtkWidget *text_size_spin; + GtkWidget *text_bold_toggle; + GtkWidget *text_italic_toggle; + GtkWidget *text_color_combo; + GtkWidget *text_left_toggle; + GtkWidget *text_center_toggle; + GtkWidget *text_right_toggle; + + GtkWidget *edit_page_vbox; + GtkWidget *edit_text_view; + GtkWidget *edit_key_label; + GtkWidget *edit_key_entry; + GtkWidget *edit_key_combo; + GtkWidget *edit_insert_field_button; + + GtkWidget *bc_page_vbox; + GtkWidget *bc_style_entry; + GtkWidget *bc_style_combo; + GtkWidget *bc_text_check; + GtkWidget *bc_cs_check; + GtkWidget *bc_color_combo; + + GtkWidget *data_page_vbox; + GtkWidget *data_literal_radio; + GtkWidget *data_key_radio; + GtkWidget *data_text_entry; + GtkWidget *data_key_entry; + GtkWidget *data_key_combo; + +}; + +enum { + CHANGED, + LAST_SIGNAL +}; + +extern gint gl_object_editor_signals[LAST_SIGNAL]; + + + +void gl_object_editor_prepare_position_page (glObjectEditor *editor); + +void gl_object_editor_prepare_size_page (glObjectEditor *editor, + glObjectEditorOption option); + +void gl_object_editor_prepare_lsize_page (glObjectEditor *editor); + +void gl_object_editor_prepare_fill_page (glObjectEditor *editor); + +void gl_object_editor_prepare_line_page (glObjectEditor *editor); + +void gl_object_editor_prepare_image_page (glObjectEditor *editor); + +void gl_object_editor_prepare_text_page (glObjectEditor *editor); + +void gl_object_editor_prepare_edit_page (glObjectEditor *editor); + +void gl_object_editor_prepare_bc_page (glObjectEditor *editor); + +void gl_object_editor_prepare_data_page (glObjectEditor *editor); + + +void gl_object_editor_changed_cb (glObjectEditor *editor); + +G_END_DECLS + +#endif diff --git a/glabels2/src/object-editor-size-page.c b/glabels2/src/object-editor-size-page.c new file mode 100644 index 00000000..90db43b8 --- /dev/null +++ b/glabels2/src/object-editor-size-page.c @@ -0,0 +1,376 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static void aspect_toggle_cb (glObjectEditor *editor); +static void size_reset_cb (glObjectEditor *editor); +static void w_spin_cb (glObjectEditor *editor); +static void h_spin_cb (glObjectEditor *editor); + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare size page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_size_page (glObjectEditor *editor, + glObjectEditorOption option) +{ + const gchar *units_string; + gdouble climb_rate; + gint digits; + GtkSizeGroup *label_size_group; + GtkWidget *label; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->size_page_vbox = + glade_xml_get_widget (editor->priv->gui, "size_page_vbox"); + editor->priv->size_w_spin = + glade_xml_get_widget (editor->priv->gui, "size_w_spin"); + editor->priv->size_h_spin = + glade_xml_get_widget (editor->priv->gui, "size_h_spin"); + editor->priv->size_w_units_label = + glade_xml_get_widget (editor->priv->gui, "size_w_units_label"); + editor->priv->size_h_units_label = + glade_xml_get_widget (editor->priv->gui, "size_h_units_label"); + editor->priv->size_aspect_checkbutton = + glade_xml_get_widget (editor->priv->gui, "size_aspect_checkbutton"); + editor->priv->size_reset_image_button = + glade_xml_get_widget (editor->priv->gui, "size_reset_image_button"); + + /* Get configuration information */ + units_string = gl_prefs_get_units_string (); + editor->priv->units_per_point = gl_prefs_get_units_per_point (); + climb_rate = gl_prefs_get_units_step_size (); + digits = gl_prefs_get_units_precision (); + + /* Modify widgets based on configuration */ + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->size_w_spin), digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(editor->priv->size_w_spin), + climb_rate, 10.0*climb_rate); + gtk_label_set_text (GTK_LABEL(editor->priv->size_w_units_label), units_string); + gtk_spin_button_set_digits (GTK_SPIN_BUTTON(editor->priv->size_h_spin), digits); + gtk_spin_button_set_increments (GTK_SPIN_BUTTON(editor->priv->size_h_spin), + climb_rate, 10.0*climb_rate); + gtk_label_set_text (GTK_LABEL(editor->priv->size_h_units_label), units_string); + + /* Align label widths */ + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + label = glade_xml_get_widget (editor->priv->gui, "size_w_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "size_h_label"); + gtk_size_group_add_widget (label_size_group, label); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->size_page_vbox); + if (option != GL_OBJECT_EDITOR_SIZE_IMAGE_PAGE) { + gtk_widget_hide (editor->priv->size_reset_image_button); + } + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->size_aspect_checkbutton), + "toggled", + G_CALLBACK (aspect_toggle_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->size_w_spin), + "changed", + G_CALLBACK (w_spin_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->size_h_spin), + "changed", + G_CALLBACK (h_spin_cb), + G_OBJECT (editor)); + + if (option == GL_OBJECT_EDITOR_SIZE_IMAGE_PAGE) { + g_signal_connect_swapped (G_OBJECT (editor->priv->size_reset_image_button), + "clicked", + G_CALLBACK (size_reset_cb), + G_OBJECT (editor)); + } + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Maintain aspect ratio checkbox callback. */ +/*--------------------------------------------------------------------------*/ +static void +aspect_toggle_cb (glObjectEditor *editor) +{ + GtkToggleButton *toggle; + gdouble w, h; + + toggle = GTK_TOGGLE_BUTTON (editor->priv->size_aspect_checkbutton); + + if (gtk_toggle_button_get_active (toggle)) { + + w = gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->size_w_spin)); + h = gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->size_h_spin)); + + editor->priv->size_aspect_ratio = h / w; + + } +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. W spin button changed callback. */ +/*--------------------------------------------------------------------------*/ +static void +w_spin_cb (glObjectEditor *editor) +{ + gdouble w, h; + GtkToggleButton *toggle; + + toggle = GTK_TOGGLE_BUTTON (editor->priv->size_aspect_checkbutton); + + if (gtk_toggle_button_get_active (toggle)) { + + w = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin)); + + h = w * editor->priv->size_aspect_ratio; + + /* Update our sibling control, blocking recursion. */ + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->size_h_spin), + G_CALLBACK (h_spin_cb), + editor); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin), h); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->size_h_spin), + G_CALLBACK (h_spin_cb), + editor); + } + + /* Emit our "changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. H spin button changed callback. */ +/*--------------------------------------------------------------------------*/ +static void +h_spin_cb (glObjectEditor *editor) +{ + gdouble w, h; + + GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (editor->priv->size_aspect_checkbutton); + + if (gtk_toggle_button_get_active (toggle)) { + + h = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin)); + + w = h / editor->priv->size_aspect_ratio; + + /* Update our sibling control, blocking recursion. */ + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->size_w_spin), + G_CALLBACK (w_spin_cb), + editor); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin), w); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->size_w_spin), + G_CALLBACK (w_spin_cb), + editor); + } + + /* Emit our "changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Reset image size callback. */ +/*--------------------------------------------------------------------------*/ +static void +size_reset_cb (glObjectEditor *editor) +{ + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->size_w_spin), + G_CALLBACK (h_spin_cb), + editor); + g_signal_handlers_block_by_func (G_OBJECT (editor->priv->size_h_spin), + G_CALLBACK (h_spin_cb), + editor); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin), + editor->priv->w_base); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin), + editor->priv->h_base); + + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->size_w_spin), + G_CALLBACK (h_spin_cb), + editor); + g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->size_h_spin), + G_CALLBACK (h_spin_cb), + editor); + /* Emit our "changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); +} + +/*****************************************************************************/ +/* Set size. */ +/*****************************************************************************/ +void +gl_object_editor_set_size (glObjectEditor *editor, + gdouble w, + gdouble h) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->size_w_spin), + w_spin_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->size_h_spin), + h_spin_cb, + editor); + + /* convert internal units to displayed units */ + gl_debug (DEBUG_EDITOR, "internal w,h = %g, %g", w, h); + w *= editor->priv->units_per_point; + h *= editor->priv->units_per_point; + gl_debug (DEBUG_EDITOR, "display w,h = %g, %g", w, h); + + /* Set widget values */ + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin), w); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin), h); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->size_w_spin), + w_spin_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->size_h_spin), + h_spin_cb, + editor); + + /* Update aspect ratio */ + editor->priv->size_aspect_ratio = h / w; + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set maximum size. */ +/*****************************************************************************/ +void +gl_object_editor_set_max_size (glObjectEditor *editor, + gdouble w_max, + gdouble h_max) +{ + gdouble tmp; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->size_w_spin), + w_spin_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->size_h_spin), + h_spin_cb, + editor); + + /* convert internal units to displayed units */ + gl_debug (DEBUG_EDITOR, "internal w_max,h_max = %g, %g", w_max, h_max); + w_max *= editor->priv->units_per_point; + h_max *= editor->priv->units_per_point; + gl_debug (DEBUG_EDITOR, "display w_max,h_max = %g, %g", w_max, h_max); + + /* Set widget values */ + tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin)); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->size_w_spin), + 0.0, w_max); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin), tmp); + tmp = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin)); + gtk_spin_button_set_range (GTK_SPIN_BUTTON (editor->priv->size_h_spin), + 0.0, h_max); + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin), tmp); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->size_w_spin), + w_spin_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->size_h_spin), + h_spin_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set base or natural size of image. */ +/*****************************************************************************/ +void +gl_object_editor_set_base_size (glObjectEditor *editor, + gdouble w_base, + gdouble h_base) +{ + w_base *= editor->priv->units_per_point; + h_base *= editor->priv->units_per_point; + + gl_debug (DEBUG_EDITOR, "Setting w_base = %g", w_base); + gl_debug (DEBUG_EDITOR, "Setting h_base = %g", h_base); + + editor->priv->w_base = w_base; + editor->priv->h_base = h_base; +} + +/*****************************************************************************/ +/* Query size. */ +/*****************************************************************************/ +void +gl_object_editor_get_size (glObjectEditor *editor, + gdouble *w, + gdouble *h) +{ + gl_debug (DEBUG_EDITOR, "START"); + + + /* Get values from widgets */ + *w = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_w_spin)); + *h = gtk_spin_button_get_value (GTK_SPIN_BUTTON (editor->priv->size_h_spin)); + + /* convert everything back to our internal units (points) */ + *w /= editor->priv->units_per_point; + *h /= editor->priv->units_per_point; + + gl_debug (DEBUG_EDITOR, "END"); +} + diff --git a/glabels2/src/object-editor-text-page.c b/glabels2/src/object-editor-text-page.c new file mode 100644 index 00000000..4a8ce49a --- /dev/null +++ b/glabels2/src/object-editor-text-page.c @@ -0,0 +1,499 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include + +#include "object-editor.h" +#include "prefs.h" +#include "mygal/widget-color-combo.h" +#include "color.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static void align_toggle_cb (GtkToggleButton *toggle, + glObjectEditor *editor); + + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Prepare size page. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_prepare_text_page (glObjectEditor *editor) +{ + GList *family_names = NULL; + GtkSizeGroup *label_size_group; + GtkWidget *label; + + gl_debug (DEBUG_EDITOR, "START"); + + /* Extract widgets from XML tree. */ + editor->priv->text_page_vbox = + glade_xml_get_widget (editor->priv->gui, "text_page_vbox"); + editor->priv->text_family_entry = + glade_xml_get_widget (editor->priv->gui, "text_family_entry"); + editor->priv->text_family_combo = + glade_xml_get_widget (editor->priv->gui, "text_family_combo"); + editor->priv->text_size_spin = + glade_xml_get_widget (editor->priv->gui, "text_size_spin"); + editor->priv->text_bold_toggle = + glade_xml_get_widget (editor->priv->gui, "text_bold_toggle"); + editor->priv->text_italic_toggle = + glade_xml_get_widget (editor->priv->gui, "text_italic_toggle"); + editor->priv->text_color_combo = + glade_xml_get_widget (editor->priv->gui, "text_color_combo"); + editor->priv->text_left_toggle = + glade_xml_get_widget (editor->priv->gui, "text_left_toggle"); + editor->priv->text_center_toggle = + glade_xml_get_widget (editor->priv->gui, "text_center_toggle"); + editor->priv->text_right_toggle = + glade_xml_get_widget (editor->priv->gui, "text_right_toggle"); + + /* Load family names */ + family_names = gnome_font_family_list (); + gtk_combo_set_popdown_strings (GTK_COMBO(editor->priv->text_family_combo), + family_names); + gnome_font_family_list_free (family_names); + + /* Align label widths */ + label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); + label = glade_xml_get_widget (editor->priv->gui, "text_family_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "text_size_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "text_style_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "text_color_label"); + gtk_size_group_add_widget (label_size_group, label); + label = glade_xml_get_widget (editor->priv->gui, "text_align_label"); + gtk_size_group_add_widget (label_size_group, label); + + /* Un-hide */ + gtk_widget_show_all (editor->priv->text_page_vbox); + + /* Connect signals */ + g_signal_connect_swapped (G_OBJECT (editor->priv->text_family_entry), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->text_size_spin), + "changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->text_bold_toggle), + "toggled", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->text_italic_toggle), + "toggled", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + g_signal_connect_swapped (G_OBJECT (editor->priv->text_color_combo), + "color_changed", + G_CALLBACK (gl_object_editor_changed_cb), + G_OBJECT (editor)); + + g_signal_connect (G_OBJECT (editor->priv->text_left_toggle), + "toggled", + G_CALLBACK (align_toggle_cb), + G_OBJECT (editor)); + g_signal_connect (G_OBJECT (editor->priv->text_center_toggle), + "toggled", + G_CALLBACK (align_toggle_cb), + G_OBJECT (editor)); + g_signal_connect (G_OBJECT (editor->priv->text_right_toggle), + "toggled", + G_CALLBACK (align_toggle_cb), + G_OBJECT (editor)); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Alignment togglebutton callback. */ +/*--------------------------------------------------------------------------*/ +static void +align_toggle_cb (GtkToggleButton *toggle, + glObjectEditor *editor) +{ + if (gtk_toggle_button_get_active (toggle)) { + + if (GTK_WIDGET (toggle) == GTK_WIDGET (editor->priv->text_left_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_center_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_right_toggle), + FALSE); + } else if (GTK_WIDGET (toggle) == + GTK_WIDGET (editor->priv->text_center_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_left_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_right_toggle), + FALSE); + } else if (GTK_WIDGET (toggle) == + GTK_WIDGET (editor->priv->text_right_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_left_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (editor->priv->text_center_toggle), + FALSE); + } + + /* Emit our "changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + } + +} + +/*****************************************************************************/ +/* Set font family. */ +/*****************************************************************************/ +void +gl_object_editor_set_font_family (glObjectEditor *editor, + const gchar *font_family) +{ + GList *family_names; + gchar *good_font_family; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_family_entry), + gl_object_editor_changed_cb, + editor); + + /* Make sure we have a valid font family. if not provide a good default. */ + family_names = gnome_font_family_list (); + if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) { + good_font_family = g_strdup (font_family); + } else { + if (family_names != NULL) { + good_font_family = g_strdup (family_names->data); /* 1st entry */ + } else { + good_font_family = NULL; + } + } + gnome_font_family_list_free (family_names); + gtk_entry_set_text (GTK_ENTRY (editor->priv->text_family_entry), good_font_family); + g_free (good_font_family); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_family_entry), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query font family. */ +/*****************************************************************************/ +gchar * +gl_object_editor_get_font_family (glObjectEditor *editor) +{ + gchar *font_family; + + gl_debug (DEBUG_EDITOR, "START"); + + font_family = + gtk_editable_get_chars (GTK_EDITABLE (editor->priv->text_family_entry), + 0, -1); + + gl_debug (DEBUG_EDITOR, "END"); + + return font_family; +} + +/*****************************************************************************/ +/* Set font size. */ +/*****************************************************************************/ +void +gl_object_editor_set_font_size (glObjectEditor *editor, + gdouble font_size) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_size_spin), + gl_object_editor_changed_cb, + editor); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (editor->priv->text_size_spin), + font_size); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_size_spin), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query font size. */ +/*****************************************************************************/ +gdouble +gl_object_editor_get_font_size (glObjectEditor *editor) +{ + gdouble font_size; + + gl_debug (DEBUG_EDITOR, "START"); + + font_size = + gtk_spin_button_get_value (GTK_SPIN_BUTTON(editor->priv->text_size_spin)); + + gl_debug (DEBUG_EDITOR, "END"); + + return font_size; +} + +/*****************************************************************************/ +/* Set font weight. */ +/*****************************************************************************/ +void +gl_object_editor_set_font_weight (glObjectEditor *editor, + GnomeFontWeight font_weight) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_bold_toggle), + gl_object_editor_changed_cb, + editor); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_bold_toggle), + (font_weight == GNOME_FONT_BOLD)); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_bold_toggle), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query font weight. */ +/*****************************************************************************/ +GnomeFontWeight +gl_object_editor_get_font_weight (glObjectEditor *editor) +{ + GnomeFontWeight font_weight; + + gl_debug (DEBUG_EDITOR, "START"); + + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (editor->priv->text_bold_toggle))) { + font_weight = GNOME_FONT_BOLD; + } else { + font_weight = GNOME_FONT_BOOK; + } + + gl_debug (DEBUG_EDITOR, "END"); + + return font_weight; +} + +/*****************************************************************************/ +/* Set font italic flag. */ +/*****************************************************************************/ +void +gl_object_editor_set_font_italic_flag (glObjectEditor *editor, + gboolean font_italic_flag) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_italic_toggle), + gl_object_editor_changed_cb, + editor); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_italic_toggle), + font_italic_flag); + + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_italic_toggle), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query font italic flag. */ +/*****************************************************************************/ +gboolean +gl_object_editor_get_font_italic_flag (glObjectEditor *editor) +{ + gboolean italic_flag; + + gl_debug (DEBUG_EDITOR, "START"); + + italic_flag = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON + (editor->priv->text_italic_toggle)); + + gl_debug (DEBUG_EDITOR, "END"); + + return italic_flag; +} + +/*****************************************************************************/ +/* Set text alignment. */ +/*****************************************************************************/ +void +gl_object_editor_set_text_alignment (glObjectEditor *editor, + GtkJustification just) +{ + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_left_toggle), + align_toggle_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_center_toggle), + align_toggle_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_right_toggle), + align_toggle_cb, + editor); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_left_toggle), + (just == GTK_JUSTIFY_LEFT)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_center_toggle), + (just == GTK_JUSTIFY_CENTER)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_right_toggle), + (just == GTK_JUSTIFY_RIGHT)); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_left_toggle), + align_toggle_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_center_toggle), + align_toggle_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_right_toggle), + align_toggle_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query text alignment. */ +/*****************************************************************************/ +GtkJustification +gl_object_editor_get_text_alignment (glObjectEditor *editor) +{ + GtkJustification just; + + gl_debug (DEBUG_EDITOR, "START"); + + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (editor->priv->text_left_toggle))) { + just = GTK_JUSTIFY_LEFT; + } else + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (editor->priv->text_right_toggle))) { + just = GTK_JUSTIFY_RIGHT; + } else + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (editor->priv->text_center_toggle))) { + just = GTK_JUSTIFY_CENTER; + } else { + just = GTK_JUSTIFY_LEFT; /* Should not happen. */ + } + + gl_debug (DEBUG_EDITOR, "END"); + + return just; +} + +/*****************************************************************************/ +/* Set text color. */ +/*****************************************************************************/ +void +gl_object_editor_set_text_color (glObjectEditor *editor, + guint text_color) +{ + GdkColor *gdk_color; + + gl_debug (DEBUG_EDITOR, "START"); + + g_signal_handlers_block_by_func (G_OBJECT(editor->priv->text_color_combo), + gl_object_editor_changed_cb, + editor); + + gdk_color = gl_color_to_gdk_color (text_color); + color_combo_set_color (COLOR_COMBO(editor->priv->text_color_combo), gdk_color); + g_free (gdk_color); + + g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->text_color_combo), + gl_object_editor_changed_cb, + editor); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Query text color. */ +/*****************************************************************************/ +guint +gl_object_editor_get_text_color (glObjectEditor *editor) +{ + GdkColor *gdk_color; + guint color; + gboolean is_default; + + gl_debug (DEBUG_EDITOR, "START"); + + gdk_color = color_combo_get_color (COLOR_COMBO(editor->priv->text_color_combo), + &is_default); + + if (is_default) { + color = gl_prefs->default_text_color; + } else { + color = gl_color_from_gdk_color (gdk_color); + } + + + gl_debug (DEBUG_EDITOR, "END"); + + return color; +} + + + diff --git a/glabels2/src/object-editor.c b/glabels2/src/object-editor.c new file mode 100644 index 00000000..d0e84f0a --- /dev/null +++ b/glabels2/src/object-editor.c @@ -0,0 +1,458 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.c: object properties editor module + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include +#include +#include + +#include "object-editor.h" +#include "prefs.h" +#include "mygal/widget-color-combo.h" +#include "color.h" +#include "marshal.h" + +#include "object-editor-private.h" + +#include "debug.h" + +/*===========================================*/ +/* Private macros */ +/*===========================================*/ + +/*===========================================*/ +/* Private data types */ +/*===========================================*/ + +typedef void (*ChangedSignal) (GObject * object, gpointer data); + +/*===========================================*/ +/* Private globals */ +/*===========================================*/ + +gint gl_object_editor_signals[LAST_SIGNAL] = { 0 }; + +static GtkVBoxClass *parent_class = NULL; + +/*===========================================*/ +/* Local function prototypes */ +/*===========================================*/ + +static void gl_object_editor_class_init (glObjectEditorClass *klass); +static void gl_object_editor_init (glObjectEditor *editor); +static void gl_object_editor_finalize (GObject *object); + +static void gl_object_notebook_construct_valist (glObjectEditor *editor, + glObjectEditorOption first_option, + va_list args); + + +/*****************************************************************************/ +/* Boilerplate object stuff. */ +/*****************************************************************************/ +GType +gl_object_editor_get_type (void) +{ + static GType editor_type = 0; + + if (!editor_type) + { + static const GTypeInfo editor_info = + { + sizeof (glObjectEditorClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) gl_object_editor_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (glObjectEditor), + 0, /* n_preallocs */ + (GInstanceInitFunc) gl_object_editor_init + }; + + editor_type = g_type_register_static (GTK_TYPE_VBOX, + "glObjectEditor", + &editor_info, + 0); + } + + return editor_type; +} + +static void +gl_object_editor_class_init (glObjectEditorClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + gl_debug (DEBUG_EDITOR, "START"); + + parent_class = g_type_class_peek_parent (klass); + + object_class->finalize = gl_object_editor_finalize; + + gl_object_editor_signals[CHANGED] = + g_signal_new ("changed", + G_OBJECT_CLASS_TYPE(object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (glObjectEditorClass, changed), + NULL, NULL, + gl_marshal_VOID__VOID, + G_TYPE_NONE, 0); + + gl_debug (DEBUG_EDITOR, "END"); +} + +static void +gl_object_editor_init (glObjectEditor *editor) +{ + gl_debug (DEBUG_EDITOR, "START"); + + editor->priv = g_new0 (glObjectEditorPrivate, 1); + + editor->priv->gui = glade_xml_new ("object-editor.glade", + "editor_vbox", + NULL); + + if (!editor->priv->gui) { + g_warning ("Could not open object-editor.glade, reinstall glabels!"); + return; + } + + editor->priv->editor_vbox = glade_xml_get_widget (editor->priv->gui, + "editor_vbox"); + gtk_box_pack_start (GTK_BOX(editor), + editor->priv->editor_vbox, + FALSE, FALSE, 0); + + editor->priv->title_image = glade_xml_get_widget (editor->priv->gui, + "title_image"); + editor->priv->title_label = glade_xml_get_widget (editor->priv->gui, + "title_label"); + editor->priv->notebook = glade_xml_get_widget (editor->priv->gui, + "notebook"); + + gtk_widget_show_all (GTK_WIDGET(editor)); + + /* Hide all notebook pages to start with. */ + gtk_widget_hide_all (editor->priv->notebook); + gtk_widget_show (editor->priv->notebook); + + gl_debug (DEBUG_EDITOR, "END"); +} + +static void +gl_object_editor_finalize (GObject *object) +{ + glObjectEditor* editor; + + gl_debug (DEBUG_EDITOR, "START"); + + g_return_if_fail (object != NULL); + + editor = GL_OBJECT_EDITOR (object); + + g_return_if_fail (GL_IS_OBJECT_EDITOR (editor)); + g_return_if_fail (editor->priv != NULL); + + g_free (editor->priv); + + G_OBJECT_CLASS (parent_class)->finalize (object); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* NEW object editor. */ +/*****************************************************************************/ +GtkWidget* +gl_object_editor_new (gchar *image, + gchar *label, + glObjectEditorOption first_option, ...) +{ + glObjectEditor *editor; + va_list args; + + gl_debug (DEBUG_EDITOR, "START"); + + editor = GL_OBJECT_EDITOR (g_object_new (GL_TYPE_OBJECT_EDITOR, NULL)); + + if (image) { + gtk_image_set_from_stock (GTK_IMAGE(editor->priv->title_image), + image, + GTK_ICON_SIZE_LARGE_TOOLBAR); + } + + if (label) { + gchar *s; + + s = g_strdup_printf ("%s", + label); + gtk_label_set_text (GTK_LABEL(editor->priv->title_label), s); + g_free (s); + + gtk_label_set_use_markup (GTK_LABEL(editor->priv->title_label), TRUE); + + } + + gtk_notebook_set_homogeneous_tabs (GTK_NOTEBOOK(editor->priv->notebook), TRUE); + + va_start (args, first_option); + gl_object_notebook_construct_valist (editor, first_option, args); + va_end (args); + + gl_debug (DEBUG_EDITOR, "END"); + + return GTK_WIDGET(editor); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Construct notebook. */ +/*--------------------------------------------------------------------------*/ +static void +gl_object_notebook_construct_valist (glObjectEditor *editor, + glObjectEditorOption first_option, + va_list args) +{ + glObjectEditorOption option; + + gl_debug (DEBUG_EDITOR, "START"); + + option = first_option; + + for ( option=first_option; option; option=va_arg (args, glObjectEditorOption) ) { + + switch (option) { + + case GL_OBJECT_EDITOR_EMPTY: + gtk_widget_set_sensitive (editor->priv->title_image, FALSE); + gtk_widget_set_sensitive (editor->priv->title_label, FALSE); + break; + + case GL_OBJECT_EDITOR_POSITION_PAGE: + gl_object_editor_prepare_position_page (editor); + break; + + case GL_OBJECT_EDITOR_SIZE_PAGE: + case GL_OBJECT_EDITOR_SIZE_IMAGE_PAGE: + gl_object_editor_prepare_size_page (editor, option); + break; + + case GL_OBJECT_EDITOR_SIZE_LINE_PAGE: + gl_object_editor_prepare_lsize_page (editor); + break; + + case GL_OBJECT_EDITOR_FILL_PAGE: + gl_object_editor_prepare_fill_page (editor); + break; + + case GL_OBJECT_EDITOR_LINE_PAGE: + gl_object_editor_prepare_line_page (editor); + break; + + case GL_OBJECT_EDITOR_IMAGE_PAGE: + gl_object_editor_prepare_image_page (editor); + break; + + case GL_OBJECT_EDITOR_TEXT_PAGE: + gl_object_editor_prepare_text_page (editor); + break; + + case GL_OBJECT_EDITOR_EDIT_PAGE: + gl_object_editor_prepare_edit_page (editor); + break; + + case GL_OBJECT_EDITOR_BC_PAGE: + gl_object_editor_prepare_bc_page (editor); + break; + + case GL_OBJECT_EDITOR_DATA_PAGE: + gl_object_editor_prepare_data_page (editor); + break; + + default: + g_warning ("option = %d", option); + g_assert_not_reached (); + } + + } + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Widget changed callback. Emit our "changed" signal. */ +/*--------------------------------------------------------------------------*/ +void +gl_object_editor_changed_cb (glObjectEditor *editor) +{ + gl_debug (DEBUG_EDITOR, "START"); + + /* Emit our "changed" signal */ + g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0); + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Set possible key names from merge object. */ +/*****************************************************************************/ +void +gl_object_editor_set_key_names (glObjectEditor *editor, + glMerge *merge) +{ + GList *keys; + GtkWidget *combo; + + gl_debug (DEBUG_EDITOR, "START"); + + if (editor->priv->edit_key_label) { + gtk_widget_set_sensitive (editor->priv->edit_key_label, merge != NULL); + } + + if (editor->priv->edit_key_combo) { + gtk_widget_set_sensitive (editor->priv->edit_key_combo, merge != NULL); + } + + if (editor->priv->edit_insert_field_button) { + gtk_widget_set_sensitive (editor->priv->edit_insert_field_button, + merge != NULL); + } + + if (editor->priv->img_key_combo) { + gtk_widget_set_sensitive (editor->priv->img_key_combo, merge != NULL); + } + + if (editor->priv->img_key_radio) { + gtk_widget_set_sensitive (editor->priv->img_key_radio, merge != NULL); + if (merge == NULL) { + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON(editor->priv->img_file_radio), TRUE); + } + } + + if (editor->priv->data_key_combo) { + gtk_widget_set_sensitive (editor->priv->data_key_combo, merge != NULL); + } + + if (editor->priv->data_key_radio) { + gtk_widget_set_sensitive (editor->priv->data_key_radio, merge != NULL); + if (merge == NULL) { + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON(editor->priv->data_literal_radio), TRUE); + } + } + + + + keys = gl_merge_get_key_list (merge); + if ( keys != NULL ) { + + combo = editor->priv->img_key_combo; + if (combo) { + gtk_combo_set_popdown_strings (GTK_COMBO (combo), keys); + } + + combo = editor->priv->edit_key_combo; + if (combo) { + gtk_combo_set_popdown_strings (GTK_COMBO (combo), keys); + } + + combo = editor->priv->data_key_combo; + if (combo) { + gtk_combo_set_popdown_strings (GTK_COMBO (combo), keys); + } + + gl_merge_free_key_list (&keys); + } else { + + keys = g_list_append (keys, ""); + + combo = editor->priv->img_key_combo; + if (combo) { + gtk_combo_set_popdown_strings (GTK_COMBO (combo), keys); + } + + combo = editor->priv->edit_key_combo; + if (combo) { + gtk_combo_set_popdown_strings (GTK_COMBO (combo), keys); + } + + combo = editor->priv->data_key_combo; + if (combo) { + gtk_combo_set_popdown_strings (GTK_COMBO (combo), keys); + } + + g_list_free (keys); + } + + gl_debug (DEBUG_EDITOR, "END"); +} + +/*****************************************************************************/ +/* Construct color combo "Custom widget". */ +/*****************************************************************************/ +GtkWidget * +gl_object_editor_construct_color_combo (gchar *name, + gchar *string1, + gchar *string2, + gint int1, + gint int2) +{ + GtkWidget *color_combo; + ColorGroup *cg; + gchar *cg_name; + guint color; + GdkColor *gdk_color; + gchar *no_color; + + switch (int1) { + + case 2: + cg_name = "text_color_group"; + color = gl_prefs->default_text_color; + no_color = _("Default"); + break; + + case 1: + cg_name = "line_color_group"; + color = gl_prefs->default_line_color; + no_color = _("No line"); + break; + + case 0: + default: + cg_name = "fill_color_group"; + color = gl_prefs->default_fill_color; + no_color = _("No fill"); + break; + + } + + cg = color_group_fetch (cg_name, NULL); + gdk_color = gl_color_to_gdk_color (color); + color_combo = color_combo_new (NULL, no_color, gdk_color, cg); + g_free (gdk_color); + + color_combo_box_set_preview_relief (COLOR_COMBO(color_combo), GTK_RELIEF_NORMAL); + + return color_combo; +} diff --git a/glabels2/src/object-editor.glade b/glabels2/src/object-editor.glade new file mode 100644 index 00000000..b1666b82 --- /dev/null +++ b/glabels2/src/object-editor.glade @@ -0,0 +1,2083 @@ + + + + + + + + 6 + True + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 12 + + + + True + False + 12 + + + + True + 0.5 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + <span weight="bold" size="larger">Xxx object properties</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + True + True + True + GTK_POS_TOP + True + False + + + + 12 + True + False + 6 + + + + True + False + 0 + + + + True + True + GTK_POLICY_ALWAYS + GTK_POLICY_ALWAYS + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + 232 + True + True + True + GTK_JUSTIFY_LEFT + GTK_WRAP_NONE + True + 0 + 0 + 0 + 0 + 0 + 0 + + + + + + 0 + False + False + + + + + 0 + True + True + + + + + + True + False + 12 + + + + True + Key: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + False + False + True + False + + + + 66 + True + True + False + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + + 0 + False + False + + + + + + True + True + Insert merge field + True + GTK_RELIEF_NORMAL + + + 0 + False + False + + + + + 0 + False + False + + + + + False + False + + + + + + True + Edit + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + False + 12 + + + + True + Family: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + False + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Size: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Style: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-bold + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-italic + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + gl_object_editor_construct_color_combo + 2 + 0 + Sun, 16 Nov 2003 06:52:23 GMT + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Alignment: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-left + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-center + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-right + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + Text + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + False + 12 + + + + True + Width: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 0.25 + 2 + False + GTK_UPDATE_ALWAYS + False + False + 1 0.25 4 0.25 1 1 + + + 0 + False + False + + + + + + True + points + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + gl_object_editor_construct_color_combo + 1 + 0 + Sat, 15 Nov 2003 22:10:18 GMT + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + Line + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 0 + + + + True + False + 12 + + + + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + gl_object_editor_construct_color_combo + + 0 + 0 + Sat, 15 Nov 2003 20:47:48 GMT + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + Fill + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + False + 12 + + + + True + True + File: + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + image + 10 + Load image + False + True + + + + True + True + True + True + 0 + + True + * + False + + + + + 0 + False + False + + + + + + True + + + 0 + True + True + + + + + + True + False + 12 + + + + True + False + True + Key: + True + GTK_RELIEF_NORMAL + False + False + True + img_file_radio + + + 0 + False + False + + + + + + True + False + True + False + True + False + + + + True + False + True + False + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + Image + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + False + 12 + + + + True + True + Literal: + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + + True + True + True + True + 0 + + True + * + False + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + True + Key: + True + GTK_RELIEF_NORMAL + False + False + True + data_literal_radio + + + 0 + False + False + + + + + + True + False + True + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + Data + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + False + 12 + + + + True + Style: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + False + True + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + + 0 + True + True + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + True + Text + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + True + Checksum + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + gl_object_editor_construct_color_combo + 1 + 0 + Sun, 16 Nov 2003 07:00:32 GMT + + + 0 + False + False + + + + + 0 + False + False + + + + + True + True + + + + + + True + Barcode + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + False + 12 + + + + True + Width: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 1 0 100 0.01 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Height: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 1 0 100 0.01 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + True + Maintain current aspect ratio + True + GTK_RELIEF_NORMAL + True + False + True + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + True + Reset image size + True + GTK_RELIEF_NORMAL + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + Size + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + False + 12 + + + + True + Length: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 1 0 100 0.01 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Angle: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 0.1 + 1 + True + GTK_UPDATE_ALWAYS + True + False + 0 -180 180 0.1 5 5 + + + 0 + False + True + + + + + + True + degrees + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + Size + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + False + 12 + + + + True + X: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 0 0 100 0.01 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + + True + False + 12 + + + + True + Y: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 0.01 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 0 0 100 0.01 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + False + False + + + + + False + True + + + + + + True + Position + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + diff --git a/glabels2/src/object-editor.h b/glabels2/src/object-editor.h new file mode 100644 index 00000000..d91c46c2 --- /dev/null +++ b/glabels2/src/object-editor.h @@ -0,0 +1,247 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * object-editor.h: object properties editor module header file + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 __OBJECT_EDITOR_H__ +#define __OBJECT_EDITOR_H__ + +#include +#include "text-node.h" +#include "merge.h" +#include "bc.h" +#include +#include + +G_BEGIN_DECLS + +typedef enum { + GL_OBJECT_EDITOR_EMPTY = 1, + GL_OBJECT_EDITOR_POSITION_PAGE, + GL_OBJECT_EDITOR_SIZE_PAGE, + GL_OBJECT_EDITOR_SIZE_IMAGE_PAGE, + GL_OBJECT_EDITOR_SIZE_LINE_PAGE, + GL_OBJECT_EDITOR_FILL_PAGE, + GL_OBJECT_EDITOR_LINE_PAGE, + GL_OBJECT_EDITOR_IMAGE_PAGE, + GL_OBJECT_EDITOR_TEXT_PAGE, + GL_OBJECT_EDITOR_EDIT_PAGE, + GL_OBJECT_EDITOR_BC_PAGE, + GL_OBJECT_EDITOR_DATA_PAGE, +} glObjectEditorOption; + +#define GL_TYPE_OBJECT_EDITOR (gl_object_editor_get_type ()) +#define GL_OBJECT_EDITOR(obj) (GTK_CHECK_CAST ((obj), GL_TYPE_OBJECT_EDITOR, glObjectEditor)) +#define GL_OBJECT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_OBJECT_EDITOR, glObjectEditorClass)) +#define GL_IS_OBJECT_EDITOR(obj) (GTK_CHECK_TYPE ((obj), GL_TYPE_OBJECT_EDITOR)) +#define GL_IS_OBJECT_EDITOR_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_OBJECT_EDITOR)) +#define GL_OBJECT_EDITOR_GET_CLASS(obj) (GTK_CHECK_GET_CLASS ((obj), GL_TYPE_OBJECT_EDITOR, glObjectEditorClass)) + + +typedef struct _glObjectEditor glObjectEditor; +typedef struct _glObjectEditorClass glObjectEditorClass; + +typedef struct _glObjectEditorPrivate glObjectEditorPrivate; + +struct _glObjectEditor +{ + GtkVBox parent_instance; + + glObjectEditorPrivate *priv; + +}; + +struct _glObjectEditorClass +{ + GtkVBoxClass parent_class; + + void (*changed) (glObjectEditor *editor, gpointer user_data); +}; + + + + +GtkType gl_object_editor_get_type (void) G_GNUC_CONST; + +GtkWidget *gl_object_editor_new (gchar *image, + gchar *label, + glObjectEditorOption first_option, ...); + +void gl_object_editor_set_key_names (glObjectEditor *editor, + glMerge *merge); + + +/* + * Position Page + */ +void gl_object_editor_set_position (glObjectEditor *editor, + gdouble x, + gdouble y); + +void gl_object_editor_set_max_position (glObjectEditor *editor, + gdouble x_max, + gdouble y_max); + +void gl_object_editor_get_position (glObjectEditor *editor, + gdouble *x, + gdouble *y); + +/* + * Size Page + */ +void gl_object_editor_set_size (glObjectEditor *editor, + gdouble w, + gdouble h); + +void gl_object_editor_set_max_size (glObjectEditor *editor, + gdouble w_max, + gdouble h_max); + +void gl_object_editor_set_base_size (glObjectEditor *editor, + gdouble w_max, + gdouble h_max); + +void gl_object_editor_get_size (glObjectEditor *editor, + gdouble *w, + gdouble *h); + + +/* + * Line Size Page + */ +void gl_object_editor_set_lsize (glObjectEditor *editor, + gdouble dx, + gdouble dy); + +void gl_object_editor_set_max_lsize (glObjectEditor *editor, + gdouble dx_max, + gdouble dy_max); + +void gl_object_editor_get_lsize (glObjectEditor *editor, + gdouble *dx, + gdouble *dy); + + +/* + * Fill Page + */ +void gl_object_editor_set_fill_color (glObjectEditor *editor, + guint color); + +guint gl_object_editor_get_fill_color (glObjectEditor *editor); + + +/* + * Line/Outline Page + */ +void gl_object_editor_set_line_color (glObjectEditor *editor, + guint color); + +guint gl_object_editor_get_line_color (glObjectEditor *editor); + +void gl_object_editor_set_line_width (glObjectEditor *editor, + gdouble width); + +gdouble gl_object_editor_get_line_width (glObjectEditor *editor); + + +/* + * Image Page + */ +void gl_object_editor_set_image (glObjectEditor *editor, + gboolean merge_flag, + glTextNode *text_node); + +glTextNode *gl_object_editor_get_image (glObjectEditor *editor); + + +/* + * Text Page + */ +void gl_object_editor_set_font_family (glObjectEditor *editor, + const gchar *font_family); + +gchar *gl_object_editor_get_font_family (glObjectEditor *editor); + +void gl_object_editor_set_font_size (glObjectEditor *editor, + gdouble font_size); + +gdouble gl_object_editor_get_font_size (glObjectEditor *editor); + +void gl_object_editor_set_font_weight (glObjectEditor *editor, + GnomeFontWeight font_weight); + +GnomeFontWeight gl_object_editor_get_font_weight (glObjectEditor *editor); + +void gl_object_editor_set_font_italic_flag (glObjectEditor *editor, + gboolean font_italic_flag); + +gboolean gl_object_editor_get_font_italic_flag (glObjectEditor *editor); + +void gl_object_editor_set_text_alignment (glObjectEditor *editor, + GtkJustification text_alignment); + +GtkJustification gl_object_editor_get_text_alignment (glObjectEditor *editor); + +void gl_object_editor_set_text_color (glObjectEditor *editor, + guint text_color); + +guint gl_object_editor_get_text_color (glObjectEditor *editor); + + +/* + * Edit Text Page + */ +void gl_object_editor_set_text_buffer (glObjectEditor *editor, + GtkTextBuffer *buffer); + +/* + * Barcode Page + */ +void gl_object_editor_set_bc_style (glObjectEditor *editor, + glBarcodeStyle style, + gboolean text_flag, + gboolean checksum_flag); + +void gl_object_editor_get_bc_style (glObjectEditor *editor, + glBarcodeStyle *style, + gboolean *text_flag, + gboolean *checksum_flag); + +void gl_object_editor_set_bc_color (glObjectEditor *editor, + guint text_color); + +guint gl_object_editor_get_bc_color (glObjectEditor *editor); + + +/* + * Barcode Data Page + */ +void gl_object_editor_set_data (glObjectEditor *editor, + gboolean merge_flag, + glTextNode *text_node); + +glTextNode *gl_object_editor_get_data (glObjectEditor *editor); + + + + +G_END_DECLS + +#endif diff --git a/glabels2/src/prefs-dialog.c b/glabels2/src/prefs-dialog.c index e810648b..4032712a 100644 --- a/glabels2/src/prefs-dialog.c +++ b/glabels2/src/prefs-dialog.c @@ -23,12 +23,12 @@ #include #include +#include #include "prefs-dialog.h" #include "prefs.h" -#include "wdgt-line.h" -#include "wdgt-fill.h" -#include "wdgt-text-props.h" +#include "mygal/widget-color-combo.h" +#include "color.h" #include "debug.h" /*========================================================*/ @@ -44,29 +44,34 @@ struct _glPrefsDialogPrivate { - GtkWidget* categories_tree; + GladeXML *gui; - GtkWidget* notebook; - - GtkTreeModel *categories_tree_model; - - /* Units page */ + /* Units properties */ GtkWidget *units_points_radio; GtkWidget *units_inches_radio; GtkWidget *units_mm_radio; - /* Page size page */ + /* Page size properties */ GtkWidget *page_size_us_letter_radio; GtkWidget *page_size_a4_radio; /* Default text properties */ - GtkWidget *text; + GtkWidget *text_family_entry; + GtkWidget *text_family_combo; + GtkWidget *text_size_spin; + GtkWidget *text_bold_toggle; + GtkWidget *text_italic_toggle; + GtkWidget *text_color_combo; + GtkWidget *text_left_toggle; + GtkWidget *text_center_toggle; + GtkWidget *text_right_toggle; /* Default line properties */ - GtkWidget *line; + GtkWidget *line_width_spin; + GtkWidget *line_color_combo; /* Default fill properties */ - GtkWidget *fill; + GtkWidget *fill_color_combo; }; /*========================================================*/ @@ -79,23 +84,26 @@ static glHigDialogClass* parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_prefs_dialog_class_init (glPrefsDialogClass *klass); -static void gl_prefs_dialog_init (glPrefsDialog *dlg); -static void gl_prefs_dialog_finalize (GObject *object); -static void gl_prefs_dialog_construct (glPrefsDialog *dlg); +static void gl_prefs_dialog_class_init (glPrefsDialogClass *klass); +static void gl_prefs_dialog_init (glPrefsDialog *dlg); +static void gl_prefs_dialog_finalize (GObject *object); +static void gl_prefs_dialog_construct (glPrefsDialog *dlg); -static void response_cb (glPrefsDialog *dialog, - gint response, - gpointer user_data); +static void response_cb (glPrefsDialog *dialog, + gint response, + gpointer user_data); -static GtkWidget *locale_page (glPrefsDialog *dlg); -static GtkWidget *object_page (glPrefsDialog *dlg); +static void construct_locale_page (glPrefsDialog *dlg); +static void construct_object_page (glPrefsDialog *dlg); -static update_locale_page_from_prefs (glPrefsDialog *dlg); -static update_object_page_from_prefs (glPrefsDialog *dlg); +static void align_toggle_cb (GtkToggleButton *toggle, + glPrefsDialog *dlg); + +static void update_locale_page_from_prefs (glPrefsDialog *dlg); +static void update_object_page_from_prefs (glPrefsDialog *dlg); -static update_prefs_from_locale_page (glPrefsDialog *dlg); -static update_prefs_from_object_page (glPrefsDialog *dlg); +static void update_prefs_from_locale_page (glPrefsDialog *dlg); +static void update_prefs_from_object_page (glPrefsDialog *dlg); /*****************************************************************************/ @@ -145,9 +153,20 @@ gl_prefs_dialog_class_init (glPrefsDialogClass *klass) static void gl_prefs_dialog_init (glPrefsDialog *dlg) { - gl_debug (DEBUG_PREFS, ""); + gl_debug (DEBUG_PREFS, "START"); + + dlg->priv = g_new0 (glPrefsDialogPrivate, 1); + + dlg->priv->gui = glade_xml_new ("prefs-dialog.glade", + "prefs_notebook", + NULL); + + if (!dlg->priv->gui) { + g_warning ("Could not open prefs-dialog.glade, reinstall glabels!"); + return; + } - dlg->private = g_new0 (glPrefsDialogPrivate, 1); + gl_debug (DEBUG_PREFS, "END"); } static void @@ -155,18 +174,20 @@ gl_prefs_dialog_finalize (GObject *object) { glPrefsDialog* dlg; - gl_debug (DEBUG_PREFS, ""); + gl_debug (DEBUG_PREFS, "START"); g_return_if_fail (object != NULL); dlg = GL_PREFS_DIALOG (object); g_return_if_fail (GL_IS_PREFS_DIALOG (dlg)); - g_return_if_fail (dlg->private != NULL); + g_return_if_fail (dlg->priv != NULL); G_OBJECT_CLASS (parent_class)->finalize (object); - g_free (dlg->private); + g_free (dlg->priv); + + gl_debug (DEBUG_PREFS, "END"); } /*****************************************************************************/ @@ -177,7 +198,7 @@ gl_prefs_dialog_new (GtkWindow *parent) { GtkWidget *dlg; - gl_debug (DEBUG_PREFS, ""); + gl_debug (DEBUG_PREFS, "START"); dlg = GTK_WIDGET (g_object_new (GL_TYPE_PREFS_DIALOG, NULL)); @@ -186,6 +207,9 @@ gl_prefs_dialog_new (GtkWindow *parent) gl_prefs_dialog_construct (GL_PREFS_DIALOG(dlg)); + + gl_debug (DEBUG_PREFS, "END"); + return dlg; } @@ -195,11 +219,10 @@ gl_prefs_dialog_new (GtkWindow *parent) static void gl_prefs_dialog_construct (glPrefsDialog *dlg) { - GtkWidget *notebook, *wlabel, *wvbox, *wvbox1, *whbox, *wframe; - GSList *radio_group = NULL; + GtkWidget *notebook; g_return_if_fail (GL_IS_PREFS_DIALOG (dlg)); - g_return_if_fail (dlg->private != NULL); + g_return_if_fail (dlg->priv != NULL); gtk_dialog_add_button (GTK_DIALOG(dlg), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE); @@ -209,16 +232,11 @@ gl_prefs_dialog_construct (glPrefsDialog *dlg) g_signal_connect(G_OBJECT (dlg), "response", G_CALLBACK (response_cb), NULL); - notebook = gtk_notebook_new (); + notebook = glade_xml_get_widget (dlg->priv->gui, "prefs_notebook"); gl_hig_dialog_add_widget (GL_HIG_DIALOG(dlg), notebook); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), - locale_page (dlg), - gtk_label_new (_("Locale"))); - - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), - object_page (dlg), - gtk_label_new (_("Object defaults"))); + construct_locale_page (dlg); + construct_object_page (dlg); update_locale_page_from_prefs (dlg); update_object_page_from_prefs (dlg); @@ -260,179 +278,210 @@ response_cb (glPrefsDialog *dlg, /*--------------------------------------------------------------------------*/ /* PRIVATE. Build Locale Properties Notebook Tab */ /*--------------------------------------------------------------------------*/ -static GtkWidget * -locale_page (glPrefsDialog *dlg) +static void +construct_locale_page (glPrefsDialog *dlg) { - GtkWidget *wlabel, *wvbox, *wframe; - GSList *radio_group = NULL; - - wvbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER); - - wlabel = gtk_label_new (_("Select locale specific behavior.")); - gtk_misc_set_alignment (GTK_MISC(wlabel), 0.0, 0.0); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wlabel); - - /* ----- Display Units Frame ------------------------------------ */ - wframe = gl_hig_category_new (_("Display units")); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); - - radio_group = NULL; - - dlg->private->units_points_radio = - gtk_radio_button_new_with_label (radio_group, _("Points")); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->units_points_radio)); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), - dlg->private->units_points_radio); - - dlg->private->units_inches_radio = - gtk_radio_button_new_with_label (radio_group, _("Inches")); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->units_inches_radio)); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), - dlg->private->units_inches_radio); - - dlg->private->units_mm_radio = - gtk_radio_button_new_with_label (radio_group, _("Millimeters")); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->units_mm_radio)); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), - dlg->private->units_mm_radio); - - /* ----- Page Size Frame ------------------------------------ */ - wframe = gl_hig_category_new (_("Default page size")); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); - - radio_group = NULL; - - dlg->private->page_size_us_letter_radio = - gtk_radio_button_new_with_label (radio_group, _("US Letter")); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON - (dlg->private->page_size_us_letter_radio)); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), - dlg->private->page_size_us_letter_radio); - - dlg->private->page_size_a4_radio = - gtk_radio_button_new_with_label (radio_group, _("A4")); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (dlg->private->page_size_a4_radio)); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), - dlg->private->page_size_a4_radio); + + dlg->priv->units_points_radio = + glade_xml_get_widget (dlg->priv->gui, "units_points_radio"); + + dlg->priv->units_inches_radio = + glade_xml_get_widget (dlg->priv->gui, "units_inches_radio"); + + dlg->priv->units_mm_radio = + glade_xml_get_widget (dlg->priv->gui, "units_mm_radio"); + + dlg->priv->page_size_us_letter_radio = + glade_xml_get_widget (dlg->priv->gui, "page_size_us_letter_radio"); + + dlg->priv->page_size_a4_radio = + glade_xml_get_widget (dlg->priv->gui, "page_size_a4_radio"); g_signal_connect_swapped ( - G_OBJECT(dlg->private->units_points_radio), - "toggled", G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_points_radio), + "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_connect_swapped ( - G_OBJECT(dlg->private->units_inches_radio), - "toggled", G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_inches_radio), + "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_connect_swapped ( - G_OBJECT(dlg->private->units_mm_radio), - "toggled", G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_mm_radio), + "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_connect_swapped ( - G_OBJECT(dlg->private->page_size_us_letter_radio), - "toggled", G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->page_size_us_letter_radio), + "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_connect_swapped ( - G_OBJECT(dlg->private->page_size_a4_radio), - "toggled", G_CALLBACK(update_prefs_from_locale_page), dlg); - - return wvbox; + G_OBJECT(dlg->priv->page_size_a4_radio), + "toggled", G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); } /*--------------------------------------------------------------------------*/ /* PRIVATE. Build Default Object Properties Notebook Tab */ /*--------------------------------------------------------------------------*/ -static GtkWidget * -object_page (glPrefsDialog *dlg) +static void +construct_object_page (glPrefsDialog *dlg) { - GtkWidget *wlabel, *wvbox, *wframe; - GtkSizeGroup *label_size_group; - - wvbox = gl_hig_vbox_new (GL_HIG_VBOX_OUTER); - label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - wlabel = gtk_label_new (_("Select default properties for new objects.")); - gtk_misc_set_alignment (GTK_MISC(wlabel), 0.0, 0.0); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wlabel); - - /* ------ text props entry ------ */ - wframe = gl_hig_category_new (_("Text")); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); - dlg->private->text = gl_wdgt_text_props_new (); - gl_wdgt_text_props_set_label_size_group (GL_WDGT_TEXT_PROPS(dlg->private->text), - label_size_group); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), - dlg->private->text); - - /* ------ Line box ------ */ - wframe = gl_hig_category_new (_("Line")); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); - dlg->private->line = gl_wdgt_line_new (); - gl_wdgt_line_set_label_size_group (GL_WDGT_LINE(dlg->private->line), - label_size_group); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), - dlg->private->line); - - /* ------ Fill box ------ */ - wframe = gl_hig_category_new (_("Fill")); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), wframe); - dlg->private->fill = gl_wdgt_fill_new (); - gl_wdgt_fill_set_label_size_group (GL_WDGT_FILL(dlg->private->fill), - label_size_group); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wframe), - dlg->private->fill); - - g_signal_connect_swapped (G_OBJECT(dlg->private->text), + GList *family_names; + + dlg->priv->text_family_entry = + glade_xml_get_widget (dlg->priv->gui, "text_family_entry"); + dlg->priv->text_family_combo = + glade_xml_get_widget (dlg->priv->gui, "text_family_combo"); + dlg->priv->text_size_spin = + glade_xml_get_widget (dlg->priv->gui, "text_size_spin"); + dlg->priv->text_bold_toggle = + glade_xml_get_widget (dlg->priv->gui, "text_bold_toggle"); + dlg->priv->text_italic_toggle = + glade_xml_get_widget (dlg->priv->gui, "text_italic_toggle"); + dlg->priv->text_color_combo = + glade_xml_get_widget (dlg->priv->gui, "text_color_combo"); + dlg->priv->text_left_toggle = + glade_xml_get_widget (dlg->priv->gui, "text_left_toggle"); + dlg->priv->text_center_toggle = + glade_xml_get_widget (dlg->priv->gui, "text_center_toggle"); + dlg->priv->text_right_toggle = + glade_xml_get_widget (dlg->priv->gui, "text_right_toggle"); + + dlg->priv->line_width_spin = + glade_xml_get_widget (dlg->priv->gui, "line_width_spin"); + dlg->priv->line_color_combo = + glade_xml_get_widget (dlg->priv->gui, "line_color_combo"); + + dlg->priv->fill_color_combo = + glade_xml_get_widget (dlg->priv->gui, "fill_color_combo"); + + /* Load family names */ + family_names = gnome_font_family_list (); + gtk_combo_set_popdown_strings (GTK_COMBO(dlg->priv->text_family_combo), + family_names); + gnome_font_family_list_free (family_names); + + + g_signal_connect_swapped (G_OBJECT(dlg->priv->text_family_entry), "changed", G_CALLBACK(update_prefs_from_object_page), - dlg); - g_signal_connect_swapped (G_OBJECT(dlg->private->line), + G_OBJECT(dlg)); + g_signal_connect_swapped (G_OBJECT(dlg->priv->text_size_spin), "changed", G_CALLBACK(update_prefs_from_object_page), - dlg); - g_signal_connect_swapped (G_OBJECT(dlg->private->fill), + G_OBJECT(dlg)); + g_signal_connect_swapped (G_OBJECT(dlg->priv->text_bold_toggle), + "toggled", + G_CALLBACK(update_prefs_from_object_page), + G_OBJECT(dlg)); + g_signal_connect_swapped (G_OBJECT(dlg->priv->text_italic_toggle), + "toggled", + G_CALLBACK(update_prefs_from_object_page), + G_OBJECT(dlg)); + g_signal_connect_swapped (G_OBJECT(dlg->priv->text_color_combo), + "color_changed", + G_CALLBACK(update_prefs_from_object_page), + G_OBJECT(dlg)); + + g_signal_connect (G_OBJECT(dlg->priv->text_left_toggle), + "toggled", + G_CALLBACK(align_toggle_cb), + G_OBJECT(dlg)); + g_signal_connect (G_OBJECT(dlg->priv->text_center_toggle), + "toggled", + G_CALLBACK(align_toggle_cb), + G_OBJECT(dlg)); + g_signal_connect (G_OBJECT(dlg->priv->text_right_toggle), + "toggled", + G_CALLBACK(align_toggle_cb), + G_OBJECT(dlg)); + + g_signal_connect_swapped (G_OBJECT(dlg->priv->line_width_spin), "changed", G_CALLBACK(update_prefs_from_object_page), - dlg); - return wvbox; + G_OBJECT(dlg)); + g_signal_connect_swapped (G_OBJECT(dlg->priv->line_color_combo), + "color_changed", + G_CALLBACK(update_prefs_from_object_page), + G_OBJECT(dlg)); + + g_signal_connect_swapped (G_OBJECT(dlg->priv->fill_color_combo), + "color_changed", + G_CALLBACK(update_prefs_from_object_page), + G_OBJECT(dlg)); } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Alignment togglebutton callback. */ +/*--------------------------------------------------------------------------*/ +static void +align_toggle_cb (GtkToggleButton *toggle, + glPrefsDialog *dlg) +{ + if (gtk_toggle_button_get_active (toggle)) { + + if (GTK_WIDGET (toggle) == GTK_WIDGET (dlg->priv->text_left_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (dlg->priv->text_center_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (dlg->priv->text_right_toggle), + FALSE); + } else if (GTK_WIDGET (toggle) == + GTK_WIDGET (dlg->priv->text_center_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (dlg->priv->text_left_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (dlg->priv->text_right_toggle), + FALSE); + } else if (GTK_WIDGET (toggle) == + GTK_WIDGET (dlg->priv->text_right_toggle)) { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (dlg->priv->text_left_toggle), + FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (dlg->priv->text_center_toggle), + FALSE); + } + + update_prefs_from_object_page (dlg); + } + +} + + /*--------------------------------------------------------------------------*/ /* PRIVATE. Update locale page widgets from current prefs. */ /*--------------------------------------------------------------------------*/ -static update_locale_page_from_prefs (glPrefsDialog *dlg) +static void +update_locale_page_from_prefs (glPrefsDialog *dlg) { g_signal_handlers_block_by_func ( - G_OBJECT(dlg->private->units_points_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_points_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_handlers_block_by_func ( - G_OBJECT(dlg->private->units_inches_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_inches_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_handlers_block_by_func ( - G_OBJECT(dlg->private->units_mm_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_mm_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_handlers_block_by_func ( - G_OBJECT(dlg->private->page_size_us_letter_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->page_size_us_letter_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_handlers_block_by_func ( - G_OBJECT(dlg->private->page_size_a4_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->page_size_a4_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); switch (gl_prefs->units) { case GL_PREFS_UNITS_PTS: gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(dlg->private->units_points_radio), + GTK_TOGGLE_BUTTON(dlg->priv->units_points_radio), TRUE); break; case GL_PREFS_UNITS_INCHES: gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(dlg->private->units_inches_radio), + GTK_TOGGLE_BUTTON(dlg->priv->units_inches_radio), TRUE); break; case GL_PREFS_UNITS_MM: gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(dlg->private->units_mm_radio), + GTK_TOGGLE_BUTTON(dlg->priv->units_mm_radio), TRUE); break; default: @@ -442,98 +491,189 @@ static update_locale_page_from_prefs (glPrefsDialog *dlg) if ( g_strcasecmp(gl_prefs->default_page_size, US_LETTER_ID) == 0) { gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(dlg->private->page_size_us_letter_radio), + GTK_TOGGLE_BUTTON(dlg->priv->page_size_us_letter_radio), TRUE); } else if ( g_strcasecmp(gl_prefs->default_page_size, A4_ID) == 0) { gtk_toggle_button_set_active ( - GTK_TOGGLE_BUTTON(dlg->private->page_size_a4_radio), + GTK_TOGGLE_BUTTON(dlg->priv->page_size_a4_radio), TRUE); } else { g_warning ("Unknown default page size"); /* Shouldn't happen */ } g_signal_handlers_unblock_by_func ( - G_OBJECT(dlg->private->units_points_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_points_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_handlers_unblock_by_func ( - G_OBJECT(dlg->private->units_inches_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_inches_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_handlers_unblock_by_func ( - G_OBJECT(dlg->private->units_mm_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->units_mm_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_handlers_unblock_by_func ( - G_OBJECT(dlg->private->page_size_us_letter_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->page_size_us_letter_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); g_signal_handlers_unblock_by_func ( - G_OBJECT(dlg->private->page_size_a4_radio), - G_CALLBACK(update_prefs_from_locale_page), dlg); + G_OBJECT(dlg->priv->page_size_a4_radio), + G_CALLBACK(update_prefs_from_locale_page), G_OBJECT(dlg)); } /*--------------------------------------------------------------------------*/ /* PRIVATE. Update object page widgets from current prefs. */ /*--------------------------------------------------------------------------*/ -static update_object_page_from_prefs (glPrefsDialog *dlg) +static void + update_object_page_from_prefs (glPrefsDialog *dlg) { + GList *family_names; + gchar *good_font_family; + GdkColor *gdk_color; + g_signal_handlers_block_by_func ( - G_OBJECT(dlg->private->text), - G_CALLBACK(update_prefs_from_object_page), dlg); + G_OBJECT(dlg->priv->text_family_entry), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); g_signal_handlers_block_by_func ( - G_OBJECT(dlg->private->line), - G_CALLBACK(update_prefs_from_object_page), dlg); + G_OBJECT(dlg->priv->text_size_spin), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); g_signal_handlers_block_by_func ( - G_OBJECT(dlg->private->fill), - G_CALLBACK(update_prefs_from_object_page), dlg); - - gl_wdgt_text_props_set_params (GL_WDGT_TEXT_PROPS(dlg->private->text), - gl_prefs->default_font_family, - gl_prefs->default_font_size, - gl_prefs->default_font_weight, - gl_prefs->default_font_italic_flag, - gl_prefs->default_text_color, - gl_prefs->default_text_alignment); - - gl_wdgt_line_set_params (GL_WDGT_LINE(dlg->private->line), - gl_prefs->default_line_width, - gl_prefs->default_line_color); + G_OBJECT(dlg->priv->text_bold_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->text_italic_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->text_color_combo), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->text_left_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->text_center_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->text_right_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->line_width_spin), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->line_color_combo), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_block_by_func ( + G_OBJECT(dlg->priv->fill_color_combo), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + + + /* Make sure we have a valid font family. if not provide a good default. */ + family_names = gnome_font_family_list (); + if (g_list_find_custom (family_names, + gl_prefs->default_font_family, + (GCompareFunc)g_utf8_collate)) { + good_font_family = g_strdup (gl_prefs->default_font_family); + } else { + if (family_names != NULL) { + good_font_family = g_strdup (family_names->data); /* 1st entry */ + } else { + good_font_family = NULL; + } + } + gnome_font_family_list_free (family_names); + gtk_entry_set_text (GTK_ENTRY (dlg->priv->text_family_entry), good_font_family); + g_free (good_font_family); + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->text_size_spin), + gl_prefs->default_font_size); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->text_bold_toggle), + (gl_prefs->default_font_weight == GNOME_FONT_BOLD)); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->text_italic_toggle), + gl_prefs->default_font_italic_flag); + + gdk_color = gl_color_to_gdk_color (gl_prefs->default_text_color); + color_combo_set_color (COLOR_COMBO(dlg->priv->text_color_combo), gdk_color); + g_free (gdk_color); + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->text_left_toggle), + (gl_prefs->default_text_alignment == GTK_JUSTIFY_LEFT)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->text_center_toggle), + (gl_prefs->default_text_alignment == GTK_JUSTIFY_CENTER)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->text_right_toggle), + (gl_prefs->default_text_alignment == GTK_JUSTIFY_RIGHT)); + + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (dlg->priv->line_width_spin), + gl_prefs->default_line_width); + + gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); + color_combo_set_color (COLOR_COMBO(dlg->priv->line_color_combo), gdk_color); + g_free (gdk_color); + + + gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color); + color_combo_set_color (COLOR_COMBO(dlg->priv->fill_color_combo), gdk_color); + g_free (gdk_color); - gl_wdgt_fill_set_params (GL_WDGT_FILL(dlg->private->fill), - gl_prefs->default_fill_color); g_signal_handlers_unblock_by_func ( - G_OBJECT(dlg->private->text), - G_CALLBACK(update_prefs_from_object_page), dlg); + G_OBJECT(dlg->priv->text_family_entry), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->text_size_spin), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->text_bold_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->text_italic_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->text_color_combo), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); g_signal_handlers_unblock_by_func ( - G_OBJECT(dlg->private->line), - G_CALLBACK(update_prefs_from_object_page), dlg); + G_OBJECT(dlg->priv->text_left_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); g_signal_handlers_unblock_by_func ( - G_OBJECT(dlg->private->fill), - G_CALLBACK(update_prefs_from_object_page), dlg); + G_OBJECT(dlg->priv->text_center_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->text_right_toggle), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->line_width_spin), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->line_color_combo), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); + g_signal_handlers_unblock_by_func ( + G_OBJECT(dlg->priv->fill_color_combo), + G_CALLBACK(update_prefs_from_object_page), G_OBJECT(dlg)); } /*--------------------------------------------------------------------------*/ /* PRIVATE. Update prefs from current state of locale page widgets. */ /*--------------------------------------------------------------------------*/ -static update_prefs_from_locale_page (glPrefsDialog *dlg) +static void +update_prefs_from_locale_page (glPrefsDialog *dlg) { if (gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON(dlg->private->units_points_radio))) { + GTK_TOGGLE_BUTTON(dlg->priv->units_points_radio))) { gl_prefs->units = GL_PREFS_UNITS_PTS; } if (gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON(dlg->private->units_inches_radio))) { + GTK_TOGGLE_BUTTON(dlg->priv->units_inches_radio))) { gl_prefs->units = GL_PREFS_UNITS_INCHES; } if (gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON(dlg->private->units_mm_radio))) { + GTK_TOGGLE_BUTTON(dlg->priv->units_mm_radio))) { gl_prefs->units = GL_PREFS_UNITS_MM; } if (gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON(dlg->private->page_size_us_letter_radio))) { + GTK_TOGGLE_BUTTON(dlg->priv->page_size_us_letter_radio))) { gl_prefs->default_page_size = US_LETTER_ID; } if (gtk_toggle_button_get_active ( - GTK_TOGGLE_BUTTON(dlg->private->page_size_a4_radio))) { + GTK_TOGGLE_BUTTON(dlg->priv->page_size_a4_radio))) { gl_prefs->default_page_size = A4_ID; } @@ -543,22 +683,69 @@ static update_prefs_from_locale_page (glPrefsDialog *dlg) /*--------------------------------------------------------------------------*/ /* PRIVATE. Update prefs from current state of object page widgets. */ /*--------------------------------------------------------------------------*/ -static update_prefs_from_object_page (glPrefsDialog *dlg) +static void +update_prefs_from_object_page (glPrefsDialog *dlg) { - gl_wdgt_text_props_get_params (GL_WDGT_TEXT_PROPS(dlg->private->text), - &gl_prefs->default_font_family, - &gl_prefs->default_font_size, - &gl_prefs->default_font_weight, - &gl_prefs->default_font_italic_flag, - &gl_prefs->default_text_color, - &gl_prefs->default_text_alignment); - - gl_wdgt_line_get_params (GL_WDGT_LINE(dlg->private->line), - &gl_prefs->default_line_width, - &gl_prefs->default_line_color); - - gl_wdgt_fill_get_params (GL_WDGT_FILL(dlg->private->fill), - &gl_prefs->default_fill_color); + GdkColor *gdk_color; + gboolean is_default; + + + g_free (gl_prefs->default_font_family); + gl_prefs->default_font_family = + gtk_editable_get_chars (GTK_EDITABLE (dlg->priv->text_family_entry), + 0, -1); + gl_prefs->default_font_size = + gtk_spin_button_get_value (GTK_SPIN_BUTTON(dlg->priv->text_size_spin)); + + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (dlg->priv->text_bold_toggle))) { + gl_prefs->default_font_weight = GNOME_FONT_BOLD; + } else { + gl_prefs->default_font_weight = GNOME_FONT_BOOK; + } + + gl_prefs->default_font_italic_flag = + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON + (dlg->priv->text_italic_toggle)); + + gdk_color = color_combo_get_color (COLOR_COMBO(dlg->priv->text_color_combo), + &is_default); + if (!is_default) { + gl_prefs->default_text_color = gl_color_from_gdk_color (gdk_color); + } + + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (dlg->priv->text_left_toggle))) { + gl_prefs->default_text_alignment = GTK_JUSTIFY_LEFT; + } else + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (dlg->priv->text_right_toggle))) { + gl_prefs->default_text_alignment = GTK_JUSTIFY_RIGHT; + } else + if (gtk_toggle_button_get_active + (GTK_TOGGLE_BUTTON (dlg->priv->text_center_toggle))) { + gl_prefs->default_text_alignment = GTK_JUSTIFY_CENTER; + } else { + /* Should not happen. */ + gl_prefs->default_text_alignment = GTK_JUSTIFY_LEFT; + } + + + gl_prefs->default_line_width = + gtk_spin_button_get_value (GTK_SPIN_BUTTON(dlg->priv->line_width_spin)); + + gdk_color = color_combo_get_color (COLOR_COMBO(dlg->priv->line_color_combo), + &is_default); + if (!is_default) { + gl_prefs->default_line_color = gl_color_from_gdk_color (gdk_color); + } + + + gdk_color = color_combo_get_color (COLOR_COMBO(dlg->priv->fill_color_combo), + &is_default); + if (!is_default) { + gl_prefs->default_fill_color = gl_color_from_gdk_color (gdk_color); + } gl_prefs_save_settings (); } diff --git a/glabels2/src/prefs-dialog.glade b/glabels2/src/prefs-dialog.glade new file mode 100644 index 00000000..59bcbb7d --- /dev/null +++ b/glabels2/src/prefs-dialog.glade @@ -0,0 +1,1132 @@ + + + + + + + True + gLabels Preferences + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + True + True + True + True + GTK_POS_TOP + False + False + + + + 12 + True + False + 12 + + + + True + Select locale specific behavior. + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 6 + True + False + 6 + + + + True + True + Points + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + + True + True + Inches + True + GTK_RELIEF_NORMAL + False + False + True + units_points_radio + + + 0 + False + False + + + + + + True + True + Millimeters + True + GTK_RELIEF_NORMAL + False + False + True + units_points_radio + + + 0 + False + False + + + + + 0 + True + True + + + + + + + + True + <span weight="bold">Units</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + False + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 6 + True + False + 6 + + + + True + True + US Letter + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + False + False + + + + + + True + True + ISO A4 + True + GTK_RELIEF_NORMAL + False + False + True + page_size_us_letter_radio + + + 0 + False + False + + + + + 0 + True + True + + + + + + + + True + <span weight="bold">Default page size</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + False + + + + + False + True + + + + + + True + Locale + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + + 12 + True + False + 12 + + + + True + Select default properties for new objects. + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 6 + True + False + 12 + + + + True + False + 12 + + + + 64 + True + Font: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + False + False + True + False + + + + True + True + True + True + 0 + + True + * + False + + + + + + True + GTK_SELECTION_BROWSE + + + + + 0 + False + False + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-bold + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-italic + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 0 + True + True + + + + + + True + False + 12 + + + + 64 + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + gl_object_editor_construct_color_combo + 2 + 0 + Sun, 23 Nov 2003 15:42:02 GMT + + + 0 + False + False + + + + + 0 + True + True + + + + + + True + False + 12 + + + + 64 + True + Alignment: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-left + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-center + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + + True + True + GTK_RELIEF_NORMAL + False + False + + + + True + gtk-justify-right + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + + True + <span weight="bold">Text</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + False + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 6 + True + False + 12 + + + + True + False + 12 + + + + 64 + True + Width: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 0 + False + False + + + + + + True + points + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + + True + False + 12 + + + + 64 + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + gl_object_editor_construct_color_combo + 1 + 0 + Sun, 23 Nov 2003 15:42:41 GMT + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + + True + <span weight="bold">Line</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + False + + + + + + True + 0 + 0.5 + GTK_SHADOW_NONE + + + + True + False + 0 + + + + True + + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 6 + True + False + 12 + + + + True + False + 12 + + + + 64 + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + gl_object_editor_construct_color_combo + 0 + 0 + Sun, 23 Nov 2003 15:43:12 GMT + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + + True + <span weight="bold">Fill</span> + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + label_item + + + + + 0 + False + False + + + + + False + True + + + + + + True + Object defaults + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + tab + + + + + 0 + True + True + + + + + + + diff --git a/glabels2/src/prefs-dialog.h b/glabels2/src/prefs-dialog.h index 04383f01..adc68b53 100644 --- a/glabels2/src/prefs-dialog.h +++ b/glabels2/src/prefs-dialog.h @@ -45,7 +45,7 @@ struct _glPrefsDialog { glHigDialog parent_instance; - glPrefsDialogPrivate *private; + glPrefsDialogPrivate *priv; }; diff --git a/glabels2/src/stock-pixmaps/Makefile.am b/glabels2/src/stock-pixmaps/Makefile.am index 4cfdfc76..dd8327d3 100644 --- a/glabels2/src/stock-pixmaps/Makefile.am +++ b/glabels2/src/stock-pixmaps/Makefile.am @@ -14,6 +14,7 @@ IMAGES = \ stock_line_16.png \ stock_merge_24.png \ stock_merge_16.png \ + stock_properties_24.png \ stock_properties_16.png \ stock_text_24.png \ stock_text_16.png \ @@ -51,6 +52,7 @@ VARIABLES1 = \ stock_line_16 $(srcdir)/stock_line_16.png \ stock_merge_24 $(srcdir)/stock_merge_24.png \ stock_merge_16 $(srcdir)/stock_merge_16.png \ + stock_properties_24 $(srcdir)/stock_properties_24.png \ stock_properties_16 $(srcdir)/stock_properties_16.png \ stock_text_24 $(srcdir)/stock_text_24.png \ stock_text_16 $(srcdir)/stock_text_16.png \ diff --git a/glabels2/src/stock-pixmaps/stock_properties_24.png b/glabels2/src/stock-pixmaps/stock_properties_24.png new file mode 100644 index 0000000000000000000000000000000000000000..362b771340f7db83dfad9af2394d20a9af960267 GIT binary patch literal 495 zcmVP`B&QoJ-n9+NRA9F1i2m`|iExgc~SW-bmXn$hQLg0{x{08D;@i0G6{x zdvTP{wd&prfIc8a?Z7DwsAa9FQjLh8Kj#M2fIDjkG5&siaT7#@-R1=kkMDBSqM6Mm0*o<;$U=-&dPGN_=i&Rl8|Zes?imCDomPqR zdNViR8mKEIZQf`!=(I`ztZr=P1_0b^B@9EtFdUkgXZ53iLR2_lEKQ9uE(WSW+Fs=X zq<3KTV@t=N-EQYHR_T4<%#AT)lQf%vohf|<=m9bW$TC+2K>)A^JWT=UlUz93VO0!n zHCIH$iiid5)>?TV@Ut8z$tonN*OKDQQ~fgmG|2Ugu^32a)LGK^|2a<3A>%96_6a$U lX7sNjeXGUEv&tMR{{teXnUh%7TbKX<002ovPDHLkV1ncv&GY~O literal 0 HcmV?d00001 diff --git a/glabels2/src/stock.c b/glabels2/src/stock.c index c4fb0a41..58dbcab9 100644 --- a/glabels2/src/stock.c +++ b/glabels2/src/stock.c @@ -99,7 +99,9 @@ gl_stock_init (void) add_icons (factory, GL_STOCK_BARCODE, stock_barcode_24, stock_barcode_16); add_icons (factory, GL_STOCK_MERGE, stock_merge_24, stock_merge_16); - add_icons (factory, GL_STOCK_PROPERTIES, NULL, stock_properties_16); + add_icons (factory, GL_STOCK_PROPERTIES, + stock_properties_24, + stock_properties_16); add_icons (factory, GL_STOCK_ORDER_TOP, NULL, stock_order_top_16); add_icons (factory, GL_STOCK_ORDER_BOTTOM, NULL, stock_order_bottom_16); diff --git a/glabels2/src/tools.c b/glabels2/src/tools.c index 1085e433..9b6e1e81 100644 --- a/glabels2/src/tools.c +++ b/glabels2/src/tools.c @@ -225,12 +225,12 @@ gl_tools_zoom1to1 (BonoboUIComponent *uic, } /*****************************************************************************/ -/* edit merge properties callback. */ +/* zoom to fit callback. */ /*****************************************************************************/ void -gl_tools_merge_properties (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) +gl_tools_zoom_to_fit (BonoboUIComponent *uic, + gpointer user_data, + const gchar *verbname) { glWindow *window; @@ -238,17 +238,17 @@ gl_tools_merge_properties (BonoboUIComponent *uic, window = GL_WINDOW (user_data); if (window->view != NULL) { - gl_view_edit_merge_props (GL_VIEW(window->view)); + gl_view_zoom_best_fit (GL_VIEW(window->view)); } } /*****************************************************************************/ -/* edit object properties callback. */ +/* edit merge properties callback. */ /*****************************************************************************/ void -gl_tools_object_properties (BonoboUIComponent *uic, - gpointer user_data, - const gchar *verbname) +gl_tools_merge_properties (BonoboUIComponent *uic, + gpointer user_data, + const gchar *verbname) { glWindow *window; @@ -256,7 +256,7 @@ gl_tools_object_properties (BonoboUIComponent *uic, window = GL_WINDOW (user_data); if (window->view != NULL) { - gl_view_edit_object_props (GL_VIEW(window->view)); + gl_view_edit_merge_props (GL_VIEW(window->view)); } } diff --git a/glabels2/src/tools.h b/glabels2/src/tools.h index c99df5e9..f76ae950 100644 --- a/glabels2/src/tools.h +++ b/glabels2/src/tools.h @@ -66,11 +66,11 @@ void gl_tools_zoom1to1 (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname); -void gl_tools_merge_properties (BonoboUIComponent *uic, +void gl_tools_zoom_to_fit (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname); -void gl_tools_object_properties (BonoboUIComponent *uic, +void gl_tools_merge_properties (BonoboUIComponent *uic, gpointer user_data, const gchar *verbname); diff --git a/glabels2/src/ui-sidebar.c b/glabels2/src/ui-sidebar.c new file mode 100644 index 00000000..e59b3d25 --- /dev/null +++ b/glabels2/src/ui-sidebar.c @@ -0,0 +1,248 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * ui-sidebar.c: Object property sidebar + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 + +#include + +#include "ui-sidebar.h" +#include "ui-util.h" +#include "object-editor.h" +#include "stock.h" + +#include "debug.h" + +/*============================================================================*/ +/* Private macros and constants. */ +/*============================================================================*/ + +#define DEFAULT_SIDEBAR_WIDTH 300 + +/*============================================================================*/ +/* Private globals */ +/*============================================================================*/ + +static GObjectClass *parent_class; + +static gchar* doc_verbs [] = { + "/commands/PropertyEditor", + + NULL +}; + +/*============================================================================*/ +/* Local function prototypes */ +/*============================================================================*/ + +static void gl_ui_sidebar_class_init (glUISidebarClass *class); +static void gl_ui_sidebar_instance_init (glUISidebar *sidebar); +static void gl_ui_sidebar_finalize (GObject *object); + +static void gl_ui_sidebar_construct (glUISidebar *sidebar, + BonoboUIComponent *ui_component); + +static void selection_changed_cb (glView *view, + glUISidebar *sidebar); + + + +/****************************************************************************/ +/* Boilerplate Object stuff. */ +/****************************************************************************/ +guint +gl_ui_sidebar_get_type (void) +{ + static guint sidebar_type = 0; + + if (!sidebar_type) { + GTypeInfo sidebar_info = { + sizeof (glUISidebarClass), + NULL, + NULL, + (GClassInitFunc) gl_ui_sidebar_class_init, + NULL, + NULL, + sizeof (glUISidebar), + 0, + (GInstanceInitFunc) gl_ui_sidebar_instance_init, + }; + + sidebar_type = + g_type_register_static (GTK_TYPE_VBOX, + "glUISidebar", + &sidebar_info, 0); + } + + return sidebar_type; +} + +static void +gl_ui_sidebar_class_init (glUISidebarClass *class) +{ + GObjectClass *object_class = (GObjectClass *) class; + + gl_debug (DEBUG_UI, "START"); + + parent_class = g_type_class_peek_parent (class); + + object_class->finalize = gl_ui_sidebar_finalize; + + gl_debug (DEBUG_UI, "END"); +} + +static void +gl_ui_sidebar_instance_init (glUISidebar *sidebar) +{ + gl_debug (DEBUG_UI, "START"); + + sidebar->view = NULL; + + gl_debug (DEBUG_UI, "END"); +} + +static void +gl_ui_sidebar_finalize (GObject *object) +{ + glUISidebar *sidebar; + + gl_debug (DEBUG_UI, "START"); + + g_return_if_fail (object != NULL); + g_return_if_fail (GL_IS_UI_SIDEBAR (object)); + + sidebar = GL_UI_SIDEBAR (object); + + if (sidebar->view) { + g_object_unref (G_OBJECT(sidebar->view)); + sidebar = NULL; + } + + G_OBJECT_CLASS (parent_class)->finalize (object); + + gl_debug (DEBUG_UI, "END"); +} + +/****************************************************************************/ +/* Create a NEW sidebar. */ +/****************************************************************************/ +GObject * +gl_ui_sidebar_new (BonoboUIComponent *ui_component) +{ + glUISidebar *sidebar; + + gl_debug (DEBUG_UI, "START"); + + sidebar = g_object_new (gl_ui_sidebar_get_type (), NULL); + + gtk_widget_set_size_request (GTK_WIDGET (sidebar), DEFAULT_SIDEBAR_WIDTH, -1); + + gl_ui_sidebar_construct (sidebar, ui_component); + + gl_debug (DEBUG_UI, "END"); + + return G_OBJECT(sidebar); +} + +/******************************************************************************/ +/* Initialize property toolbar. */ +/******************************************************************************/ +static void +gl_ui_sidebar_construct (glUISidebar *sidebar, + BonoboUIComponent *ui_component) +{ + gl_debug (DEBUG_UI, "START"); + + sidebar->ui_component = ui_component; + + gl_ui_util_insert_widget (ui_component, + GTK_WIDGET (sidebar), + "/PropertySidebar/PropertyEditor"); + + sidebar->empty_child = gl_object_editor_new (GL_STOCK_PROPERTIES, + _("Object properties"), + GL_OBJECT_EDITOR_EMPTY, + NULL); + + sidebar->child = gtk_widget_ref (sidebar->empty_child); + gtk_widget_show (sidebar->child); + gtk_container_add (GTK_CONTAINER(sidebar), sidebar->child); + + gl_ui_util_set_verb_list_sensitive (ui_component, doc_verbs, FALSE); + + gl_debug (DEBUG_UI, "END"); +} + +/****************************************************************************/ +/* Set view associated with sidebar. */ +/****************************************************************************/ +void +gl_ui_sidebar_set_view (glUISidebar *sidebar, + glView *view) +{ + gl_debug (DEBUG_UI, "START"); + + g_return_if_fail (view && GL_IS_VIEW (view)); + + gl_ui_util_set_verb_list_sensitive (sidebar->ui_component, doc_verbs, TRUE); + + sidebar->view = GL_VIEW (g_object_ref (G_OBJECT (view))); + + g_signal_connect (G_OBJECT(view), "selection_changed", + G_CALLBACK(selection_changed_cb), sidebar); + + gl_debug (DEBUG_UI, "END"); +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. View "selection state changed" callback. */ +/*---------------------------------------------------------------------------*/ +static void +selection_changed_cb (glView *view, + glUISidebar *sidebar) +{ + gl_debug (DEBUG_UI, "START"); + + g_return_if_fail (view && GL_IS_VIEW (view)); + g_return_if_fail (sidebar && GL_IS_UI_SIDEBAR (sidebar)); + + gtk_container_remove (GTK_CONTAINER(sidebar), sidebar->child); + + if (gl_view_is_selection_empty (view)) { + + sidebar->child = gtk_widget_ref (sidebar->empty_child); + + } else { + + sidebar->child = gtk_widget_ref (gl_view_get_editor (view)); + + } + + gtk_widget_show (sidebar->child); +#if 0 + gtk_container_add (GTK_CONTAINER(sidebar), sidebar->child); +#else + gtk_box_pack_start (GTK_BOX(sidebar), sidebar->child, TRUE, TRUE, 0); +#endif + + gl_debug (DEBUG_UI, "END"); +} + diff --git a/glabels2/src/ui-sidebar.h b/glabels2/src/ui-sidebar.h new file mode 100644 index 00000000..a7f62fab --- /dev/null +++ b/glabels2/src/ui-sidebar.h @@ -0,0 +1,71 @@ +/* + * (GLABELS) Label and Business Card Creation program for GNOME + * + * ui-sidebar.h: Object property sidebar header file + * + * Copyright (C) 2003 Jim Evins . + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * 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 __UI_SIDEBAR_H__ +#define __UI_SIDEBAR_H__ + +#include +#include +#include + +#include "view.h" + +G_BEGIN_DECLS + +#define GL_TYPE_UI_SIDEBAR (gl_ui_sidebar_get_type ()) +#define GL_UI_SIDEBAR(obj) \ + (GTK_CHECK_CAST((obj), GL_TYPE_UI_SIDEBAR, glUISidebar )) +#define GL_UI_SIDEBAR_CLASS(klass) \ + (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_UI_SIDEBAR, glUISidebarClass)) +#define GL_IS_UI_SIDEBAR(obj) \ + (GTK_CHECK_TYPE ((obj), GL_TYPE_UI_SIDEBAR)) +#define GL_IS_UI_SIDEBAR_CLASS(klass) \ + (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_UI_SIDEBAR)) + +typedef struct _glUISidebar glUISidebar; +typedef struct _glUISidebarClass glUISidebarClass; + +struct _glUISidebar { + GtkVBox parent_widget; + + BonoboUIComponent *ui_component; + + glView *view; + GtkWidget *child; + GtkWidget *empty_child; +}; + +struct _glUISidebarClass { + GtkVBoxClass parent_class; +}; + +guint gl_ui_sidebar_get_type (void); + +GObject *gl_ui_sidebar_new (BonoboUIComponent *ui_component); + +void gl_ui_sidebar_set_view (glUISidebar *sidebar, + glView *view); + + +G_END_DECLS + +#endif /* __UI_SIDEBAR_H__ */ diff --git a/glabels2/src/ui.c b/glabels2/src/ui.c index acb3332f..62ecce86 100644 --- a/glabels2/src/ui.c +++ b/glabels2/src/ui.c @@ -74,8 +74,8 @@ static BonoboUIVerb gl_ui_verbs [] = { BONOBO_UI_VERB ("ToolsZoomIn", gl_tools_zoomin), BONOBO_UI_VERB ("ToolsZoomOut", gl_tools_zoomout), BONOBO_UI_VERB ("ToolsZoom1to1", gl_tools_zoom1to1), + BONOBO_UI_VERB ("ToolsZoomToFit", gl_tools_zoom_to_fit), BONOBO_UI_VERB ("ToolsMergeProperties", gl_tools_merge_properties), - BONOBO_UI_VERB ("ToolsObjectProperties", gl_tools_object_properties), BONOBO_UI_VERB ("ToolsRaiseObjects", gl_tools_raise_objects), BONOBO_UI_VERB ("ToolsLowerObjects", gl_tools_lower_objects), BONOBO_UI_VERB ("ToolsRotateLeft", gl_tools_rotate_objects_left), @@ -123,8 +123,8 @@ static gchar* doc_verbs [] = { "/commands/ToolsZoomIn", "/commands/ToolsZoomOut", "/commands/ToolsZoom1to1", + "/commands/ToolsZoomToFit", "/commands/ToolsMergeProperties", - "/commands/ToolsObjectProperties", "/commands/ToolsRaiseObjects", "/commands/ToolsLowerObjects", "/commands/ToolsRotateLeft", @@ -178,7 +178,6 @@ static gchar* selection_verbs [] = { }; static gchar* atomic_selection_verbs [] = { - "/commands/ToolsObjectProperties", NULL }; diff --git a/glabels2/src/view-barcode.c b/glabels2/src/view-barcode.c index e2782c03..901ff9b9 100644 --- a/glabels2/src/view-barcode.c +++ b/glabels2/src/view-barcode.c @@ -1,9 +1,9 @@ /* * (GLABELS) Label and Business Card Creation program for GNOME * - * view_barcode.c: GLabels label barcode object widget + * view_text.c: GLabels label text object widget * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2003 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,14 +26,11 @@ #include "view-barcode.h" #include "canvas-hacktext.h" - #include "view-highlight.h" -#include "wdgt-bc-data.h" -#include "wdgt-bc-props.h" -#include "wdgt-bc-style.h" -#include "wdgt-position.h" #include "color.h" +#include "object-editor.h" +#include "stock.h" #include "pixmaps/cursor_barcode.xbm" #include "pixmaps/cursor_barcode_mask.xbm" @@ -50,17 +47,8 @@ struct _glViewBarcodePrivate { - GList *item_list; - - /* Page 0 widgets */ - GtkWidget *bc_data; + GList *item_list; - /* Page 1 widgets */ - GtkWidget *bc_props; - GtkWidget *bc_style; - - /* Page 2 widgets */ - GtkWidget *position; }; /*========================================================*/ @@ -74,40 +62,31 @@ static glViewObjectClass *parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_barcode_class_init (glViewBarcodeClass *klass); -static void gl_view_barcode_instance_init (glViewBarcode *view_barcode); -static void gl_view_barcode_finalize (GObject *object); - -static void update_view_barcode_cb (glLabelObject *object, - glViewBarcode *view_barcode); +static void gl_view_barcode_class_init (glViewBarcodeClass *klass); +static void gl_view_barcode_instance_init (glViewBarcode *view_bc); +static void gl_view_barcode_finalize (GObject *object); -static GtkWidget *construct_properties_dialog (glViewObject *view_object); +static GtkWidget *construct_properties_editor (glViewObject *view_object); -static void response_cb (GtkDialog *dialog, - gint response, - glViewBarcode *view_barcode); +static void update_canvas_item_from_object_cb (glLabelObject *object, + glViewBarcode *view_bc); -static void bc_data_changed_cb (glWdgtBCData *bc_data, - glViewBarcode *view_barcode); +static void update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object); -static void bc_props_changed_cb (glWdgtBCProps *bc_props, - glViewBarcode *view_barcode); +static void update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor); -static void bc_style_changed_cb (glWdgtBCStyle *bc_style, - glViewBarcode *view_barcode); +static void update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor); -static void position_changed_cb (glWdgtPosition *position, - glViewBarcode *view_barcode); +static void update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor); -static void update_dialog_cb (glLabelObject *object, - glViewBarcode *view_barcode); +static void draw_barcode (glViewBarcode *view_bc); -static void update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewBarcode *view_barcode); - -static void draw_barcode (glViewBarcode *view_barcode); /*****************************************************************************/ @@ -150,17 +129,17 @@ gl_view_barcode_class_init (glViewBarcodeClass *klass) object_class->finalize = gl_view_barcode_finalize; - view_object_class->construct_dialog = construct_properties_dialog; + view_object_class->construct_editor = construct_properties_editor; gl_debug (DEBUG_VIEW, "END"); } static void -gl_view_barcode_instance_init (glViewBarcode *view_barcode) +gl_view_barcode_instance_init (glViewBarcode *view_bc) { gl_debug (DEBUG_VIEW, "START"); - view_barcode->private = g_new0 (glViewBarcodePrivate, 1); + view_bc->private = g_new0 (glViewBarcodePrivate, 1); gl_debug (DEBUG_VIEW, "END"); } @@ -186,426 +165,210 @@ glViewObject * gl_view_barcode_new (glLabelBarcode *object, glView *view) { - glViewBarcode *view_barcode; + glViewBarcode *view_bc; GtkMenu *menu; gl_debug (DEBUG_VIEW, "START"); g_return_if_fail (object && GL_IS_LABEL_BARCODE (object)); g_return_if_fail (view && GL_IS_VIEW (view)); - view_barcode = g_object_new (gl_view_barcode_get_type(), NULL); + view_bc = g_object_new (gl_view_barcode_get_type(), NULL); - gl_view_object_set_view (GL_VIEW_OBJECT(view_barcode), view); - gl_view_object_set_object (GL_VIEW_OBJECT(view_barcode), + gl_view_object_set_view (GL_VIEW_OBJECT(view_bc), view); + gl_view_object_set_object (GL_VIEW_OBJECT(view_bc), GL_LABEL_OBJECT(object), GL_VIEW_HIGHLIGHT_BOX_RESIZABLE); /* Create analogous canvas items. */ - draw_barcode (view_barcode); + draw_barcode (view_bc); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_view_barcode_cb), view_barcode); + G_CALLBACK (update_canvas_item_from_object_cb), view_bc); gl_debug (DEBUG_VIEW, "END"); - return GL_VIEW_OBJECT (view_barcode); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -update_view_barcode_cb (glLabelObject *object, - glViewBarcode *view_barcode) -{ - glView *view; - GnomeCanvasItem *group; - - gl_debug (DEBUG_VIEW, "START"); - - view = gl_view_object_get_view (GL_VIEW_OBJECT(view_barcode)); - - /* Adjust appearance of analogous canvas items. */ - draw_barcode (view_barcode); - - gl_debug (DEBUG_VIEW, "END"); + return GL_VIEW_OBJECT (view_bc); } /*****************************************************************************/ -/* Create a properties dialog for a barcode object. */ +/* Create a properties editor for a barcode object. */ /*****************************************************************************/ static GtkWidget * -construct_properties_dialog (glViewObject *view_object) +construct_properties_editor (glViewObject *view_object) { - glViewBarcode *view_barcode = (glViewBarcode *)view_object; - GtkWidget *dialog, *wsection; + GtkWidget *editor; + glViewBarcode *view_bc = (glViewBarcode *)view_object; glLabelObject *object; - gdouble x, y, w, h, label_width, label_height; - glTextNode *text_node; - glBarcodeStyle style; - gboolean text_flag; - gboolean checksum_flag; - guint color; - glMerge *merge; - GtkSizeGroup *label_size_group; - GtkWidget *window; gl_debug (DEBUG_VIEW, "START"); - /* retrieve object and query parameters */ - object = gl_view_object_get_object (view_object); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object)); - gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &checksum_flag, &color); - gl_label_get_size (GL_LABEL(object->parent), - &label_width, &label_height); - merge = gl_label_get_merge (GL_LABEL(object->parent)); + object = gl_view_object_get_object (GL_VIEW_OBJECT(view_bc)); + + /* Build editor. */ + editor = gl_object_editor_new (GL_STOCK_BARCODE, _("Barcode object properties"), + GL_OBJECT_EDITOR_POSITION_PAGE, + GL_OBJECT_EDITOR_SIZE_PAGE, + GL_OBJECT_EDITOR_BC_PAGE, + GL_OBJECT_EDITOR_DATA_PAGE, + 0); + + /* Update */ + update_editor_from_object_cb (object, GL_OBJECT_EDITOR(editor)); + update_editor_from_move_cb (object, 0, 0, GL_OBJECT_EDITOR(editor)); + update_editor_from_label_cb (object->parent, GL_OBJECT_EDITOR(editor)); - /*-----------------------------------------------------------------*/ - /* Build dialog. */ - /*-----------------------------------------------------------------*/ - window = gtk_widget_get_toplevel ( - GTK_WIDGET(gl_view_object_get_view(view_object))); - dialog = gl_hig_dialog_new_with_buttons ( _("Edit barcode object properties"), - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL ); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (response_cb), view_object); - - label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - /*---------------------------*/ - /* Data section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Data")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - - /* barcode data */ - view_barcode->private->bc_data = gl_wdgt_bc_data_new (merge); - gl_wdgt_bc_data_set_label_size_group (GL_WDGT_BC_DATA(view_barcode->private->bc_data), - label_size_group); - gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data), - (merge != NULL), - text_node); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_barcode->private->bc_data); - g_signal_connect ( G_OBJECT(view_barcode->private->bc_data), - "changed", G_CALLBACK (bc_data_changed_cb), - view_barcode); - - - /*---------------------------*/ - /* Appearance section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Properties")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - - /* Barcode style widget */ - view_barcode->private->bc_style = gl_wdgt_bc_style_new (); - gl_wdgt_bc_style_set_label_size_group (GL_WDGT_BC_STYLE(view_barcode->private->bc_style), - label_size_group); - gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE (view_barcode->private->bc_style), - style, text_flag, checksum_flag); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_barcode->private->bc_style); - g_signal_connect (G_OBJECT (view_barcode->private->bc_style), - "changed", G_CALLBACK (bc_style_changed_cb), - view_barcode); - - /* barcode props entry */ - gl_debug (DEBUG_VIEW, "Creating props entry..."); - view_barcode->private->bc_props = gl_wdgt_bc_props_new (); - gl_wdgt_bc_props_set_label_size_group (GL_WDGT_BC_PROPS(view_barcode->private->bc_props), - label_size_group); - gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props), - color); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_barcode->private->bc_props); - g_signal_connect ( G_OBJECT(view_barcode->private->bc_props), - "changed", G_CALLBACK (bc_props_changed_cb), - view_barcode); - - - /*----------------------------*/ - /* Position section */ - /*----------------------------*/ - wsection = gl_hig_category_new (_("Position")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - - /* ------ Position Frame ------ */ - view_barcode->private->position = gl_wdgt_position_new (); - gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_barcode->private->position), - label_size_group); - gl_wdgt_position_set_params (GL_WDGT_POSITION (view_barcode->private->position), - x, y, - label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_barcode->private->position); - g_signal_connect (G_OBJECT (view_barcode->private->position), - "changed", - G_CALLBACK(position_changed_cb), view_barcode); - - - /*----------------------------*/ - /* Track object changes. */ - /*----------------------------*/ + /* Connect signals. */ + g_signal_connect (G_OBJECT (editor), "changed", + G_CALLBACK(update_object_from_editor_cb), object); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_dialog_cb), view_barcode); + G_CALLBACK (update_editor_from_object_cb), editor); g_signal_connect (G_OBJECT (object), "moved", - G_CALLBACK (update_dialog_from_move_cb), - view_barcode); + G_CALLBACK (update_editor_from_move_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "size_changed", + G_CALLBACK (update_editor_from_label_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "merge_changed", + G_CALLBACK (update_editor_from_label_cb), editor); gl_debug (DEBUG_VIEW, "END"); - return dialog; + return editor; } /*---------------------------------------------------------------------------*/ -/* PRIVATE. "Response" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -response_cb (GtkDialog *dialog, - gint response, - glViewBarcode *view_barcode) +update_canvas_item_from_object_cb (glLabelObject *object, + glViewBarcode *view_bc) { - glLabelObject *object; - gl_debug (DEBUG_VIEW, "START"); - g_return_if_fail(dialog != NULL); - g_return_if_fail(GTK_IS_DIALOG(dialog)); - - switch(response) { - case GTK_RESPONSE_CLOSE: - gtk_widget_hide (GTK_WIDGET(dialog)); - break; - case GTK_RESPONSE_DELETE_EVENT: - /* Dialog destroyed, remove callbacks that reference it. */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); - - g_signal_handlers_disconnect_by_func (object, update_dialog_cb, - view_barcode); - g_signal_handlers_disconnect_by_func (object, update_dialog_from_move_cb, - view_barcode); - break; - default: - g_print ("response = %d", response); - g_assert_not_reached(); - } + /* Adjust appearance of analogous canvas item. */ + draw_barcode (view_bc); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. barcode data "changed" callback. */ +/* PRIVATE. editor "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -bc_data_changed_cb (glWdgtBCData *bc_data, - glViewBarcode *view_barcode) +update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object) { - glLabelObject *object; - glTextNode *text_node; + gdouble x, y, w, h; + glTextNode *text_node; + glBarcodeStyle style; + gboolean text_flag, cs_flag; + guint color; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); - - text_node = gl_wdgt_bc_data_get_data (bc_data); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - - gl_text_node_free (&text_node); + update_editor_from_object_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); - gl_debug (DEBUG_VIEW, "END"); -} -/*---------------------------------------------------------------------------*/ -/* PRIVATE. barcode props "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -bc_props_changed_cb (glWdgtBCProps *text_props, - glViewBarcode *view_barcode) -{ - glLabelObject *object; - glBarcodeStyle style; - gboolean text_flag; - gboolean checksum_flag; - guint color; + gl_object_editor_get_position (editor, &x, &y); + gl_label_object_set_position (object, x, y); - gl_debug (DEBUG_VIEW, "START"); + gl_object_editor_get_size (editor, &w, &h); + gl_label_object_set_size (object, w, h); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); - - gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &checksum_flag, &color); - gl_wdgt_bc_props_get_params (text_props, &color); + text_node = gl_object_editor_get_data (editor); + gl_label_barcode_set_data (GL_LABEL_BARCODE(object), text_node); + gl_text_node_free (&text_node); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); + gl_object_editor_get_bc_style (editor, &style, &text_flag, &cs_flag); + color = gl_object_editor_get_bc_color (editor); gl_label_barcode_set_props (GL_LABEL_BARCODE(object), - style, text_flag, checksum_flag, color); + style, text_flag, cs_flag, color); + g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); + update_editor_from_object_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. barcode style "changed" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -bc_style_changed_cb (glWdgtBCStyle *bc_style, - glViewBarcode *view_barcode) +update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor) { - glLabelObject *object; + gdouble w, h; + glTextNode *text_node; glBarcodeStyle style; - gboolean text_flag; - gboolean checksum_flag; + gboolean text_flag, cs_flag; guint color; - + glMerge *merge; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); + gl_label_object_get_size (object, &w, &h); + gl_object_editor_set_size (editor, w, h); gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &checksum_flag, &color); - gl_wdgt_bc_style_get_params (bc_style, &style, &text_flag, &checksum_flag); + &style, &text_flag, &cs_flag, &color); + gl_object_editor_set_bc_style (editor, style, text_flag, cs_flag); + gl_object_editor_set_bc_color (editor, color); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - gl_label_barcode_set_props (GL_LABEL_BARCODE(object), - style, text_flag, checksum_flag, color); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - - gl_debug (DEBUG_VIEW, "END"); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. position "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -position_changed_cb (glWdgtPosition *position, - glViewBarcode *view_barcode) -{ - glLabelObject *object; - gdouble x, y; - - gl_debug (DEBUG_VIEW, "START"); - - gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y); - - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_barcode)); + text_node = gl_label_barcode_get_data (GL_LABEL_BARCODE(object)); + merge = gl_label_get_merge (GL_LABEL(object->parent)); + gl_object_editor_set_data (editor, (merge != NULL), text_node); + gl_text_node_free (&text_node); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); - gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_barcode); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ +/* PRIVATE. label object "moved" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_cb (glLabelObject *object, - glViewBarcode *view_barcode) +update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor) { gdouble x, y; - glTextNode *text_node; - glBarcodeStyle style; - gboolean text_flag; - gboolean checksum_flag; - guint color; - glMerge *merge; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - text_node = gl_label_barcode_get_data(GL_LABEL_BARCODE(object)); - gl_label_barcode_get_props (GL_LABEL_BARCODE(object), - &style, &text_flag, &checksum_flag, &color); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - merge = gl_label_get_merge (GL_LABEL(object->parent)); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_data), - bc_data_changed_cb, view_barcode); - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_props), - bc_props_changed_cb, view_barcode); - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->bc_style), - bc_style_changed_cb, view_barcode); - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position), - position_changed_cb, view_barcode); - - /* Update widgets in property dialog */ - - gl_wdgt_bc_data_set_data (GL_WDGT_BC_DATA(view_barcode->private->bc_data), - (merge != NULL), - text_node); - gl_wdgt_bc_data_set_field_defs (GL_WDGT_BC_DATA(view_barcode->private->bc_data), - merge); - gl_wdgt_bc_props_set_params (GL_WDGT_BC_PROPS(view_barcode->private->bc_props), - color); - gl_wdgt_bc_style_set_params (GL_WDGT_BC_STYLE(view_barcode->private->bc_style), - style, text_flag, checksum_flag); - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position), - x, y); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_data), - bc_data_changed_cb, view_barcode); - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_props), - bc_props_changed_cb, view_barcode); - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->bc_style), - bc_style_changed_cb, view_barcode); - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position), - position_changed_cb, view_barcode); - - gl_text_node_free (&text_node); + gl_label_object_get_position (object, &x, &y); + gl_object_editor_set_position (editor, x, y); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "moved" callback. */ +/* PRIVATE. label "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewBarcode *view_barcode) +update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor) { - gdouble x, y; + gdouble label_width, label_height; + glMerge *merge; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_barcode->private->position), - position_changed_cb, view_barcode); - - /* Update widgets in property dialog */ - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_barcode->private->position), - x, y); + gl_label_get_size (label, &label_width, &label_height); + gl_object_editor_set_max_position (GL_OBJECT_EDITOR (editor), + label_width, label_height); + gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor), + label_width, label_height); - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_barcode->private->position), - position_changed_cb, view_barcode); + merge = gl_label_get_merge (label); + gl_object_editor_set_key_names (editor, merge); gl_debug (DEBUG_VIEW, "END"); } diff --git a/glabels2/src/view-box.c b/glabels2/src/view-box.c index 67b94647..158d5353 100644 --- a/glabels2/src/view-box.c +++ b/glabels2/src/view-box.c @@ -3,7 +3,7 @@ * * view_box.c: GLabels label box object widget * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2003 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,11 +26,9 @@ #include "view-highlight.h" -#include "wdgt-line.h" -#include "wdgt-fill.h" -#include "wdgt-size.h" -#include "wdgt-position.h" #include "color.h" +#include "object-editor.h" +#include "stock.h" #include "pixmaps/cursor_box.xbm" #include "pixmaps/cursor_box_mask.xbm" @@ -49,14 +47,6 @@ struct _glViewBoxPrivate { GnomeCanvasItem *item; - - /* Property dialog Page 0 widgets */ - GtkWidget *line; - GtkWidget *fill; - - /* Property dialog Page 1 widgets */ - GtkWidget *position; - GtkWidget *size; }; /*========================================================*/ @@ -70,38 +60,29 @@ static glViewObjectClass *parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_box_class_init (glViewBoxClass *klass); -static void gl_view_box_instance_init (glViewBox *view_box); -static void gl_view_box_finalize (GObject *object); - -static void update_view_box_cb (glLabelObject *object, - glViewBox *view_box); - -static GtkWidget *construct_properties_dialog (glViewObject *view_object); +static void gl_view_box_class_init (glViewBoxClass *klass); +static void gl_view_box_instance_init (glViewBox *view_box); +static void gl_view_box_finalize (GObject *object); -static void response_cb (GtkDialog *dialog, - gint response, - glViewBox *view_box); +static GtkWidget *construct_properties_editor (glViewObject *view_object); -static void line_changed_cb (glWdgtLine *line, - glViewBox *view_box); +static void update_canvas_item_from_object_cb (glLabelObject *object, + glViewBox *view_box); -static void fill_changed_cb (glWdgtFill *fill, - glViewBox *view_box); +static void update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object); -static void position_changed_cb (glWdgtPosition *position, - glViewBox *view_box); +static void update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor); -static void size_changed_cb (glWdgtSize *size, - glViewBox *view_box); +static void update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor); -static void update_dialog_cb (glLabelObject *object, - glViewBox *view_box); +static void update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor); -static void update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewBox *view_box); /*****************************************************************************/ @@ -144,7 +125,7 @@ gl_view_box_class_init (glViewBoxClass *klass) object_class->finalize = gl_view_box_finalize; - view_object_class->construct_dialog = construct_properties_dialog; + view_object_class->construct_editor = construct_properties_editor; gl_debug (DEBUG_VIEW, "END"); } @@ -184,7 +165,6 @@ gl_view_box_new (glLabelBox *object, gdouble line_width; guint line_color, fill_color; gdouble w, h; - GtkMenu *menu; gl_debug (DEBUG_VIEW, "START"); g_return_if_fail (object && GL_IS_LABEL_BOX (object)); @@ -217,391 +197,192 @@ gl_view_box_new (glLabelBox *object, NULL); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_view_box_cb), view_box); + G_CALLBACK (update_canvas_item_from_object_cb), view_box); gl_debug (DEBUG_VIEW, "END"); return GL_VIEW_OBJECT (view_box); } -/*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -update_view_box_cb (glLabelObject *object, - glViewBox *view_box) -{ - gdouble line_width; - guint line_color, fill_color; - gdouble w, h; - - gl_debug (DEBUG_VIEW, "START"); - - /* Query properties of object. */ - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - line_width = gl_label_box_get_line_width(GL_LABEL_BOX(object)); - line_color = gl_label_box_get_line_color(GL_LABEL_BOX(object)); - fill_color = gl_label_box_get_fill_color(GL_LABEL_BOX(object)); - - /* Adjust appearance of analogous canvas item. */ - gnome_canvas_item_set (view_box->private->item, - "x2", w + DELTA, - "y2", h + DELTA, - "width_units", line_width, - "outline_color_rgba", line_color, - "fill_color_rgba", fill_color, - NULL); - - gl_debug (DEBUG_VIEW, "END"); -} - /*****************************************************************************/ /* Create a properties dialog for a box object. */ /*****************************************************************************/ static GtkWidget * -construct_properties_dialog (glViewObject *view_object) +construct_properties_editor (glViewObject *view_object) { + GtkWidget *editor; glViewBox *view_box = (glViewBox *)view_object; - GtkWidget *dialog, *wsection; glLabelObject *object; - gdouble line_width; - guint line_color, fill_color; - gdouble x, y, w, h, label_width, label_height; - GtkSizeGroup *label_size_group; - GtkWidget *window; gl_debug (DEBUG_VIEW, "START"); - /* retrieve object and query parameters */ object = gl_view_object_get_object (GL_VIEW_OBJECT(view_box)); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - line_width = gl_label_box_get_line_width(GL_LABEL_BOX(object)); - line_color = gl_label_box_get_line_color(GL_LABEL_BOX(object)); - fill_color = gl_label_box_get_fill_color(GL_LABEL_BOX(object)); - gl_label_get_size (GL_LABEL(object->parent), - &label_width, &label_height); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - window = gtk_widget_get_toplevel ( - GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_box)))); - dialog = gl_hig_dialog_new_with_buttons ( _("Edit box object properties"), - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL ); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (response_cb), view_box); - - label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - - /*---------------------------*/ - /* Outline section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Outline")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_box->private->line = gl_wdgt_line_new (); - gl_wdgt_line_set_label_size_group (GL_WDGT_LINE(view_box->private->line), - label_size_group); - gl_wdgt_line_set_params (GL_WDGT_LINE (view_box->private->line), - line_width, - line_color); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_box->private->line); - g_signal_connect (G_OBJECT (view_box->private->line), "changed", - G_CALLBACK(line_changed_cb), view_box); - - /*---------------------------*/ - /* Fill section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Fill")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_box->private->fill = gl_wdgt_fill_new (); - gl_wdgt_fill_set_label_size_group (GL_WDGT_FILL(view_box->private->fill), - label_size_group); - gl_wdgt_fill_set_params (GL_WDGT_FILL (view_box->private->fill), - fill_color); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_box->private->fill); - g_signal_connect (G_OBJECT (view_box->private->fill), "changed", - G_CALLBACK(fill_changed_cb), view_box); - - - /*---------------------------*/ - /* Position section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Position")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_box->private->position = gl_wdgt_position_new (); - gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_box->private->position), - label_size_group); - gl_wdgt_position_set_params (GL_WDGT_POSITION (view_box->private->position), - x, y, label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_box->private->position); - g_signal_connect (G_OBJECT (view_box->private->position), "changed", - G_CALLBACK(position_changed_cb), view_box); - - /*---------------------------*/ - /* Size section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Size")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_box->private->size = gl_wdgt_size_new (); - gl_wdgt_size_set_label_size_group (GL_WDGT_SIZE(view_box->private->size), - label_size_group); - gl_wdgt_size_set_params (GL_WDGT_SIZE (view_box->private->size), - w, h, TRUE, label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_box->private->size); - g_signal_connect (G_OBJECT (view_box->private->size), "changed", - G_CALLBACK(size_changed_cb), view_box); - - - /*----------------------------*/ - /* Track object changes. */ - /*----------------------------*/ + + /* Build editor. */ + editor = gl_object_editor_new (GL_STOCK_BOX, _("Box object properties"), + GL_OBJECT_EDITOR_POSITION_PAGE, + GL_OBJECT_EDITOR_SIZE_PAGE, + GL_OBJECT_EDITOR_FILL_PAGE, + GL_OBJECT_EDITOR_LINE_PAGE, + 0); + + /* Update */ + update_editor_from_object_cb (object, GL_OBJECT_EDITOR(editor)); + update_editor_from_move_cb (object, 0, 0, GL_OBJECT_EDITOR(editor)); + update_editor_from_label_cb (object->parent, GL_OBJECT_EDITOR(editor)); + + /* Connect signals. */ + g_signal_connect (G_OBJECT (editor), "changed", + G_CALLBACK(update_object_from_editor_cb), object); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_dialog_cb), view_box); + G_CALLBACK (update_editor_from_object_cb), editor); g_signal_connect (G_OBJECT (object), "moved", - G_CALLBACK (update_dialog_from_move_cb), view_box); + G_CALLBACK (update_editor_from_move_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "size_changed", + G_CALLBACK (update_editor_from_label_cb), editor); gl_debug (DEBUG_VIEW, "END"); - return dialog; + return editor; } /*---------------------------------------------------------------------------*/ -/* PRIVATE. "Response" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -response_cb (GtkDialog *dialog, - gint response, - glViewBox *view_box) +update_canvas_item_from_object_cb (glLabelObject *object, + glViewBox *view_box) { - glLabelObject *object; + gdouble line_width; + guint line_color, fill_color; + gdouble w, h; gl_debug (DEBUG_VIEW, "START"); - g_return_if_fail(dialog != NULL); - g_return_if_fail(GTK_IS_DIALOG(dialog)); - - switch(response) { - - case GTK_RESPONSE_CLOSE: - gtk_widget_hide (GTK_WIDGET(dialog)); - break; - - case GTK_RESPONSE_DELETE_EVENT: - /* Dialog destroyed, remove callbacks that reference it. */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_box)); - - g_signal_handlers_disconnect_by_func (object, update_dialog_cb, view_box); - g_signal_handlers_disconnect_by_func (object, update_dialog_from_move_cb, - view_box); - break; + /* Query properties of object. */ + gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); + line_width = gl_label_box_get_line_width(GL_LABEL_BOX(object)); + line_color = gl_label_box_get_line_color(GL_LABEL_BOX(object)); + fill_color = gl_label_box_get_fill_color(GL_LABEL_BOX(object)); - default: - g_print ("response = %d", response); - g_assert_not_reached (); - } + /* Adjust appearance of analogous canvas item. */ + gnome_canvas_item_set (view_box->private->item, + "x2", w + DELTA, + "y2", h + DELTA, + "width_units", line_width, + "outline_color_rgba", line_color, + "fill_color_rgba", fill_color, + NULL); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. line properties "changed" callback. */ +/* PRIVATE. editor "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -line_changed_cb (glWdgtLine *line, - glViewBox *view_box) +update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object) { - glLabelObject *object; + gdouble w, h; + guint line_color, fill_color; gdouble line_width; - guint line_color; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_box)); - - gl_wdgt_line_get_params (GL_WDGT_LINE (line), - &line_width, - &line_color); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_box); - gl_label_box_set_line_width(GL_LABEL_BOX(object), line_width); - gl_label_box_set_line_color(GL_LABEL_BOX(object), line_color); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_box); - - gl_debug (DEBUG_VIEW, "END"); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. fill properties "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -fill_changed_cb (glWdgtFill *fill, - glViewBox *view_box) -{ - glLabelObject *object; - guint fill_color; - - gl_debug (DEBUG_VIEW, "START"); - - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_box)); - - gl_wdgt_fill_get_params (GL_WDGT_FILL (fill), - &fill_color); - + update_editor_from_object_cb, + editor); g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_box); - gl_label_box_set_fill_color(GL_LABEL_BOX(object), fill_color); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_box); + update_editor_from_move_cb, + editor); - gl_debug (DEBUG_VIEW, "END"); -} + gl_object_editor_get_size (editor, &w, &h); + gl_label_object_set_size (object, w, h); -/*---------------------------------------------------------------------------*/ -/* PRIVATE. position "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -position_changed_cb (glWdgtPosition *position, - glViewBox *view_box) -{ - glLabelObject *object; - gdouble x, y; + fill_color = gl_object_editor_get_fill_color (editor); + gl_label_object_set_fill_color (object, fill_color); - gl_debug (DEBUG_VIEW, "START"); + line_color = gl_object_editor_get_line_color (editor); + gl_label_object_set_line_color (object, line_color); - gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y); + line_width = gl_object_editor_get_line_width (editor); + gl_label_object_set_line_width (object, line_width); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_box)); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_box); - gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_box); + update_editor_from_object_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. size "changed" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -size_changed_cb (glWdgtSize *size, - glViewBox *view_box) +update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor) { - glLabelObject *object; - gdouble w, h; - gboolean keep_aspect_ratio_flag; + gdouble w, h; + guint line_color, fill_color; + gdouble line_width; gl_debug (DEBUG_VIEW, "START"); - gl_wdgt_size_get_size (GL_WDGT_SIZE (size), - &w, &h, &keep_aspect_ratio_flag); + gl_label_object_get_size (object, &w, &h); + gl_object_editor_set_size (editor, w, h); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_box)); + fill_color = gl_label_box_get_fill_color (GL_LABEL_BOX(object)); + gl_object_editor_set_fill_color (editor, fill_color); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_box); - gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_box); + line_color = gl_label_box_get_line_color (GL_LABEL_BOX(object)); + gl_object_editor_set_line_color (editor, line_color); + + line_width = gl_label_box_get_line_width (GL_LABEL_BOX(object)); + gl_object_editor_set_line_width (editor, line_width); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ +/* PRIVATE. label object "moved" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_cb (glLabelObject *object, - glViewBox *view_box) +update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor) { - gdouble line_width; - guint line_color, fill_color; - gdouble x, y, w, h; + gdouble x, y; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - line_width = gl_label_box_get_line_width(GL_LABEL_BOX(object)); - line_color = gl_label_box_get_line_color(GL_LABEL_BOX(object)); - fill_color = gl_label_box_get_fill_color(GL_LABEL_BOX(object)); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_box->private->line), - line_changed_cb, view_box); - g_signal_handlers_block_by_func (G_OBJECT(view_box->private->fill), - fill_changed_cb, view_box); - g_signal_handlers_block_by_func (G_OBJECT(view_box->private->position), - position_changed_cb, view_box); - g_signal_handlers_block_by_func (G_OBJECT(view_box->private->size), - size_changed_cb, view_box); - - /* Update widgets in property dialog */ - gl_wdgt_line_set_params (GL_WDGT_LINE (view_box->private->line), - line_width, - line_color); - gl_wdgt_fill_set_params (GL_WDGT_FILL (view_box->private->fill), - fill_color); - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_box->private->position), - x, y); - gl_wdgt_size_set_size (GL_WDGT_SIZE(view_box->private->size), w, h); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_box->private->line), - line_changed_cb, view_box); - g_signal_handlers_unblock_by_func (G_OBJECT(view_box->private->fill), - fill_changed_cb, view_box); - g_signal_handlers_unblock_by_func (G_OBJECT(view_box->private->position), - position_changed_cb, view_box); - g_signal_handlers_unblock_by_func (G_OBJECT(view_box->private->size), - size_changed_cb, view_box); - + gl_label_object_get_position (object, &x, &y); + gl_object_editor_set_position (editor, x, y); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "moved" callback. */ +/* PRIVATE. label "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewBox *view_box) +update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor) { - gdouble x, y; + gdouble label_width, label_height; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_box->private->position), - position_changed_cb, view_box); - - /* Update widgets in property dialog */ - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_box->private->position), - x, y); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_box->private->position), - position_changed_cb, view_box); + gl_label_get_size (label, &label_width, &label_height); + gl_object_editor_set_max_position (GL_OBJECT_EDITOR (editor), + label_width, label_height); + gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor), + label_width, label_height); gl_debug (DEBUG_VIEW, "END"); } @@ -647,12 +428,12 @@ gl_view_box_create_event_handler (GnomeCanvas *canvas, GdkEvent *event, glView *view) { - static gdouble x0, y0; - static gboolean dragging = FALSE; + static gdouble x0, y0; + static gboolean dragging = FALSE; static glViewObject *view_box; static GObject *object; - guint line_color, fill_color; - gdouble x, y, w, h; + guint line_color, fill_color; + gdouble x, y, w, h; gl_debug (DEBUG_VIEW, ""); diff --git a/glabels2/src/view-ellipse.c b/glabels2/src/view-ellipse.c index 656aeb84..837b5e03 100644 --- a/glabels2/src/view-ellipse.c +++ b/glabels2/src/view-ellipse.c @@ -3,7 +3,7 @@ * * view_ellipse.c: GLabels label ellipse object widget * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2003 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,11 +26,9 @@ #include "view-highlight.h" -#include "wdgt-line.h" -#include "wdgt-fill.h" -#include "wdgt-size.h" -#include "wdgt-position.h" #include "color.h" +#include "object-editor.h" +#include "stock.h" #include "pixmaps/cursor_ellipse.xbm" #include "pixmaps/cursor_ellipse_mask.xbm" @@ -48,15 +46,7 @@ /*========================================================*/ struct _glViewEllipsePrivate { - GnomeCanvasItem *item; - - /* Property dialog Page 0 widgets */ - GtkWidget *line; - GtkWidget *fill; - - /* Property dialog Page 1 widgets */ - GtkWidget *position; - GtkWidget *size; + GnomeCanvasItem *item; }; /*========================================================*/ @@ -70,38 +60,29 @@ static glViewObjectClass *parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_ellipse_class_init (glViewEllipseClass *klass); -static void gl_view_ellipse_instance_init (glViewEllipse *view_ellipse); -static void gl_view_ellipse_finalize (GObject *object); - -static void update_view_ellipse_cb (glLabelObject *object, - glViewEllipse *view_ellipse); - -static GtkWidget *construct_properties_dialog (glViewObject *view_object); +static void gl_view_ellipse_class_init (glViewEllipseClass *klass); +static void gl_view_ellipse_instance_init (glViewEllipse *view_ellipse); +static void gl_view_ellipse_finalize (GObject *object); -static void response_cb (GtkDialog *dialog, - gint response, - glViewEllipse *view_ellipse); +static GtkWidget *construct_properties_editor (glViewObject *view_object); -static void line_changed_cb (glWdgtLine *line, - glViewEllipse *view_ellipse); +static void update_canvas_item_from_object_cb (glLabelObject *object, + glViewEllipse *view_ellipse); -static void fill_changed_cb (glWdgtFill *fill, - glViewEllipse *view_ellipse); +static void update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object); -static void position_changed_cb (glWdgtPosition *position, - glViewEllipse *view_ellipse); +static void update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor); -static void size_changed_cb (glWdgtSize *size, - glViewEllipse *view_ellipse); +static void update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor); -static void update_dialog_cb (glLabelObject *object, - glViewEllipse *view_ellipse); +static void update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor); -static void update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewEllipse *view_ellipse); /*****************************************************************************/ @@ -144,7 +125,7 @@ gl_view_ellipse_class_init (glViewEllipseClass *klass) object_class->finalize = gl_view_ellipse_finalize; - view_object_class->construct_dialog = construct_properties_dialog; + view_object_class->construct_editor = construct_properties_editor; gl_debug (DEBUG_VIEW, "END"); } @@ -178,13 +159,12 @@ gl_view_ellipse_finalize (GObject *object) /*****************************************************************************/ glViewObject * gl_view_ellipse_new (glLabelEllipse *object, - glView *view) + glView *view) { - glViewEllipse *view_ellipse; + glViewEllipse *view_ellipse; gdouble line_width; guint line_color, fill_color; gdouble w, h; - GtkMenu *menu; gl_debug (DEBUG_VIEW, "START"); g_return_if_fail (object && GL_IS_LABEL_ELLIPSE (object)); @@ -217,19 +197,61 @@ gl_view_ellipse_new (glLabelEllipse *object, NULL); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_view_ellipse_cb), view_ellipse); + G_CALLBACK (update_canvas_item_from_object_cb), view_ellipse); gl_debug (DEBUG_VIEW, "END"); return GL_VIEW_OBJECT (view_ellipse); } +/*****************************************************************************/ +/* Create a properties editor for an ellipse object. */ +/*****************************************************************************/ +static GtkWidget * +construct_properties_editor (glViewObject *view_object) +{ + GtkWidget *editor; + glViewEllipse *view_ellipse = (glViewEllipse *)view_object; + glLabelObject *object; + + gl_debug (DEBUG_VIEW, "START"); + + object = gl_view_object_get_object (GL_VIEW_OBJECT(view_ellipse)); + + /* Build editor. */ + editor = gl_object_editor_new (GL_STOCK_ELLIPSE, _("Ellipse object properties"), + GL_OBJECT_EDITOR_POSITION_PAGE, + GL_OBJECT_EDITOR_SIZE_PAGE, + GL_OBJECT_EDITOR_FILL_PAGE, + GL_OBJECT_EDITOR_LINE_PAGE, + 0); + + /* Update */ + update_editor_from_object_cb (object, GL_OBJECT_EDITOR(editor)); + update_editor_from_move_cb (object, 0, 0, GL_OBJECT_EDITOR(editor)); + update_editor_from_label_cb (object->parent, GL_OBJECT_EDITOR(editor)); + + /* Connect signals. */ + g_signal_connect (G_OBJECT (editor), "changed", + G_CALLBACK(update_object_from_editor_cb), object); + g_signal_connect (G_OBJECT (object), "changed", + G_CALLBACK (update_editor_from_object_cb), editor); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_editor_from_move_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "size_changed", + G_CALLBACK (update_editor_from_label_cb), editor); + + gl_debug (DEBUG_VIEW, "END"); + + return editor; +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_view_ellipse_cb (glLabelObject *object, - glViewEllipse *view_ellipse) +update_canvas_item_from_object_cb (glLabelObject *object, + glViewEllipse *view_ellipse) { gdouble line_width; guint line_color, fill_color; @@ -255,351 +277,116 @@ update_view_ellipse_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "END"); } -/*****************************************************************************/ -/* Create a properties dialog for a ellipse object. */ -/*****************************************************************************/ -static GtkWidget * -construct_properties_dialog (glViewObject *view_object) -{ - glViewEllipse *view_ellipse = (glViewEllipse *)view_object; - GtkWidget *dialog, *wsection; - glLabelObject *object; - gdouble line_width; - guint line_color, fill_color; - gdouble x, y, w, h, label_width, label_height; - GtkSizeGroup *label_size_group; - GtkWidget *window; - - gl_debug (DEBUG_VIEW, "START"); - - /* retrieve object and query parameters */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_ellipse)); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - line_width = gl_label_ellipse_get_line_width(GL_LABEL_ELLIPSE(object)); - line_color = gl_label_ellipse_get_line_color(GL_LABEL_ELLIPSE(object)); - fill_color = gl_label_ellipse_get_fill_color(GL_LABEL_ELLIPSE(object)); - gl_label_get_size (GL_LABEL(object->parent), - &label_width, &label_height); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - window = gtk_widget_get_toplevel ( - GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_ellipse)))); - dialog = gl_hig_dialog_new_with_buttons ( _("Edit ellipse object properties"), - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL ); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (response_cb), view_ellipse); - - label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - - /*---------------------------*/ - /* Outline section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Outline")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_ellipse->private->line = gl_wdgt_line_new (); - gl_wdgt_line_set_label_size_group (GL_WDGT_LINE(view_ellipse->private->line), - label_size_group); - gl_wdgt_line_set_params (GL_WDGT_LINE (view_ellipse->private->line), - line_width, - line_color); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_ellipse->private->line); - g_signal_connect (G_OBJECT (view_ellipse->private->line), "changed", - G_CALLBACK(line_changed_cb), view_ellipse); - - /*---------------------------*/ - /* Fill section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Fill")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_ellipse->private->fill = gl_wdgt_fill_new (); - gl_wdgt_fill_set_label_size_group (GL_WDGT_FILL(view_ellipse->private->fill), - label_size_group); - gl_wdgt_fill_set_params (GL_WDGT_FILL (view_ellipse->private->fill), - fill_color); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_ellipse->private->fill); - g_signal_connect (G_OBJECT (view_ellipse->private->fill), "changed", - G_CALLBACK(fill_changed_cb), view_ellipse); - - - /*---------------------------*/ - /* Position section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Position")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_ellipse->private->position = gl_wdgt_position_new (); - gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_ellipse->private->position), - label_size_group); - gl_wdgt_position_set_params (GL_WDGT_POSITION (view_ellipse->private->position), - x, y, label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_ellipse->private->position); - g_signal_connect (G_OBJECT (view_ellipse->private->position), "changed", - G_CALLBACK(position_changed_cb), view_ellipse); - - /*---------------------------*/ - /* Size section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Size")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_ellipse->private->size = gl_wdgt_size_new (); - gl_wdgt_size_set_label_size_group (GL_WDGT_SIZE(view_ellipse->private->size), - label_size_group); - gl_wdgt_size_set_params (GL_WDGT_SIZE (view_ellipse->private->size), - w, h, TRUE, label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_ellipse->private->size); - g_signal_connect (G_OBJECT (view_ellipse->private->size), "changed", - G_CALLBACK(size_changed_cb), view_ellipse); - - - /*----------------------------*/ - /* Track object changes. */ - /*----------------------------*/ - g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_dialog_cb), view_ellipse); - g_signal_connect (G_OBJECT (object), "moved", - G_CALLBACK (update_dialog_from_move_cb), - view_ellipse); - - gl_debug (DEBUG_VIEW, "END"); - - return dialog; -} - /*---------------------------------------------------------------------------*/ -/* PRIVATE. "Response" callback. */ +/* PRIVATE. editor "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -response_cb (GtkDialog *dialog, - gint response, - glViewEllipse *view_ellipse) +update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object) { - glLabelObject *object; - - gl_debug (DEBUG_VIEW, "START"); - - g_return_if_fail(dialog != NULL); - g_return_if_fail(GTK_IS_DIALOG(dialog)); - - switch(response) { - case GTK_RESPONSE_CLOSE: - gtk_widget_hide (GTK_WIDGET(dialog)); - break; - case GTK_RESPONSE_DELETE_EVENT: - /* Dialog destroyed, remove callbacks that reference it. */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_ellipse)); - - g_signal_handlers_disconnect_by_func (object, update_dialog_cb, - view_ellipse); - g_signal_handlers_disconnect_by_func (object, update_dialog_from_move_cb, - view_ellipse); - break; - default: - g_print ("response = %d", response); - g_assert_not_reached(); - } - - gl_debug (DEBUG_VIEW, "END"); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. line properties "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -line_changed_cb (glWdgtLine *line, - glViewEllipse *view_ellipse) -{ - glLabelObject *object; + gdouble x, y, w, h; + guint line_color, fill_color; gdouble line_width; - guint line_color; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_ellipse)); - - gl_wdgt_line_get_params (GL_WDGT_LINE (line), - &line_width, - &line_color); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_ellipse); - gl_label_ellipse_set_line_width(GL_LABEL_ELLIPSE(object), line_width); - gl_label_ellipse_set_line_color(GL_LABEL_ELLIPSE(object), line_color); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_ellipse); - - gl_debug (DEBUG_VIEW, "END"); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. fill properties "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -fill_changed_cb (glWdgtFill *fill, - glViewEllipse *view_ellipse) -{ - glLabelObject *object; - guint fill_color; - - gl_debug (DEBUG_VIEW, "START"); + update_editor_from_object_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_ellipse)); - gl_wdgt_fill_get_params (GL_WDGT_FILL (fill), - &fill_color); + gl_object_editor_get_position (editor, &x, &y); + gl_label_object_set_position (object, x, y); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_ellipse); - gl_label_ellipse_set_fill_color(GL_LABEL_ELLIPSE(object), fill_color); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_ellipse); + gl_object_editor_get_size (editor, &w, &h); + gl_label_object_set_size (object, w, h); - gl_debug (DEBUG_VIEW, "END"); -} + fill_color = gl_object_editor_get_fill_color (editor); + gl_label_object_set_fill_color (object, fill_color); -/*---------------------------------------------------------------------------*/ -/* PRIVATE. position "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -position_changed_cb (glWdgtPosition *position, - glViewEllipse *view_ellipse) -{ - glLabelObject *object; - gdouble x, y; + line_color = gl_object_editor_get_line_color (editor); + gl_label_object_set_line_color (object, line_color); - gl_debug (DEBUG_VIEW, "START"); + line_width = gl_object_editor_get_line_width (editor); + gl_label_object_set_line_width (object, line_width); - gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_ellipse)); - - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_ellipse); - gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_ellipse); + update_editor_from_object_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. size "changed" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -size_changed_cb (glWdgtSize *size, - glViewEllipse *view_ellipse) +update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor) { - glLabelObject *object; - gdouble w, h; - gboolean keep_aspect_ratio_flag; + gdouble w, h; + guint line_color, fill_color; + gdouble line_width; gl_debug (DEBUG_VIEW, "START"); - gl_wdgt_size_get_size (GL_WDGT_SIZE (size), - &w, &h, &keep_aspect_ratio_flag); + gl_label_object_get_size (object, &w, &h); + gl_object_editor_set_size (editor, w, h); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_ellipse)); + fill_color = gl_label_ellipse_get_fill_color (GL_LABEL_ELLIPSE(object)); + gl_object_editor_set_fill_color (editor, fill_color); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_ellipse); - gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_ellipse); + line_color = gl_label_ellipse_get_line_color (GL_LABEL_ELLIPSE(object)); + gl_object_editor_set_line_color (editor, line_color); + + line_width = gl_label_ellipse_get_line_width (GL_LABEL_ELLIPSE(object)); + gl_object_editor_set_line_width (editor, line_width); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ +/* PRIVATE. label object "moved" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_cb (glLabelObject *object, - glViewEllipse *view_ellipse) +update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor) { - gdouble line_width; - guint line_color, fill_color; - gdouble x, y, w, h; + gdouble x, y; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - line_width = gl_label_ellipse_get_line_width(GL_LABEL_ELLIPSE(object)); - line_color = gl_label_ellipse_get_line_color(GL_LABEL_ELLIPSE(object)); - fill_color = gl_label_ellipse_get_fill_color(GL_LABEL_ELLIPSE(object)); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_ellipse->private->line), - line_changed_cb, view_ellipse); - g_signal_handlers_block_by_func (G_OBJECT(view_ellipse->private->fill), - fill_changed_cb, view_ellipse); - g_signal_handlers_block_by_func (G_OBJECT(view_ellipse->private->position), - position_changed_cb, view_ellipse); - g_signal_handlers_block_by_func (G_OBJECT(view_ellipse->private->size), - size_changed_cb, view_ellipse); - - /* Update widgets in property dialog */ - gl_wdgt_line_set_params (GL_WDGT_LINE (view_ellipse->private->line), - line_width, - line_color); - gl_wdgt_fill_set_params (GL_WDGT_FILL (view_ellipse->private->fill), - fill_color); - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_ellipse->private->position), - x, y); - gl_wdgt_size_set_size (GL_WDGT_SIZE(view_ellipse->private->size), w, h); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_ellipse->private->line), - line_changed_cb, view_ellipse); - g_signal_handlers_unblock_by_func (G_OBJECT(view_ellipse->private->fill), - fill_changed_cb, view_ellipse); - g_signal_handlers_unblock_by_func (G_OBJECT(view_ellipse->private->position), - position_changed_cb, view_ellipse); - g_signal_handlers_unblock_by_func (G_OBJECT(view_ellipse->private->size), - size_changed_cb, view_ellipse); + gl_label_object_get_position (object, &x, &y); + gl_object_editor_set_position (editor, x, y); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "moved" callback. */ +/* PRIVATE. label "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewEllipse *view_ellipse) +update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor) { - gdouble x, y; + gdouble label_width, label_height; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_ellipse->private->position), - position_changed_cb, view_ellipse); - - /* Update widgets in property dialog */ - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_ellipse->private->position), - x, y); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_ellipse->private->position), - position_changed_cb, view_ellipse); + gl_label_get_size (label, &label_width, &label_height); + gl_object_editor_set_max_position (GL_OBJECT_EDITOR (editor), + label_width, label_height); + gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor), + label_width, label_height); gl_debug (DEBUG_VIEW, "END"); } @@ -645,12 +432,12 @@ gl_view_ellipse_create_event_handler (GnomeCanvas *canvas, GdkEvent *event, glView *view) { - static gdouble x0, y0; - static gboolean dragging = FALSE; + static gdouble x0, y0; + static gboolean dragging = FALSE; static glViewObject *view_ellipse; static GObject *object; - guint line_color, fill_color; - gdouble x, y, w, h; + guint line_color, fill_color; + gdouble x, y, w, h; gl_debug (DEBUG_VIEW, ""); @@ -660,11 +447,11 @@ gl_view_ellipse_create_event_handler (GnomeCanvas *canvas, switch (event->button.button) { case 1: dragging = TRUE; - gnome_canvas_item_grab (canvas->root, - GDK_POINTER_MOTION_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_BUTTON_PRESS_MASK, - NULL, event->button.time); + gnome_canvas_item_grab ( canvas->root, + GDK_POINTER_MOTION_MASK | + GDK_BUTTON_RELEASE_MASK | + GDK_BUTTON_PRESS_MASK, + NULL, event->button.time); gnome_canvas_window_to_world (canvas, event->button.x, event->button.y, &x, &y); @@ -676,13 +463,13 @@ gl_view_ellipse_create_event_handler (GnomeCanvas *canvas, line_color = gl_color_set_opacity (gl_view_get_default_line_color(view), 0.5); fill_color = gl_color_set_opacity (gl_view_get_default_fill_color(view), 0.5); gl_label_ellipse_set_line_width (GL_LABEL_ELLIPSE(object), - gl_view_get_default_line_width (view)); + gl_view_get_default_line_width(view)); gl_label_ellipse_set_line_color (GL_LABEL_ELLIPSE(object), - line_color); + line_color); gl_label_ellipse_set_fill_color (GL_LABEL_ELLIPSE(object), - fill_color); + fill_color); view_ellipse = gl_view_ellipse_new (GL_LABEL_ELLIPSE(object), - view); + view); x0 = x; y0 = y; return TRUE; @@ -710,9 +497,9 @@ gl_view_ellipse_create_event_handler (GnomeCanvas *canvas, gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); gl_label_ellipse_set_line_color (GL_LABEL_ELLIPSE(object), - gl_view_get_default_line_color (view)); + gl_view_get_default_line_color(view)); gl_label_ellipse_set_fill_color (GL_LABEL_ELLIPSE(object), - gl_view_get_default_fill_color (view)); + gl_view_get_default_fill_color(view)); gl_view_unselect_all (view); gl_view_object_select (GL_VIEW_OBJECT(view_ellipse)); gl_view_arrow_mode (view); diff --git a/glabels2/src/view-image.c b/glabels2/src/view-image.c index 5ae36970..c48f7396 100644 --- a/glabels2/src/view-image.c +++ b/glabels2/src/view-image.c @@ -3,7 +3,7 @@ * * view_image.c: GLabels label image object widget * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2003 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,11 +26,9 @@ #include "view-highlight.h" -#include "wdgt-image-select.h" -#include "wdgt-line.h" -#include "wdgt-fill.h" -#include "wdgt-size.h" -#include "wdgt-position.h" +#include "color.h" +#include "object-editor.h" +#include "stock.h" #include "pixmaps/cursor_image.xbm" #include "pixmaps/cursor_image_mask.xbm" @@ -48,14 +46,7 @@ /*========================================================*/ struct _glViewImagePrivate { - GnomeCanvasItem *item; - - /* Page 0 widgets */ - GtkWidget *pixmap_entry; - - /* Page 1 widgets */ - GtkWidget *position; - GtkWidget *size; + GnomeCanvasItem *item; }; /*========================================================*/ @@ -67,43 +58,33 @@ static glViewObjectClass *parent_class = NULL; /* Save state of image file entry */ static gchar *image_path = NULL; - /*========================================================*/ /* Private function prototypes. */ /*========================================================*/ -static void gl_view_image_class_init (glViewImageClass *klass); -static void gl_view_image_instance_init (glViewImage *view_image); -static void gl_view_image_finalize (GObject *object); - -static void update_view_image_cb (glLabelObject *object, - glViewImage *view_image); +static void gl_view_image_class_init (glViewImageClass *klass); +static void gl_view_image_instance_init (glViewImage *view_image); +static void gl_view_image_finalize (GObject *object); -static GtkWidget *construct_properties_dialog (glViewObject *view_object); +static GtkWidget *construct_properties_editor (glViewObject *view_object); -static void response_cb (GtkDialog *dialog, - gint response, - glViewImage *view_image); +static void update_canvas_item_from_object_cb (glLabelObject *object, + glViewImage *view_image); -static void file_changed_cb (GtkEntry *pixmap_entry, - glViewImage *view_image); +static void update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object); -static void position_changed_cb (glWdgtPosition *position, - glViewImage *view_image); +static void update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor); -static void size_changed_cb (glWdgtSize *size, - glViewImage *view_image); +static void update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor); -static void size_reset_cb (GtkButton *button, - glViewImage *view_image); +static void update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor); -static void update_dialog_cb (glLabelObject *object, - glViewImage *view_image); - -static void update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewImage *view_image); /*****************************************************************************/ @@ -146,7 +127,7 @@ gl_view_image_class_init (glViewImageClass *klass) object_class->finalize = gl_view_image_finalize; - view_object_class->construct_dialog = construct_properties_dialog; + view_object_class->construct_editor = construct_properties_editor; gl_debug (DEBUG_VIEW, "END"); } @@ -176,7 +157,7 @@ gl_view_image_finalize (GObject *object) } /*****************************************************************************/ -/* NEW image object view. */ +/* NEW image object view. */ /*****************************************************************************/ glViewObject * gl_view_image_new (glLabelImage *object, @@ -185,7 +166,6 @@ gl_view_image_new (glLabelImage *object, glViewImage *view_image; const GdkPixbuf *pixbuf; gdouble w, h; - GtkMenu *menu; gl_debug (DEBUG_VIEW, "START"); g_return_if_fail (object && GL_IS_LABEL_IMAGE (object)); @@ -216,370 +196,194 @@ gl_view_image_new (glLabelImage *object, NULL); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_view_image_cb), view_image); + G_CALLBACK (update_canvas_item_from_object_cb), view_image); gl_debug (DEBUG_VIEW, "END"); return GL_VIEW_OBJECT (view_image); } -/*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -update_view_image_cb (glLabelObject *object, - glViewImage *view_image) -{ - const GdkPixbuf *pixbuf; - gdouble w, h; - - gl_debug (DEBUG_VIEW, "START"); - - /* Query properties of object. */ - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object), NULL); - - /* Adjust appearance of analogous canvas item. */ - gnome_canvas_item_set (view_image->private->item, - "width_set", TRUE, - "height_set", TRUE, - "width", w, - "height", h, - "pixbuf", pixbuf, - NULL); - - gl_debug (DEBUG_VIEW, "END"); -} - /*****************************************************************************/ -/* Create a properties dialog for a image object. */ +/* Create a properties editor for an image object. */ /*****************************************************************************/ static GtkWidget * -construct_properties_dialog (glViewObject *view_object) +construct_properties_editor (glViewObject *view_object) { + GtkWidget *editor; glViewImage *view_image = (glViewImage *)view_object; - GtkWidget *dialog, *wsection, *wbutton; glLabelObject *object; - gdouble x, y, w, h, label_width, label_height; - glTextNode *filename; - glMerge *merge; - GtkSizeGroup *label_size_group; - GtkWidget *window; gl_debug (DEBUG_VIEW, "START"); - /* retrieve object and query parameters */ object = gl_view_object_get_object (GL_VIEW_OBJECT(view_image)); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - filename = gl_label_image_get_filename (GL_LABEL_IMAGE(object)); - gl_label_get_size (GL_LABEL(object->parent), - &label_width, &label_height); - merge = gl_label_get_merge (GL_LABEL(object->parent)); - /*-----------------------------------------------------------------*/ - /* Build dialog. */ - /*-----------------------------------------------------------------*/ - window = gtk_widget_get_toplevel ( - GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_image)))); - dialog = gl_hig_dialog_new_with_buttons ( _("Edit image object properties"), - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL ); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (response_cb), view_image); - - label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - /*---------------------------*/ - /* Image section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Image")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - - view_image->private->pixmap_entry = - gl_wdgt_image_select_new (merge, filename); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_image->private->pixmap_entry); - g_signal_connect ( G_OBJECT(view_image->private->pixmap_entry), "changed", - G_CALLBACK (file_changed_cb), view_image); - - - /*----------------------------*/ - /* Position section */ - /*----------------------------*/ - wsection = gl_hig_category_new (_("Position")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_image->private->position = gl_wdgt_position_new (); - gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_image->private->position), - label_size_group); - gl_wdgt_position_set_params (GL_WDGT_POSITION (view_image->private->position), - x, y, label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_image->private->position); - g_signal_connect (G_OBJECT (view_image->private->position), - "changed", - G_CALLBACK(position_changed_cb), view_image); - - - /*----------------------------*/ - /* Size section */ - /*----------------------------*/ - wsection = gl_hig_category_new (_("Size")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_image->private->size = gl_wdgt_size_new (); - gl_wdgt_size_set_label_size_group (GL_WDGT_SIZE(view_image->private->size), - label_size_group); - gl_wdgt_size_set_params (GL_WDGT_SIZE (view_image->private->size), - w, h, TRUE, label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_image->private->size); - g_signal_connect (G_OBJECT (view_image->private->size), "changed", - G_CALLBACK(size_changed_cb), view_image); - - /* ------ Size Reset Button ------ */ - wbutton = gtk_button_new_with_label (_("Reset image size")); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), wbutton); - g_signal_connect (G_OBJECT (wbutton), "clicked", - G_CALLBACK (size_reset_cb), view_image); - - - /*----------------------------*/ - /* Track object changes. */ - /*----------------------------*/ + /* Build editor. */ + editor = gl_object_editor_new (GL_STOCK_IMAGE, _("Image object properties"), + GL_OBJECT_EDITOR_POSITION_PAGE, + GL_OBJECT_EDITOR_SIZE_IMAGE_PAGE, + GL_OBJECT_EDITOR_IMAGE_PAGE, + 0); + + /* Update */ + update_editor_from_object_cb (object, GL_OBJECT_EDITOR(editor)); + update_editor_from_move_cb (object, 0, 0, GL_OBJECT_EDITOR(editor)); + update_editor_from_label_cb (object->parent, GL_OBJECT_EDITOR(editor)); + + /* Connect signals. */ + g_signal_connect (G_OBJECT (editor), "changed", + G_CALLBACK(update_object_from_editor_cb), object); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_dialog_cb), view_image); + G_CALLBACK (update_editor_from_object_cb), editor); g_signal_connect (G_OBJECT (object), "moved", - G_CALLBACK (update_dialog_from_move_cb), view_image); + G_CALLBACK (update_editor_from_move_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "size_changed", + G_CALLBACK (update_editor_from_label_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "merge_changed", + G_CALLBACK (update_editor_from_label_cb), editor); gl_debug (DEBUG_VIEW, "END"); - return dialog; + return editor; } /*---------------------------------------------------------------------------*/ -/* PRIVATE. "Response" callback. */ -/*---------------------------------------------------------------------------*/ -static void -response_cb (GtkDialog *dialog, - gint response, - glViewImage *view_image) -{ - glLabelObject *object; - - gl_debug (DEBUG_VIEW, "START"); - - g_return_if_fail(dialog != NULL); - g_return_if_fail(GTK_IS_DIALOG(dialog)); - - switch(response) { - case GTK_RESPONSE_CLOSE: - gtk_widget_hide (GTK_WIDGET(dialog)); - break; - case GTK_RESPONSE_DELETE_EVENT: - /* Dialog destroyed, remove callbacks that reference it. */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_image)); - - g_signal_handlers_disconnect_by_func (object, update_dialog_cb, - view_image); - g_signal_handlers_disconnect_by_func (object, update_dialog_from_move_cb, - view_image); - break; - default: - g_print ("response = %d", response); - g_assert_not_reached(); - } - - gl_debug (DEBUG_VIEW, "END"); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. file "changed" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -file_changed_cb (GtkEntry *pixmap_entry, - glViewImage *view_image) +update_canvas_item_from_object_cb (glLabelObject *object, + glViewImage *view_image) { - glLabelObject *object; - glTextNode *filename; + const GdkPixbuf *pixbuf; + gdouble w, h; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_image)); - - filename = gl_wdgt_image_select_get_data (GL_WDGT_IMAGE_SELECT(view_image->private->pixmap_entry)); - gl_debug (DEBUG_VIEW, "filename = %s", filename->data); - - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_image); - gl_label_image_set_filename(GL_LABEL_IMAGE(object), filename); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_image); + /* Query properties of object. */ + gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); + pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object), NULL); - gl_text_node_free (&filename); + /* Adjust appearance of analogous canvas item. */ + gnome_canvas_item_set (view_image->private->item, + "width_set", TRUE, + "height_set", TRUE, + "width", w, + "height", h, + "pixbuf", pixbuf, + NULL); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. position "changed" callback. */ +/* PRIVATE. editor "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -position_changed_cb (glWdgtPosition *position, - glViewImage *view_image) +update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object) { - glLabelObject *object; - gdouble x, y; + gdouble x, y, w, h; + glTextNode *filename; gl_debug (DEBUG_VIEW, "START"); - gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y); - - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_image)); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_image); - gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_image); - - gl_debug (DEBUG_VIEW, "END"); -} + update_editor_from_object_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); -/*---------------------------------------------------------------------------*/ -/* PRIVATE. size "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -size_changed_cb (glWdgtSize *size, - glViewImage *view_image) -{ - glLabelObject *object; - gdouble w, h; - gboolean keep_aspect_ratio_flag; - gl_debug (DEBUG_VIEW, "START"); + gl_object_editor_get_position (editor, &x, &y); + gl_label_object_set_position (object, x, y); - gl_wdgt_size_get_size (GL_WDGT_SIZE (size), - &w, &h, &keep_aspect_ratio_flag); + gl_object_editor_get_size (editor, &w, &h); + gl_label_object_set_size (object, w, h); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_image)); + filename = gl_object_editor_get_image (editor); + gl_label_image_set_filename (GL_LABEL_IMAGE(object), filename); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_image); - gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_image); + update_editor_from_object_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. size "changed" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -size_reset_cb (GtkButton *button, - glViewImage *view_image) +update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor) { - glLabelObject *object; - gdouble image_w, image_h; - const GdkPixbuf *pixbuf; + gdouble w, h; + const GdkPixbuf *pixbuf; + gdouble image_w, image_h; + glTextNode *filename; + glMerge *merge; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_image)); - pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object), NULL); + gl_label_object_get_size (object, &w, &h); + gl_object_editor_set_size (editor, w, h); - image_w = gdk_pixbuf_get_width (pixbuf); - image_h = gdk_pixbuf_get_height (pixbuf); + pixbuf = gl_label_image_get_pixbuf (GL_LABEL_IMAGE(object), NULL); + image_w = gdk_pixbuf_get_width (pixbuf); + image_h = gdk_pixbuf_get_height (pixbuf); + gl_object_editor_set_base_size (editor, image_w, image_h); - gl_label_object_set_size (GL_LABEL_OBJECT(object), image_w, image_h); + filename = gl_label_image_get_filename (GL_LABEL_IMAGE(object)); + merge = gl_label_get_merge (GL_LABEL(object->parent)); + if ( filename != NULL ) { + gl_object_editor_set_image (editor, (merge != NULL), filename); + } gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ +/* PRIVATE. label object "moved" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_cb (glLabelObject *object, - glViewImage *view_image) +update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor) { - glTextNode *filename; - gdouble x, y, w, h; - glMerge *merge; + gdouble x, y; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - filename = gl_label_image_get_filename (GL_LABEL_IMAGE(object)); - merge = gl_label_get_merge (GL_LABEL(object->parent)); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_image->private->pixmap_entry), - file_changed_cb, view_image); - g_signal_handlers_block_by_func (G_OBJECT(view_image->private->position), - position_changed_cb, view_image); - g_signal_handlers_block_by_func (G_OBJECT(view_image->private->size), - size_changed_cb, view_image); - - /* Update widgets in property dialog */ - - if ( filename != NULL ) { - gl_wdgt_image_select_set_data (GL_WDGT_IMAGE_SELECT(view_image->private->pixmap_entry), - (merge != NULL), - filename); - } - gl_wdgt_image_select_set_field_defs (GL_WDGT_IMAGE_SELECT(view_image->private->pixmap_entry), - merge); - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_image->private->position), - x, y); - gl_wdgt_size_set_size (GL_WDGT_SIZE(view_image->private->size), w, h); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_image->private->pixmap_entry), - file_changed_cb, view_image); - g_signal_handlers_unblock_by_func (G_OBJECT(view_image->private->position), - position_changed_cb, view_image); - g_signal_handlers_unblock_by_func (G_OBJECT(view_image->private->size), - size_changed_cb, view_image); - - g_free (filename); + gl_label_object_get_position (object, &x, &y); + gl_object_editor_set_position (editor, x, y); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "moved" callback. */ +/* PRIVATE. label "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewImage *view_image) +update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor) { - gdouble x, y; + gdouble label_width, label_height; + glMerge *merge; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_image->private->position), - position_changed_cb, view_image); - - /* Update widgets in property dialog */ - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_image->private->position), - x, y); + gl_label_get_size (label, &label_width, &label_height); + gl_object_editor_set_max_position (GL_OBJECT_EDITOR (editor), + label_width, label_height); + gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor), + label_width, label_height); - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_image->private->position), - position_changed_cb, view_image); + merge = gl_label_get_merge (label); + gl_object_editor_set_key_names (editor, merge); gl_debug (DEBUG_VIEW, "END"); } diff --git a/glabels2/src/view-line.c b/glabels2/src/view-line.c index 05e279e5..3190d962 100644 --- a/glabels2/src/view-line.c +++ b/glabels2/src/view-line.c @@ -3,7 +3,7 @@ * * view_line.c: GLabels label line object widget * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2003 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,10 +26,9 @@ #include "view-highlight.h" -#include "wdgt-line.h" -#include "wdgt-vector.h" -#include "wdgt-position.h" #include "color.h" +#include "object-editor.h" +#include "stock.h" #include "pixmaps/cursor_line.xbm" #include "pixmaps/cursor_line_mask.xbm" @@ -46,13 +45,6 @@ struct _glViewLinePrivate { GnomeCanvasItem *item; - - /* Property dialog Page 0 widgets */ - GtkWidget *line; - - /* Property dialog Page 1 widgets */ - GtkWidget *position; - GtkWidget *vector; }; /*========================================================*/ @@ -66,35 +58,29 @@ static glViewObjectClass *parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_line_class_init (glViewLineClass *klass); -static void gl_view_line_instance_init (glViewLine *view_line); -static void gl_view_line_finalize (GObject *object); +static void gl_view_line_class_init (glViewLineClass *klass); +static void gl_view_line_instance_init (glViewLine *view_line); +static void gl_view_line_finalize (GObject *object); -static void update_view_line_cb (glLabelObject *object, - glViewLine *view_line); +static GtkWidget *construct_properties_editor (glViewObject *view_object); -static GtkWidget *construct_properties_dialog (glViewObject *view_object); +static void update_canvas_item_from_object_cb (glLabelObject *object, + glViewLine *view_line); -static void response_cb (GtkDialog *dialog, - gint response, - glViewLine *view_line); +static void update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object); -static void line_changed_cb (glWdgtLine *line, - glViewLine *view_line); +static void update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor); -static void position_changed_cb (glWdgtPosition *position, - glViewLine *view_line); +static void update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor); -static void vector_changed_cb (glWdgtVector *vector, - glViewLine *view_line); +static void update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor); -static void update_dialog_cb (glLabelObject *object, - glViewLine *view_line); - -static void update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewLine *view_line); /*****************************************************************************/ @@ -137,7 +123,7 @@ gl_view_line_class_init (glViewLineClass *klass) object_class->finalize = gl_view_line_finalize; - view_object_class->construct_dialog = construct_properties_dialog; + view_object_class->construct_editor = construct_properties_editor; gl_debug (DEBUG_VIEW, "END"); } @@ -167,18 +153,17 @@ gl_view_line_finalize (GObject *object) } /*****************************************************************************/ -/* NEW line object view. */ +/* NEW line object view. */ /*****************************************************************************/ glViewObject * gl_view_line_new (glLabelLine *object, - glView *view) + glView *view) { - glViewLine *view_line; + glViewLine *view_line; gdouble line_width; guint line_color; gdouble w, h; - GtkMenu *menu; - GnomeCanvasPoints *points; + GnomeCanvasPoints *points; gl_debug (DEBUG_VIEW, "START"); g_return_if_fail (object && GL_IS_LABEL_LINE (object)); @@ -212,19 +197,60 @@ gl_view_line_new (glLabelLine *object, gnome_canvas_points_free (points); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_view_line_cb), view_line); + G_CALLBACK (update_canvas_item_from_object_cb), view_line); gl_debug (DEBUG_VIEW, "END"); return GL_VIEW_OBJECT (view_line); } +/*****************************************************************************/ +/* Create a properties editor for a line object. */ +/*****************************************************************************/ +static GtkWidget * +construct_properties_editor (glViewObject *view_object) +{ + GtkWidget *editor; + glViewLine *view_line = (glViewLine *)view_object; + glLabelObject *object; + + gl_debug (DEBUG_VIEW, "START"); + + object = gl_view_object_get_object (GL_VIEW_OBJECT(view_line)); + + /* Build editor. */ + editor = gl_object_editor_new (GL_STOCK_LINE, _("Line object properties"), + GL_OBJECT_EDITOR_POSITION_PAGE, + GL_OBJECT_EDITOR_SIZE_LINE_PAGE, + GL_OBJECT_EDITOR_LINE_PAGE, + 0); + + /* Update */ + update_editor_from_object_cb (object, GL_OBJECT_EDITOR(editor)); + update_editor_from_move_cb (object, 0, 0, GL_OBJECT_EDITOR(editor)); + update_editor_from_label_cb (object->parent, GL_OBJECT_EDITOR(editor)); + + /* Connect signals. */ + g_signal_connect (G_OBJECT (editor), "changed", + G_CALLBACK(update_object_from_editor_cb), object); + g_signal_connect (G_OBJECT (object), "changed", + G_CALLBACK (update_editor_from_object_cb), editor); + g_signal_connect (G_OBJECT (object), "moved", + G_CALLBACK (update_editor_from_move_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "size_changed", + G_CALLBACK (update_editor_from_label_cb), editor); + + gl_debug (DEBUG_VIEW, "END"); + + return editor; +} + /*---------------------------------------------------------------------------*/ /* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_view_line_cb (glLabelObject *object, - glViewLine *view_line) +update_canvas_item_from_object_cb (glLabelObject *object, + glViewLine *view_line) { gdouble line_width; guint line_color; @@ -254,306 +280,110 @@ update_view_line_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "END"); } -/*****************************************************************************/ -/* Create a properties dialog for a line object. */ -/*****************************************************************************/ -static GtkWidget * -construct_properties_dialog (glViewObject *view_object) -{ - glViewLine *view_line = (glViewLine *)view_object; - GtkWidget *dialog, *wsection; - glLabelObject *object; - gdouble line_width; - guint line_color; - gdouble x, y, w, h, label_width, label_height; - GtkSizeGroup *label_size_group; - GtkWidget *window; - - gl_debug (DEBUG_VIEW, "START"); - - /* retrieve object and query parameters */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_line)); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - line_width = gl_label_line_get_line_width(GL_LABEL_LINE(object)); - line_color = gl_label_line_get_line_color(GL_LABEL_LINE(object)); - gl_label_get_size (GL_LABEL(object->parent), - &label_width, &label_height); - - /*-----------------------------------------------------------------*/ - /* Build dialog with notebook. */ - /*-----------------------------------------------------------------*/ - window = gtk_widget_get_toplevel ( - GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_line)))); - dialog = gl_hig_dialog_new_with_buttons ( _("Edit line object properties"), - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL ); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (response_cb), view_line); - - label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - /*---------------------------*/ - /* Line section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Line")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_line->private->line = gl_wdgt_line_new (); - gl_wdgt_line_set_label_size_group (GL_WDGT_LINE(view_line->private->line), - label_size_group); - gl_wdgt_line_set_params (GL_WDGT_LINE (view_line->private->line), - line_width, - line_color); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_line->private->line); - g_signal_connect (G_OBJECT (view_line->private->line), "changed", - G_CALLBACK(line_changed_cb), view_line); - - /*---------------------------*/ - /* Position section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Position")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_line->private->position = gl_wdgt_position_new (); - gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_line->private->position), - label_size_group); - gl_wdgt_position_set_params (GL_WDGT_POSITION (view_line->private->position), - x, y, - label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_line->private->position); - g_signal_connect (G_OBJECT (view_line->private->position), - "changed", - G_CALLBACK(position_changed_cb), view_line); - - - /*---------------------------*/ - /* Size section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Size")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_line->private->vector = gl_wdgt_vector_new (); - gl_wdgt_vector_set_label_size_group (GL_WDGT_VECTOR(view_line->private->vector), - label_size_group); - gl_wdgt_vector_set_params (GL_WDGT_VECTOR (view_line->private->vector), - w, h, - label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_line->private->vector); - g_signal_connect (G_OBJECT (view_line->private->vector), "changed", - G_CALLBACK(vector_changed_cb), view_line); - - - /*----------------------------*/ - /* Track object changes. */ - /*----------------------------*/ - g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_dialog_cb), view_line); - g_signal_connect (G_OBJECT (object), "moved", - G_CALLBACK (update_dialog_from_move_cb), view_line); - - gl_debug (DEBUG_VIEW, "END"); - - return dialog; -} - /*---------------------------------------------------------------------------*/ -/* PRIVATE. "Response" callback. */ +/* PRIVATE. editor "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -response_cb (GtkDialog *dialog, - gint response, - glViewLine *view_line) +update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object) { - glLabelObject *object; - - gl_debug (DEBUG_VIEW, "START"); - - g_return_if_fail(dialog != NULL); - g_return_if_fail(GTK_IS_DIALOG(dialog)); - - switch(response) { - case GTK_RESPONSE_CLOSE: - gtk_widget_hide (GTK_WIDGET(dialog)); - break; - case GTK_RESPONSE_DELETE_EVENT: - /* Dialog destroyed, remove callbacks that reference it. */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_line)); - - g_signal_handlers_disconnect_by_func (object, update_dialog_cb, - view_line); - g_signal_handlers_disconnect_by_func (object, update_dialog_from_move_cb, - view_line); - break; - default: - g_print ("response = %d", response); - g_assert_not_reached(); - } - - gl_debug (DEBUG_VIEW, "END"); -} - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. line properties "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -line_changed_cb (glWdgtLine *line, - glViewLine *view_line) -{ - glLabelObject *object; - gdouble line_width; + gdouble x, y, w, h; guint line_color; + gdouble line_width; gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_line)); - - gl_wdgt_line_get_params (GL_WDGT_LINE (line), - &line_width, - &line_color); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_line); - gl_label_line_set_line_width(GL_LABEL_LINE(object), line_width); - gl_label_line_set_line_color(GL_LABEL_LINE(object), line_color); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_line); + update_editor_from_object_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); - gl_debug (DEBUG_VIEW, "END"); -} -/*---------------------------------------------------------------------------*/ -/* PRIVATE. position "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -position_changed_cb (glWdgtPosition *position, - glViewLine *view_line) -{ - glLabelObject *object; - gdouble x, y; + gl_object_editor_get_position (editor, &x, &y); + gl_label_object_set_position (object, x, y); - gl_debug (DEBUG_VIEW, "START"); + gl_object_editor_get_lsize (editor, &w, &h); + gl_label_object_set_size (object, w, h); - gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y); + line_color = gl_object_editor_get_line_color (editor); + gl_label_object_set_line_color (object, line_color); + + line_width = gl_object_editor_get_line_width (editor); + gl_label_object_set_line_width (object, line_width); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_line)); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_line); - gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_line); + update_editor_from_object_cb, + editor); + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. vector "changed" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -vector_changed_cb (glWdgtVector *vector, - glViewLine *view_line) +update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor) { - glLabelObject *object; - gdouble w, h; - gboolean keep_aspect_ratio_flag; + gdouble w, h; + guint line_color; + gdouble line_width; gl_debug (DEBUG_VIEW, "START"); - gl_wdgt_vector_get_params (GL_WDGT_VECTOR (vector), &w, &h); + gl_label_object_get_size (object, &w, &h); + gl_object_editor_set_lsize (editor, w, h); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_line)); + line_color = gl_label_line_get_line_color (GL_LABEL_LINE(object)); + gl_object_editor_set_line_color (editor, line_color); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_line); - gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_line); + line_width = gl_label_line_get_line_width (GL_LABEL_LINE(object)); + gl_object_editor_set_line_width (editor, line_width); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ +/* PRIVATE. label object "moved" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_cb (glLabelObject *object, - glViewLine *view_line) +update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor) { - gdouble line_width; - guint line_color; - gdouble x, y, w, h, label_width, label_height; + gdouble x, y; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - line_width = gl_label_line_get_line_width(GL_LABEL_LINE(object)); - line_color = gl_label_line_get_line_color(GL_LABEL_LINE(object)); - gl_label_get_size (GL_LABEL(object->parent), - &label_width, &label_height); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_line->private->line), - line_changed_cb, view_line); - g_signal_handlers_block_by_func (G_OBJECT(view_line->private->position), - position_changed_cb, view_line); - g_signal_handlers_block_by_func (G_OBJECT(view_line->private->vector), - vector_changed_cb, view_line); - - /* Update widgets in property dialog */ - gl_wdgt_line_set_params (GL_WDGT_LINE (view_line->private->line), - line_width, - line_color); - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_line->private->position), - x, y); - gl_wdgt_vector_set_params (GL_WDGT_VECTOR(view_line->private->vector), - w, h, label_width, label_height); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_line->private->line), - line_changed_cb, view_line); - g_signal_handlers_unblock_by_func (G_OBJECT(view_line->private->position), - position_changed_cb, view_line); - g_signal_handlers_unblock_by_func (G_OBJECT(view_line->private->vector), - vector_changed_cb, view_line); - + gl_label_object_get_position (object, &x, &y); + gl_object_editor_set_position (editor, x, y); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "moved" callback. */ +/* PRIVATE. label "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewLine *view_line) +update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor) { - gdouble x, y; + gdouble label_width, label_height; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_line->private->position), - position_changed_cb, view_line); - - /* Update widgets in property dialog */ - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_line->private->position), - x, y); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_line->private->position), - position_changed_cb, view_line); + gl_label_get_size (label, &label_width, &label_height); + gl_object_editor_set_max_position (GL_OBJECT_EDITOR (editor), + label_width, label_height); + gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor), + label_width, label_height); gl_debug (DEBUG_VIEW, "END"); } @@ -686,3 +516,4 @@ gl_view_line_create_event_handler (GnomeCanvas *canvas, } } + diff --git a/glabels2/src/view-object.c b/glabels2/src/view-object.c index 2e9eb073..7c19c989 100644 --- a/glabels2/src/view-object.c +++ b/glabels2/src/view-object.c @@ -46,7 +46,7 @@ struct _glViewObjectPrivate { GnomeCanvasItem *group; glViewHighlight *highlight; - GtkWidget *property_dialog; + GtkWidget *property_editor; }; /*========================================================*/ @@ -156,8 +156,8 @@ gl_view_object_finalize (GObject *object) g_object_unref (GL_VIEW_OBJECT(object)->private->object); g_object_unref (G_OBJECT(GL_VIEW_OBJECT(object)->private->highlight)); gtk_object_destroy (GTK_OBJECT(GL_VIEW_OBJECT(object)->private->group)); - if (GL_VIEW_OBJECT(object)->private->property_dialog) { - gtk_object_destroy (GTK_OBJECT(GL_VIEW_OBJECT(object)->private->property_dialog)); + if (GL_VIEW_OBJECT(object)->private->property_editor) { + gtk_object_destroy (GTK_OBJECT(GL_VIEW_OBJECT(object)->private->property_editor)); } G_OBJECT_CLASS (parent_class)->finalize (object); @@ -374,36 +374,34 @@ gl_view_object_hide_highlight (glViewObject *view_object) /*****************************************************************************/ -/* Show property dialog. */ +/* Get property editor. */ /*****************************************************************************/ -void -gl_view_object_show_dialog (glViewObject *view_object) +GtkWidget * +gl_view_object_get_editor (glViewObject *view_object) { gl_debug (DEBUG_VIEW, "START"); - g_return_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object)); - - if (view_object->private->property_dialog != NULL) { - gtk_window_present (GTK_WINDOW (view_object->private->property_dialog)); - return; - } - - if ( GL_VIEW_OBJECT_GET_CLASS(view_object)->construct_dialog != NULL ) { + g_return_val_if_fail (view_object && GL_IS_VIEW_OBJECT (view_object), NULL); - view_object->private->property_dialog = - GL_VIEW_OBJECT_GET_CLASS(view_object)->construct_dialog (view_object); + if ( GL_VIEW_OBJECT_GET_CLASS(view_object)->construct_editor != NULL ) { - g_signal_connect (G_OBJECT (view_object->private->property_dialog), + if (view_object->private->property_editor == NULL) { + view_object->private->property_editor = + GL_VIEW_OBJECT_GET_CLASS(view_object)->construct_editor (view_object); + } + g_signal_connect (G_OBJECT (view_object->private->property_editor), "destroy", G_CALLBACK (gtk_widget_destroyed), - &view_object->private->property_dialog); + &view_object->private->property_editor); - gtk_widget_show_all (view_object->private->property_dialog); + gtk_widget_show (view_object->private->property_editor); } gl_debug (DEBUG_VIEW, "END"); + + return view_object->private->property_editor; } @@ -632,11 +630,10 @@ item_event_arrow_mode (GnomeCanvasItem *item, gl_debug (DEBUG_VIEW, "2BUTTON_PRESS"); switch (event->button.button) { case 1: - /* Also exit dragging mode w/ double-click, run dlg */ + /* Also exit dragging mode w/ double-click */ gnome_canvas_item_ungrab (item, event->button.time); dragging = FALSE; gl_view_select_object (view, view_object); - gl_view_object_show_dialog (view_object); return TRUE; default: diff --git a/glabels2/src/view-object.h b/glabels2/src/view-object.h index 17b0e613..b1af97fb 100644 --- a/glabels2/src/view-object.h +++ b/glabels2/src/view-object.h @@ -56,7 +56,7 @@ struct _glViewObjectClass { * Methods */ - GtkWidget * (*construct_dialog) (glViewObject *view_object); + GtkWidget * (*construct_editor) (glViewObject *view_object); }; @@ -89,7 +89,7 @@ void gl_view_object_show_highlight (glViewObject *view_ob void gl_view_object_hide_highlight (glViewObject *view_object); -void gl_view_object_show_dialog (glViewObject *view_object); +GtkWidget *gl_view_object_get_editor (glViewObject *view_object); void gl_view_object_select (glViewObject *view_object); diff --git a/glabels2/src/view-text.c b/glabels2/src/view-text.c index 57d357d3..6ff471fa 100644 --- a/glabels2/src/view-text.c +++ b/glabels2/src/view-text.c @@ -3,7 +3,7 @@ * * view_text.c: GLabels label text object widget * - * Copyright (C) 2001-2002 Jim Evins . + * Copyright (C) 2001-2003 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,11 +27,10 @@ #include "view-text.h" #include "canvas-hacktext.h" #include "view-highlight.h" -#include "wdgt-text-entry.h" -#include "wdgt-text-props.h" -#include "wdgt-position.h" + #include "color.h" -#include "hig.h" +#include "object-editor.h" +#include "stock.h" #include "pixmaps/cursor_text.xbm" #include "pixmaps/cursor_text_mask.xbm" @@ -60,14 +59,6 @@ struct _glViewTextPrivate { gboolean cursor_state; guint cursor_timeout; - /* Page 0 widgets */ - GtkWidget *text_entry; - - /* Page 1 widgets */ - GtkWidget *text_props; - - /* Page 2 widgets */ - GtkWidget *position; }; /*========================================================*/ @@ -81,49 +72,46 @@ static glViewObjectClass *parent_class = NULL; /* Private function prototypes. */ /*========================================================*/ -static void gl_view_text_class_init (glViewTextClass *klass); -static void gl_view_text_instance_init (glViewText *view_text); -static void gl_view_text_finalize (GObject *object); +static void gl_view_text_class_init (glViewTextClass *klass); +static void gl_view_text_instance_init (glViewText *view_text); +static void gl_view_text_finalize (GObject *object); -static void update_view_text_cb (glLabelObject *object, - glViewText *view_text); +static GtkWidget *construct_properties_editor (glViewObject *view_object); -static GtkWidget *construct_properties_dialog (glViewObject *view_object); +static void update_canvas_item_from_object_cb (glLabelObject *object, + glViewText *view_text); -static void response_cb (GtkDialog *dialog, - gint response, - glViewText *view_text); +static void update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object); -static void text_props_changed_cb (glWdgtTextProps *text_props, - glViewText *view_text); +static void update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor); -static void position_changed_cb (glWdgtPosition *position, - glViewText *view_text); +static void update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor); -static void update_dialog_cb (glLabelObject *object, - glViewText *view_text); +static void update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor); -static void update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewText *view_text); +static void draw_hacktext (glViewText *view_text); -static void draw_hacktext (glViewText *view_text); +static void draw_cursor (glViewText *view_text); -static void draw_cursor (glViewText *view_text); +static void mark_set_cb (GtkTextBuffer *textbuffer, + GtkTextIter *iter, + GtkTextMark *mark, + glViewText *view_text); -static void mark_set_cb (GtkTextBuffer *textbuffer, - GtkTextIter *iter, - GtkTextMark *mark, - glViewText *view_text); +static void blink_start (glViewText *view_text); +static void blink_stop (glViewText *view_text); +static gboolean blink_cb (glViewText *view_text); -static void blink_start (glViewText *view_text); -static void blink_stop (glViewText *view_text); -static gboolean blink_cb (glViewText *view_text); +static gint item_event_cb (GnomeCanvasItem *item, + GdkEvent *event, + glViewObject *view_object); -static gint item_event_cb (GnomeCanvasItem *item, - GdkEvent *event, - glViewObject *view_object); /*****************************************************************************/ @@ -166,7 +154,7 @@ gl_view_text_class_init (glViewTextClass *klass) object_class->finalize = gl_view_text_finalize; - view_object_class->construct_dialog = construct_properties_dialog; + view_object_class->construct_editor = construct_properties_editor; gl_debug (DEBUG_VIEW, "END"); } @@ -196,11 +184,11 @@ gl_view_text_finalize (GObject *object) } /*****************************************************************************/ -/* NEW text object view. */ +/* NEW text object view. */ /*****************************************************************************/ glViewObject * gl_view_text_new (glLabelText *object, - glView *view) + glView *view) { glViewText *view_text; GtkMenu *menu; @@ -225,7 +213,7 @@ gl_view_text_new (glLabelText *object, draw_cursor (view_text); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_view_text_cb), view_text); + G_CALLBACK (update_canvas_item_from_object_cb), view_text); g_signal_connect (G_OBJECT (group), "event", G_CALLBACK (item_event_cb), view_text); @@ -239,236 +227,127 @@ gl_view_text_new (glLabelText *object, return GL_VIEW_OBJECT (view_text); } -/*---------------------------------------------------------------------------*/ -/* PRIVATE. label object "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -update_view_text_cb (glLabelObject *object, - glViewText *view_text) -{ - gl_debug (DEBUG_VIEW, "START"); - - /* Adjust appearance of analogous canvas item. */ - draw_hacktext (view_text); - draw_cursor (view_text); - - gl_debug (DEBUG_VIEW, "END"); -} - /*****************************************************************************/ -/* Create a properties dialog for a text object. */ +/* Create a properties editor for a text object. */ /*****************************************************************************/ static GtkWidget * -construct_properties_dialog (glViewObject *view_object) +construct_properties_editor (glViewObject *view_object) { - glViewText *view_text = (glViewText *)view_object; - GtkWidget *dialog, *wsection, *wbutton; - glLabelObject *object; - gdouble x, y, w, h, label_width, label_height; - GtkTextBuffer *buffer; - gchar *font_family; - gdouble font_size; - GnomeFontWeight font_weight; - gboolean font_italic_flag; - guint color; - GtkJustification just; - glMerge *merge; - GtkSizeGroup *label_size_group; - GtkWidget *window; + GtkWidget *editor; + glViewText *view_text = (glViewText *)view_object; + glLabelObject *object; + GtkTextBuffer *buffer; gl_debug (DEBUG_VIEW, "START"); - /* retrieve object and query parameters */ object = gl_view_object_get_object (GL_VIEW_OBJECT(view_text)); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - buffer = gl_label_text_get_buffer(GL_LABEL_TEXT(object)); - gl_label_text_get_props (GL_LABEL_TEXT(object), - &font_family, &font_size, - &font_weight, &font_italic_flag, - &color, &just); - gl_label_get_size (GL_LABEL(object->parent), - &label_width, &label_height); - merge = gl_label_get_merge (GL_LABEL(object->parent)); - - /*-----------------------------------------------------------------*/ - /* Build dialog. */ - /*-----------------------------------------------------------------*/ - window = gtk_widget_get_toplevel ( - GTK_WIDGET(gl_view_object_get_view(GL_VIEW_OBJECT(view_text)))); - dialog = gl_hig_dialog_new_with_buttons ( _("Edit text object properties"), - GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE, - NULL ); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (response_cb), view_text); - - label_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - - /*---------------------------*/ - /* Text Section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Text")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_text->private->text_entry = - gl_wdgt_text_entry_new (merge); - gl_wdgt_text_entry_set_label_size_group (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry), - label_size_group); - gl_wdgt_text_entry_set_buffer (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry), - buffer); - gl_wdgt_text_entry_set_field_defs (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry), - merge); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_text->private->text_entry); - - - /*---------------------------*/ - /* Text Properties section */ - /*---------------------------*/ - wsection = gl_hig_category_new (_("Properties")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_text->private->text_props = gl_wdgt_text_props_new (); - gl_wdgt_text_props_set_label_size_group (GL_WDGT_TEXT_PROPS(view_text->private->text_props), - label_size_group); - gl_wdgt_text_props_set_params (GL_WDGT_TEXT_PROPS(view_text->private->text_props), - font_family, font_size, font_weight, - font_italic_flag, color, just); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_text->private->text_props); - g_signal_connect ( G_OBJECT(view_text->private->text_props), - "changed", G_CALLBACK (text_props_changed_cb), - view_text); - - - /*----------------------------*/ - /* Position section */ - /*----------------------------*/ - wsection = gl_hig_category_new (_("Position")); - gl_hig_dialog_add_widget (GL_HIG_DIALOG(dialog), wsection); - view_text->private->position = gl_wdgt_position_new (); - gl_wdgt_position_set_label_size_group (GL_WDGT_POSITION(view_text->private->position), - label_size_group); - gl_wdgt_position_set_params (GL_WDGT_POSITION (view_text->private->position), - x, y, - label_width, label_height); - gl_hig_category_add_widget (GL_HIG_CATEGORY(wsection), - view_text->private->position); - g_signal_connect (G_OBJECT (view_text->private->position), - "changed", - G_CALLBACK(position_changed_cb), view_text); - - - /*----------------------------*/ - /* Track object changes. */ - /*----------------------------*/ + + /* Build editor. */ + editor = gl_object_editor_new (GL_STOCK_TEXT, _("Text object properties"), + GL_OBJECT_EDITOR_POSITION_PAGE, + GL_OBJECT_EDITOR_SIZE_PAGE, + GL_OBJECT_EDITOR_TEXT_PAGE, + GL_OBJECT_EDITOR_EDIT_PAGE, + 0); + + buffer = gl_label_text_get_buffer (GL_LABEL_TEXT(object)); + gl_object_editor_set_text_buffer (GL_OBJECT_EDITOR(editor), buffer); + + /* Update */ + update_editor_from_object_cb (object, GL_OBJECT_EDITOR(editor)); + update_editor_from_move_cb (object, 0, 0, GL_OBJECT_EDITOR(editor)); + update_editor_from_label_cb (object->parent, GL_OBJECT_EDITOR(editor)); + + /* Connect signals. */ + g_signal_connect (G_OBJECT (editor), "changed", + G_CALLBACK(update_object_from_editor_cb), object); g_signal_connect (G_OBJECT (object), "changed", - G_CALLBACK (update_dialog_cb), view_text); + G_CALLBACK (update_editor_from_object_cb), editor); g_signal_connect (G_OBJECT (object), "moved", - G_CALLBACK (update_dialog_from_move_cb), view_text); + G_CALLBACK (update_editor_from_move_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "size_changed", + G_CALLBACK (update_editor_from_label_cb), editor); + g_signal_connect (G_OBJECT (object->parent), "merge_changed", + G_CALLBACK (update_editor_from_label_cb), editor); gl_debug (DEBUG_VIEW, "END"); - return dialog; + return editor; } /*---------------------------------------------------------------------------*/ -/* PRIVATE. "Response" callback. */ +/* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -response_cb (GtkDialog *dialog, - gint response, - glViewText *view_text) +update_canvas_item_from_object_cb (glLabelObject *object, + glViewText *view_text) { - glLabelObject *object; - gl_debug (DEBUG_VIEW, "START"); - g_return_if_fail(dialog != NULL); - g_return_if_fail(GTK_IS_DIALOG(dialog)); - - switch(response) { - case GTK_RESPONSE_CLOSE: - gtk_widget_hide (GTK_WIDGET(dialog)); - break; - case GTK_RESPONSE_DELETE_EVENT: - /* Dialog destroyed, remove callbacks that reference it. */ - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_text)); - - g_signal_handlers_disconnect_by_func (object, update_dialog_cb, - view_text); - g_signal_handlers_disconnect_by_func (object, update_dialog_from_move_cb, - view_text); - break; - default: - g_print ("response = %d", response); - g_assert_not_reached(); - } + /* Adjust appearance of analogous canvas item. */ + draw_hacktext (view_text); + draw_cursor (view_text); gl_debug (DEBUG_VIEW, "END"); } /*---------------------------------------------------------------------------*/ -/* PRIVATE. text_props "changed" callback. */ +/* PRIVATE. editor "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -text_props_changed_cb (glWdgtTextProps *text_props, - glViewText *view_text) +update_object_from_editor_cb (glObjectEditor *editor, + glLabelObject *object) { - glLabelObject *object; - gchar *font_family; + gdouble x, y, w, h; + gchar *font_family; gdouble font_size; GnomeFontWeight font_weight; gboolean font_italic_flag; guint color; GtkJustification just; - gl_debug (DEBUG_VIEW, "START"); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_text)); + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_object_cb, + editor); + g_signal_handlers_block_by_func (G_OBJECT(object), + update_editor_from_move_cb, + editor); - gl_wdgt_text_props_get_params (text_props, - &font_family, &font_size, &font_weight, - &font_italic_flag, - &color, &just); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_text); - gl_label_text_set_props (GL_LABEL_TEXT(object), - font_family, font_size, font_weight, - font_italic_flag, - color, just); - g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_text); + gl_object_editor_get_position (editor, &x, &y); + gl_label_object_set_position (object, x, y); + + gl_object_editor_get_size (editor, &w, &h); + gl_label_object_set_size (object, w, h); + font_family = gl_object_editor_get_font_family (editor); + gl_label_object_set_font_family (object, font_family); g_free (font_family); - gl_debug (DEBUG_VIEW, "END"); -} + font_size = gl_object_editor_get_font_size (editor); + gl_label_object_set_font_size (object, font_size); -/*---------------------------------------------------------------------------*/ -/* PRIVATE. position "changed" callback. */ -/*---------------------------------------------------------------------------*/ -static void -position_changed_cb (glWdgtPosition *position, - glViewText *view_text) -{ - glLabelObject *object; - gdouble x, y; + font_weight = gl_object_editor_get_font_weight (editor); + gl_label_object_set_font_weight (object, font_weight); - gl_debug (DEBUG_VIEW, "START"); + font_italic_flag = gl_object_editor_get_font_italic_flag (editor); + gl_label_object_set_font_italic_flag (object, font_italic_flag); - gl_wdgt_position_get_position (GL_WDGT_POSITION (position), &x, &y); + color = gl_object_editor_get_text_color (editor); + gl_label_object_set_text_color (object, color); - object = gl_view_object_get_object (GL_VIEW_OBJECT(view_text)); + just = gl_object_editor_get_text_alignment (editor); + gl_label_object_set_text_alignment (object, just); - g_signal_handlers_block_by_func (G_OBJECT(object), - update_dialog_cb, view_text); - gl_label_object_set_position (GL_LABEL_OBJECT(object), x, y); + + g_signal_handlers_unblock_by_func (G_OBJECT(object), + update_editor_from_object_cb, + editor); g_signal_handlers_unblock_by_func (G_OBJECT(object), - update_dialog_cb, view_text); + update_editor_from_move_cb, + editor); gl_debug (DEBUG_VIEW, "END"); } @@ -477,12 +356,11 @@ position_changed_cb (glWdgtPosition *position, /* PRIVATE. label object "changed" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_cb (glLabelObject *object, - glViewText *view_text) +update_editor_from_object_cb (glLabelObject *object, + glObjectEditor *editor) { - gdouble x, y; - glMerge *merge; - gchar *font_family; + gdouble w, h; + gchar *font_family; gdouble font_size; GnomeFontWeight font_weight; gboolean font_italic_flag; @@ -491,35 +369,27 @@ update_dialog_cb (glLabelObject *object, gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ + gl_label_object_get_size (object, &w, &h); + gl_object_editor_set_size (editor, w, h); + gl_label_text_get_props (GL_LABEL_TEXT(object), &font_family, &font_size, &font_weight, &font_italic_flag, &color, &just); - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); - merge = gl_label_get_merge (GL_LABEL(object->parent)); - - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_text->private->text_props), - text_props_changed_cb, view_text); - g_signal_handlers_block_by_func (G_OBJECT(view_text->private->position), - position_changed_cb, view_text); - - /* Update widgets in property dialog */ - - gl_wdgt_text_entry_set_field_defs (GL_WDGT_TEXT_ENTRY(view_text->private->text_entry), - merge); - gl_wdgt_text_props_set_params (GL_WDGT_TEXT_PROPS(view_text->private->text_props), - font_family, font_size, font_weight, - font_italic_flag, color, just); - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_text->private->position), - x, y); - - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_text->private->text_props), - text_props_changed_cb, view_text); - g_signal_handlers_unblock_by_func (G_OBJECT(view_text->private->position), - position_changed_cb, view_text); + + gl_object_editor_set_font_family (editor, font_family); + g_free (font_family); + + gl_object_editor_set_font_size (editor, font_size); + + gl_object_editor_set_font_weight (editor, font_weight); + + gl_object_editor_set_font_italic_flag (editor, font_italic_flag); + + gl_object_editor_set_text_color (editor, color); + + gl_object_editor_set_text_alignment (editor, just); + gl_debug (DEBUG_VIEW, "END"); } @@ -528,29 +398,41 @@ update_dialog_cb (glLabelObject *object, /* PRIVATE. label object "moved" callback. */ /*---------------------------------------------------------------------------*/ static void -update_dialog_from_move_cb (glLabelObject *object, - gdouble dx, - gdouble dy, - glViewText *view_text) +update_editor_from_move_cb (glLabelObject *object, + gdouble dx, + gdouble dy, + glObjectEditor *editor) { gdouble x, y; gl_debug (DEBUG_VIEW, "START"); - /* Query properties of object. */ - gl_label_object_get_position (GL_LABEL_OBJECT(object), &x, &y); + gl_label_object_get_position (object, &x, &y); + gl_object_editor_set_position (editor, x, y); - /* Block widget handlers to prevent recursion */ - g_signal_handlers_block_by_func (G_OBJECT(view_text->private->position), - position_changed_cb, view_text); + gl_debug (DEBUG_VIEW, "END"); +} + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. label "changed" callback. */ +/*---------------------------------------------------------------------------*/ +static void +update_editor_from_label_cb (glLabel *label, + glObjectEditor *editor) +{ + gdouble label_width, label_height; + glMerge *merge; + + gl_debug (DEBUG_VIEW, "START"); - /* Update widgets in property dialog */ - gl_wdgt_position_set_position (GL_WDGT_POSITION(view_text->private->position), - x, y); + gl_label_get_size (label, &label_width, &label_height); + gl_object_editor_set_max_position (GL_OBJECT_EDITOR (editor), + label_width, label_height); + gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor), + label_width, label_height); - /* Unblock widget handlers */ - g_signal_handlers_unblock_by_func (G_OBJECT(view_text->private->position), - position_changed_cb, view_text); + merge = gl_label_get_merge (label); + gl_object_editor_set_key_names (editor, merge); gl_debug (DEBUG_VIEW, "END"); } diff --git a/glabels2/src/view.c b/glabels2/src/view.c index 2cd4581c..80d96508 100644 --- a/glabels2/src/view.c +++ b/glabels2/src/view.c @@ -61,6 +61,9 @@ #define ARC_FINE 2 /* Resolution in degrees of large arcs */ #define ARC_COURSE 5 /* Resolution in degrees of small arcs */ +#define ZOOMTOFIT_PAD 16 +#define HOME_SCALE 2.0 + /*==========================================================================*/ /* Private types. */ /*==========================================================================*/ @@ -87,12 +90,22 @@ static guint signals[LAST_SIGNAL] = {0}; static GdkAtom clipboard_atom = GDK_NONE; static gdouble scales[] = { - 8.0, 6.0, 4.0, 3.0, - 2.0, - 1.5, 1.0, 0.5, 0.25, + 4.00*HOME_SCALE, + 3.00*HOME_SCALE, + 2.00*HOME_SCALE, + 1.50*HOME_SCALE, + 1.00*HOME_SCALE, + 0.75*HOME_SCALE, + 0.67*HOME_SCALE, + 0.50*HOME_SCALE, + 0.33*HOME_SCALE, + 0.25*HOME_SCALE, + 0.20*HOME_SCALE, + 0.15*HOME_SCALE, + 0.10*HOME_SCALE, }; #define N_SCALES G_N_ELEMENTS(scales) -#define HOME_SCALE 2.0 + /*==========================================================================*/ /* Local function prototypes */ @@ -106,8 +119,6 @@ static void gl_view_construct (glView *view); static GtkWidget *gl_view_construct_canvas (glView *view); static void gl_view_construct_selection (glView *view); -static gdouble get_apropriate_scale (gdouble w, gdouble h); - static void draw_layers (glView *view); static void label_resized_cb (glLabel *label, @@ -405,18 +416,14 @@ gl_view_construct_canvas (glView *view) gl_debug (DEBUG_VIEW, "Label size: w=%lf, h=%lf", label_width, label_height); - scale = get_apropriate_scale (label_width, label_height); - gl_debug (DEBUG_VIEW, "scale =%lf", scale); + scale = HOME_SCALE; + gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (view->canvas), scale); + view->scale = scale; + gl_debug (DEBUG_VIEW, "scale =%lf", scale); gl_debug (DEBUG_VIEW, "Canvas size: w=%lf, h=%lf", scale * label_width + 40, scale * label_height + 40); - gtk_widget_set_size_request (GTK_WIDGET(view->canvas), - scale * label_width + 40, - scale * label_height + 40); - gnome_canvas_set_pixels_per_unit (GNOME_CANVAS (view->canvas), - scale); - view->scale = scale; gnome_canvas_set_scroll_region (GNOME_CANVAS (view->canvas), 0.0, 0.0, label_width, label_height); @@ -468,33 +475,6 @@ gl_view_construct_selection (glView *view) gl_debug (DEBUG_VIEW, "END"); } -/*---------------------------------------------------------------------------*/ -/* PRIVATE. Determine an apropriate scale for given label & screen size */ -/*---------------------------------------------------------------------------*/ -static gdouble -get_apropriate_scale (gdouble w, gdouble h) -{ - gdouble w_screen, h_screen; - gint i; - gdouble k; - - gl_debug (DEBUG_VIEW, ""); - - w_screen = (gdouble) gdk_screen_width (); - h_screen = (gdouble) gdk_screen_height (); - - for (i = 0; i < N_SCALES; 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. Create, draw and order layers. */ /*---------------------------------------------------------------------------*/ @@ -1982,25 +1962,28 @@ gl_view_delete_selection (glView *view) } /*****************************************************************************/ -/* Edit properties of selected object. */ +/* Get object property editor of first selected object. */ /*****************************************************************************/ -void -gl_view_edit_object_props (glView *view) +GtkWidget * +gl_view_get_editor (glView *view) { glViewObject *view_object; + GtkWidget *editor = NULL; gl_debug (DEBUG_VIEW, "START"); g_return_if_fail (view && GL_IS_VIEW (view)); - if (gl_view_is_selection_atomic (view)) { + if (!gl_view_is_selection_empty (view)) { view_object = GL_VIEW_OBJECT(view->selected_object_list->data); - gl_view_object_show_dialog (view_object); + editor = gl_view_object_get_editor (view_object); } gl_debug (DEBUG_VIEW, "END"); + + return editor; } /*****************************************************************************/ @@ -3010,6 +2993,45 @@ gl_view_zoom_out (glView *view) gl_debug (DEBUG_VIEW, "END"); } +/*****************************************************************************/ +/* Set zoom to best fit. */ +/*****************************************************************************/ +void +gl_view_zoom_best_fit (glView *view) +{ + gint w_view, h_view; + gdouble w_label, h_label; + gdouble x_zoom, y_zoom, new_zoom; + + gl_debug (DEBUG_VIEW, ""); + + if ( ! GTK_WIDGET_VISIBLE(view)) { + gl_view_set_zoom (view, 1.0); + return; + } + + w_view = GTK_WIDGET(view)->allocation.width; + h_view = GTK_WIDGET(view)->allocation.height; + + gl_label_get_size (GL_LABEL(view->label), &w_label, &h_label); + + gl_debug (DEBUG_VIEW, "View size: %d, %d", w_view, h_view); + gl_debug (DEBUG_VIEW, "Label size: %g, %g", w_label, h_label); + + /* Calculate best zoom level */ + x_zoom = (double)(w_view - ZOOMTOFIT_PAD) / w_label; + y_zoom = (double)(h_view - ZOOMTOFIT_PAD) / h_label; + new_zoom = MIN (x_zoom, y_zoom) / HOME_SCALE; + gl_debug (DEBUG_VIEW, "Candidate scales: %g, %g => %g", x_zoom, y_zoom, new_zoom); + + /* Limit */ + new_zoom = MIN (new_zoom, scales[0]/HOME_SCALE); + new_zoom = MAX (new_zoom, scales[N_SCALES-1]/HOME_SCALE); + gl_debug (DEBUG_VIEW, "Limitted zoom: %g", new_zoom); + + gl_view_set_zoom (view, new_zoom); +} + /*****************************************************************************/ /* Set current zoom factor to explicit value. */ /*****************************************************************************/ @@ -3352,21 +3374,6 @@ construct_selection_menu (glView *view) menu = gtk_menu_new (); - menuitem = gtk_image_menu_item_new_from_stock (GL_STOCK_PROPERTIES, NULL); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - gtk_widget_show (menuitem); - g_signal_connect_swapped (G_OBJECT (menuitem), "activate", - G_CALLBACK (gl_view_edit_object_props), view); - view->atomic_selection_items = - g_list_prepend (view->atomic_selection_items, menuitem); - - /* - * Separator ------------------------- - */ - menuitem = gtk_menu_item_new (); - gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem); - gtk_widget_show (menuitem); - /* * Submenu: Order */ diff --git a/glabels2/src/view.h b/glabels2/src/view.h index 48fc0261..e3628187 100644 --- a/glabels2/src/view.h +++ b/glabels2/src/view.h @@ -168,7 +168,7 @@ gboolean gl_view_is_selection_atomic (glView *view); void gl_view_delete_selection (glView *view); -void gl_view_edit_object_props (glView *view); +GtkWidget *gl_view_get_editor (glView *view); void gl_view_raise_selection (glView *view); @@ -252,6 +252,8 @@ void gl_view_zoom_in (glView *view); void gl_view_zoom_out (glView *view); +void gl_view_zoom_best_fit (glView *view); + void gl_view_set_zoom (glView *view, gdouble scale); diff --git a/glabels2/src/wdgt-bc-data.c b/glabels2/src/wdgt-bc-data.c deleted file mode 100644 index 9da7abec..00000000 --- a/glabels2/src/wdgt-bc-data.c +++ /dev/null @@ -1,417 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_bc_data.c: barcode data widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "wdgt-bc-data.h" -#include "merge.h" -#include "marshal.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtBCDataSignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static glHigVBoxClass *parent_class; - -static gint wdgt_bc_data_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_bc_data_class_init (glWdgtBCDataClass *class); -static void gl_wdgt_bc_data_instance_init (glWdgtBCData *bc_data); -static void gl_wdgt_bc_data_finalize (GObject *object); -static void gl_wdgt_bc_data_construct (glWdgtBCData *bc_data, - glMerge *merge); - -static void changed_cb (glWdgtBCData *bc_data); -static void radio_toggled_cb (GtkToggleButton *togglebutton, - glWdgtBCData *bc_data); - - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_wdgt_bc_data_get_type (void) -{ - static guint wdgt_bc_data_type = 0; - - if (!wdgt_bc_data_type) { - GTypeInfo wdgt_bc_data_info = { - sizeof (glWdgtBCDataClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_bc_data_class_init, - NULL, - NULL, - sizeof (glWdgtBCData), - 0, - (GInstanceInitFunc) gl_wdgt_bc_data_instance_init, - }; - - wdgt_bc_data_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtBCData", - &wdgt_bc_data_info, 0); - } - - return wdgt_bc_data_type; -} - -static void -gl_wdgt_bc_data_class_init (glWdgtBCDataClass *class) -{ - GObjectClass *object_class; - - gl_debug (DEBUG_WDGT, "START"); - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_bc_data_finalize; - - wdgt_bc_data_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtBCDataClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - - gl_debug (DEBUG_WDGT, "END"); -} - -static void -gl_wdgt_bc_data_instance_init (glWdgtBCData *bc_data) -{ - gl_debug (DEBUG_WDGT, "START"); - - bc_data->literal_radio = NULL; - bc_data->literal_entry = NULL; - - bc_data->key_radio = NULL; - bc_data->key_combo = NULL; - bc_data->key_entry = NULL; - - gl_debug (DEBUG_WDGT, "END"); -} - -static void -gl_wdgt_bc_data_finalize (GObject *object) -{ - glWdgtBCData *bc_data; - glWdgtBCDataClass *class; - - gl_debug (DEBUG_WDGT, "START"); - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_BC_DATA (object)); - - bc_data = GL_WDGT_BC_DATA (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); - - gl_debug (DEBUG_WDGT, "END"); -} - -/****************************************************************************/ -/* New widget. */ -/****************************************************************************/ -GtkWidget * -gl_wdgt_bc_data_new (glMerge *merge) -{ - glWdgtBCData *bc_data; - - gl_debug (DEBUG_WDGT, "START"); - - bc_data = g_object_new (gl_wdgt_bc_data_get_type (), NULL); - - gl_wdgt_bc_data_construct (bc_data, merge); - - gl_debug (DEBUG_WDGT, "END"); - - return GTK_WIDGET (bc_data); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_wdgt_bc_data_construct (glWdgtBCData *bc_data, - glMerge *merge) -{ - GtkWidget *wvbox, *whbox; - GSList *radio_group = NULL; - GList *keys; - - gl_debug (DEBUG_WDGT, "START"); - - wvbox = GTK_WIDGET (bc_data); - - /* ---- Literal line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Literal radio */ - bc_data->literal_radio = gtk_radio_button_new_with_label (radio_group, - _ - ("Literal:")); - radio_group = - gtk_radio_button_get_group (GTK_RADIO_BUTTON (bc_data->literal_radio)); - g_signal_connect (G_OBJECT (bc_data->literal_radio), "toggled", - G_CALLBACK (radio_toggled_cb), - G_OBJECT (bc_data)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->literal_radio); - - /* Literal entry widget */ - bc_data->literal_entry = gtk_entry_new (); - gtk_widget_set_size_request (bc_data->literal_entry, 200, -1); - g_signal_connect_swapped (G_OBJECT (bc_data->literal_entry), - "changed", G_CALLBACK (changed_cb), - G_OBJECT (bc_data)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->literal_entry); - - /* ---- Key line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Key radio */ - bc_data->key_radio = gtk_radio_button_new_with_label (radio_group, - _("Key:")); - g_signal_connect (G_OBJECT (bc_data->key_radio), "toggled", - G_CALLBACK (radio_toggled_cb), - G_OBJECT (bc_data)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->key_radio); - - /* Key entry widget */ - bc_data->key_combo = gtk_combo_new (); - keys = gl_merge_get_key_list (merge); - if (keys != NULL) - gtk_combo_set_popdown_strings (GTK_COMBO (bc_data->key_combo), - keys); - gl_merge_free_key_list (&keys); - bc_data->key_entry = GTK_COMBO (bc_data->key_combo)->entry; - gtk_entry_set_editable (GTK_ENTRY (bc_data->key_entry), FALSE); - gtk_widget_set_size_request (bc_data->key_combo, 200, -1); - g_signal_connect_swapped (G_OBJECT (bc_data->key_entry), "changed", - G_CALLBACK (changed_cb), - G_OBJECT (bc_data)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_data->key_combo); - - gl_debug (DEBUG_WDGT, "END"); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glWdgtBCData *bc_data) -{ - gl_debug (DEBUG_WDGT, "START"); - - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (bc_data), wdgt_bc_data_signals[CHANGED], 0); - - gl_debug (DEBUG_WDGT, "END"); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback to handle toggling of radio buttons */ -/*--------------------------------------------------------------------------*/ -static void -radio_toggled_cb (GtkToggleButton *togglebutton, - glWdgtBCData *bc_data) -{ - gl_debug (DEBUG_WDGT, "START"); - - 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_combo, FALSE); - } else { - gtk_widget_set_sensitive (bc_data->literal_entry, FALSE); - gtk_widget_set_sensitive (bc_data->key_combo, TRUE); - } - - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (bc_data), wdgt_bc_data_signals[CHANGED], 0); - - gl_debug (DEBUG_WDGT, "END"); -} - -/****************************************************************************/ -/* Set new field definitions. */ -/****************************************************************************/ -void -gl_wdgt_bc_data_set_field_defs (glWdgtBCData *bc_data, - glMerge *merge) -{ - GList *keys; - - gl_debug (DEBUG_WDGT, "START"); - - keys = gl_merge_get_key_list (merge); - if ( keys != NULL ) { - gtk_combo_set_popdown_strings (GTK_COMBO (bc_data->key_combo), - keys); - gl_merge_free_key_list (&keys); - } else { - keys = g_list_append (keys, ""); - gtk_combo_set_popdown_strings (GTK_COMBO (bc_data->key_combo), - keys); - g_list_free (keys); - } - - gl_debug (DEBUG_WDGT, "END"); -} - - -/****************************************************************************/ -/* Get widget data. */ -/****************************************************************************/ -glTextNode * -gl_wdgt_bc_data_get_data (glWdgtBCData *bc_data) -{ - glTextNode *text_node; - - gl_debug (DEBUG_WDGT, "START"); - - text_node = g_new0(glTextNode,1); - - if (gtk_toggle_button_get_active - (GTK_TOGGLE_BUTTON (bc_data->literal_radio))) { - text_node->field_flag = FALSE; - text_node->data = - gtk_editable_get_chars (GTK_EDITABLE - (bc_data->literal_entry), 0, -1); - } else { - text_node->field_flag = TRUE; - text_node->data = - gtk_editable_get_chars (GTK_EDITABLE (bc_data->key_entry), - 0, -1); - gl_debug (DEBUG_WDGT, "text_node: field_flag=%d, data=%s", - text_node->field_flag, text_node->data); - } - - gl_debug (DEBUG_WDGT, "END"); - - return text_node; -} - -/****************************************************************************/ -/* Set widget data. */ -/****************************************************************************/ -void -gl_wdgt_bc_data_set_data (glWdgtBCData *bc_data, - gboolean merge_flag, - glTextNode *text_node) -{ - gint pos; - - gl_debug (DEBUG_WDGT, "START"); - - gtk_widget_set_sensitive (bc_data->key_radio, merge_flag); - - if (!text_node->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_combo, FALSE); - - g_signal_handlers_block_by_func (G_OBJECT - (bc_data->literal_entry), - G_CALLBACK (changed_cb), - bc_data); - gtk_editable_delete_text (GTK_EDITABLE (bc_data->literal_entry), - 0, -1); - g_signal_handlers_unblock_by_func (G_OBJECT - (bc_data->literal_entry), - G_CALLBACK - (changed_cb), bc_data); - - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (bc_data->literal_entry), - text_node->data, - strlen (text_node->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_combo, TRUE); - - g_signal_handlers_block_by_func (G_OBJECT - (bc_data->key_entry), - G_CALLBACK (changed_cb), - bc_data); - gtk_editable_delete_text (GTK_EDITABLE (bc_data->key_entry), 0, - -1); - g_signal_handlers_unblock_by_func (G_OBJECT - (bc_data->key_entry), - G_CALLBACK - (changed_cb), bc_data); - - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (bc_data->key_entry), - text_node->data, - strlen (text_node->data), - &pos); - } - - gl_debug (DEBUG_WDGT, "END"); -} - -/****************************************************************************/ -/* Set size group for internal labels */ -/****************************************************************************/ -void -gl_wdgt_bc_data_set_label_size_group (glWdgtBCData *bc_data, - GtkSizeGroup *label_size_group) -{ - gl_debug (DEBUG_WDGT, "START"); - - gtk_size_group_add_widget (label_size_group, bc_data->literal_radio); - gtk_size_group_add_widget (label_size_group, bc_data->key_radio); - - gl_debug (DEBUG_WDGT, "END"); -} diff --git a/glabels2/src/wdgt-bc-data.h b/glabels2/src/wdgt-bc-data.h deleted file mode 100644 index 2fd8c001..00000000 --- a/glabels2/src/wdgt-bc-data.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_bc_data.h: barcode data widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_BC_DATA_H__ -#define __WDGT_BC_DATA_H__ - -#include -#include "text-node.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_BC_DATA (gl_wdgt_bc_data_get_type ()) -#define GL_WDGT_BC_DATA(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_BC_DATA, glWdgtBCData )) -#define GL_WDGT_BC_DATA_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_BC_DATA, glWdgtBCDataClass)) -#define GL_IS_WDGT_BC_DATA(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_BC_DATA)) -#define GL_IS_WDGT_BC_DATA_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_BC_DATA)) - -typedef struct _glWdgtBCData glWdgtBCData; -typedef struct _glWdgtBCDataClass glWdgtBCDataClass; - -struct _glWdgtBCData { - glHigVBox parent_widget; - - GtkWidget *literal_radio; - GtkWidget *literal_entry; - - GtkWidget *key_radio; - GtkWidget *key_combo; - GtkWidget *key_entry; -}; - -struct _glWdgtBCDataClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtBCData * bc_data, gpointer user_data); -}; - -guint gl_wdgt_bc_data_get_type (void); - -GtkWidget *gl_wdgt_bc_data_new (glMerge *merge); - -void gl_wdgt_bc_data_set_field_defs (glWdgtBCData *bc_data, - glMerge *merge); - -glTextNode *gl_wdgt_bc_data_get_data (glWdgtBCData *bc_data); - -void gl_wdgt_bc_data_set_data (glWdgtBCData *bc_data, - gboolean merge_flag, - glTextNode *text_node); - -void gl_wdgt_bc_data_set_label_size_group (glWdgtBCData *bc_data, - GtkSizeGroup *label_size_group); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-bc-props.c b/glabels2/src/wdgt-bc-props.c deleted file mode 100644 index f76063b5..00000000 --- a/glabels2/src/wdgt-bc-props.c +++ /dev/null @@ -1,237 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_bc_props.c: barcode properties widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "mygal/widget-color-combo.h" -#include "prefs.h" -#include "wdgt-bc-props.h" -#include "marshal.h" -#include "color.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtBCPropsSignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static glHigVBoxClass *parent_class; - -static gint wdgt_bc_props_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_bc_props_class_init (glWdgtBCPropsClass *class); -static void gl_wdgt_bc_props_instance_init (glWdgtBCProps *prop); -static void gl_wdgt_bc_props_finalize (GObject *object); -static void gl_wdgt_bc_props_construct (glWdgtBCProps *prop); - -static void changed_cb (glWdgtBCProps *prop); - -/***************************************************************************/ -/* Boilerplate Object stuff. */ -/***************************************************************************/ -guint -gl_wdgt_bc_props_get_type (void) -{ - static guint wdgt_bc_props_type = 0; - - if (!wdgt_bc_props_type) { - GTypeInfo wdgt_bc_props_info = { - sizeof (glWdgtBCPropsClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_bc_props_class_init, - NULL, - NULL, - sizeof (glWdgtBCProps), - 0, - (GInstanceInitFunc) gl_wdgt_bc_props_instance_init, - }; - - wdgt_bc_props_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtBCProps", - &wdgt_bc_props_info, 0); - } - - return wdgt_bc_props_type; -} - -static void -gl_wdgt_bc_props_class_init (glWdgtBCPropsClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_bc_props_finalize; - - wdgt_bc_props_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtBCPropsClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} - -static void -gl_wdgt_bc_props_instance_init (glWdgtBCProps *prop) -{ - prop->color_picker = NULL; -} - -static void -gl_wdgt_bc_props_finalize (GObject * object) -{ - glWdgtBCProps *prop; - glWdgtBCPropsClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_BC_PROPS (object)); - - prop = GL_WDGT_BC_PROPS (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/***************************************************************************/ -/* New widget. */ -/***************************************************************************/ -GtkWidget * -gl_wdgt_bc_props_new (void) -{ - glWdgtBCProps *prop; - - prop = g_object_new (gl_wdgt_bc_props_get_type (), NULL); - - gl_wdgt_bc_props_construct (prop); - - return GTK_WIDGET (prop); -} - -/*------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*------------------------------------------------------------------------*/ -static void -gl_wdgt_bc_props_construct (glWdgtBCProps *prop) -{ - GtkWidget *wvbox, *whbox, *wlabel; - ColorGroup *cg; - GdkColor *gdk_color; - - wvbox = GTK_WIDGET (prop); - - /* ---- Color line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Line Color Label */ - prop->color_label = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (prop->color_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->color_label); - - /* Line Color picker widget */ - cg = color_group_fetch ("line_color_group", NULL); - gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); - prop->color_picker = color_combo_new (NULL, _("Default"), gdk_color, cg); - color_combo_box_set_preview_relief (COLOR_COMBO(prop->color_picker), - GTK_RELIEF_NORMAL); - g_free (gdk_color); - g_signal_connect_swapped (G_OBJECT (prop->color_picker), "color_changed", - G_CALLBACK (changed_cb), - G_OBJECT (prop)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), prop->color_picker); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glWdgtBCProps *prop) -{ - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (prop), wdgt_bc_props_signals[CHANGED], 0); -} - -/***************************************************************************/ -/* query values from controls. */ -/***************************************************************************/ -void -gl_wdgt_bc_props_get_params (glWdgtBCProps *prop, - guint *color) -{ - GdkColor *gdk_color; - gboolean is_default; - - gdk_color = color_combo_get_color (COLOR_COMBO(prop->color_picker), - &is_default); - - if (is_default) { - *color = gl_prefs->default_line_color; - } else { - *color = gl_color_from_gdk_color (gdk_color); - } -} - -/***************************************************************************/ -/* fill in values and ranges for controls. */ -/***************************************************************************/ -void -gl_wdgt_bc_props_set_params (glWdgtBCProps *prop, - guint color) -{ - GdkColor *gdk_color; - - gdk_color = gl_color_to_gdk_color (color); - color_combo_set_color (COLOR_COMBO(prop->color_picker), gdk_color); - g_free (gdk_color); -} - -/****************************************************************************/ -/* Set size group for internal labels */ -/****************************************************************************/ -void -gl_wdgt_bc_props_set_label_size_group (glWdgtBCProps *prop, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, prop->color_label); -} - diff --git a/glabels2/src/wdgt-bc-props.h b/glabels2/src/wdgt-bc-props.h deleted file mode 100644 index fd588e31..00000000 --- a/glabels2/src/wdgt-bc-props.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_bc_props.h: barcode properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_BC_PROPS_H__ -#define __WDGT_BC_PROPS_H__ - -#include -#include "bc.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_BC_PROPS (gl_wdgt_bc_props_get_type ()) -#define GL_WDGT_BC_PROPS(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_BC_PROPS, glWdgtBCProps )) -#define GL_WDGT_BC_PROPS_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_BC_PROPS, glWdgtBCPropsClass)) -#define GL_IS_WDGT_BC_PROPS(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_BC_PROPS)) -#define GL_IS_WDGT_BC_PROPS_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_BC_PROPS)) - -typedef struct _glWdgtBCProps glWdgtBCProps; -typedef struct _glWdgtBCPropsClass glWdgtBCPropsClass; - -struct _glWdgtBCProps { - glHigVBox parent_widget; - - GtkWidget *color_label; - GtkWidget *color_picker; -}; - -struct _glWdgtBCPropsClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtBCProps * prop, gpointer user_data); -}; - -guint gl_wdgt_bc_props_get_type (void); - -GtkWidget *gl_wdgt_bc_props_new (void); - -void gl_wdgt_bc_props_get_params (glWdgtBCProps *prop, - guint *color); - -void gl_wdgt_bc_props_set_params (glWdgtBCProps *prop, - guint color); - -void gl_wdgt_bc_props_set_label_size_group (glWdgtBCProps *prop, - GtkSizeGroup *label_size_group); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-bc-style.c b/glabels2/src/wdgt-bc-style.c deleted file mode 100644 index 0f97455a..00000000 --- a/glabels2/src/wdgt-bc-style.c +++ /dev/null @@ -1,323 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_bc_style.c: barcode style selection widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "wdgt-bc-style.h" -#include "marshal.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtBCStyleSignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static glHigVBoxClass *parent_class; - -static gint wdgt_bc_style_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_bc_style_class_init (glWdgtBCStyleClass *class); -static void gl_wdgt_bc_style_instance_init (glWdgtBCStyle *bc_style); -static void gl_wdgt_bc_style_finalize (GObject *object); -static void gl_wdgt_bc_style_construct (glWdgtBCStyle *bc_style); - -static void style_changed_cb (glWdgtBCStyle *bc_style); -static void checkbox_changed_cb (glWdgtBCStyle *bc_style); - - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_wdgt_bc_style_get_type (void) -{ - static guint wdgt_bc_style_type = 0; - - if (!wdgt_bc_style_type) { - GTypeInfo wdgt_bc_style_info = { - sizeof (glWdgtBCStyleClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_bc_style_class_init, - NULL, - NULL, - sizeof (glWdgtBCStyle), - 0, - (GInstanceInitFunc) gl_wdgt_bc_style_instance_init, - }; - - wdgt_bc_style_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtBCStyle", - &wdgt_bc_style_info, 0); - } - - return wdgt_bc_style_type; -} - -static void -gl_wdgt_bc_style_class_init (glWdgtBCStyleClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_bc_style_finalize; - - wdgt_bc_style_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtBCStyleClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} - -static void -gl_wdgt_bc_style_instance_init (glWdgtBCStyle *bc_style) -{ - bc_style->style_label = NULL; - bc_style->style_entry = NULL; - bc_style->text_check = NULL; -} - -static void -gl_wdgt_bc_style_finalize (GObject *object) -{ - glWdgtBCStyle *bc_style; - glWdgtBCStyleClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_BC_STYLE (object)); - - bc_style = GL_WDGT_BC_STYLE (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/****************************************************************************/ -/* New widget. */ -/****************************************************************************/ -GtkWidget * -gl_wdgt_bc_style_new (void) -{ - glWdgtBCStyle *bc_style; - - bc_style = g_object_new (gl_wdgt_bc_style_get_type (), NULL); - - gl_wdgt_bc_style_construct (bc_style); - - return GTK_WIDGET (bc_style); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_wdgt_bc_style_construct (glWdgtBCStyle *bc_style) -{ - GtkWidget *wvbox, *whbox, *wcombo; - GList *style_list; - - wvbox = GTK_WIDGET (bc_style); - - /* ---- Style line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Style Label */ - bc_style->style_label = gtk_label_new (_("Style:")); - gtk_misc_set_alignment (GTK_MISC (bc_style->style_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), bc_style->style_label); - - /* Style entry widget */ - wcombo = gtk_combo_new (); - style_list = gl_barcode_get_styles_list ();; - gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), style_list); - gl_barcode_free_styles_list (style_list); - bc_style->style_entry = GTK_COMBO (wcombo)->entry; - gtk_entry_set_editable (GTK_ENTRY (bc_style->style_entry), FALSE); - gtk_widget_set_size_request (wcombo, 200, -1); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo); - - - /* Text checkbox widget */ - bc_style->text_check = - gtk_check_button_new_with_label (_("Text")); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), bc_style->text_check); - - - /* Checksum checkbox widget */ - bc_style->checksum_check = - gtk_check_button_new_with_label (_("Checksum")); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), bc_style->checksum_check); - - - /* Connect signal callbacks */ - g_signal_connect_swapped (G_OBJECT (bc_style->style_entry), "changed", - G_CALLBACK (style_changed_cb), - G_OBJECT (bc_style)); - g_signal_connect_swapped (G_OBJECT (bc_style->text_check), "toggled", - G_CALLBACK (checkbox_changed_cb), - G_OBJECT (bc_style)); - g_signal_connect_swapped (G_OBJECT (bc_style->checksum_check), "toggled", - G_CALLBACK (checkbox_changed_cb), - G_OBJECT (bc_style)); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when style has changed. */ -/*--------------------------------------------------------------------------*/ -static void -style_changed_cb (glWdgtBCStyle *bc_style) -{ - gchar *style_string; - glBarcodeStyle style; - - style_string = - gtk_editable_get_chars (GTK_EDITABLE(bc_style->style_entry), - 0, -1); - - /* Don't emit if entry is empty. */ - if ( *style_string != 0 ) { - style = gl_barcode_text_to_style (style_string); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(bc_style->text_check), - gl_barcode_can_text (style)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(bc_style->checksum_check), - gl_barcode_can_csum (style)); - - gtk_widget_set_sensitive (bc_style->text_check, - gl_barcode_text_optional (style)); - gtk_widget_set_sensitive (bc_style->checksum_check, - gl_barcode_csum_optional (style)); - - - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (bc_style), - wdgt_bc_style_signals[CHANGED], 0); - } - - g_free (style_string); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when either checkbox has changed. */ -/*--------------------------------------------------------------------------*/ -static void -checkbox_changed_cb (glWdgtBCStyle *bc_style) -{ - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (bc_style), - wdgt_bc_style_signals[CHANGED], 0); -} - -/****************************************************************************/ -/* query values from controls. */ -/****************************************************************************/ -void -gl_wdgt_bc_style_get_params (glWdgtBCStyle *bc_style, - glBarcodeStyle *style, - gboolean *text_flag, - gboolean *checksum_flag) -{ - gchar *style_string; - - style_string = - gtk_editable_get_chars (GTK_EDITABLE(bc_style->style_entry), - 0, -1); - *style = gl_barcode_text_to_style (style_string); - - *text_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bc_style->text_check)); - - *checksum_flag = - gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bc_style->checksum_check)); - - g_free (style_string); -} - -/****************************************************************************/ -/* fill in values and ranges for controls. */ -/****************************************************************************/ -void -gl_wdgt_bc_style_set_params (glWdgtBCStyle *bc_style, - glBarcodeStyle style, - gboolean text_flag, - gboolean checksum_flag) -{ - const gchar *style_string; - gint pos; - - style_string = gl_barcode_style_to_text (style); - - g_signal_handlers_block_by_func (G_OBJECT(bc_style->style_entry), - G_CALLBACK (style_changed_cb), - bc_style); - gtk_editable_delete_text (GTK_EDITABLE (bc_style->style_entry), - 0, -1); - g_signal_handlers_unblock_by_func (G_OBJECT(bc_style->style_entry), - G_CALLBACK(style_changed_cb), - bc_style); - - pos = 0; - gtk_editable_insert_text (GTK_EDITABLE (bc_style->style_entry), - style_string, - strlen (style_string), - &pos); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bc_style->text_check), - text_flag); - - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (bc_style->checksum_check), - checksum_flag); - -} - -/****************************************************************************/ -/* Set size group for internal labels */ -/****************************************************************************/ -void -gl_wdgt_bc_style_set_label_size_group (glWdgtBCStyle *bc_style, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, bc_style->style_label); -} diff --git a/glabels2/src/wdgt-bc-style.h b/glabels2/src/wdgt-bc-style.h deleted file mode 100644 index d02f9074..00000000 --- a/glabels2/src/wdgt-bc-style.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_bc_style.h: barcode style selection widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_BC_STYLE_H__ -#define __WDGT_BC_STYLE_H__ - -#include -#include "bc.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_BC_STYLE (gl_wdgt_bc_style_get_type ()) -#define GL_WDGT_BC_STYLE(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_BC_STYLE, glWdgtBCStyle )) -#define GL_WDGT_BC_STYLE_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_BC_STYLE, glWdgtBCStyleClass)) -#define GL_IS_WDGT_BC_STYLE(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_BC_STYLE)) -#define GL_IS_WDGT_BC_STYLE_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_BC_STYLE)) - -typedef struct _glWdgtBCStyle glWdgtBCStyle; -typedef struct _glWdgtBCStyleClass glWdgtBCStyleClass; - -struct _glWdgtBCStyle { - glHigVBox parent_widget; - - GtkWidget *style_label; - GtkWidget *style_entry; - - GtkWidget *text_check; - GtkWidget *checksum_check; -}; - -struct _glWdgtBCStyleClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtBCStyle * prop, gpointer user_data); -}; - -guint gl_wdgt_bc_style_get_type (void); - -GtkWidget *gl_wdgt_bc_style_new (void); - -void gl_wdgt_bc_style_get_params (glWdgtBCStyle *bc_style, - glBarcodeStyle *style, - gboolean *text_flag, - gboolean *checksum_flag); - -void gl_wdgt_bc_style_set_params (glWdgtBCStyle *bc_style, - glBarcodeStyle style, - gboolean text_flag, - gboolean checksum_flag); - -void gl_wdgt_bc_style_set_label_size_group (glWdgtBCStyle *bc_style, - GtkSizeGroup *label_size_group); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-fill.c b/glabels2/src/wdgt-fill.c deleted file mode 100644 index c2c59703..00000000 --- a/glabels2/src/wdgt-fill.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_fill.c: fill properties widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "mygal/widget-color-combo.h" -#include "prefs.h" -#include "wdgt-fill.h" -#include "marshal.h" -#include "color.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtFillSignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GtkContainerClass *parent_class; - -static gint wdgt_fill_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_fill_class_init (glWdgtFillClass *class); -static void gl_wdgt_fill_instance_init (glWdgtFill *fill); -static void gl_wdgt_fill_finalize (GObject *object); -static void gl_wdgt_fill_construct (glWdgtFill *fill); - -static void changed_cb (glWdgtFill *fill); - - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_wdgt_fill_get_type (void) -{ - static guint wdgt_fill_type = 0; - - if (!wdgt_fill_type) { - GTypeInfo wdgt_fill_info = { - sizeof (glWdgtFillClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_fill_class_init, - NULL, - NULL, - sizeof (glWdgtFill), - 0, - (GInstanceInitFunc) gl_wdgt_fill_instance_init, - }; - - wdgt_fill_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtFill", - &wdgt_fill_info, 0); - } - - return wdgt_fill_type; -} - -static void -gl_wdgt_fill_class_init (glWdgtFillClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_fill_finalize; - - wdgt_fill_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtFillClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} - -static void -gl_wdgt_fill_instance_init (glWdgtFill *fill) -{ - fill->color_picker = NULL; -} - -static void -gl_wdgt_fill_finalize (GObject *object) -{ - glWdgtFill *fill; - glWdgtFillClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_FILL (object)); - - fill = GL_WDGT_FILL (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/****************************************************************************/ -/* New widget. */ -/****************************************************************************/ -GtkWidget * -gl_wdgt_fill_new (void) -{ - glWdgtFill *fill; - - fill = g_object_new (gl_wdgt_fill_get_type (), NULL); - - gl_wdgt_fill_construct (fill); - - return GTK_WIDGET (fill); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_wdgt_fill_construct (glWdgtFill *fill) -{ - GtkWidget *wvbox, *whbox; - ColorGroup *cg; - GdkColor *gdk_color; - - wvbox = GTK_WIDGET (fill); - - /* ---- Line color line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Fill Color Label */ - fill->color_label = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (fill->color_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), fill->color_label); - - /* Fill Color picker widget */ - cg = color_group_fetch ("fill_color_group", NULL); - gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); - fill->color_picker = color_combo_new (NULL, _("No fill"), gdk_color, cg); - color_combo_box_set_preview_relief (COLOR_COMBO(fill->color_picker), - GTK_RELIEF_NORMAL); - g_free (gdk_color); - g_signal_connect_swapped (G_OBJECT (fill->color_picker), "color_changed", - G_CALLBACK (changed_cb), - G_OBJECT (fill)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), fill->color_picker); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glWdgtFill *fill) -{ - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (fill), wdgt_fill_signals[CHANGED], 0); -} - -/****************************************************************************/ -/* query values from controls. */ -/****************************************************************************/ -void -gl_wdgt_fill_get_params (glWdgtFill *fill, - guint *color) -{ - GdkColor *gdk_color; - gboolean is_default; - - gdk_color = color_combo_get_color (COLOR_COMBO(fill->color_picker), - &is_default); - - if (is_default) { - *color = GL_COLOR_NONE; - } else { - *color = gl_color_from_gdk_color (gdk_color); - } -} - -/****************************************************************************/ -/* fill in values and ranges for controls. */ -/****************************************************************************/ -void -gl_wdgt_fill_set_params (glWdgtFill *fill, - guint color) -{ - GdkColor *gdk_color; - - gdk_color = gl_color_to_gdk_color (color); - color_combo_set_color (COLOR_COMBO(fill->color_picker), gdk_color); - g_free (gdk_color); -} - -/****************************************************************************/ -/* Set size group for internal labels */ -/****************************************************************************/ -void -gl_wdgt_fill_set_label_size_group (glWdgtFill *fill, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, fill->color_label); -} - diff --git a/glabels2/src/wdgt-fill.h b/glabels2/src/wdgt-fill.h deleted file mode 100644 index fae0d0ce..00000000 --- a/glabels2/src/wdgt-fill.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_fill.h: fill properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_FILL_H__ -#define __WDGT_FILL_H__ - -#include -#include "label.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_FILL (gl_wdgt_fill_get_type ()) -#define GL_WDGT_FILL(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_FILL, glWdgtFill )) -#define GL_WDGT_FILL_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_FILL, glWdgtFillClass)) -#define GL_IS_WDGT_FILL(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_FILL)) -#define GL_IS_WDGT_FILL_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_FILL)) - -typedef struct _glWdgtFill glWdgtFill; -typedef struct _glWdgtFillClass glWdgtFillClass; - -struct _glWdgtFill { - glHigVBox parent_widget; - - GtkWidget *color_label; - GtkWidget *color_picker; -}; - -struct _glWdgtFillClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtFill * fill, gpointer user_data); -}; - -guint gl_wdgt_fill_get_type (void); - -GtkWidget *gl_wdgt_fill_new (void); - -void gl_wdgt_fill_get_params (glWdgtFill *fill, - guint *color); - -void gl_wdgt_fill_set_params (glWdgtFill *fill, - guint color); - -void gl_wdgt_fill_set_label_size_group (glWdgtFill *fill, - GtkSizeGroup *label_size_group); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-line.c b/glabels2/src/wdgt-line.c deleted file mode 100644 index b975b1f1..00000000 --- a/glabels2/src/wdgt-line.c +++ /dev/null @@ -1,274 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_line.c: line properties widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "mygal/widget-color-combo.h" -#include "prefs.h" -#include "wdgt-line.h" -#include "marshal.h" -#include "color.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtLineSignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GObjectClass *parent_class; - -static gint wdgt_line_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_line_class_init (glWdgtLineClass *class); -static void gl_wdgt_line_instance_init (glWdgtLine *line); -static void gl_wdgt_line_finalize (GObject *object); -static void gl_wdgt_line_construct (glWdgtLine *line); - -static void changed_cb (glWdgtLine *line); - - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_wdgt_line_get_type (void) -{ - static guint wdgt_line_type = 0; - - if (!wdgt_line_type) { - GTypeInfo wdgt_line_info = { - sizeof (glWdgtLineClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_line_class_init, - NULL, - NULL, - sizeof (glWdgtLine), - 0, - (GInstanceInitFunc) gl_wdgt_line_instance_init, - }; - - wdgt_line_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtLine", - &wdgt_line_info, 0); - } - - return wdgt_line_type; -} - -static void -gl_wdgt_line_class_init (glWdgtLineClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_line_finalize; - - wdgt_line_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtLineClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} - -static void -gl_wdgt_line_instance_init (glWdgtLine *line) -{ - line->width_spin = NULL; - line->color_picker = NULL; - line->units_label = NULL; -} - -static void -gl_wdgt_line_finalize (GObject *object) -{ - glWdgtLine *line; - glWdgtLineClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_LINE (object)); - - line = GL_WDGT_LINE (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/****************************************************************************/ -/* New widget. */ -/****************************************************************************/ -GtkWidget * -gl_wdgt_line_new (void) -{ - glWdgtLine *line; - - line = g_object_new (gl_wdgt_line_get_type (), NULL); - - gl_wdgt_line_construct (line); - - return GTK_WIDGET (line); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_wdgt_line_construct (glWdgtLine *line) -{ - GtkWidget *wvbox, *wframe, *whbox; - GtkObject *adjust; - ColorGroup *cg; - GdkColor *gdk_color; - - wvbox = GTK_WIDGET (line); - - /* ---- Line width line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Line Width Label */ - line->width_label = gtk_label_new (_("Width:")); - gtk_misc_set_alignment (GTK_MISC (line->width_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->width_label); - - /* 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); - g_signal_connect_swapped (G_OBJECT (line->width_spin), "changed", - G_CALLBACK (changed_cb), - G_OBJECT (line)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->width_spin); - - /* Line Width units */ - line->units_label = gtk_label_new (_("points")); - gtk_misc_set_alignment (GTK_MISC (line->units_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->units_label); - - /* ---- Line color line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Line Color Label */ - line->color_label = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (line->color_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->color_label); - - /* Line Color picker widget */ - cg = color_group_fetch ("line_color_group", NULL); - gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); - line->color_picker = color_combo_new (NULL, _("No line"), gdk_color, cg); - color_combo_box_set_preview_relief (COLOR_COMBO(line->color_picker), - GTK_RELIEF_NORMAL); - g_free (gdk_color); - g_signal_connect_swapped (G_OBJECT (line->color_picker), "color_changed", - G_CALLBACK (changed_cb), - G_OBJECT (line)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), line->color_picker); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glWdgtLine *line) -{ - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (line), wdgt_line_signals[CHANGED], 0); -} - -/****************************************************************************/ -/* query values from controls. */ -/****************************************************************************/ -void -gl_wdgt_line_get_params (glWdgtLine *line, - gdouble *width, - guint *color) -{ - GdkColor *gdk_color; - gboolean is_default; - - *width = - gtk_spin_button_get_value (GTK_SPIN_BUTTON(line->width_spin)); - - gdk_color = color_combo_get_color (COLOR_COMBO(line->color_picker), - &is_default); - - if (is_default) { - *color = GL_COLOR_NONE; - } else { - *color = gl_color_from_gdk_color (gdk_color); - } -} - -/****************************************************************************/ -/* fill in values and ranges for controls. */ -/****************************************************************************/ -void -gl_wdgt_line_set_params (glWdgtLine *line, - gdouble width, - guint color) -{ - GdkColor *gdk_color; - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (line->width_spin), width); - - gdk_color = gl_color_to_gdk_color (color); - color_combo_set_color (COLOR_COMBO(line->color_picker), gdk_color); - g_free (gdk_color); - -} - -/****************************************************************************/ -/* Set size group for internal labels */ -/****************************************************************************/ -void -gl_wdgt_line_set_label_size_group (glWdgtLine *line, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, line->width_label); - gtk_size_group_add_widget (label_size_group, line->color_label); -} - diff --git a/glabels2/src/wdgt-line.h b/glabels2/src/wdgt-line.h deleted file mode 100644 index 21abef25..00000000 --- a/glabels2/src/wdgt-line.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_line.h: line properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_LINE_H__ -#define __WDGT_LINE_H__ - -#include -#include "label.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_LINE (gl_wdgt_line_get_type ()) -#define GL_WDGT_LINE(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_LINE, glWdgtLine )) -#define GL_WDGT_LINE_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_LINE, glWdgtLineClass)) -#define GL_IS_WDGT_LINE(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_LINE)) -#define GL_IS_WDGT_LINE_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_LINE)) - -typedef struct _glWdgtLine glWdgtLine; -typedef struct _glWdgtLineClass glWdgtLineClass; - -struct _glWdgtLine { - glHigVBox parent_widget; - - GtkWidget *width_label; - GtkWidget *width_spin; - - GtkWidget *color_label; - GtkWidget *color_picker; - GtkWidget *units_label; -}; - -struct _glWdgtLineClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtLine * line, gpointer user_data); -}; - -guint gl_wdgt_line_get_type (void); - -GtkWidget *gl_wdgt_line_new (void); - -void gl_wdgt_line_get_params (glWdgtLine *line, - gdouble *width, - guint *color); - -void gl_wdgt_line_set_params (glWdgtLine *line, - gdouble width, - guint color); - -void gl_wdgt_line_set_label_size_group (glWdgtLine *line, - GtkSizeGroup *label_size_group); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-position.c b/glabels2/src/wdgt-position.c deleted file mode 100644 index a010a143..00000000 --- a/glabels2/src/wdgt-position.c +++ /dev/null @@ -1,338 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_position.c: position properties widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "wdgt-position.h" -#include "prefs.h" -#include "marshal.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtPositionSignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static glHigVBoxClass *parent_class; - -static gint wdgt_position_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_position_class_init (glWdgtPositionClass *class); -static void gl_wdgt_position_instance_init (glWdgtPosition *position); -static void gl_wdgt_position_finalize (GObject *object); -static void gl_wdgt_position_construct (glWdgtPosition *position); - -static void changed_cb (glWdgtPosition *position); - - -/***************************************************************************/ -/* Boilerplate Object stuff. */ -/***************************************************************************/ -guint -gl_wdgt_position_get_type (void) -{ - static guint wdgt_position_type = 0; - - if (!wdgt_position_type) { - GTypeInfo wdgt_position_info = { - sizeof (glWdgtPositionClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_position_class_init, - NULL, - NULL, - sizeof (glWdgtPosition), - 0, - (GInstanceInitFunc) gl_wdgt_position_instance_init, - }; - - wdgt_position_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtPosition", - &wdgt_position_info, 0); - } - - return wdgt_position_type; -} - -static void -gl_wdgt_position_class_init (glWdgtPositionClass * class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_position_finalize; - - wdgt_position_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtPositionClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} - -static void -gl_wdgt_position_instance_init (glWdgtPosition * position) -{ - position->x_label = NULL; - position->x_spin = NULL; - - position->y_label = NULL; - position->y_spin = NULL; - - position->units_label = NULL; -} - -static void -gl_wdgt_position_finalize (GObject * object) -{ - glWdgtPosition *position; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_POSITION (object)); - - position = GL_WDGT_POSITION (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/***************************************************************************/ -/* New widget. */ -/***************************************************************************/ -GtkWidget * -gl_wdgt_position_new (void) -{ - glWdgtPosition *position; - - position = g_object_new (gl_wdgt_position_get_type (), NULL); - - gl_wdgt_position_construct (position); - - return GTK_WIDGET (position); -} - -/*-------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*-------------------------------------------------------------------------*/ -static void -gl_wdgt_position_construct (glWdgtPosition *position) -{ - GtkWidget *wvbox, *whbox; - GtkObject *x_adjust, *y_adjust; - const gchar *units_string; - gdouble units_per_point, climb_rate; - gint digits; - - gl_debug (DEBUG_WDGT, "START"); - - 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 (); - - gl_debug (DEBUG_WDGT, "units = %s", units_string); - gl_debug (DEBUG_WDGT, "units/point = %f", units_per_point); - gl_debug (DEBUG_WDGT, "climb_rate = %f", climb_rate); - gl_debug (DEBUG_WDGT, "digits = %d", digits); - - wvbox = GTK_WIDGET (position); - - /* ---- X line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* X label */ - position->x_label = gtk_label_new (_("X:")); - gtk_misc_set_alignment (GTK_MISC (position->x_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->x_label); - - /* 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); - g_signal_connect_swapped (G_OBJECT (position->x_spin), "changed", - G_CALLBACK (changed_cb), - G_OBJECT (position)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->x_spin); - - /* ---- Y line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Y label */ - position->y_label = gtk_label_new (_("Y:")); - gtk_misc_set_alignment (GTK_MISC (position->y_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->y_label); - - /* 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); - g_signal_connect_swapped (G_OBJECT (position->y_spin), "changed", - G_CALLBACK (changed_cb), - G_OBJECT (position)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->y_spin); - - /* Units */ - position->units_label = gtk_label_new (units_string); - gtk_misc_set_alignment (GTK_MISC (position->units_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), position->units_label); - - gl_debug (DEBUG_WDGT, "END"); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glWdgtPosition *position) -{ - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (position), wdgt_position_signals[CHANGED], 0); -} - -/***************************************************************************/ -/* query values from controls. */ -/***************************************************************************/ -void -gl_wdgt_position_get_position (glWdgtPosition *position, - gdouble *x, - gdouble *y) -{ - gdouble units_per_point; - - units_per_point = gl_prefs_get_units_per_point (); - - *x = gtk_spin_button_get_value (GTK_SPIN_BUTTON(position->x_spin)); - *y = gtk_spin_button_get_value (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_wdgt_position_set_params (glWdgtPosition *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); - -} - -/***************************************************************************/ -/* fill in position info only. */ -/***************************************************************************/ -void -gl_wdgt_position_set_position (glWdgtPosition *position, - gdouble x, - gdouble y) -{ - gdouble units_per_point; - - gl_debug (DEBUG_WDGT, "START"); - - units_per_point = gl_prefs_get_units_per_point (); - - gl_debug (DEBUG_WDGT, "units/point = %f", units_per_point); - - /* Put everything in our display units */ - x *= units_per_point; - y *= units_per_point; - - /* update X/Y spin controls */ - gtk_spin_button_set_value (GTK_SPIN_BUTTON (position->x_spin), x); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (position->y_spin), y); - - gl_debug (DEBUG_WDGT, "END"); -} - -/****************************************************************************/ -/* Set size group for internal labels */ -/****************************************************************************/ -void -gl_wdgt_position_set_label_size_group (glWdgtPosition *position, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, position->x_label); - gtk_size_group_add_widget (label_size_group, position->y_label); -} - diff --git a/glabels2/src/wdgt-position.h b/glabels2/src/wdgt-position.h deleted file mode 100644 index 00ecbfbd..00000000 --- a/glabels2/src/wdgt-position.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_position.h: position properties widget module header file - * - * Copyright (C) 2000, 2001 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_POSITION_H__ -#define __WDGT_POSITION_H__ - -#include -#include "label.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_POSITION (gl_wdgt_position_get_type ()) -#define GL_WDGT_POSITION(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_POSITION, glWdgtPosition )) -#define GL_WDGT_POSITION_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_POSITION, glWdgtPositionClass)) -#define GL_IS_WDGT_POSITION(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_POSITION)) -#define GL_IS_WDGT_POSITION_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_POSITION)) - -typedef struct _glWdgtPosition glWdgtPosition; -typedef struct _glWdgtPositionClass glWdgtPositionClass; - -struct _glWdgtPosition { - glHigVBox parent_widget; - - GtkWidget *x_label; - GtkWidget *x_spin; - - GtkWidget *y_label; - GtkWidget *y_spin; - - GtkWidget *units_label; -}; - -struct _glWdgtPositionClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtPosition * prop, gpointer user_data); -}; - -guint gl_wdgt_position_get_type (void); - -GtkWidget *gl_wdgt_position_new (void); - -void gl_wdgt_position_get_position (glWdgtPosition *position, - gdouble *x, - gdouble *y); - -void gl_wdgt_position_set_params (glWdgtPosition *position, - gdouble x, - gdouble y, - gdouble x_max, - gdouble y_max); - -void gl_wdgt_position_set_position (glWdgtPosition *position, - gdouble x, - gdouble y); - -void gl_wdgt_position_set_label_size_group (glWdgtPosition *position, - GtkSizeGroup *size_group); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-size.c b/glabels2/src/wdgt-size.c deleted file mode 100644 index 5e7f291d..00000000 --- a/glabels2/src/wdgt-size.c +++ /dev/null @@ -1,507 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_size.c: size properties widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "wdgt-size.h" -#include "prefs.h" -#include "marshal.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtSizeSignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static glHigVBoxClass *parent_class; - -static gint wdgt_size_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_size_class_init (glWdgtSizeClass *class); -static void gl_wdgt_size_instance_init (glWdgtSize *size); -static void gl_wdgt_size_finalize (GObject *object); -static void gl_wdgt_size_construct (glWdgtSize *size); - -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_wdgt_size_get_type (void) -{ - static guint wdgt_size_type = 0; - - if (!wdgt_size_type) { - GTypeInfo wdgt_size_info = { - sizeof (glWdgtSizeClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_size_class_init, - NULL, - NULL, - sizeof (glWdgtSize), - 0, - (GInstanceInitFunc) gl_wdgt_size_instance_init, - }; - - wdgt_size_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtSize", - &wdgt_size_info, 0); - } - - return wdgt_size_type; -} - -static void -gl_wdgt_size_class_init (glWdgtSizeClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_size_finalize; - - wdgt_size_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtSizeClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} - -static void -gl_wdgt_size_instance_init (glWdgtSize *size) -{ - size->aspect_ratio = 1.0; - - size->w_label = NULL; - size->w_spin = NULL; - size->h_label = NULL; - size->h_spin = NULL; - - size->units_label = NULL; - - size->aspect_checkbox = NULL; -} - -static void -gl_wdgt_size_finalize (GObject *object) -{ - glWdgtSize *size; - glWdgtSizeClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_SIZE (object)); - - size = GL_WDGT_SIZE (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/***************************************************************************/ -/* New widget. */ -/***************************************************************************/ -GtkWidget * -gl_wdgt_size_new (void) -{ - glWdgtSize *size; - - size = g_object_new (gl_wdgt_size_get_type (), NULL); - - gl_wdgt_size_construct (size); - - return GTK_WIDGET (size); -} - -/*-------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*-------------------------------------------------------------------------*/ -static void -gl_wdgt_size_construct (glWdgtSize *size) -{ - GtkWidget *wvbox, *whbox; - 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); - - /* ---- W line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* W Label */ - size->w_label = gtk_label_new (_("Width:")); - gtk_misc_set_alignment (GTK_MISC (size->w_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), size->w_label); - - /* 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); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), size->w_spin); - - /* ---- H line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* H label */ - size->h_label = gtk_label_new (_("Height:")); - gtk_misc_set_alignment (GTK_MISC (size->h_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), size->h_label); - - /* 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); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), size->h_spin); - - /* Units */ - size->units_label = gtk_label_new (units_string); - gtk_misc_set_alignment (GTK_MISC (size->units_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), size->units_label); - - /* Maintain aspect ratio checkbox */ - size->aspect_checkbox = - gtk_check_button_new_with_label (_ - ("Maintain current aspect ratio")); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), size->aspect_checkbox); - - /* Connect signals to controls */ - g_signal_connect (G_OBJECT (size->aspect_checkbox), "toggled", - G_CALLBACK (aspect_toggle_cb), size); - g_signal_connect (G_OBJECT (size->w_spin), "changed", - G_CALLBACK (w_spin_cb), size); - g_signal_connect (G_OBJECT (size->h_spin), "changed", - G_CALLBACK (h_spin_cb), size); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Maintain aspect ratio checkbox callback. */ -/*--------------------------------------------------------------------------*/ -static void -aspect_toggle_cb (GtkToggleButton *togglebutton, - gpointer user_data) -{ - glWdgtSize *size = GL_WDGT_SIZE (user_data); - GtkAdjustment *w_adjust, *h_adjust; - - if (gtk_toggle_button_get_active (togglebutton)) { - - size->w = - gtk_spin_button_get_value (GTK_SPIN_BUTTON(size->w_spin)); - size->h = - gtk_spin_button_get_value (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; - - } - - g_signal_handlers_block_by_func (GTK_OBJECT (size->w_spin), - G_CALLBACK (w_spin_cb), - user_data); - g_signal_handlers_block_by_func (GTK_OBJECT (size->h_spin), - G_CALLBACK (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)); - g_signal_handlers_unblock_by_func (GTK_OBJECT (size->w_spin), - G_CALLBACK (w_spin_cb), - user_data); - g_signal_handlers_unblock_by_func (GTK_OBJECT (size->h_spin), - G_CALLBACK (h_spin_cb), - user_data); - - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (size), wdgt_size_signals[CHANGED], 0); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. W spin button changed callback. */ -/*--------------------------------------------------------------------------*/ -static void -w_spin_cb (GtkSpinButton *spinbutton, - gpointer user_data) -{ - glWdgtSize *size = GL_WDGT_SIZE (user_data); - GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (size->aspect_checkbox); - - size->w = - gtk_spin_button_get_value (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. */ - g_signal_handlers_block_by_func (GTK_OBJECT (size->h_spin), - G_CALLBACK (h_spin_cb), - user_data); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (size->h_spin), - size->h); - g_signal_handlers_unblock_by_func (GTK_OBJECT (size->h_spin), - G_CALLBACK (h_spin_cb), - user_data); - } - - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (size), wdgt_size_signals[CHANGED], 0); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. H spin button changed callback. */ -/*--------------------------------------------------------------------------*/ -static void -h_spin_cb (GtkSpinButton *spinbutton, - gpointer user_data) -{ - glWdgtSize *size = GL_WDGT_SIZE (user_data); - GtkToggleButton *toggle = GTK_TOGGLE_BUTTON (size->aspect_checkbox); - - size->h = - gtk_spin_button_get_value (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. */ - g_signal_handlers_block_by_func (GTK_OBJECT (size->w_spin), - G_CALLBACK (w_spin_cb), - user_data); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (size->w_spin), - size->w); - g_signal_handlers_unblock_by_func (GTK_OBJECT (size->w_spin), - G_CALLBACK (w_spin_cb), - user_data); - } - - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (size), wdgt_size_signals[CHANGED], 0); - -} - -/***************************************************************************/ -/* query values from controls. */ -/***************************************************************************/ -void -gl_wdgt_size_get_size (glWdgtSize *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 (GTK_SPIN_BUTTON(size->w_spin)); - *h = gtk_spin_button_get_value (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_wdgt_size_set_params (glWdgtSize *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); - -} - -/***************************************************************************/ -/* set size only. */ -/***************************************************************************/ -void -gl_wdgt_size_set_size (glWdgtSize *size, - gdouble w, - gdouble h) -{ - gdouble units_per_point; - - units_per_point = gl_prefs_get_units_per_point (); - - /* Put everything into our display units */ - size->w = w * units_per_point; - size->h = h * units_per_point; - - /* update aspect ratio */ - size->aspect_ratio = size->h / size->w; - - /* update W/H spin controls */ - g_signal_handlers_block_by_func (GTK_OBJECT (size->w_spin), - G_CALLBACK (w_spin_cb), - size); - g_signal_handlers_block_by_func (GTK_OBJECT (size->h_spin), - G_CALLBACK (h_spin_cb), - size); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (size->w_spin), size->w); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (size->h_spin), size->h); - g_signal_handlers_unblock_by_func (GTK_OBJECT (size->w_spin), - G_CALLBACK (w_spin_cb), - size); - g_signal_handlers_unblock_by_func (GTK_OBJECT (size->h_spin), - G_CALLBACK (h_spin_cb), - size); -} - -/****************************************************************************/ -/* Set size group for internal labels */ -/****************************************************************************/ -void -gl_wdgt_size_set_label_size_group (glWdgtSize *size, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, size->w_label); - gtk_size_group_add_widget (label_size_group, size->h_label); -} diff --git a/glabels2/src/wdgt-size.h b/glabels2/src/wdgt-size.h deleted file mode 100644 index 3b3723d2..00000000 --- a/glabels2/src/wdgt-size.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_size.h: size properties widget module header file - * - * Copyright (C) 2000, 2001 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_SIZE_H__ -#define __WDGT_SIZE_H__ - -#include -#include "label.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_SIZE (gl_wdgt_size_get_type ()) -#define GL_WDGT_SIZE(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_SIZE, glWdgtSize )) -#define GL_WDGT_SIZE_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_SIZE, glWdgtSizeClass)) -#define GL_IS_WDGT_SIZE(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_SIZE)) -#define GL_IS_WDGT_SIZE_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_SIZE)) - -typedef struct _glWdgtSize glWdgtSize; -typedef struct _glWdgtSizeClass glWdgtSizeClass; - -struct _glWdgtSize { - glHigVBox parent_widget; - - gdouble w, h; - gdouble aspect_ratio; - gdouble w_max, h_max; - gdouble w_max_orig, h_max_orig; - - GtkWidget *w_label; - GtkWidget *w_spin; - - GtkWidget *h_label; - GtkWidget *h_spin; - GtkWidget *units_label; - - GtkWidget *aspect_checkbox; -}; - -struct _glWdgtSizeClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtSize * size, gpointer user_data); -}; - -guint gl_wdgt_size_get_type (void); - -GtkWidget *gl_wdgt_size_new (void); - -void gl_wdgt_size_get_size (glWdgtSize *size, - gdouble *w, - gdouble *h, - gboolean *keep_aspect_ratio_flag); - -void gl_wdgt_size_set_params (glWdgtSize *size, - gdouble w, - gdouble h, - gboolean keep_aspect_ratio_flag, - gdouble w_max, - gdouble h_max); - -void gl_wdgt_size_set_size (glWdgtSize *size, - gdouble w, - gdouble h); - -void gl_wdgt_size_set_label_size_group (glWdgtSize *size, - GtkSizeGroup *label_size_group); - - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-text-entry.c b/glabels2/src/wdgt-text-entry.c deleted file mode 100644 index ca498ff9..00000000 --- a/glabels2/src/wdgt-text-entry.c +++ /dev/null @@ -1,295 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_text_entry.c: text entry widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "wdgt-text-entry.h" -#include "merge.h" -#include "text-node.h" -#include "marshal.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -typedef void (*glWdgtTextEntrySignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static glHigVBoxClass *parent_class; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_text_entry_class_init (glWdgtTextEntryClass *class); -static void gl_wdgt_text_entry_instance_init (glWdgtTextEntry *text_entry); -static void gl_wdgt_text_entry_finalize (GObject *object); -static void gl_wdgt_text_entry_construct (glWdgtTextEntry *text_entry, - glMerge *merge); - -static void insert_cb (glWdgtTextEntry *text_entry); - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_wdgt_text_entry_get_type (void) -{ - static guint wdgt_text_entry_type = 0; - - if (!wdgt_text_entry_type) { - GTypeInfo wdgt_text_entry_info = { - sizeof (glWdgtTextEntryClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_text_entry_class_init, - NULL, - NULL, - sizeof (glWdgtTextEntry), - 0, - (GInstanceInitFunc) gl_wdgt_text_entry_instance_init, - }; - - wdgt_text_entry_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtTextEntry", - &wdgt_text_entry_info, 0); - } - - return wdgt_text_entry_type; -} - -static void -gl_wdgt_text_entry_class_init (glWdgtTextEntryClass * class) -{ - GObjectClass *object_class; - - gl_debug (DEBUG_WDGT, "START"); - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_text_entry_finalize; - - gl_debug (DEBUG_WDGT, "END"); -} - -static void -gl_wdgt_text_entry_instance_init (glWdgtTextEntry *text_entry) -{ - gl_debug (DEBUG_WDGT, "START"); - - text_entry->text_entry = NULL; - - text_entry->key_combo = NULL; - text_entry->key_entry = NULL; - text_entry->insert_button = NULL; - - gl_debug (DEBUG_WDGT, "END"); -} - -static void -gl_wdgt_text_entry_finalize (GObject *object) -{ - glWdgtTextEntry *text_entry; - glWdgtTextEntryClass *class; - - gl_debug (DEBUG_WDGT, "START"); - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_TEXT_ENTRY (object)); - - text_entry = GL_WDGT_TEXT_ENTRY (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); - - gl_debug (DEBUG_WDGT, "END"); -} - -/****************************************************************************/ -/* New widget. */ -/****************************************************************************/ -GtkWidget * -gl_wdgt_text_entry_new (glMerge *merge) -{ - glWdgtTextEntry *text_entry; - - gl_debug (DEBUG_WDGT, "START"); - - text_entry = g_object_new (gl_wdgt_text_entry_get_type (), NULL); - - gl_wdgt_text_entry_construct (text_entry, merge); - - gl_debug (DEBUG_WDGT, "END"); - - return GTK_WIDGET (text_entry); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_wdgt_text_entry_construct (glWdgtTextEntry *text_entry, - glMerge *merge) -{ - GtkWidget *wvbox, *whbox, *wscroll; - GList *keys; - - gl_debug (DEBUG_WDGT, "START"); - - wvbox = GTK_WIDGET (text_entry); - - /* ---- Entry line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Text Label */ - text_entry->edit_label = gtk_label_new (_("Edit text:")); - gtk_misc_set_alignment (GTK_MISC (text_entry->edit_label), 0, 0); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text_entry->edit_label); - - /* Actual text entry widget */ - wscroll = gtk_scrolled_window_new (NULL, NULL); - gtk_widget_set_size_request (wscroll, -1, 70); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wscroll), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gl_hig_hbox_add_widget_justify (GL_HIG_HBOX(whbox), wscroll); - text_entry->text_entry = gtk_text_view_new (); - text_entry->text_buffer = - gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_entry->text_entry)); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (wscroll), - text_entry->text_entry); - - /* ---- Merge field line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Insert merge field label */ - text_entry->key_label = gtk_label_new (_("Key:")); - gtk_misc_set_alignment (GTK_MISC (text_entry->key_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text_entry->key_label); - - /* Key entry widget */ - text_entry->key_combo = gtk_combo_new (); - keys = gl_merge_get_key_list (merge); - if (keys != NULL) - gtk_combo_set_popdown_strings (GTK_COMBO (text_entry->key_combo), - keys); - gl_merge_free_key_list (&keys); - text_entry->key_entry = GTK_COMBO (text_entry->key_combo)->entry; - gtk_entry_set_editable (GTK_ENTRY (text_entry->key_entry), FALSE); - gtk_widget_set_size_request (text_entry->key_combo, 200, -1); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text_entry->key_combo); - - /* Insert button */ - text_entry->insert_button = - gtk_button_new_with_label (_("Insert merge field")); - g_signal_connect_swapped (G_OBJECT (text_entry->insert_button), - "clicked", G_CALLBACK (insert_cb), - G_OBJECT (text_entry)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text_entry->insert_button); - - gl_debug (DEBUG_WDGT, "END"); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback to insert field into text buffer. */ -/*--------------------------------------------------------------------------*/ -static void -insert_cb (glWdgtTextEntry *text_entry) -{ - GtkTextBuffer *buffer; - gchar *key, *field; - - gl_debug (DEBUG_WDGT, "START"); - - key = - gtk_editable_get_chars (GTK_EDITABLE (text_entry->key_entry), 0, - -1); - field = g_strdup_printf ("${%s}", key); - gl_debug (DEBUG_WDGT, "Inserting %s", field); - - buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_entry->text_entry)); - gtk_text_buffer_insert_at_cursor (buffer, field, -1); - - g_free (field); - g_free (key); - - - gl_debug (DEBUG_WDGT, "END"); -} - -/****************************************************************************/ -/* Set new field definitions. */ -/****************************************************************************/ -void -gl_wdgt_text_entry_set_field_defs (glWdgtTextEntry *text_entry, - glMerge *merge) -{ - GList *keys; - - gtk_widget_set_sensitive (text_entry->key_combo, merge != NULL); - gtk_widget_set_sensitive (text_entry->insert_button, merge != NULL); - - keys = gl_merge_get_key_list (merge); - if ( keys != NULL ) { - gtk_combo_set_popdown_strings (GTK_COMBO (text_entry->key_combo), - keys); - gl_merge_free_key_list (&keys); - } else { - keys = g_list_append (keys, ""); - gtk_combo_set_popdown_strings (GTK_COMBO (text_entry->key_combo), - keys); - g_list_free (keys); - } -} - -/****************************************************************************/ -/* Set text buffer */ -/****************************************************************************/ -void -gl_wdgt_text_entry_set_buffer (glWdgtTextEntry *text_entry, - GtkTextBuffer *buffer) -{ - text_entry->text_buffer = buffer; - - gtk_text_view_set_buffer (GTK_TEXT_VIEW(text_entry->text_entry), buffer); -} - -/*****************************************************************************/ -/* Set size group for internal labels */ -/*****************************************************************************/ -void -gl_wdgt_text_entry_set_label_size_group (glWdgtTextEntry *text_entry, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, text_entry->edit_label); - gtk_size_group_add_widget (label_size_group, text_entry->key_label); -} - diff --git a/glabels2/src/wdgt-text-entry.h b/glabels2/src/wdgt-text-entry.h deleted file mode 100644 index d62ba058..00000000 --- a/glabels2/src/wdgt-text-entry.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_text_entry.h: text entry widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_TEXT_ENTRY_H__ -#define __WDGT_TEXT_ENTRY_H__ - -#include -#include "merge.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_TEXT_ENTRY (gl_wdgt_text_entry_get_type ()) -#define GL_WDGT_TEXT_ENTRY(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_TEXT_ENTRY, glWdgtTextEntry )) -#define GL_WDGT_TEXT_ENTRY_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_TEXT_ENTRY, glWdgtTextEntryClass)) -#define GL_IS_WDGT_TEXT_ENTRY(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_TEXT_ENTRY)) -#define GL_IS_WDGT_TEXT_ENTRY_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_TEXT_ENTRY)) - -typedef struct _glWdgtTextEntry glWdgtTextEntry; -typedef struct _glWdgtTextEntryClass glWdgtTextEntryClass; - -struct _glWdgtTextEntry { - glHigVBox parent_widget; - - GtkWidget *edit_label; - GtkWidget *text_entry; - - GtkWidget *key_label; - GtkWidget *key_combo; - GtkWidget *key_entry; - GtkWidget *insert_button; - - GtkTextBuffer *text_buffer; -}; - -struct _glWdgtTextEntryClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtTextEntry * text_entry, gpointer user_data); -}; - -guint gl_wdgt_text_entry_get_type (void); - -GtkWidget *gl_wdgt_text_entry_new (glMerge *merge); - -void gl_wdgt_text_entry_set_field_defs (glWdgtTextEntry *text_entry, - glMerge *merge); - -void gl_wdgt_text_entry_set_buffer (glWdgtTextEntry *text_entry, - GtkTextBuffer *buffer); - -void gl_wdgt_text_entry_set_label_size_group (glWdgtTextEntry *text_entry, - GtkSizeGroup *label_size_group); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-text-props.c b/glabels2/src/wdgt-text-props.c deleted file mode 100644 index 15b867fd..00000000 --- a/glabels2/src/wdgt-text-props.c +++ /dev/null @@ -1,479 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_text_props.c: text properties widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include - -#include "mygal/widget-color-combo.h" -#include "prefs.h" -#include "wdgt-text-props.h" -#include "marshal.h" -#include "color.h" - -#include "debug.h" - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtTextPropsSignal) (GObject *object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static GObjectClass *parent_class; - -static gint wdgt_text_props_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_text_props_class_init (glWdgtTextPropsClass *class); -static void gl_wdgt_text_props_instance_init (glWdgtTextProps *text); -static void gl_wdgt_text_props_finalize (GObject *object); -static void gl_wdgt_text_props_construct (glWdgtTextProps *text); - -static void family_changed_cb (GtkEntry *entry, - glWdgtTextProps *text); - -static void changed_cb (glWdgtTextProps *text); - -static void just_toggled_cb (GtkToggleButton *togglebutton, - gpointer user_data); - -/*****************************************************************************/ -/* Boilerplate Object stuff. */ -/*****************************************************************************/ -guint -gl_wdgt_text_props_get_type (void) -{ - static guint wdgt_text_props_type = 0; - - if (!wdgt_text_props_type) { - GTypeInfo wdgt_text_props_info = { - sizeof (glWdgtTextPropsClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_text_props_class_init, - NULL, - NULL, - sizeof (glWdgtTextProps), - 0, - (GInstanceInitFunc) gl_wdgt_text_props_instance_init, - }; - - wdgt_text_props_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtTextProps", - &wdgt_text_props_info, 0); - } - - return wdgt_text_props_type; -} - -static void -gl_wdgt_text_props_class_init (glWdgtTextPropsClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_text_props_finalize; - - wdgt_text_props_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtTextPropsClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} - -static void -gl_wdgt_text_props_instance_init (glWdgtTextProps *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_wdgt_text_props_finalize (GObject *object) -{ - glWdgtTextProps *text; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_TEXT_PROPS (object)); - - text = GL_WDGT_TEXT_PROPS (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/*****************************************************************************/ -/* New widget. */ -/*****************************************************************************/ -GtkWidget * -gl_wdgt_text_props_new (void) -{ - glWdgtTextProps *text; - - text = g_object_new (gl_wdgt_text_props_get_type (), NULL); - - gl_wdgt_text_props_construct (text); - - return GTK_WIDGET (text); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*--------------------------------------------------------------------------*/ -static void -gl_wdgt_text_props_construct (glWdgtTextProps *text) -{ - GtkWidget *wvbox, *whbox, *wcombo, *wbhbox; - GList *family_names = NULL; - GtkObject *adjust; - ColorGroup *cg; - GdkColor *gdk_color; - - wvbox = GTK_WIDGET (text); - - /* ---- Font line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Font label */ - text->font_label = gtk_label_new (_("Font:")); - gtk_misc_set_alignment (GTK_MISC (text->font_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->font_label); - - /* 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_combo_set_value_in_list (GTK_COMBO(wcombo), TRUE, FALSE); - gtk_entry_set_editable (GTK_ENTRY (text->font_family_entry), FALSE); - gtk_widget_set_size_request (wcombo, 200, -1); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), wcombo); - g_signal_connect (G_OBJECT (text->font_family_entry), - "changed", G_CALLBACK (family_changed_cb), 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); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->font_size_spin); - g_signal_connect_swapped (G_OBJECT (text->font_size_spin), "changed", - G_CALLBACK (changed_cb), - G_OBJECT (text)); - - /* Font weight/italic button widgets */ - text->font_b_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->font_b_button), - gtk_image_new_from_stock (GTK_STOCK_BOLD, - GTK_ICON_SIZE_BUTTON)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->font_b_button); - g_signal_connect_swapped (G_OBJECT (text->font_b_button), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (text)); - text->font_i_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->font_i_button), - gtk_image_new_from_stock (GTK_STOCK_ITALIC, - GTK_ICON_SIZE_BUTTON)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->font_i_button); - g_signal_connect_swapped (G_OBJECT (text->font_i_button), "toggled", - G_CALLBACK (changed_cb), - G_OBJECT (text)); - - /* ---- Color line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Text Color Label */ - text->color_label = gtk_label_new (_("Color:")); - gtk_misc_set_alignment (GTK_MISC (text->color_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->color_label); - - /* Text Color picker widget */ - cg = color_group_fetch ("text_color_group", NULL); - gdk_color = gl_color_to_gdk_color (gl_prefs->default_line_color); - text->color_picker = color_combo_new (NULL, _("Default"), gdk_color, cg); - color_combo_box_set_preview_relief (COLOR_COMBO(text->color_picker), - GTK_RELIEF_NORMAL); - g_free (gdk_color); - g_signal_connect_swapped (G_OBJECT (text->color_picker), "color_changed", - G_CALLBACK (changed_cb), - G_OBJECT (text)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->color_picker); - - /* ---- Alignment line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Alignment label */ - text->alignment_label = gtk_label_new (_("Alignment:")); - gtk_misc_set_alignment (GTK_MISC (text->alignment_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->alignment_label); - - /* Justification entry widget */ - text->left_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->left_button), - gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_LEFT, - GTK_ICON_SIZE_BUTTON)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->left_button); - text->center_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->center_button), - gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_CENTER, - GTK_ICON_SIZE_BUTTON)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->center_button); - text->right_button = gtk_toggle_button_new (); - gtk_container_add (GTK_CONTAINER (text->right_button), - gtk_image_new_from_stock (GTK_STOCK_JUSTIFY_RIGHT, - GTK_ICON_SIZE_BUTTON)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), text->right_button); - - /* Now connect a callback that makes these toggles mutually exclusive */ - g_signal_connect (G_OBJECT (text->left_button), "toggled", - G_CALLBACK (just_toggled_cb), text); - g_signal_connect (G_OBJECT (text->center_button), "toggled", - G_CALLBACK (just_toggled_cb), text); - g_signal_connect (G_OBJECT (text->right_button), "toggled", - G_CALLBACK (just_toggled_cb), text); - -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. modify widget due to change in selection */ -/*--------------------------------------------------------------------------*/ -static void -family_changed_cb (GtkEntry *entry, - glWdgtTextProps *text) -{ - gchar *family_name; - - family_name = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - if ( strlen(family_name) ) { - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (text), - wdgt_text_props_signals[CHANGED], 0); - } - g_free (family_name); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glWdgtTextProps *text) -{ - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (text), wdgt_text_props_signals[CHANGED], 0); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Justify toggle button callback. */ -/*--------------------------------------------------------------------------*/ -static void -just_toggled_cb (GtkToggleButton *togglebutton, - gpointer user_data) -{ - glWdgtTextProps *text = GL_WDGT_TEXT_PROPS (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 */ - g_signal_emit (G_OBJECT (text), wdgt_text_props_signals[CHANGED], 0); -} - -/*****************************************************************************/ -/* query values from controls. */ -/*****************************************************************************/ -void -gl_wdgt_text_props_get_params (glWdgtTextProps *text, - gchar **font_family, - gdouble *font_size, - GnomeFontWeight *font_weight, - gboolean *font_italic_flag, - guint *color, - GtkJustification *just) -{ - GdkColor *gdk_color; - gboolean is_default; - - /* ------ 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 (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 ------ */ - gdk_color = color_combo_get_color (COLOR_COMBO(text->color_picker), - &is_default); - - if (is_default) { - *color = gl_prefs->default_text_color; - } else { - *color = gl_color_from_gdk_color (gdk_color); - } - - /* ------- 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_wdgt_text_props_set_params (glWdgtTextProps *text, - gchar *font_family, - gdouble font_size, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - guint color, - GtkJustification just) -{ - GList *family_names; - gchar *good_font_family; - GdkColor *gdk_color; - - /* Make sure we have a valid font family. if not provide a good default. */ - family_names = gnome_font_family_list (); - if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) { - good_font_family = g_strdup (font_family); - } else { - if (family_names != NULL) { - good_font_family = g_strdup (family_names->data); /* 1st entry */ - } else { - good_font_family = NULL; - } - } - gnome_font_family_list_free (family_names); - - gtk_entry_set_text (GTK_ENTRY (text->font_family_entry), good_font_family); - g_free (good_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); - - gdk_color = gl_color_to_gdk_color (color); - color_combo_set_color (COLOR_COMBO(text->color_picker), gdk_color); - g_free (gdk_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)); -} - -/*****************************************************************************/ -/* Set size group for internal labels */ -/*****************************************************************************/ -void -gl_wdgt_text_props_set_label_size_group (glWdgtTextProps *text, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, text->font_label); - gtk_size_group_add_widget (label_size_group, text->color_label); - gtk_size_group_add_widget (label_size_group, text->alignment_label); -} - diff --git a/glabels2/src/wdgt-text-props.h b/glabels2/src/wdgt-text-props.h deleted file mode 100644 index 80b1b224..00000000 --- a/glabels2/src/wdgt-text-props.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_text_props.h: text properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_TEXT_PROPS_H__ -#define __WDGT_TEXT_PROPS_H__ - -#include -#include -#include "label.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_TEXT_PROPS (gl_wdgt_text_props_get_type ()) -#define GL_WDGT_TEXT_PROPS(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_TEXT_PROPS, glWdgtTextProps )) -#define GL_WDGT_TEXT_PROPS_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_TEXT_PROPS, glWdgtTextPropsClass)) -#define GL_IS_WDGT_TEXT_PROPS(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_TEXT_PROPS)) -#define GL_IS_WDGT_TEXT_PROPS_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_TEXT_PROPS)) - -typedef struct _glWdgtTextProps glWdgtTextProps; -typedef struct _glWdgtTextPropsClass glWdgtTextPropsClass; - -struct _glWdgtTextProps { - glHigVBox parent_widget; - - GtkWidget *font_label; - GtkWidget *font_family_entry; - GtkWidget *font_size_spin; - GtkWidget *font_b_button; - GtkWidget *font_i_button; - - GtkWidget *color_label; - GtkWidget *color_picker; - - GtkWidget *alignment_label; - GtkWidget *left_button, *right_button, *center_button; -}; - -struct _glWdgtTextPropsClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtTextProps * text, gpointer user_data); -}; - -guint gl_wdgt_text_props_get_type (void); - -GtkWidget *gl_wdgt_text_props_new (void); - -void gl_wdgt_text_props_get_params (glWdgtTextProps *text, - gchar **font_family, - gdouble *font_size, - GnomeFontWeight *font_weight, - gboolean *font_italic_flag, - guint *color, - GtkJustification *just); - -void gl_wdgt_text_props_set_params (glWdgtTextProps *text, - gchar *font_family, - gdouble font_size, - GnomeFontWeight font_weight, - gboolean font_italic_flag, - guint color, - GtkJustification just); - -void gl_wdgt_text_props_set_label_size_group (glWdgtTextProps *text, - GtkSizeGroup *size_grp); - -G_END_DECLS - -#endif diff --git a/glabels2/src/wdgt-vector.c b/glabels2/src/wdgt-vector.c deleted file mode 100644 index 34ec89d9..00000000 --- a/glabels2/src/wdgt-vector.c +++ /dev/null @@ -1,318 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_vector.c: vector properties widget module - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 - -#include "wdgt-vector.h" -#include "prefs.h" -#include "marshal.h" - -#include "debug.h" - -#include - -#define LENGTH(x,y) sqrt( (x)*(x) + (y)*(y) ) -#define ANGLE(x,y) ( (180.0/G_PI)*atan2( -(y), (x) ) ) -#define COMP_X(l,a) ( (l) * cos( (G_PI/180.0)*(a) ) ) -#define COMP_Y(l,a) ( -(l) * sin( (G_PI/180.0)*(a) ) ) - -/*===========================================*/ -/* Private types */ -/*===========================================*/ - -enum { - CHANGED, - LAST_SIGNAL -}; - -typedef void (*glWdgtVectorSignal) (GObject * object, gpointer data); - -/*===========================================*/ -/* Private globals */ -/*===========================================*/ - -static glHigVBoxClass *parent_class; - -static gint wdgt_vector_signals[LAST_SIGNAL] = { 0 }; - -/*===========================================*/ -/* Local function prototypes */ -/*===========================================*/ - -static void gl_wdgt_vector_class_init (glWdgtVectorClass *class); -static void gl_wdgt_vector_instance_init (glWdgtVector *vector); -static void gl_wdgt_vector_finalize (GObject *object); -static void gl_wdgt_vector_construct (glWdgtVector *vector); - -static void changed_cb (glWdgtVector *vector); - -/****************************************************************************/ -/* Boilerplate Object stuff. */ -/****************************************************************************/ -guint -gl_wdgt_vector_get_type (void) -{ - static guint wdgt_vector_type = 0; - - if (!wdgt_vector_type) { - GTypeInfo wdgt_vector_info = { - sizeof (glWdgtVectorClass), - NULL, - NULL, - (GClassInitFunc) gl_wdgt_vector_class_init, - NULL, - NULL, - sizeof (glWdgtVector), - 0, - (GInstanceInitFunc) gl_wdgt_vector_instance_init, - }; - - wdgt_vector_type = - g_type_register_static (gl_hig_vbox_get_type (), - "glWdgtVector", - &wdgt_vector_info, 0); - } - - return wdgt_vector_type; -} - -static void -gl_wdgt_vector_class_init (glWdgtVectorClass *class) -{ - GObjectClass *object_class; - - object_class = (GObjectClass *) class; - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = gl_wdgt_vector_finalize; - - wdgt_vector_signals[CHANGED] = - g_signal_new ("changed", - G_OBJECT_CLASS_TYPE(object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (glWdgtVectorClass, changed), - NULL, NULL, - gl_marshal_VOID__VOID, - G_TYPE_NONE, 0); - -} - -static void -gl_wdgt_vector_instance_init (glWdgtVector *vector) -{ - vector->len_label = NULL; - vector->len_spin = NULL; - vector->len_units_label = NULL; - - vector->angle_label = NULL; - vector->angle_spin = NULL; - vector->angle_units_label = NULL; -} - -static void -gl_wdgt_vector_finalize (GObject *object) -{ - glWdgtVector *vector; - glWdgtVectorClass *class; - - g_return_if_fail (object != NULL); - g_return_if_fail (GL_IS_WDGT_VECTOR (object)); - - vector = GL_WDGT_VECTOR (object); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -/****************************************************************************/ -/* New widget. */ -/****************************************************************************/ -GtkWidget * -gl_wdgt_vector_new (void) -{ - glWdgtVector *vector; - - vector = g_object_new (gl_wdgt_vector_get_type (), NULL); - - gl_wdgt_vector_construct (vector); - - return GTK_WIDGET (vector); -} - -/*-------------------------------------------------------------------------*/ -/* PRIVATE. Construct composite widget. */ -/*-------------------------------------------------------------------------*/ -static void -gl_wdgt_vector_construct (glWdgtVector *vector) -{ - GtkWidget *wvbox, *whbox; - 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); - - /* ---- Length line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Length label */ - vector->len_label = gtk_label_new (_("Length:")); - gtk_misc_set_alignment (GTK_MISC (vector->len_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), vector->len_label); - - /* 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); - g_signal_connect_swapped (G_OBJECT (vector->len_spin), "changed", - G_CALLBACK (changed_cb), - G_OBJECT (vector)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), vector->len_spin); - - /* 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); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), vector->len_units_label); - - /* ---- Angle line ---- */ - whbox = gl_hig_hbox_new (); - gl_hig_vbox_add_widget (GL_HIG_VBOX(wvbox), whbox); - - /* Angle label */ - vector->angle_label = gtk_label_new (_("Angle:")); - gtk_misc_set_alignment (GTK_MISC (vector->angle_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), vector->angle_label); - - /* 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); - g_signal_connect_swapped (G_OBJECT (vector->angle_spin), "changed", - G_CALLBACK (changed_cb), - G_OBJECT (vector)); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), vector->angle_spin); - - /* Angle units label */ - vector->angle_units_label = gtk_label_new (_("degrees")); - gtk_misc_set_alignment (GTK_MISC (vector->angle_units_label), 0, 0.5); - gl_hig_hbox_add_widget (GL_HIG_HBOX(whbox), vector->angle_units_label); -} - -/*--------------------------------------------------------------------------*/ -/* PRIVATE. Callback for when any control in the widget has changed. */ -/*--------------------------------------------------------------------------*/ -static void -changed_cb (glWdgtVector * vector) -{ - /* Emit our "changed" signal */ - g_signal_emit (G_OBJECT (vector), wdgt_vector_signals[CHANGED], 0); -} - -/****************************************************************************/ -/* query values from controls. */ -/****************************************************************************/ -void -gl_wdgt_vector_get_params (glWdgtVector *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 (GTK_SPIN_BUTTON(vector->len_spin)); - angle = - gtk_spin_button_get_value (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_wdgt_vector_set_params (glWdgtVector *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); -} - -/****************************************************************************/ -/* Set size group for internal labels */ -/****************************************************************************/ -void -gl_wdgt_vector_set_label_size_group (glWdgtVector *vector, - GtkSizeGroup *label_size_group) -{ - gtk_size_group_add_widget (label_size_group, vector->len_label); - gtk_size_group_add_widget (label_size_group, vector->angle_label); -} diff --git a/glabels2/src/wdgt-vector.h b/glabels2/src/wdgt-vector.h deleted file mode 100644 index 1e99f22a..00000000 --- a/glabels2/src/wdgt-vector.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * (GLABELS) Label and Business Card Creation program for GNOME - * - * wdgt_vector.h: vector properties widget module header file - * - * Copyright (C) 2001-2002 Jim Evins . - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * 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 __WDGT_VECTOR_H__ -#define __WDGT_VECTOR_H__ - -#include -#include "label.h" -#include "hig.h" - -G_BEGIN_DECLS - -#define GL_TYPE_WDGT_VECTOR (gl_wdgt_vector_get_type ()) -#define GL_WDGT_VECTOR(obj) \ - (GTK_CHECK_CAST((obj), GL_TYPE_WDGT_VECTOR, glWdgtVector )) -#define GL_WDGT_VECTOR_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_VECTOR, glWdgtVectorClass)) -#define GL_IS_WDGT_VECTOR(obj) \ - (GTK_CHECK_TYPE ((obj), GL_TYPE_WDGT_VECTOR)) -#define GL_IS_WDGT_VECTOR_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_VECTOR)) - -typedef struct _glWdgtVector glWdgtVector; -typedef struct _glWdgtVectorClass glWdgtVectorClass; - -struct _glWdgtVector { - glHigVBox parent_widget; - - GtkWidget *len_label; - GtkWidget *len_spin; - GtkWidget *len_units_label; - - GtkWidget *angle_label; - GtkWidget *angle_spin; - GtkWidget *angle_units_label; -}; - -struct _glWdgtVectorClass { - glHigVBoxClass parent_class; - - void (*changed) (glWdgtVector * vector, gpointer user_data); -}; - -guint gl_wdgt_vector_get_type (void); - -GtkWidget *gl_wdgt_vector_new (void); - -void gl_wdgt_vector_get_params (glWdgtVector *vector, - gdouble *dx, - gdouble *dy); - -void gl_wdgt_vector_set_params (glWdgtVector *vector, - gdouble dx, - gdouble dy, - gdouble x_max, - gdouble y_max); - -void gl_wdgt_vector_set_label_size_group (glWdgtVector *vector, - GtkSizeGroup *label_size_group); - -G_END_DECLS - -#endif diff --git a/glabels2/src/window.c b/glabels2/src/window.c index 21cbedb3..330dba8d 100644 --- a/glabels2/src/window.c +++ b/glabels2/src/window.c @@ -34,7 +34,7 @@ /* Private macros and constants. */ /*============================================================================*/ -#define DEFAULT_WINDOW_WIDTH 700 +#define DEFAULT_WINDOW_WIDTH 788 #define DEFAULT_WINDOW_HEIGHT 560 #define CURSOR_INFO_WIDTH 150 @@ -168,6 +168,8 @@ gl_window_init (glWindow *window) window->property_bar = GL_UI_PROPERTY_BAR(gl_ui_property_bar_new (ui_component)); + window->sidebar = + GL_UI_SIDEBAR(gl_ui_sidebar_new (ui_component)); gtk_window_set_default_size (GTK_WINDOW (window), DEFAULT_WINDOW_WIDTH, @@ -350,6 +352,7 @@ gl_window_set_label (glWindow *window, gl_ui_update_all (window->uic, GL_VIEW(window->view)); gl_ui_property_bar_set_view (window->property_bar, GL_VIEW(window->view)); + gl_ui_sidebar_set_view (window->sidebar, GL_VIEW(window->view)); string = g_strdup_printf ("%3.0f%%", 100.0*gl_view_get_zoom (GL_VIEW(window->view))); diff --git a/glabels2/src/window.h b/glabels2/src/window.h index c3dd731c..402d131a 100644 --- a/glabels2/src/window.h +++ b/glabels2/src/window.h @@ -31,6 +31,7 @@ #include "label.h" #include "ui-property-bar.h" +#include "ui-sidebar.h" G_BEGIN_DECLS @@ -55,6 +56,7 @@ struct _glWindow { GtkWidget *view; glUIPropertyBar *property_bar; + glUISidebar *sidebar; GtkWidget *cursor_info; GtkWidget *cursor_info_frame; -- 2.39.5