2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2002 Match Grun
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Export address book to HTML file.
31 #include <gdk/gdkkeysyms.h>
32 #include <gtk/gtkwindow.h>
33 #include <gtk/gtksignal.h>
34 #include <gtk/gtklabel.h>
35 #include <gtk/gtkentry.h>
36 #include <gtk/gtktable.h>
37 #include <gtk/gtkbutton.h>
41 #include "prefs_common.h"
42 #include "alertpanel.h"
44 #include "addrcache.h"
45 #include "addressitem.h"
46 #include "exporthtml.h"
48 #include "manage_window.h"
50 #define PAGE_FILE_INFO 0
54 #define EXPORTHTML_WIDTH 480
55 #define EXPORTHTML_HEIGHT -1
57 static struct _ExpHtml_Dlg {
62 GtkWidget *optmenuCSS;
63 GtkWidget *optmenuName;
64 GtkWidget *checkBanding;
65 GtkWidget *checkLinkEMail;
66 GtkWidget *checkAttributes;
67 GtkWidget *labelOutBook;
68 GtkWidget *labelOutFile;
77 static struct _AddressFileSelection _exp_html_file_selector_;
79 static ExportHtmlCtl *_exportCtl_ = NULL;
80 static AddressCache *_addressCache_ = NULL;
82 static void export_html_status_show( gchar *msg ) {
83 if( exphtml_dlg.statusbar != NULL ) {
85 GTK_STATUSBAR(exphtml_dlg.statusbar),
86 exphtml_dlg.status_cid );
89 GTK_STATUSBAR(exphtml_dlg.statusbar),
90 exphtml_dlg.status_cid, msg );
95 static void export_html_message( void ) {
99 pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) );
100 if( pageNum == PAGE_FILE_INFO ) {
101 sMsg = _( "Please specify output directory and file to create." );
103 else if( pageNum == PAGE_FORMAT ) {
104 sMsg = _( "Select stylesheet and formatting." );
106 else if( pageNum == PAGE_FINISH ) {
107 sMsg = _( "File exported successfully." );
109 export_html_status_show( sMsg );
112 static void export_html_cancel( GtkWidget *widget, gpointer data ) {
115 pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) );
116 if( pageNum != PAGE_FINISH ) {
117 exphtml_dlg.cancelled = TRUE;
122 static gint export_html_delete_event( GtkWidget *widget, GdkEventAny *event, gpointer data ) {
123 export_html_cancel( widget, data );
127 static void export_html_key_pressed( GtkWidget *widget, GdkEventKey *event, gpointer data ) {
128 if (event && event->keyval == GDK_Escape) {
129 export_html_cancel( widget, data );
134 * Move off file info page.
135 * return: TRUE if OK to move off page.
137 static gboolean exp_html_move_file() {
138 gchar *sFile, *msg, *reason;
141 sFile = gtk_editable_get_chars( GTK_EDITABLE(exphtml_dlg.entryHtml), 0, -1 );
142 g_strchug( sFile ); g_strchomp( sFile );
143 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml), sFile );
144 exporthtml_parse_filespec( _exportCtl_, sFile );
147 /* Test for directory */
148 if( exporthtml_test_dir( _exportCtl_ ) ) {
152 /* Prompt to create */
153 msg = g_strdup_printf( _(
154 "HTML Output Directory '%s'\n" \
155 "does not exist. OK to create new directory?" ),
156 _exportCtl_->dirOutput );
157 aval = alertpanel( _("Create Directory" ),
158 msg, _( "Yes" ), _( "No" ), NULL );
160 if( aval != G_ALERTDEFAULT ) return FALSE;
162 /* Create directory */
163 if( ! exporthtml_create_dir( _exportCtl_ ) ) {
164 reason = exporthtml_get_create_msg( _exportCtl_ );
165 msg = g_strdup_printf( _(
166 "Could not create output directory for HTML file:\n%s" ),
168 aval = alertpanel( _( "Failed to Create Directory" ),
169 msg, _( "Close" ), NULL, NULL );
178 * Move off format page.
179 * return: TRUE if OK to move off page.
181 static gboolean exp_html_move_format() {
182 GtkWidget *menu, *menuItem;
186 menu = gtk_option_menu_get_menu( GTK_OPTION_MENU( exphtml_dlg.optmenuCSS ) );
187 menuItem = gtk_menu_get_active( GTK_MENU( menu ) );
188 id = GPOINTER_TO_INT( gtk_object_get_user_data(GTK_OBJECT(menuItem)) );
189 exporthtml_set_stylesheet( _exportCtl_, id );
191 /* Set name format */
192 menu = gtk_option_menu_get_menu( GTK_OPTION_MENU( exphtml_dlg.optmenuName ) );
193 menuItem = gtk_menu_get_active( GTK_MENU( menu ) );
194 id = GPOINTER_TO_INT( gtk_object_get_user_data(GTK_OBJECT(menuItem)) );
195 exporthtml_set_name_format( _exportCtl_, id );
197 exporthtml_set_banding( _exportCtl_,
198 gtk_toggle_button_get_active(
199 GTK_TOGGLE_BUTTON( exphtml_dlg.checkBanding ) ) );
200 exporthtml_set_link_email( _exportCtl_,
201 gtk_toggle_button_get_active(
202 GTK_TOGGLE_BUTTON( exphtml_dlg.checkLinkEMail ) ) );
203 exporthtml_set_attributes( _exportCtl_,
204 gtk_toggle_button_get_active(
205 GTK_TOGGLE_BUTTON( exphtml_dlg.checkAttributes ) ) );
208 exporthtml_process( _exportCtl_, _addressCache_ );
214 * Display finish page.
216 static void exp_html_finish_show() {
217 gtk_label_set_text( GTK_LABEL(exphtml_dlg.labelOutFile), _exportCtl_->path );
218 gtk_widget_set_sensitive( exphtml_dlg.btnNext, FALSE );
219 gtk_widget_grab_focus( exphtml_dlg.btnCancel );
223 * Previous button handler.
225 static void export_html_prev( GtkWidget *widget ) {
228 pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) );
229 if( pageNum == PAGE_FORMAT ) {
230 /* Goto file page stuff */
231 gtk_notebook_set_page(
232 GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FILE_INFO );
233 gtk_widget_set_sensitive( exphtml_dlg.btnPrev, FALSE );
235 else if( pageNum == PAGE_FINISH ) {
236 /* Goto format page */
237 gtk_notebook_set_page(
238 GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FORMAT );
239 gtk_widget_set_sensitive( exphtml_dlg.btnNext, TRUE );
241 export_html_message();
245 * Next button handler.
247 static void export_html_next( GtkWidget *widget ) {
250 pageNum = gtk_notebook_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) );
251 if( pageNum == PAGE_FILE_INFO ) {
252 /* Goto format page */
253 if( exp_html_move_file() ) {
254 gtk_notebook_set_page(
255 GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FORMAT );
256 gtk_widget_set_sensitive( exphtml_dlg.btnPrev, TRUE );
259 else if( pageNum == PAGE_FORMAT ) {
260 /* Goto finish page */
261 if( exp_html_move_format() ) {
262 gtk_notebook_set_page(
263 GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FINISH );
264 exp_html_finish_show();
265 exporthtml_save_settings( _exportCtl_ );
268 export_html_message();
272 * Open file with web browser.
274 static void export_html_browse( GtkWidget *widget, gpointer data ) {
277 uri = g_strconcat( "file://", _exportCtl_->path, NULL );
278 open_uri( uri, prefs_common.uri_cmd );
285 static void exp_html_file_ok( GtkWidget *widget, gpointer data ) {
287 AddressFileSelection *afs;
290 afs = ( AddressFileSelection * ) data;
291 fileSel = afs->fileSelector;
292 sFile = gtk_file_selection_get_filename( GTK_FILE_SELECTION(fileSel) );
294 afs->cancelled = FALSE;
295 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml), sFile );
296 gtk_widget_hide( afs->fileSelector );
297 gtk_grab_remove( afs->fileSelector );
298 gtk_widget_grab_focus( exphtml_dlg.entryHtml );
302 * Output file - Cancel.
304 static void exp_html_file_cancel( GtkWidget *widget, gpointer data ) {
305 AddressFileSelection *afs = ( AddressFileSelection * ) data;
306 afs->cancelled = TRUE;
307 gtk_widget_hide( afs->fileSelector );
308 gtk_grab_remove( afs->fileSelector );
309 gtk_widget_grab_focus( exphtml_dlg.entryHtml );
313 * Output file - Create.
315 static void exp_html_file_select_create( AddressFileSelection *afs ) {
316 GtkWidget *fileSelector;
318 fileSelector = gtk_file_selection_new( _("Select HTML Output File") );
319 gtk_file_selection_hide_fileop_buttons( GTK_FILE_SELECTION(fileSelector) );
320 gtk_file_selection_complete( GTK_FILE_SELECTION(fileSelector), "*.html" );
321 gtk_signal_connect( GTK_OBJECT (GTK_FILE_SELECTION(fileSelector)->ok_button),
322 "clicked", GTK_SIGNAL_FUNC (exp_html_file_ok), ( gpointer ) afs );
323 gtk_signal_connect( GTK_OBJECT (GTK_FILE_SELECTION(fileSelector)->cancel_button),
324 "clicked", GTK_SIGNAL_FUNC (exp_html_file_cancel), ( gpointer ) afs );
325 afs->fileSelector = fileSelector;
326 afs->cancelled = TRUE;
330 * Output file - Handle file selection.
332 static void exp_html_file_select( void ) {
334 if( ! _exp_html_file_selector_.fileSelector )
335 exp_html_file_select_create( & _exp_html_file_selector_ );
337 sFile = gtk_editable_get_chars( GTK_EDITABLE(exphtml_dlg.entryHtml), 0, -1 );
338 gtk_file_selection_set_filename(
339 GTK_FILE_SELECTION( _exp_html_file_selector_.fileSelector ),
342 gtk_widget_show( _exp_html_file_selector_.fileSelector );
343 gtk_grab_add( _exp_html_file_selector_.fileSelector );
346 static void export_html_page_file( gint pageNum, gchar *pageLbl ) {
350 GtkWidget *labelBook;
351 GtkWidget *entryHtml;
355 vbox = gtk_vbox_new(FALSE, 8);
356 gtk_container_add( GTK_CONTAINER( exphtml_dlg.notebook ), vbox );
357 gtk_container_set_border_width( GTK_CONTAINER (vbox), BORDER_WIDTH );
359 label = gtk_label_new( pageLbl );
360 gtk_widget_show( label );
361 gtk_notebook_set_tab_label(
362 GTK_NOTEBOOK( exphtml_dlg.notebook ),
363 gtk_notebook_get_nth_page(
364 GTK_NOTEBOOK( exphtml_dlg.notebook ), pageNum ),
367 table = gtk_table_new( 3, 3, FALSE );
368 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
369 gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
370 gtk_table_set_row_spacings(GTK_TABLE(table), 8);
371 gtk_table_set_col_spacings(GTK_TABLE(table), 8 );
375 label = gtk_label_new( _( "Address Book" ) );
376 gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1),
378 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
380 labelBook = gtk_label_new( "Address book name goes here" );
381 gtk_table_attach(GTK_TABLE(table), labelBook, 1, 2, top, (top + 1),
382 GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
383 gtk_misc_set_alignment(GTK_MISC(labelBook), 0, 0.5);
387 label = gtk_label_new( _( "HTML Output File" ) );
388 gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1),
390 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
392 entryHtml = gtk_entry_new();
393 gtk_table_attach(GTK_TABLE(table), entryHtml, 1, 2, top, (top + 1),
394 GTK_EXPAND|GTK_SHRINK|GTK_FILL, 0, 0, 0);
396 btnFile = gtk_button_new_with_label( _(" ... "));
397 gtk_table_attach(GTK_TABLE(table), btnFile, 2, 3, top, (top + 1),
400 gtk_widget_show_all(vbox);
403 gtk_signal_connect(GTK_OBJECT(btnFile), "clicked",
404 GTK_SIGNAL_FUNC(exp_html_file_select), NULL);
406 exphtml_dlg.labelBook = labelBook;
407 exphtml_dlg.entryHtml = entryHtml;
410 static void export_html_page_format( gint pageNum, gchar *pageLbl ) {
414 GtkWidget *optmenuCSS;
415 GtkWidget *optmenuName;
418 GtkWidget *checkBanding;
419 GtkWidget *checkLinkEMail;
420 GtkWidget *checkAttributes;
423 vbox = gtk_vbox_new(FALSE, 8);
424 gtk_container_add( GTK_CONTAINER( exphtml_dlg.notebook ), vbox );
425 gtk_container_set_border_width( GTK_CONTAINER (vbox), BORDER_WIDTH );
427 label = gtk_label_new( pageLbl );
428 gtk_widget_show( label );
429 gtk_notebook_set_tab_label(
430 GTK_NOTEBOOK( exphtml_dlg.notebook ),
431 gtk_notebook_get_nth_page(
432 GTK_NOTEBOOK( exphtml_dlg.notebook ), pageNum ),
435 table = gtk_table_new( 5, 3, FALSE );
436 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
437 gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
438 gtk_table_set_row_spacings(GTK_TABLE(table), 8);
439 gtk_table_set_col_spacings(GTK_TABLE(table), 8 );
443 label = gtk_label_new( _( "Stylesheet" ) );
444 gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1),
446 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
448 menu = gtk_menu_new ();
450 menuItem = gtk_menu_item_new_with_label( _( "None" ) );
451 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
452 GINT_TO_POINTER( EXPORT_HTML_ID_NONE ) );
453 gtk_menu_append( GTK_MENU(menu), menuItem );
454 gtk_widget_show( menuItem );
456 menuItem = gtk_menu_item_new_with_label( _( "Default" ) );
457 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
458 GINT_TO_POINTER( EXPORT_HTML_ID_DEFAULT ) );
459 gtk_menu_append( GTK_MENU(menu), menuItem );
460 gtk_widget_show( menuItem );
462 menuItem = gtk_menu_item_new_with_label( _( "Full" ) );
463 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
464 GINT_TO_POINTER( EXPORT_HTML_ID_FULL ) );
465 gtk_menu_append( GTK_MENU(menu), menuItem );
466 gtk_widget_show( menuItem );
468 menuItem = gtk_menu_item_new_with_label( _( "Custom" ) );
469 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
470 GINT_TO_POINTER( EXPORT_HTML_ID_CUSTOM ) );
471 gtk_menu_append( GTK_MENU(menu), menuItem );
472 gtk_widget_show( menuItem );
474 menuItem = gtk_menu_item_new_with_label( _( "Custom-2" ) );
475 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
476 GINT_TO_POINTER( EXPORT_HTML_ID_CUSTOM2 ) );
477 gtk_menu_append( GTK_MENU(menu), menuItem );
478 gtk_widget_show( menuItem );
480 menuItem = gtk_menu_item_new_with_label( _( "Custom-3" ) );
481 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
482 GINT_TO_POINTER( EXPORT_HTML_ID_CUSTOM3 ) );
483 gtk_menu_append( GTK_MENU(menu), menuItem );
484 gtk_widget_show( menuItem );
486 menuItem = gtk_menu_item_new_with_label( _( "Custom-4" ) );
487 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
488 GINT_TO_POINTER( EXPORT_HTML_ID_CUSTOM4 ) );
489 gtk_menu_append( GTK_MENU(menu), menuItem );
490 gtk_widget_show( menuItem );
492 optmenuCSS = gtk_option_menu_new();
493 gtk_option_menu_set_menu( GTK_OPTION_MENU( optmenuCSS ), menu );
495 gtk_table_attach(GTK_TABLE(table), optmenuCSS, 1, 2, top, (top + 1),
500 label = gtk_label_new( _( "Full Name Format" ) );
501 gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1),
503 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
505 menu = gtk_menu_new ();
507 menuItem = gtk_menu_item_new_with_label( _( "First Name, Last Name" ) );
508 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
509 GINT_TO_POINTER( EXPORT_HTML_FIRST_LAST ) );
510 gtk_menu_append( GTK_MENU(menu), menuItem );
511 gtk_widget_show( menuItem );
513 menuItem = gtk_menu_item_new_with_label( _( "Last Name, First Name" ) );
514 gtk_object_set_user_data( GTK_OBJECT( menuItem ),
515 GINT_TO_POINTER( EXPORT_HTML_LAST_FIRST ) );
516 gtk_menu_append( GTK_MENU(menu), menuItem );
517 gtk_widget_show( menuItem );
519 optmenuName = gtk_option_menu_new();
520 gtk_option_menu_set_menu( GTK_OPTION_MENU( optmenuName ), menu );
522 gtk_table_attach(GTK_TABLE(table), optmenuName, 1, 2, top, (top + 1),
527 checkBanding = gtk_check_button_new_with_label( _( "Color Banding" ) );
528 gtk_table_attach(GTK_TABLE(table), checkBanding, 1, 2, top, (top + 1),
533 checkLinkEMail = gtk_check_button_new_with_label( _( "Format E-Mail Links" ) );
534 gtk_table_attach(GTK_TABLE(table), checkLinkEMail, 1, 2, top, (top + 1),
539 checkAttributes = gtk_check_button_new_with_label( _( "Format User Attributes" ) );
540 gtk_table_attach(GTK_TABLE(table), checkAttributes, 1, 2, top, (top + 1),
543 gtk_widget_show_all(vbox);
545 exphtml_dlg.optmenuCSS = optmenuCSS;
546 exphtml_dlg.optmenuName = optmenuName;
547 exphtml_dlg.checkBanding = checkBanding;
548 exphtml_dlg.checkLinkEMail = checkLinkEMail;
549 exphtml_dlg.checkAttributes = checkAttributes;
552 static void export_html_page_finish( gint pageNum, gchar *pageLbl ) {
556 GtkWidget *labelBook;
557 GtkWidget *labelFile;
558 GtkWidget *btnBrowse;
561 vbox = gtk_vbox_new(FALSE, 8);
562 gtk_container_add( GTK_CONTAINER( exphtml_dlg.notebook ), vbox );
563 gtk_container_set_border_width( GTK_CONTAINER (vbox), BORDER_WIDTH );
565 label = gtk_label_new( pageLbl );
566 gtk_widget_show( label );
567 gtk_notebook_set_tab_label(
568 GTK_NOTEBOOK( exphtml_dlg.notebook ),
569 gtk_notebook_get_nth_page( GTK_NOTEBOOK( exphtml_dlg.notebook ), pageNum ), label );
571 table = gtk_table_new( 3, 3, FALSE );
572 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
573 gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
574 gtk_table_set_row_spacings(GTK_TABLE(table), 8);
575 gtk_table_set_col_spacings(GTK_TABLE(table), 8 );
579 label = gtk_label_new( _( "Address Book" ) );
580 gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
581 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
583 labelBook = gtk_label_new("Full name of address book goes here");
584 gtk_table_attach(GTK_TABLE(table), labelBook, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0);
585 gtk_misc_set_alignment(GTK_MISC(labelBook), 0, 0.5);
589 label = gtk_label_new( _( "File Name" ) );
590 gtk_table_attach(GTK_TABLE(table), label, 0, 1, top, (top + 1), GTK_FILL, 0, 0, 0);
591 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
593 labelFile = gtk_label_new("File name goes here");
594 gtk_table_attach(GTK_TABLE(table), labelFile, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0);
595 gtk_misc_set_alignment(GTK_MISC(labelFile), 0, 0.5);
599 btnBrowse = gtk_button_new_with_label( _( "Open with Web Browser" ) );
600 gtk_table_attach(GTK_TABLE(table), btnBrowse, 1, 2, top, (top + 1), GTK_FILL, 0, 0, 0);
602 gtk_widget_show_all(vbox);
604 /* Button handlers */
605 gtk_signal_connect( GTK_OBJECT(btnBrowse), "clicked",
606 GTK_SIGNAL_FUNC(export_html_browse), NULL );
608 exphtml_dlg.labelOutBook = labelBook;
609 exphtml_dlg.labelOutFile = labelFile;
612 static void export_html_dialog_create() {
620 GtkWidget *btnCancel;
622 GtkWidget *statusbar;
624 window = gtk_window_new(GTK_WINDOW_DIALOG);
625 gtk_widget_set_usize(window, EXPORTHTML_WIDTH, EXPORTHTML_HEIGHT );
626 gtk_container_set_border_width( GTK_CONTAINER(window), 0 );
627 gtk_window_set_title( GTK_WINDOW(window),
628 _("Export Address Book to HTML File") );
629 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
630 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
631 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
632 GTK_SIGNAL_FUNC(export_html_delete_event),
634 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
635 GTK_SIGNAL_FUNC(export_html_key_pressed),
638 vbox = gtk_vbox_new(FALSE, 4);
639 gtk_widget_show(vbox);
640 gtk_container_add(GTK_CONTAINER(window), vbox);
642 vnbox = gtk_vbox_new(FALSE, 4);
643 gtk_container_set_border_width(GTK_CONTAINER(vnbox), 4);
644 gtk_widget_show(vnbox);
645 gtk_box_pack_start(GTK_BOX(vbox), vnbox, TRUE, TRUE, 0);
648 notebook = gtk_notebook_new();
649 gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook), FALSE );
650 /* gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook), TRUE ); */
651 gtk_widget_show(notebook);
652 gtk_box_pack_start(GTK_BOX(vnbox), notebook, TRUE, TRUE, 0);
653 gtk_container_set_border_width(GTK_CONTAINER(notebook), 6);
656 hsbox = gtk_hbox_new(FALSE, 0);
657 gtk_box_pack_end(GTK_BOX(vbox), hsbox, FALSE, FALSE, BORDER_WIDTH);
658 statusbar = gtk_statusbar_new();
659 gtk_box_pack_start(GTK_BOX(hsbox), statusbar, TRUE, TRUE, BORDER_WIDTH);
662 gtkut_button_set_create(&hbbox, &btnPrev, _( "Prev" ),
663 &btnNext, _( "Next" ),
664 &btnCancel, _( "Cancel" ) );
665 gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
666 gtk_container_set_border_width(GTK_CONTAINER(hbbox), 2);
667 gtk_widget_grab_default(btnNext);
669 /* Button handlers */
670 gtk_signal_connect(GTK_OBJECT(btnPrev), "clicked",
671 GTK_SIGNAL_FUNC(export_html_prev), NULL);
672 gtk_signal_connect(GTK_OBJECT(btnNext), "clicked",
673 GTK_SIGNAL_FUNC(export_html_next), NULL);
674 gtk_signal_connect(GTK_OBJECT(btnCancel), "clicked",
675 GTK_SIGNAL_FUNC(export_html_cancel), NULL);
677 gtk_widget_show_all(vbox);
679 exphtml_dlg.window = window;
680 exphtml_dlg.notebook = notebook;
681 exphtml_dlg.btnPrev = btnPrev;
682 exphtml_dlg.btnNext = btnNext;
683 exphtml_dlg.btnCancel = btnCancel;
684 exphtml_dlg.statusbar = statusbar;
685 exphtml_dlg.status_cid = gtk_statusbar_get_context_id(
686 GTK_STATUSBAR(statusbar), "Export HTML Dialog" );
690 static void export_html_create() {
691 export_html_dialog_create();
692 export_html_page_file( PAGE_FILE_INFO, _( "File Info" ) );
693 export_html_page_format( PAGE_FORMAT, _( "Format" ) );
694 export_html_page_finish( PAGE_FINISH, _( "Finish" ) );
695 gtk_widget_show_all( exphtml_dlg.window );
699 * Populate fields from control data.
700 * Enter: ctl Export control data.
702 static void export_html_fill_fields( ExportHtmlCtl *ctl ) {
703 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml), "" );
705 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml),
709 gtk_option_menu_set_history(
710 GTK_OPTION_MENU( exphtml_dlg.optmenuCSS ), ctl->stylesheet );
711 gtk_option_menu_set_history(
712 GTK_OPTION_MENU( exphtml_dlg.optmenuName ), ctl->nameFormat );
713 gtk_toggle_button_set_active(
714 GTK_TOGGLE_BUTTON( exphtml_dlg.checkBanding ), ctl->banding );
715 gtk_toggle_button_set_active(
716 GTK_TOGGLE_BUTTON( exphtml_dlg.checkLinkEMail ), ctl->linkEMail );
717 gtk_toggle_button_set_active(
718 GTK_TOGGLE_BUTTON( exphtml_dlg.checkAttributes ), ctl->showAttribs );
722 * Process export address dialog.
723 * Enter: cache Address book/data source cache.
725 void addressbook_exp_html( AddressCache *cache ) {
726 /* Set references to control data */
727 _addressCache_ = cache;
729 _exportCtl_ = exporthtml_create();
730 exporthtml_load_settings( _exportCtl_ );
733 if( ! exphtml_dlg.window )
734 export_html_create();
735 exphtml_dlg.cancelled = FALSE;
736 gtk_widget_show(exphtml_dlg.window);
737 manage_window_set_transient(GTK_WINDOW(exphtml_dlg.window));
739 gtk_label_set_text( GTK_LABEL(exphtml_dlg.labelBook), cache->name );
740 gtk_label_set_text( GTK_LABEL(exphtml_dlg.labelOutBook), cache->name );
741 export_html_fill_fields( _exportCtl_ );
743 gtk_widget_grab_default(exphtml_dlg.btnNext);
744 gtk_notebook_set_page( GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FILE_INFO );
745 gtk_widget_set_sensitive( exphtml_dlg.btnPrev, FALSE );
746 gtk_widget_set_sensitive( exphtml_dlg.btnNext, TRUE );
748 export_html_message();
749 gtk_widget_grab_focus(exphtml_dlg.entryHtml);
752 gtk_widget_hide(exphtml_dlg.window);
753 exporthtml_free( _exportCtl_ );
756 _addressCache_ = NULL;