1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
/*
* (GLABELS) Label and Business Card Creation program for GNOME
*
* merge_properties.c: document merge properties dialog module
*
* Copyright (C) 2001 Jim Evins <evins@snaught.com>.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <config.h>
#include "mdi.h"
#include "display.h"
#include "merge.h"
#include "merge_ui.h"
#include "merge_properties.h"
#include "debug.h"
/*===========================================*/
/* Private data types */
/*===========================================*/
typedef struct {
GtkWidget *dialog;
glDisplay *display;
glLabel *label;
gchar *name;
GtkWidget *type_entry;
GtkWidget *src_entry;
GtkWidget *field_ws;
glMergeType src_type;
gchar *field_ws_src;
} PropertyDialogPassback;
/*===========================================*/
/* Private globals */
/*===========================================*/
/*===========================================*/
/* Local function prototypes */
/*===========================================*/
static void create_merge_dialog_widgets (GnomeDialog * dialog,
PropertyDialogPassback * data);
static void type_changed_cb (GtkWidget * widget, PropertyDialogPassback * data);
static void src_changed_cb (GtkWidget * widget, PropertyDialogPassback * data);
static void ok_cb (GtkWidget * widget, PropertyDialogPassback * data);
/****************************************************************************/
/* Launch merge properties dialog. */
/****************************************************************************/
void
gl_merge_properties_dialog (glDisplay * display,
gchar * basename)
{
static PropertyDialogPassback *data = NULL;
GtkWidget *dialog;
if (data == NULL) {
data = g_new0 (PropertyDialogPassback, 1);
}
dialog = gnome_dialog_new (_("Edit document-merge properties"),
GNOME_STOCK_BUTTON_OK,
GNOME_STOCK_BUTTON_CANCEL, NULL);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_set_transient_for (GTK_WINDOW (dialog),
GTK_WINDOW (gl_mdi_get_active_window ()));
data->dialog = dialog;
data->display = display;
data->label = display->label;
data->name = basename;
data->type_entry = NULL;
data->src_entry = NULL;
data->field_ws = NULL;
create_merge_dialog_widgets (GNOME_DIALOG (dialog), data);
gnome_dialog_button_connect (GNOME_DIALOG (dialog), 0,
GTK_SIGNAL_FUNC (ok_cb), data);
gnome_dialog_button_connect_object (GNOME_DIALOG (dialog), 1,
GTK_SIGNAL_FUNC
(gtk_widget_destroy),
GTK_OBJECT (dialog));
gtk_widget_show_all (GTK_WIDGET (dialog));
}
/*--------------------------------------------------------------------------*/
/* PRIVATE. Create and add start page to druid. */
/*--------------------------------------------------------------------------*/
static void
create_merge_dialog_widgets (GnomeDialog * dialog,
PropertyDialogPassback * data)
{
GtkWidget *wvbox, *wframe, *whbox, *wtable, *wlabel, *wcombo, *wscroll;
GList *texts;
glMergeType type;
gchar *src;
GList *fields;
type = data->label->merge_type;
src = data->label->merge_src;
fields = data->label->merge_fields;
wvbox = dialog->vbox;
wframe = gtk_frame_new (_("Source"));
gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0);
whbox = gtk_hbox_new (FALSE, GNOME_PAD);
gtk_container_add (GTK_CONTAINER (wframe), whbox);
wtable = gtk_table_new (2, 2, FALSE);
gtk_container_set_border_width (GTK_CONTAINER (wtable), 10);
gtk_table_set_row_spacings (GTK_TABLE (wtable), 5);
gtk_table_set_col_spacings (GTK_TABLE (wtable), 5);
gtk_box_pack_start (GTK_BOX (whbox), wtable, FALSE, FALSE, GNOME_PAD);
wlabel = gtk_label_new (_("Format:"));
gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 0, 1);
wcombo = gtk_combo_new ();
gtk_widget_set_usize (wcombo, 400, -1);
texts = gl_merge_get_long_texts_list ();
gtk_combo_set_popdown_strings (GTK_COMBO (wcombo), texts);
gl_merge_free_long_texts_list (&texts);
data->type_entry = GTK_COMBO (wcombo)->entry;
gtk_entry_set_editable (GTK_ENTRY (data->type_entry), FALSE);
gtk_table_attach_defaults (GTK_TABLE (wtable), wcombo, 1, 2, 0, 1);
gtk_entry_set_text (GTK_ENTRY (data->type_entry),
gl_merge_type_to_long_text (type));
wlabel = gtk_label_new (_("Location:"));
gtk_misc_set_alignment (GTK_MISC (wlabel), 0, 0.5);
gtk_table_attach_defaults (GTK_TABLE (wtable), wlabel, 0, 1, 1, 2);
data->src_entry = gl_merge_ui_src_new ();
gtk_table_attach_defaults (GTK_TABLE (wtable), data->src_entry, 1, 2, 1,
2);
gl_merge_ui_src_set_type (GL_MERGE_UI_SRC (data->src_entry), type);
gl_merge_ui_src_set_value (GL_MERGE_UI_SRC (data->src_entry), src);
wframe = gtk_frame_new (_("Fields"));
gtk_box_pack_start (GTK_BOX (wvbox), wframe, FALSE, FALSE, 0);
wscroll = gtk_scrolled_window_new (NULL, NULL);
gtk_container_set_border_width (GTK_CONTAINER (wscroll), 5);
gtk_widget_set_usize (wscroll, 500, 300);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (wscroll),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_container_add (GTK_CONTAINER (wframe), wscroll);
data->field_ws = gl_merge_ui_field_ws_new ();
gtk_container_set_border_width (GTK_CONTAINER (data->field_ws), 10);
gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS
(data->field_ws), type, src);
gl_merge_ui_field_ws_set_field_defs (GL_MERGE_UI_FIELD_WS
(data->field_ws), fields);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (wscroll),
data->field_ws);
gtk_signal_connect (GTK_OBJECT (data->type_entry), "changed",
GTK_SIGNAL_FUNC (type_changed_cb), data);
gtk_signal_connect (GTK_OBJECT (data->src_entry), "changed",
GTK_SIGNAL_FUNC (src_changed_cb), data);
}
/*--------------------------------------------------------------------------*/
/* PRIVATE. type "changed" callback. */
/*--------------------------------------------------------------------------*/
static void
type_changed_cb (GtkWidget * widget,
PropertyDialogPassback * data)
{
glMergeType type;
gchar *type_text;
type_text = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry),
0, -1);
type = gl_merge_long_text_to_type (type_text);
g_free (type_text);
gl_merge_ui_src_set_type (GL_MERGE_UI_SRC (data->src_entry), type);
}
/*--------------------------------------------------------------------------*/
/* PRIVATE. source "changed" callback. */
/*--------------------------------------------------------------------------*/
static void
src_changed_cb (GtkWidget * widget,
PropertyDialogPassback * data)
{
glMergeType type;
gchar *type_text, *src;
type_text = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry),
0, -1);
type = gl_merge_long_text_to_type (type_text);
g_free (type_text);
src = gl_merge_ui_src_get_value (GL_MERGE_UI_SRC (data->src_entry));
gl_merge_ui_field_ws_set_type_src (GL_MERGE_UI_FIELD_WS
(data->field_ws), type, src);
}
/*--------------------------------------------------------------------------*/
/* PRIVATE. "OK" callback. */
/*--------------------------------------------------------------------------*/
static void
ok_cb (GtkWidget * widget,
PropertyDialogPassback * data)
{
gchar *type_text;
type_text = gtk_editable_get_chars (GTK_EDITABLE (data->type_entry),
0, -1);
data->label->merge_type = gl_merge_long_text_to_type (type_text);
g_free (type_text);
data->label->merge_src =
gl_merge_ui_src_get_value (GL_MERGE_UI_SRC (data->src_entry));
gl_merge_free_field_def_list (&data->label->merge_fields);
data->label->merge_fields =
gl_merge_ui_field_ws_get_field_defs (GL_MERGE_UI_FIELD_WS
(data->field_ws));
gl_display_set_modified (data->display);
gtk_widget_destroy (data->dialog);
}
|