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
27 #include "object-editor.h"
30 #include "object-editor-private.h"
34 /*===========================================*/
36 /*===========================================*/
38 /*===========================================*/
39 /* Private data types */
40 /*===========================================*/
42 /*===========================================*/
44 /*===========================================*/
46 /*===========================================*/
47 /* Local function prototypes */
48 /*===========================================*/
50 static void img_radio_toggled_cb (glObjectEditor *editor);
54 /*--------------------------------------------------------------------------*/
55 /* PRIVATE. Prepare image page. */
56 /*--------------------------------------------------------------------------*/
58 gl_object_editor_prepare_image_page (glObjectEditor *editor)
63 gl_debug (DEBUG_EDITOR, "START");
65 /* Extract widgets from XML tree. */
66 editor->priv->img_page_vbox = glade_xml_get_widget (editor->priv->gui,
68 editor->priv->img_file_radio = glade_xml_get_widget (editor->priv->gui,
70 editor->priv->img_key_radio = glade_xml_get_widget (editor->priv->gui,
72 editor->priv->img_pixmap_entry = glade_xml_get_widget (editor->priv->gui,
74 editor->priv->img_key_combo = glade_xml_get_widget (editor->priv->gui,
76 editor->priv->img_key_entry = glade_xml_get_widget (editor->priv->gui,
80 gtk_widget_show_all (editor->priv->img_page_vbox);
83 ge = gnome_file_entry_gtk_entry(GNOME_FILE_ENTRY(editor->priv->img_pixmap_entry));
84 g_signal_connect_swapped (G_OBJECT (ge),
86 G_CALLBACK (gl_object_editor_changed_cb),
88 g_signal_connect_swapped (G_OBJECT (editor->priv->img_key_entry),
90 G_CALLBACK (gl_object_editor_changed_cb),
92 g_signal_connect_swapped (G_OBJECT (editor->priv->img_file_radio),
94 G_CALLBACK (img_radio_toggled_cb),
96 g_signal_connect_swapped (G_OBJECT (editor->priv->img_key_radio),
98 G_CALLBACK (img_radio_toggled_cb),
101 gl_debug (DEBUG_EDITOR, "END");
104 /*--------------------------------------------------------------------------*/
105 /* PRIVATE. image radio callback. */
106 /*--------------------------------------------------------------------------*/
108 img_radio_toggled_cb (glObjectEditor *editor)
110 gl_debug (DEBUG_WDGT, "START");
112 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->img_file_radio))) {
113 gtk_widget_set_sensitive (editor->priv->img_pixmap_entry, TRUE);
114 gtk_widget_set_sensitive (editor->priv->img_key_combo, FALSE);
116 gtk_widget_set_sensitive (editor->priv->img_pixmap_entry, FALSE);
117 gtk_widget_set_sensitive (editor->priv->img_key_combo, TRUE);
120 /* Emit our "changed" signal */
121 g_signal_emit (G_OBJECT (editor), gl_object_editor_signals[CHANGED], 0);
123 gl_debug (DEBUG_WDGT, "END");
126 /*****************************************************************************/
128 /*****************************************************************************/
130 gl_object_editor_set_image (glObjectEditor *editor,
132 glTextNode *text_node)
136 gl_debug (DEBUG_EDITOR, "START");
138 g_signal_handlers_block_by_func (G_OBJECT (editor->priv->img_pixmap_entry),
139 G_CALLBACK (gl_object_editor_changed_cb),
141 g_signal_handlers_block_by_func (G_OBJECT (editor->priv->img_key_entry),
142 G_CALLBACK (gl_object_editor_changed_cb),
145 gtk_widget_set_sensitive (editor->priv->img_key_radio, merge_flag);
147 if (!text_node->field_flag) {
149 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
150 (editor->priv->img_file_radio), TRUE);
151 gtk_widget_set_sensitive (editor->priv->img_pixmap_entry, TRUE);
152 gtk_widget_set_sensitive (editor->priv->img_key_combo, FALSE);
154 if (text_node->data != NULL ) {
155 gnome_file_entry_set_filename (GNOME_FILE_ENTRY(editor->priv->img_pixmap_entry),
158 gnome_file_entry_set_filename (GNOME_FILE_ENTRY(editor->priv->img_pixmap_entry),
163 gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON
164 (editor->priv->img_key_radio), TRUE);
166 gtk_widget_set_sensitive (editor->priv->img_pixmap_entry, FALSE);
167 gtk_widget_set_sensitive (editor->priv->img_key_combo, TRUE);
169 gtk_editable_delete_text (GTK_EDITABLE (editor->priv->img_key_entry), 0, -1);
171 gtk_editable_insert_text (GTK_EDITABLE (editor->priv->img_key_entry),
173 strlen (text_node->data),
177 g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->img_pixmap_entry),
178 G_CALLBACK (gl_object_editor_changed_cb),
180 g_signal_handlers_unblock_by_func (G_OBJECT (editor->priv->img_key_entry),
181 G_CALLBACK (gl_object_editor_changed_cb),
184 gl_debug (DEBUG_EDITOR, "END");
187 /*****************************************************************************/
189 /*****************************************************************************/
191 gl_object_editor_get_image (glObjectEditor *editor)
193 glTextNode *text_node;
195 gl_debug (DEBUG_EDITOR, "START");
197 text_node = g_new0(glTextNode,1);
199 if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->priv->img_file_radio))) {
200 text_node->field_flag = FALSE;
202 gnome_pixmap_entry_get_filename (GNOME_PIXMAP_ENTRY(editor->priv->img_pixmap_entry));
204 text_node->field_flag = TRUE;
206 gtk_editable_get_chars (GTK_EDITABLE (editor->priv->img_key_entry),
210 gl_debug (DEBUG_EDITOR, "text_node: field_flag=%d, data=%s",
211 text_node->field_flag, text_node->data);
213 gl_debug (DEBUG_EDITOR, "END");