Statistics
| Revision:

root / src / editjpilot.c @ 2968

History | View | Annotate | Download (12.7 kB)

1 1 hiro
/*
2 1 hiro
 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 1 hiro
 * Copyright (C) 2001 Match Grun
4 1 hiro
 *
5 1 hiro
 * This program is free software; you can redistribute it and/or modify
6 1 hiro
 * it under the terms of the GNU General Public License as published by
7 1 hiro
 * the Free Software Foundation; either version 2 of the License, or
8 1 hiro
 * (at your option) any later version.
9 1 hiro
 *
10 1 hiro
 * This program is distributed in the hope that it will be useful,
11 1 hiro
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 1 hiro
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 1 hiro
 * GNU General Public License for more details.
14 1 hiro
 *
15 1 hiro
 * You should have received a copy of the GNU General Public License
16 1 hiro
 * along with this program; if not, write to the Free Software
17 1 hiro
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 1 hiro
 */
19 1 hiro
20 1 hiro
/*
21 1 hiro
 * Edit JPilot address book data.
22 1 hiro
 */
23 1 hiro
24 1 hiro
#ifdef HAVE_CONFIG_H
25 1 hiro
#  include "config.h"
26 1 hiro
#endif
27 1 hiro
28 1 hiro
#ifdef USE_JPILOT
29 1 hiro
30 1 hiro
#include "defs.h"
31 1 hiro
32 1 hiro
#include <glib.h>
33 92 hiro
#include <glib/gi18n.h>
34 1 hiro
#include <gdk/gdkkeysyms.h>
35 1 hiro
#include <gtk/gtkwindow.h>
36 1 hiro
#include <gtk/gtksignal.h>
37 1 hiro
#include <gtk/gtkhbox.h>
38 1 hiro
#include <gtk/gtklabel.h>
39 1 hiro
#include <gtk/gtkentry.h>
40 1 hiro
#include <gtk/gtkhbbox.h>
41 238 hiro
#include <gtk/gtkvbox.h>
42 238 hiro
#include <gtk/gtktable.h>
43 238 hiro
#include <gtk/gtkframe.h>
44 238 hiro
#include <gtk/gtkhseparator.h>
45 1 hiro
#include <gtk/gtkbutton.h>
46 238 hiro
#include <gtk/gtkstatusbar.h>
47 238 hiro
#include <gtk/gtkcheckbutton.h>
48 1 hiro
49 1 hiro
#include "addressbook.h"
50 1 hiro
#include "prefs_common.h"
51 1 hiro
#include "addressitem.h"
52 1 hiro
#include "jpilot.h"
53 1 hiro
#include "mgutils.h"
54 411 hiro
#include "filesel.h"
55 1 hiro
#include "gtkutils.h"
56 411 hiro
#include "codeconv.h"
57 1 hiro
#include "manage_window.h"
58 1 hiro
59 1 hiro
#define ADDRESSBOOK_GUESS_JPILOT "MyJPilot"
60 1 hiro
#define JPILOT_NUM_CUSTOM_LABEL        4
61 1 hiro
62 1 hiro
static struct _JPilotEdit {
63 1 hiro
        GtkWidget *window;
64 1 hiro
        GtkWidget *name_entry;
65 1 hiro
        GtkWidget *file_entry;
66 1 hiro
        GtkWidget *custom_check[JPILOT_NUM_CUSTOM_LABEL];
67 1 hiro
        GtkWidget *custom_label[JPILOT_NUM_CUSTOM_LABEL];
68 405 hiro
        GtkWidget *hbbox;
69 1 hiro
        GtkWidget *ok_btn;
70 1 hiro
        GtkWidget *cancel_btn;
71 1 hiro
        GtkWidget *statusbar;
72 1 hiro
        gint status_cid;
73 1 hiro
} jpilotedit;
74 1 hiro
75 1 hiro
/*
76 1 hiro
* Edit functions.
77 1 hiro
*/
78 1 hiro
void edit_jpilot_status_show( gchar *msg ) {
79 1 hiro
        if( jpilotedit.statusbar != NULL ) {
80 1 hiro
                gtk_statusbar_pop( GTK_STATUSBAR(jpilotedit.statusbar), jpilotedit.status_cid );
81 1 hiro
                if( msg ) {
82 1 hiro
                        gtk_statusbar_push( GTK_STATUSBAR(jpilotedit.statusbar), jpilotedit.status_cid, msg );
83 1 hiro
                }
84 1 hiro
        }
85 1 hiro
}
86 1 hiro
87 1 hiro
static gint edit_jpilot_delete_event( GtkWidget *widget, GdkEventAny *event, gboolean *cancelled ) {
88 1 hiro
        *cancelled = TRUE;
89 1 hiro
        gtk_main_quit();
90 1 hiro
        return TRUE;
91 1 hiro
}
92 1 hiro
93 1 hiro
static gboolean edit_jpilot_key_pressed( GtkWidget *widget, GdkEventKey *event, gboolean *cancelled ) {
94 1 hiro
        if (event && event->keyval == GDK_Escape) {
95 1 hiro
                *cancelled = TRUE;
96 1 hiro
                gtk_main_quit();
97 1 hiro
        }
98 1 hiro
        return FALSE;
99 1 hiro
}
100 1 hiro
101 1 hiro
static void edit_jpilot_ok( GtkWidget *widget, gboolean *cancelled ) {
102 1 hiro
        *cancelled = FALSE;
103 1 hiro
        gtk_main_quit();
104 1 hiro
}
105 1 hiro
106 1 hiro
static void edit_jpilot_cancel( GtkWidget *widget, gboolean *cancelled ) {
107 1 hiro
        *cancelled = TRUE;
108 1 hiro
        gtk_main_quit();
109 1 hiro
}
110 1 hiro
111 1 hiro
static void edit_jpilot_fill_check_box( JPilotFile *jpf ) {
112 1 hiro
        gint i;
113 1 hiro
        GList *node, *customLbl = NULL;
114 1 hiro
        gchar *labelName;
115 1 hiro
        gboolean done, checked;
116 1 hiro
        for( i = 0; i < JPILOT_NUM_CUSTOM_LABEL; i++ ) {
117 1 hiro
                gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( jpilotedit.custom_check[i] ), FALSE );
118 1 hiro
                gtk_label_set_text( GTK_LABEL( jpilotedit.custom_label[i] ), "" );
119 1 hiro
        }
