root / src / editbook.c @ 761
History | View | Annotate | Download (10.5 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 new address book entry. |
| 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 | #include "defs.h" |
| 29 | 1 | hiro | |
| 30 | 1 | hiro | #include <glib.h> |
| 31 | 92 | hiro | #include <glib/gi18n.h> |
| 32 | 1 | hiro | #include <gdk/gdkkeysyms.h> |
| 33 | 1 | hiro | #include <gtk/gtkwindow.h> |
| 34 | 1 | hiro | #include <gtk/gtksignal.h> |
| 35 | 237 | hiro | #include <gtk/gtkvbox.h> |
| 36 | 1 | hiro | #include <gtk/gtklabel.h> |
| 37 | 1 | hiro | #include <gtk/gtkentry.h> |
| 38 | 1 | hiro | #include <gtk/gtktable.h> |
| 39 | 1 | hiro | #include <gtk/gtkbutton.h> |
| 40 | 237 | hiro | #include <gtk/gtkstatusbar.h> |
| 41 | 237 | hiro | #include <gtk/gtkhseparator.h> |
| 42 | 237 | hiro | #include <gtk/gtkstock.h> |
| 43 | 1 | hiro | |
| 44 | 1 | hiro | #include "utils.h" |
| 45 | 1 | hiro | #include "prefs_common.h" |
| 46 | 1 | hiro | #include "mgutils.h" |
| 47 | 1 | hiro | #include "addressbook.h" |
| 48 | 1 | hiro | #include "addressitem.h" |
| 49 | 1 | hiro | #include "addrindex.h" |
| 50 | 1 | hiro | #include "addrbook.h" |
| 51 | 1 | hiro | #include "manage_window.h" |
| 52 | 1 | hiro | #include "gtkutils.h" |
| 53 | 1 | hiro | |
| 54 | 1 | hiro | #define ADDRESSBOOK_GUESS_BOOK "MyAddressBook" |
| 55 | 1 | hiro | |
| 56 | 1 | hiro | static struct _AddrBookEdit_Dlg { |
| 57 | 1 | hiro | GtkWidget *window; |
| 58 | 1 | hiro | GtkWidget *name_entry; |
| 59 | 1 | hiro | GtkWidget *file_label; |
| 60 | 405 | hiro | GtkWidget *hbbox; |
| 61 | 1 | hiro | GtkWidget *ok_btn; |
| 62 | 1 | hiro | GtkWidget *cancel_btn; |
| 63 | 1 | hiro | GtkWidget *check_btn; |
| 64 | 1 | hiro | /* GtkWidget *file_btn; */
|
| 65 | 1 | hiro | GtkWidget *statusbar; |
| 66 | 1 | hiro | gint status_cid; |
| 67 | 1 | hiro | AddressBookFile *bookFile; |
| 68 | 1 | hiro | } addrbookedit_dlg; |
| 69 | 1 | hiro | |
| 70 | 1 | hiro | /* static struct _AddressFileSelection vcard_file_selector; */
|
| 71 | 1 | hiro | |
| 72 | 1 | hiro | /*
|
| 73 | 1 | hiro | * Edit functions. |
| 74 | 1 | hiro | */ |
| 75 | 1 | hiro | void edit_book_status_show( gchar *msg ) {
|
| 76 | 1 | hiro | if( addrbookedit_dlg.statusbar != NULL ) { |
| 77 | 1 | hiro | gtk_statusbar_pop( GTK_STATUSBAR(addrbookedit_dlg.statusbar), addrbookedit_dlg.status_cid ); |
| 78 | 1 | hiro | if( msg ) {
|
| 79 | 1 | hiro | gtk_statusbar_push( |
| 80 | 1 | hiro | GTK_STATUSBAR(addrbookedit_dlg.statusbar), addrbookedit_dlg.status_cid, msg ); |
| 81 | 1 | hiro | } |
| 82 | 1 | hiro | else {
|
| 83 | 1 | hiro | gtk_statusbar_push( |
| 84 | 1 | hiro | GTK_STATUSBAR(addrbookedit_dlg.statusbar), addrbookedit_dlg.status_cid, "" );
|
| 85 | 1 | hiro | } |
| 86 | 1 | hiro | } |
| 87 | 1 | hiro | } |
| 88 | 1 | hiro | |
| 89 | 1 | hiro | static void edit_book_ok( GtkWidget *widget, gboolean *cancelled ) { |
| 90 | 1 | hiro | *cancelled = FALSE; |
| 91 | 1 | hiro | gtk_main_quit(); |
| 92 | 1 | hiro | } |
| 93 | 1 | hiro | |
| 94 | 1 | hiro | static void edit_book_cancel( GtkWidget *widget, gboolean *cancelled ) { |
| 95 | 1 | hiro | *cancelled = TRUE; |
| 96 | 1 | hiro | gtk_main_quit(); |
| 97 | 1 | hiro | } |
| 98 | 1 | hiro | |
| 99 | 1 | hiro | static gint edit_book_delete_event( GtkWidget *widget, GdkEventAny *event, gboolean *cancelled ) {
|
| 100 | 1 | hiro | *cancelled = TRUE; |
| 101 | 1 | hiro | gtk_main_quit(); |
| 102 | 1 | hiro | return TRUE;
|
| 103 | 1 | hiro | } |
| 104 | 1 | hiro | |
| 105 | 1 | hiro | static gboolean edit_book_key_pressed( GtkWidget *widget, GdkEventKey *event, gboolean *cancelled ) {
|
| 106 | 1 | hiro | if (event && event->keyval == GDK_Escape) {
|
| 107 | 1 | hiro | *cancelled = TRUE; |
| 108 | 1 | hiro | gtk_main_quit(); |
| 109 | 1 | hiro | } |
| 110 | 1 | hiro | return FALSE;
|
| 111 | 1 | hiro | } |
| 112 | 1 | hiro | |
| 113 | 1 | hiro | static void edit_book_file_check( void ) { |
| 114 | 1 | hiro | gint t; |
| 115 | 1 | hiro | gchar *sMsg; |
| 116 | 1 | hiro | AddressBookFile *abf = addrbookedit_dlg.bookFile; |
| 117 | 1 | hiro | |
| 118 | 1 | hiro | t = addrbook_test_read_file( abf, abf->fileName ); |
| 119 | 1 | hiro | if( t == MGU_SUCCESS ) {
|
| 120 | 1 | hiro | sMsg = _("File appears to be Ok.");
|
| 121 | 1 | hiro | } |
| 122 | 1 | hiro | else if( t == MGU_BAD_FORMAT ) { |
| 123 | 1 | hiro | sMsg = _("File does not appear to be a valid address book format.");
|
| 124 | 1 | hiro | } |
| 125 | 1 | hiro | else {
|
| 126 | 1 | hiro | sMsg = _("Could not read file.");
|
| 127 | 1 | hiro | } |
| 128 | 1 | hiro | edit_book_status_show( sMsg ); |
| 129 | 1 | hiro | } |
| 130 | 1 | hiro | |
| 131 | 1 | hiro | static void edit_book_enable_buttons( gboolean enable ) { |
| 132 | 1 | hiro | gtk_widget_set_sensitive( addrbookedit_dlg.check_btn, enable ); |
| 133 | 1 | hiro | /* gtk_widget_set_sensitive( addrbookedit_dlg.file_btn, enable ); */
|
| 134 | 1 | hiro | } |
| 135 | 1 | hiro | |
| 136 | 1 | hiro | static void edit_book_name_focus( GtkWidget *widget, GdkEventFocus *event, gpointer data) { |
| 137 | 1 | hiro | edit_book_status_show( "" );
|
| 138 | 1 | hiro | } |
| 139 | 1 | hiro | |
| 140 | 1 | hiro | static gchar *edit_book_guess_file( AddressBookFile *abf ) {
|
| 141 | 1 | hiro | gchar *newFile = NULL;
|
| 142 | 1 | hiro | GList *fileList = NULL;
|
| 143 | 1 | hiro | gint fileNum = 1;
|
| 144 | 1 | hiro | fileList = addrbook_get_bookfile_list( abf ); |
| 145 | 1 | hiro | if( fileList ) {
|
| 146 | 1 | hiro | fileNum = 1 + abf->maxValue;
|
| 147 | 1 | hiro | } |
| 148 | 1 | hiro | newFile = addrbook_gen_new_file_name( fileNum ); |
| 149 | 1 | hiro | g_list_free( fileList ); |
| 150 | 1 | hiro | fileList = NULL;
|
| 151 | 1 | hiro | return newFile;
|
| 152 | 1 | hiro | } |
| 153 | 1 | hiro | |
| 154 | 1 | hiro | static void addressbook_edit_book_create( gboolean *cancelled ) { |
| 155 | 1 | hiro | GtkWidget *window; |
| 156 | 1 | hiro | GtkWidget *vbox; |
| 157 | 1 | hiro | GtkWidget *table; |
| 158 | 1 | hiro | GtkWidget *label; |
| 159 | 1 | hiro | GtkWidget *name_entry; |
| 160 | 1 | hiro | GtkWidget *file_label; |
| 161 | 1 | hiro | GtkWidget *hbbox; |
| 162 | 1 | hiro | GtkWidget *hsep; |
| 163 | 1 | hiro | GtkWidget *ok_btn; |
| 164 | 1 | hiro | GtkWidget *cancel_btn; |
| 165 | 1 | hiro | GtkWidget *check_btn; |
| 166 | 1 | hiro | /* GtkWidget *file_btn; */
|
| 167 | 1 | hiro | GtkWidget *statusbar; |
| 168 | 1 | hiro | GtkWidget *hsbox; |
| 169 | 1 | hiro | gint top; |
| 170 | 1 | hiro | |
| 171 | 1 | hiro | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 172 | 1 | hiro | gtk_widget_set_size_request(window, 450, -1); |
| 173 | 1 | hiro | gtk_container_set_border_width( GTK_CONTAINER(window), 0 );
|
| 174 | 1 | hiro | gtk_window_set_title(GTK_WINDOW(window), _("Edit Addressbook"));
|
| 175 | 1 | hiro | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); |
| 176 | 1 | hiro | gtk_window_set_modal(GTK_WINDOW(window), TRUE); |
| 177 | 1 | hiro | g_signal_connect(G_OBJECT(window), "delete_event",
|
| 178 | 1 | hiro | G_CALLBACK(edit_book_delete_event), |
| 179 | 1 | hiro | cancelled); |
| 180 | 1 | hiro | g_signal_connect(G_OBJECT(window), "key_press_event",
|
| 181 | 1 | hiro | G_CALLBACK(edit_book_key_pressed), |
| 182 | 1 | hiro | cancelled); |
| 183 | 1 | hiro | |
| 184 | 1 | hiro | vbox = gtk_vbox_new(FALSE, 8);
|
| 185 | 1 | hiro | gtk_container_add(GTK_CONTAINER(window), vbox); |
| 186 | 1 | hiro | gtk_container_set_border_width( GTK_CONTAINER(vbox), 0 );
|
| 187 | 1 | hiro | |
| 188 | 1 | hiro | table = gtk_table_new(2, 3, FALSE); |
| 189 | 1 | hiro | gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
|
| 190 | 1 | hiro | gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
|
| 191 | 1 | hiro | gtk_table_set_row_spacings(GTK_TABLE(table), 8);
|
| 192 | 1 | hiro | gtk_table_set_col_spacings(GTK_TABLE(table), 8 );
|
| 193 | 1 | hiro | |
| 194 | 1 | hiro | /* First row */
|
| 195 | 1 | hiro | top = 0;
|
| 196 | 1 | hiro | label = gtk_label_new(_("Name"));
|
| 197 | 1 | hiro | gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0); |
| 198 | 1 | hiro | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 199 | 1 | hiro | |
| 200 | 1 | hiro | name_entry = gtk_entry_new(); |
| 201 | 1 | hiro | gtk_table_attach(GTK_TABLE(table), name_entry, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0); |
| 202 | 1 | hiro | |
| 203 | 1 | hiro | check_btn = gtk_button_new_with_label( _(" Check File "));
|
| 204 | 1 | hiro | gtk_table_attach(GTK_TABLE(table), check_btn, 2, 3, top, (top + 1), GTK_FILL, 0, 3, 0); |
| 205 | 1 | hiro | |
| 206 | 1 | hiro | /* Second row */
|
| 207 | 1 | hiro | top = 1;
|
| 208 | 1 | hiro | label = gtk_label_new(_("File"));
|
| 209 | 1 | hiro | gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0); |
| 210 | 1 | hiro | gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); |
| 211 | 1 | hiro | |
| 212 | 1 | hiro | file_label = gtk_label_new( "" );
|
| 213 | 1 | hiro | gtk_misc_set_alignment(GTK_MISC(file_label), 0, 0.5); |
| 214 | 1 | hiro | gtk_table_attach(GTK_TABLE(table), file_label, 1, 2, top, (top + 1), GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0); |
| 215 | 1 | hiro | |
| 216 | 1 | hiro | /* file_btn = gtk_button_new_with_label( _(" ... ")); */
|
| 217 | 1 | hiro | /* gtk_table_attach(GTK_TABLE(table), file_btn, 2, 3, top, (top + 1), GTK_FILL, 0, 3, 0); */
|
| 218 | 1 | hiro | |
| 219 | 1 | hiro | /* Status line */
|
| 220 | 1 | hiro | hsbox = gtk_hbox_new(FALSE, 0);
|
| 221 | 1 | hiro | gtk_box_pack_end(GTK_BOX(vbox), hsbox, FALSE, FALSE, BORDER_WIDTH); |
| 222 | 1 | hiro | statusbar = gtk_statusbar_new(); |
| 223 | 1 | hiro | gtk_box_pack_start(GTK_BOX(hsbox), statusbar, TRUE, TRUE, BORDER_WIDTH); |
| 224 | 1 | hiro | |
| 225 | 1 | hiro | /* Button panel */
|
| 226 | 31 | hiro | gtkut_stock_button_set_create(&hbbox, &ok_btn, GTK_STOCK_OK, |
| 227 | 31 | hiro | &cancel_btn, GTK_STOCK_CANCEL, |
| 228 | 31 | hiro | NULL, NULL); |
| 229 | 1 | hiro | gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
|
| 230 | 1 | hiro | gtk_container_set_border_width( GTK_CONTAINER(hbbox), 0 );
|
| 231 | 1 | hiro | gtk_widget_grab_default(ok_btn); |
| 232 | 1 | hiro | |
| 233 | 1 | hiro | hsep = gtk_hseparator_new(); |
| 234 | 1 | hiro | gtk_box_pack_end(GTK_BOX(vbox), hsep, FALSE, FALSE, 0);
|
| 235 | 1 | hiro | |
| 236 | 1 | hiro | g_signal_connect(G_OBJECT(name_entry), "focus_in_event",
|
| 237 | 1 | hiro | G_CALLBACK(edit_book_name_focus), NULL );
|
| 238 | 1 | hiro | g_signal_connect(G_OBJECT(ok_btn), "clicked",
|
| 239 | 1 | hiro | G_CALLBACK(edit_book_ok), cancelled); |
| 240 | 1 | hiro | g_signal_connect(G_OBJECT(cancel_btn), "clicked",
|
| 241 | 1 | hiro | G_CALLBACK(edit_book_cancel), cancelled); |
| 242 | 1 | hiro | /* g_signal_connect(G_OBJECT(file_btn), "clicked", */
|
| 243 | 1 | hiro | /* G_CALLBACK(edit_book_file_select), NULL); */
|
| 244 | 1 | hiro | g_signal_connect(G_OBJECT(check_btn), "clicked",
|
| 245 | 1 | hiro | G_CALLBACK(edit_book_file_check), NULL);
|
| 246 | 1 | hiro | |
| 247 | 1 | hiro | gtk_widget_show_all(vbox); |
| 248 | 1 | hiro | |
| 249 | 1 | hiro | addrbookedit_dlg.window = window; |
| 250 | 1 | hiro | addrbookedit_dlg.name_entry = name_entry; |
| 251 | 1 | hiro | addrbookedit_dlg.file_label = file_label; |
| 252 | 405 | hiro | addrbookedit_dlg.hbbox = hbbox; |
| 253 | 1 | hiro | addrbookedit_dlg.ok_btn = ok_btn; |
| 254 | 1 | hiro | addrbookedit_dlg.cancel_btn = cancel_btn; |
| 255 | 1 | hiro | addrbookedit_dlg.check_btn = check_btn; |
| 256 | 1 | hiro | /* addrbookedit_dlg.file_btn = file_btn; */
|
| 257 | 1 | hiro | addrbookedit_dlg.statusbar = statusbar; |
| 258 | 1 | hiro | addrbookedit_dlg.status_cid = gtk_statusbar_get_context_id( GTK_STATUSBAR(statusbar), "Edit Addressbook Dialog" );
|
| 259 | 1 | hiro | } |
| 260 | 1 | hiro | |
| 261 | 1 | hiro | AdapterDSource *addressbook_edit_book( AddressIndex *addrIndex, AdapterDSource *ads ) {
|
| 262 | 1 | hiro | static gboolean cancelled;
|
| 263 | 1 | hiro | gchar *sName; |
| 264 | 1 | hiro | AddressDataSource *ds = NULL;
|
| 265 | 1 | hiro | AddressBookFile *abf; |
| 266 | 1 | hiro | gboolean fin; |
| 267 | 1 | hiro | gboolean newBook = FALSE; |
| 268 | 1 | hiro | gchar *newFile = NULL;
|
| 269 | 1 | hiro | |
| 270 | 1 | hiro | if (!addrbookedit_dlg.window)
|
| 271 | 1 | hiro | addressbook_edit_book_create(&cancelled); |
| 272 | 405 | hiro | gtkut_box_set_reverse_order(GTK_BOX(addrbookedit_dlg.hbbox), |
| 273 | 405 | hiro | !prefs_common.comply_gnome_hig); |
| 274 | 1 | hiro | gtk_widget_grab_focus(addrbookedit_dlg.ok_btn); |
| 275 | 1 | hiro | gtk_widget_grab_focus(addrbookedit_dlg.name_entry); |
| 276 | 1 | hiro | gtk_widget_show(addrbookedit_dlg.window); |
| 277 | 1 | hiro | manage_window_set_transient(GTK_WINDOW(addrbookedit_dlg.window)); |
| 278 | 1 | hiro | |
| 279 | 1 | hiro | edit_book_status_show( "" );
|
| 280 | 1 | hiro | gtk_label_set_text( GTK_LABEL(addrbookedit_dlg.file_label), "" );
|
| 281 | 1 | hiro | if( ads ) {
|
| 282 | 1 | hiro | ds = ads->dataSource; |
| 283 | 1 | hiro | abf = ds->rawDataSource; |
| 284 | 1 | hiro | if (abf->name)
|
| 285 | 1 | hiro | gtk_entry_set_text(GTK_ENTRY(addrbookedit_dlg.name_entry), abf->name); |
| 286 | 1 | hiro | if( abf->fileName )
|
| 287 | 1 | hiro | gtk_label_set_text(GTK_LABEL(addrbookedit_dlg.file_label), abf->fileName); |
| 288 | 1 | hiro | gtk_window_set_title( GTK_WINDOW(addrbookedit_dlg.window), _("Edit Addressbook"));
|
| 289 | 1 | hiro | edit_book_enable_buttons( TRUE ); |
| 290 | 1 | hiro | } |
| 291 | 1 | hiro | else {
|
| 292 | 1 | hiro | gchar *tmp = NULL;
|
| 293 | 1 | hiro | newBook = TRUE; |
| 294 | 1 | hiro | abf = addrbook_create_book(); |
| 295 | 1 | hiro | addrbook_set_path( abf, addrIndex->filePath ); |
| 296 | 1 | hiro | |
| 297 | 1 | hiro | /* Take initial guess at file name */
|
| 298 | 1 | hiro | newFile = edit_book_guess_file( abf ); |
| 299 | 1 | hiro | if( newFile ) {
|
| 300 | 1 | hiro | tmp = g_strdup_printf( "<%s>", newFile );
|
| 301 | 1 | hiro | gtk_label_set_text(GTK_LABEL(addrbookedit_dlg.file_label), tmp ); |
| 302 | 1 | hiro | g_free( tmp ); |
| 303 | 1 | hiro | } |
| 304 | 1 | hiro | g_free( newFile ); |
| 305 | 1 | hiro | |
| 306 | 1 | hiro | gtk_entry_set_text( GTK_ENTRY(addrbookedit_dlg.name_entry), ADDRESSBOOK_GUESS_BOOK ); |
| 307 | 1 | hiro | gtk_window_set_title( GTK_WINDOW(addrbookedit_dlg.window), _("Add New Addressbook") );
|
| 308 | 1 | hiro | edit_book_enable_buttons( FALSE ); |
| 309 | 1 | hiro | } |
| 310 | 1 | hiro | |
| 311 | 1 | hiro | addrbookedit_dlg.bookFile = abf; |
| 312 | 1 | hiro | |
| 313 | 1 | hiro | gtk_main(); |
| 314 | 1 | hiro | gtk_widget_hide(addrbookedit_dlg.window); |
| 315 | 1 | hiro | |
| 316 | 1 | hiro | if( cancelled == TRUE ) {
|
| 317 | 1 | hiro | if( newBook ) {
|
| 318 | 1 | hiro | addrbook_free_book( abf ); |
| 319 | 1 | hiro | abf = NULL;
|
| 320 | 1 | hiro | } |
| 321 | 1 | hiro | return NULL; |
| 322 | 1 | hiro | } |
| 323 | 1 | hiro | |
| 324 | 1 | hiro | fin = FALSE; |
| 325 | 1 | hiro | sName = gtk_editable_get_chars( GTK_EDITABLE(addrbookedit_dlg.name_entry), 0, -1 ); |
| 326 | 1 | hiro | if( *sName == '\0' ) fin = TRUE; |
| 327 | 1 | hiro | |
| 328 | 1 | hiro | if( fin ) {
|
| 329 | 1 | hiro | if( newBook ) {
|
| 330 | 1 | hiro | addrbook_free_book( abf ); |
| 331 | 1 | hiro | abf = NULL;
|
| 332 | 1 | hiro | } |
| 333 | 1 | hiro | } |
| 334 | 1 | hiro | else {
|
| 335 | 1 | hiro | if( newBook ) {
|
| 336 | 1 | hiro | /* Get final file name in case it changed */
|
| 337 | 1 | hiro | newFile = edit_book_guess_file( abf ); |
| 338 | 1 | hiro | addrbook_set_file( abf, newFile ); |
| 339 | 1 | hiro | g_free( newFile ); |
| 340 | 1 | hiro | ds = addrindex_index_add_datasource( addrIndex, ADDR_IF_BOOK, abf ); |
| 341 | 1 | hiro | ads = addressbook_create_ds_adapter( ds, ADDR_BOOK, NULL );
|
| 342 | 1 | hiro | } |
| 343 | 1 | hiro | addressbook_ads_set_name( ads, sName ); |
| 344 | 1 | hiro | addrbook_set_name( abf, sName ); |
| 345 | 1 | hiro | abf->dirtyFlag = TRUE; |
| 346 | 1 | hiro | } |
| 347 | 1 | hiro | g_free( sName ); |
| 348 | 1 | hiro | |
| 349 | 1 | hiro | /* Save data */
|
| 350 | 1 | hiro | if( abf ) addrbook_save_data( abf );
|
| 351 | 1 | hiro | |
| 352 | 1 | hiro | return ads;
|
| 353 | 1 | hiro | } |
| 354 | 1 | hiro | |
| 355 | 1 | hiro | /*
|
| 356 | 1 | hiro | * End of Source. |
| 357 | 1 | hiro | */ |