2 * (GLABELS) Label and Business Card Creation program for GNOME
4 * object-editor.c: object properties editor module
6 * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include "object-editor.h"
26 #include <glib/gi18n.h>
27 #include <gtk/gtktogglebutton.h>
28 #include <gtk/gtkcombobox.h>
32 #include "mygal/widget-color-combo.h"
35 #include "object-editor-private.h"
39 /*===========================================*/
41 /*===========================================*/
43 /*===========================================*/
44 /* Private data types */
45 /*===========================================*/
47 /*===========================================*/
49 /*===========================================*/
51 /*===========================================*/
52 /* Local function prototypes */
53 /*===========================================*/
55 static void fill_radio_toggled_cb (glObjectEditor *editor);
58 /*--------------------------------------------------------------------------*/
59 /* PRIVATE. Prepare fill page. */
60 /*--------------------------------------------------------------------------*/
62 gl_object_editor_prepare_fill_page (glObjectEditor *editor)
66 gl_debug (DEBUG_EDITOR, "START");
68 /* Extract widgets from XML tree. */
69 editor->priv->fill_page_vbox = glade_xml_get_widget (editor->priv->gui,
71 editor->priv->fill_color_combo = glade_xml_get_widget (editor->priv->gui,
73 editor->priv->fill_key_combo = glade_xml_get_widget (editor->priv->gui,
75 editor->priv->fill_key_radio = glade_xml_get_widget (editor->priv->gui,
77 editor->priv->fill_color_radio = glade_xml_get_widget (editor->priv->gui,
81 gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->fill_key_combo));
83 /* Modify widgets based on configuration */
84 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->fill_color_radio), TRUE);
85 gtk_widget_set_sensitive (editor->priv->fill_color_combo, TRUE);
86 gtk_widget_set_sensitive (editor->priv->fill_key_combo, FALSE);
87 gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color);
88 color_combo_set_color (COLOR_COMBO(editor->priv->fill_color_combo), gdk_color);
92 gtk_widget_show_all (editor->priv->fill_page_vbox);
95 g_signal_connect_swapped (G_OBJECT (editor->priv->fill_color_combo),
97 G_CALLBACK (gl_object_editor_changed_cb),
99 g_signal_connect_swapped (G_OBJECT (editor->priv->fill_key_combo),
101 G_CALLBACK (gl_object_editor_changed_cb),
103 g_signal_connect_swapped (G_OBJECT (editor->priv->fill_color_radio),
105 G_CALLBACK (fill_radio_toggled_cb),
107 g_signal_connect_swapped (G_OBJECT (editor->priv->fill_key_radio),
109 G_CALLBACK (fill_radio_toggled_cb),
111 gl_debug (DEBUG_EDITOR, "END");
114 /*****************************************************************************/
115 /* Set fill color. */
116 /*****************************************************************************/
118 gl_object_editor_set_fill_color (glObjectEditor *editor,
120 glColorNode *color_node)
124 gl_debug (DEBUG_EDITOR, "START");
126 g_signal_handlers_block_by_func (G_OBJECT(editor->priv->fill_color_combo),
127 G_CALLBACK (gl_object_editor_changed_cb),
129 g_signal_handlers_block_by_func (G_OBJECT(editor->priv->fill_key_combo),
130 G_CALLBACK (gl_object_editor_changed_cb),
133 gtk_widget_set_sensitive (editor->priv->fill_key_radio, merge_flag);
135 if ( color_node->color == GL_COLOR_NONE ) {
137 color_combo_set_color_to_default (COLOR_COMBO(editor->priv->fill_color_combo));
141 gdk_color = gl_color_to_gdk_color (color_node->color);
142 color_combo_set_color (COLOR_COMBO(editor->priv->fill_color_combo),
148 if (!color_node->field_flag) {
149 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
150 (editor->priv->fill_color_radio), TRUE);
151 gtk_widget_set_sensitive (editor->priv->fill_color_combo, TRUE);
152 gtk_widget_set_sensitive (editor->priv->fill_key_combo, FALSE);
155 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
156 (editor->priv->fill_key_radio), TRUE);
157 gtk_widget_set_sensitive (editor->priv->fill_color_combo, FALSE);
158 gtk_widget_set_sensitive (editor->priv->fill_key_combo, TRUE);
160 gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->fill_key_combo),
164 g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->fill_color_combo),
165 G_CALLBACK (gl_object_editor_changed_cb),
167 g_signal_handlers_unblock_by_func (G_OBJECT(editor->priv->fill_key_combo),
168 G_CALLBACK (gl_object_editor_changed_cb),
171 gl_debug (DEBUG_EDITOR, "END");
174 /*****************************************************************************/
175 /* Query fill color. */
176 /*****************************************************************************/
178 gl_object_editor_get_fill_color (glObjectEditor *editor)
182 glColorNode *color_node;
184 gl_debug (DEBUG_EDITOR, "START");
186 color_node = gl_color_node_new_default ();
188 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->fill_key_radio))) {
189 color_node->field_flag = TRUE;
191 gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->fill_key_combo));
193 color_node->field_flag = FALSE;
194 color_node->key = NULL;
195 gdk_color = color_combo_get_color (COLOR_COMBO(editor->priv->fill_color_combo),
199 color_node->color = gl_color_from_gdk_color (gdk_color);
203 gl_debug (DEBUG_EDITOR, "END");
208 /*--------------------------------------------------------------------------*/
209 /* PRIVATE. fill radio callback. */
210 /*--------------------------------------------------------------------------*/
212 fill_radio_toggled_cb (glObjectEditor *editor)
214 gl_debug (DEBUG_EDITOR, "START");
216 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->fill_color_radio))) {
217 gtk_widget_set_sensitive (editor->priv->fill_color_combo, TRUE);
218 gtk_widget_set_sensitive (editor->priv->fill_key_combo, FALSE);
220 gtk_widget_set_sensitive (editor->priv->fill_color_combo, FALSE);
221 gtk_widget_set_sensitive (editor->priv->fill_key_combo, TRUE);
225 /* Emit our "changed" signal */
226 g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0);
228 gl_debug (DEBUG_EDITOR, "END");