120 1 hiro
121 1 hiro
        done = FALSE;
122 1 hiro
        i = 0;
123 1 hiro
        customLbl = jpilot_load_custom_label( jpf, customLbl );
124 1 hiro
        node = customLbl;
125 1 hiro
        while( ! done ) {
126 1 hiro
                if( node ) {
127 1 hiro
                        labelName = node->data;
128 1 hiro
                        gtk_label_set_text( GTK_LABEL( jpilotedit.custom_label[i] ), labelName );
129 1 hiro
                        checked = jpilot_test_custom_label( jpf, labelName );
130 1 hiro
                        gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( jpilotedit.custom_check[i] ), checked );
131 1 hiro
                        i++;
132 1 hiro
                        if( i >= JPILOT_NUM_CUSTOM_LABEL ) done = TRUE;
133 1 hiro
                        node = g_list_next( node );
134 1 hiro
                }
135 1 hiro
                else {
136 1 hiro
                        done = TRUE;
137 1 hiro
                }
138 1 hiro
        }
139 1 hiro
        mgu_free_dlist( customLbl );
140 1 hiro
        customLbl = NULL;
141 1 hiro
}
142 1 hiro
143 1 hiro
static void edit_jpilot_fill_check_box_new() {
144 1 hiro
        gint i;
145 1 hiro
        for( i = 0; i < JPILOT_NUM_CUSTOM_LABEL; i++ ) {
146 1 hiro
                gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( jpilotedit.custom_check[i] ), FALSE );
147 1 hiro
                gtk_label_set_text( GTK_LABEL( jpilotedit.custom_label[i] ), "" );
148 1 hiro
        }
149 1 hiro
}
150 1 hiro
151 1 hiro
static void edit_jpilot_read_check_box( JPilotFile *pilotFile ) {
152 1 hiro
        gint i;
153 1 hiro
        gchar *labelName;
154 1 hiro
        jpilot_clear_custom_labels( pilotFile );
155 1 hiro
        for( i = 0; i < JPILOT_NUM_CUSTOM_LABEL; i++ ) {
156 1 hiro
                if( gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(jpilotedit.custom_check[i]) ) ) {
157 1 hiro
                        labelName = GTK_LABEL(jpilotedit.custom_label[i])->label;
158 1 hiro
                        jpilot_add_custom_label( pilotFile, labelName );
159 1 hiro
                }
160 1 hiro
        }
