1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
4 * (GLABELS) Label and Business Card Creation program for GNOME
6 * object-editor.c: object properties editor module
8 * Copyright (C) 2003 Jim Evins <evins@snaught.com>.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "object-editor.h"
28 #include <glib/gi18n.h>
29 #include <gtk/gtktextview.h>
30 #include <gtk/gtkcombobox.h>
34 #include "mygal/widget-color-combo.h"
38 #include "object-editor-private.h"
42 /*===========================================*/
44 /*===========================================*/
46 /*===========================================*/
47 /* Private data types */
48 /*===========================================*/
50 /*===========================================*/
52 /*===========================================*/
54 /*===========================================*/
55 /* Local function prototypes */
56 /*===========================================*/
58 static void insert_button_cb (glObjectEditor *editor);
61 /*--------------------------------------------------------------------------*/
62 /* PRIVATE. Prepare size page. */
63 /*--------------------------------------------------------------------------*/
65 gl_object_editor_prepare_edit_page (glObjectEditor *editor)
67 gl_debug (DEBUG_EDITOR, "START");
69 /* Extract widgets from XML tree. */
70 editor->priv->edit_page_vbox =
71 glade_xml_get_widget (editor->priv->gui, "edit_page_vbox");
72 editor->priv->edit_text_view =
73 glade_xml_get_widget (editor->priv->gui, "edit_text_view");
74 editor->priv->edit_key_label =
75 glade_xml_get_widget (editor->priv->gui, "edit_key_label");
76 editor->priv->edit_key_combo =
77 glade_xml_get_widget (editor->priv->gui, "edit_key_combo");
78 editor->priv->edit_insert_field_button =
79 glade_xml_get_widget (editor->priv->gui, "edit_insert_field_button");
81 gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->edit_key_combo));
84 gtk_widget_show_all (editor->priv->edit_page_vbox);
87 g_signal_connect_swapped (G_OBJECT (editor->priv->edit_insert_field_button),
89 G_CALLBACK (insert_button_cb),
92 gl_debug (DEBUG_EDITOR, "END");
95 /*--------------------------------------------------------------------------*/
96 /* PRIVATE. Alignment togglebutton callback. */
97 /*--------------------------------------------------------------------------*/
99 insert_button_cb (glObjectEditor *editor)
101 GtkTextBuffer *buffer;
104 gl_debug (DEBUG_EDITOR, "START");
106 key = gtk_combo_box_get_active_text (GTK_COMBO_BOX (editor->priv->edit_key_combo));
107 field = g_strdup_printf ("${%s}", key);
108 gl_debug (DEBUG_WDGT, "Inserting %s", field);
110 buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->priv->edit_text_view));
111 gtk_text_buffer_insert_at_cursor (buffer, field, -1);
117 gl_debug (DEBUG_EDITOR, "END");
120 /*****************************************************************************/
121 /* Set text buffer as model for text view/editor. */
122 /*****************************************************************************/
124 gl_object_editor_set_text_buffer (glObjectEditor *editor,
125 GtkTextBuffer *buffer)
127 gl_debug (DEBUG_EDITOR, "START");
129 gtk_text_view_set_buffer (GTK_TEXT_VIEW(editor->priv->edit_text_view), buffer);
131 gl_debug (DEBUG_EDITOR, "END");