161 1 hiro
}
162 1 hiro
163 1 hiro
static void edit_jpilot_file_check( void ) {
164 1 hiro
        gint t = -1;
165 1 hiro
        gchar *sFile;
166 411 hiro
        gchar *sFSFile;
167 1 hiro
        gchar *sMsg;
168 1 hiro
        gboolean flg;
169 1 hiro
170 1 hiro
        flg = FALSE;
171 1 hiro
        sFile = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.file_entry), 0, -1 );
172 1 hiro
        if( sFile ) {
173 411 hiro
                sFSFile = conv_filename_from_utf8( sFile );
174 411 hiro
                if( sFSFile && *sFSFile != '\0' ) {
175 1 hiro
                        /* Attempt to read file */
176 411 hiro
                        JPilotFile *jpf;
177 411 hiro
                        jpf = jpilot_create_path( sFSFile );
178 1 hiro
                        t = jpilot_read_data( jpf );
179 1 hiro
                        if( t == MGU_SUCCESS ) {
180 1 hiro
                                /* Set check boxes */
181 1 hiro
                                edit_jpilot_fill_check_box( jpf );
182 1 hiro
                                flg = TRUE;
183 1 hiro
                        }
184 1 hiro
                        jpilot_free( jpf );
185 1 hiro
                        jpf = NULL;
186 1 hiro
                }
187 411 hiro
                g_free( sFSFile );
188 411 hiro
                g_free( sFile );
189 1 hiro
        }
190 1 hiro
        if( ! flg ) {
191 1 hiro
                /* Clear all check boxes */
192 1 hiro
                edit_jpilot_fill_check_box_new();
193 1 hiro
        }
194 1 hiro
195 1 hiro
        /* Display appropriate message */
196 1 hiro
        if( t == MGU_SUCCESS ) {
197 1 hiro
                sMsg = "";
198 1 hiro
        }
199 1 hiro
        else if( t == MGU_BAD_FORMAT || t == MGU_OO_MEMORY ) {
200 1 hiro
                sMsg = _("File does not appear to be JPilot format.");
201 1 hiro
        }
202 1 hiro
        else {
203 1 hiro
                sMsg = _("Could not read file.");
204 1 hiro
        }
205 1 hiro
        edit_jpilot_status_show( sMsg );
206 1 hiro
}
207 1 hiro
208 1 hiro
static void edit_jpilot_file_select( void ) {
209 1 hiro
        gchar *sFile;
210 411 hiro
        gchar *sUTF8File;
211 1 hiro
212 411 hiro
        sFile = filesel_select_file( _("Select JPilot File"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN );
213 1 hiro
214 411 hiro
        if( sFile ) {
215 411 hiro
                sUTF8File = conv_filename_to_utf8( sFile );
216 411 hiro
                gtk_entry_set_text( GTK_ENTRY(jpilotedit.file_entry), sUTF8File );
217 411 hiro
                g_free( sUTF8File );
218 411 hiro
                g_free( sFile );
219 411 hiro
                edit_jpilot_file_check();
220 411 hiro
        }
221 1 hiro
}
222 1 hiro
223 1 hiro
static void addressbook_edit_jpilot_create( gboolean *cancelled ) {
224 1 hiro
        GtkWidget *window;
225 1 hiro
        GtkWidget *vbox;
226 1 hiro
        GtkWidget *table;
227 1 hiro
        GtkWidget *label;
228 1 hiro
        GtkWidget *name_entry;
229 1 hiro
        GtkWidget *file_entry;
230 1 hiro
        GtkWidget *vbox_custom;
231 1 hiro
        GtkWidget *frame_custom;
232 1 hiro
        GtkWidget *custom_check[JPILOT_NUM_CUSTOM_LABEL];
233 1 hiro
        GtkWidget *custom_label[JPILOT_NUM_CUSTOM_LABEL];
234 1 hiro
        GtkWidget *hlbox;
235 1 hiro
        GtkWidget *hbbox;
236 1 hiro
        GtkWidget *hsep;
237 1 hiro
        GtkWidget *ok_btn;
238 1 hiro
        GtkWidget *cancel_btn;
239 1 hiro
        GtkWidget *check_btn;
240 1 hiro
        GtkWidget *file_btn;
241 1 hiro
        GtkWidget *hsbox;
242 1 hiro
        GtkWidget *statusbar;
243 1 hiro
        gint top, i;
244 1 hiro
245 1 hiro
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
246 1 hiro
        gtk_widget_set_size_request(window, 450, -1);
247 1 hiro
        gtk_container_set_border_width(GTK_CONTAINER(window), 0);
248 1 hiro
        gtk_window_set_title(GTK_WINDOW(window), _("Edit JPilot Entry"));
249 1 hiro
        gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
250 1 hiro
        gtk_window_set_modal(GTK_WINDOW(window), TRUE);
251 1 hiro
        g_signal_connect(G_OBJECT(window), "delete_event",
252 1 hiro
                         G_CALLBACK(edit_jpilot_delete_event),
253 1 hiro
                         cancelled);
254 1 hiro
        g_signal_connect(G_OBJECT(window), "key_press_event",
255 1 hiro
                         G_CALLBACK(edit_jpilot_key_pressed),
256 1 hiro
                         cancelled);
257 1 hiro
258 1 hiro
        vbox = gtk_vbox_new(FALSE, 8);
259 1 hiro
        gtk_container_add(GTK_CONTAINER(window), vbox);
260 1 hiro
        gtk_container_set_border_width( GTK_CONTAINER(vbox), 0 );
261 1 hiro
262 1 hiro
        table = gtk_table_new(2 + JPILOT_NUM_CUSTOM_LABEL, 3, FALSE);
263 1 hiro
        gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
264 1 hiro
        gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
265 1 hiro
        gtk_table_set_row_spacings(GTK_TABLE(table), 8);
266 1 hiro
        gtk_table_set_col_spacings(GTK_TABLE(table), 8);
267 1 hiro
268 1 hiro
        /* First row */
269 1 hiro
        top = 0;
270 1 hiro
        label = gtk_label_new(_("Name"));
271 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
272 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
273 1 hiro
274 1 hiro
        name_entry = gtk_entry_new();
275 1 hiro
        gtk_table_attach(GTK_TABLE(table), name_entry, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
276 1 hiro
277 1 hiro
        check_btn = gtk_button_new_with_label( _(" Check File "));
278 1 hiro
        gtk_table_attach(GTK_TABLE(table), check_btn, 2, 3, top, (top + 1), GTK_FILL, 0, 3, 0);
279 1 hiro
280 1 hiro
        /* Second row */
281 1 hiro
        top = 1;
282 1 hiro
        label = gtk_label_new(_("File"));
283 1 hiro
        gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
284 1 hiro
        gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
285 1 hiro
286 1 hiro
        file_entry = gtk_entry_new();
287 1 hiro
        gtk_table_attach(GTK_TABLE(table), file_entry, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
288 1 hiro
289 1 hiro
        file_btn = gtk_button_new_with_label( _(" ... "));
290 1 hiro
        gtk_table_attach(GTK_TABLE(table), file_btn, 2, 3, top, (top + 1), GTK_FILL, 0, 3, 0);
291 1 hiro
292 1 hiro
        /* Third row */
293 1 hiro
        top = 2;
294 1 hiro
        frame_custom = gtk_frame_new(_("Additional e-Mail address item(s)"));
295 1 hiro
        gtk_table_attach(GTK_TABLE(table), frame_custom, 1, 2, top, (top + JPILOT_NUM_CUSTOM_LABEL), GTK_FILL, 0, 0, 0);
296 1 hiro
297 1 hiro
        /* Now do custom labels. */
298 1 hiro
        vbox_custom = gtk_vbox_new (FALSE, 8);
299 1 hiro
        for( i = 0; i < JPILOT_NUM_CUSTOM_LABEL; i++ ) {
300 1 hiro
                hlbox = gtk_hbox_new( FALSE, 0 );
301 1 hiro
                custom_check[i] = gtk_check_button_new();
302 1 hiro
                custom_label[i] = gtk_label_new( "" );
303 1 hiro
                gtk_box_pack_start( GTK_BOX(hlbox), custom_check[i], FALSE, FALSE, 0 );
304 1 hiro
                gtk_box_pack_start( GTK_BOX(hlbox), custom_label[i], TRUE, TRUE, 0 );
305 1 hiro
                gtk_box_pack_start( GTK_BOX(vbox_custom), hlbox, TRUE, TRUE, 0 );
306 1 hiro
                gtk_misc_set_alignment(GTK_MISC(custom_label[i]), 0, 0.5);
307 1 hiro
                top++;
308 1 hiro
        }
309 1 hiro
        gtk_container_add (GTK_CONTAINER (frame_custom), vbox_custom);
310 1 hiro
        gtk_container_set_border_width( GTK_CONTAINER(vbox_custom), 8 );
311 1 hiro
312 1 hiro
        /* Status line */
313 1 hiro
        hsbox = gtk_hbox_new(FALSE, 0);
314 1040 hiro
        gtk_box_pack_end(GTK_BOX(vbox), hsbox, FALSE, FALSE, 0);
315 1 hiro
        statusbar = gtk_statusbar_new();
316 1040 hiro
        gtk_box_pack_start(GTK_BOX(hsbox), statusbar, TRUE, TRUE, 0);
317 1 hiro
318 1 hiro
        /* Button panel */
319 31 hiro
        gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK,
320 31 hiro
                                      &cancel_btn, GTK_STOCK_CANCEL,
321 31 hiro
                                      NULL, NULL);
322 1 hiro
        gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
323 1 hiro
        gtk_container_set_border_width( GTK_CONTAINER(hbbox), 0 );
324 1 hiro
        gtk_widget_grab_default(ok_btn);
325 1 hiro
326 1 hiro
        hsep = gtk_hseparator_new();
327 1 hiro
        gtk_box_pack_end(GTK_BOX(vbox), hsep, FALSE, FALSE, 0);
328 1 hiro
329 1 hiro
        g_signal_connect(G_OBJECT(ok_btn), "clicked",
330 1 hiro
                         G_CALLBACK(edit_jpilot_ok), cancelled);
331 1 hiro
        g_signal_connect(G_OBJECT(cancel_btn), "clicked",
332 1 hiro
                         G_CALLBACK(edit_jpilot_cancel), cancelled);
333 1 hiro
        g_signal_connect(G_OBJECT(file_btn), "clicked",
334 1 hiro
                         G_CALLBACK(edit_jpilot_file_select), NULL);
335 1 hiro
        g_signal_connect(G_OBJECT(check_btn), "clicked",
336 1 hiro
                         G_CALLBACK(edit_jpilot_file_check), NULL);
337 1 hiro
338 1 hiro
        gtk_widget_show_all(vbox);
339 1 hiro
340 1 hiro
        jpilotedit.window     = window;
341 1 hiro
        jpilotedit.name_entry = name_entry;
342 1 hiro
        jpilotedit.file_entry = file_entry;
343 405 hiro
        jpilotedit.hbbox      = hbbox;
344 1 hiro
        jpilotedit.ok_btn     = ok_btn;
345 1 hiro
        jpilotedit.cancel_btn = cancel_btn;
346 1 hiro
        jpilotedit.statusbar  = statusbar;
347 1 hiro
        jpilotedit.status_cid = gtk_statusbar_get_context_id( GTK_STATUSBAR(statusbar), "Edit JPilot Dialog" );
348 1 hiro
        for( i = 0; i < JPILOT_NUM_CUSTOM_LABEL; i++ ) {
349 1 hiro
                jpilotedit.custom_check[i] = custom_check[i];
350 1 hiro
                jpilotedit.custom_label[i] = custom_label[i];
351 1 hiro
        }
352 1 hiro
}
353 1 hiro
354 1 hiro
AdapterDSource *addressbook_edit_jpilot( AddressIndex *addrIndex, AdapterDSource *ads ) {
355 1 hiro
        static gboolean cancelled;
356 1 hiro
        gchar *sName;
357 1 hiro
        gchar *sFile;
358 411 hiro
        gchar *sFSFile;
359 1 hiro
        AddressDataSource *ds = NULL;
360 1 hiro
        JPilotFile *jpf = NULL;
361 1 hiro
        gboolean fin;
362 1 hiro
363 1 hiro
        if( ! jpilotedit.window )
364 1 hiro
                addressbook_edit_jpilot_create(&cancelled);
365 405 hiro
        gtkut_box_set_reverse_order(GTK_BOX(jpilotedit.hbbox),
366 405 hiro
                                    !prefs_common.comply_gnome_hig);
367 1 hiro
        gtk_widget_grab_focus(jpilotedit.ok_btn);
368 1 hiro
        gtk_widget_grab_focus(jpilotedit.name_entry);
369 1 hiro
        gtk_widget_show(jpilotedit.window);
370 1 hiro
        manage_window_set_transient(GTK_WINDOW(jpilotedit.window));
371 1 hiro
372 1 hiro
        edit_jpilot_status_show( "" );
373 1 hiro
        if( ads ) {
374 1 hiro
                ds = ads->dataSource;
375 1 hiro
                jpf = ds->rawDataSource;
376 1 hiro
                if (jpf->name)
377 1 hiro
                        gtk_entry_set_text(GTK_ENTRY(jpilotedit.name_entry), jpf->name);
378 1 hiro
                if (jpf->path)
379 1 hiro
                        gtk_entry_set_text(GTK_ENTRY(jpilotedit.file_entry), jpf->path);
380 1 hiro
                gtk_window_set_title( GTK_WINDOW(jpilotedit.window), _("Edit JPilot Entry"));
381 1 hiro
                edit_jpilot_fill_check_box( jpf );
382 1 hiro
        }
383 1 hiro
        else {
384 1 hiro
                gchar *guessFile = jpilot_find_pilotdb();
385 1 hiro
                gtk_entry_set_text(GTK_ENTRY(jpilotedit.name_entry), ADDRESSBOOK_GUESS_JPILOT );
386 1 hiro
                gtk_entry_set_text(GTK_ENTRY(jpilotedit.file_entry), guessFile );
387 1 hiro
                gtk_window_set_title( GTK_WINDOW(jpilotedit.window), _("Add New JPilot Entry"));
388 1 hiro
                edit_jpilot_fill_check_box_new();
389 1 hiro
                if( *guessFile != '\0' ) {
390 1 hiro
                        edit_jpilot_file_check();
391 1 hiro
                }
392 1 hiro
        }
393 1 hiro
394 1 hiro
        gtk_main();
395 1 hiro
        gtk_widget_hide(jpilotedit.window);
396 1 hiro
        if (cancelled == TRUE) return NULL;
397 1 hiro
398 1 hiro
        fin = FALSE;
399 1 hiro
        sName = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.name_entry), 0, -1 );
400 1 hiro
        sFile = gtk_editable_get_chars( GTK_EDITABLE(jpilotedit.file_entry), 0, -1 );
401 411 hiro
        sFSFile = conv_filename_from_utf8( sFile );
402 1 hiro
        if( *sName == '\0' ) fin = TRUE;
403 1 hiro
        if( *sFile == '\0' ) fin = TRUE;
404 411 hiro
        if( ! sFSFile || *sFSFile == '\0' ) fin = TRUE;
405 1 hiro
406 1 hiro
        if( ! fin ) {
407 1 hiro
                if( ! ads ) {
408 1 hiro
                        jpf = jpilot_create();
409 1 hiro
                        ds = addrindex_index_add_datasource( addrIndex, ADDR_IF_JPILOT, jpf );
410 1 hiro
                        ads = addressbook_create_ds_adapter( ds, ADDR_JPILOT, NULL );
411 1 hiro
                }
412 1 hiro
                addressbook_ads_set_name( ads, sName );
413 1 hiro
                jpilot_set_name( jpf, sName );
414 411 hiro
                jpilot_set_file( jpf, sFSFile );
415 1 hiro
                edit_jpilot_read_check_box( jpf );
416 1 hiro
        }
417 411 hiro
        g_free( sFSFile );
418 1 hiro
        g_free( sFile );
419 411 hiro
        g_free( sName );
420 1 hiro
421 1 hiro
        return ads;
422 1 hiro
}
423 1 hiro
424 1 hiro
#endif /* USE_JPILOT */
425 1 hiro
426 1 hiro
/*
427 1 hiro
* End of Source.
428 1 hiro
*/