2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2002-2007 Match Grun and the Claws Mail team
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 3 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, see <http://www.gnu.org/licenses/>.
21 * Export address book to HTML file.
31 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
33 #include <gtk/gtkwindow.h>
34 #include <gtk/gtksignal.h>
35 #include <gtk/gtklabel.h>
36 #include <gtk/gtkentry.h>
37 #include <gtk/gtktable.h>
38 #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"
52 #define PAGE_FILE_INFO 0
59 static struct _ExpHtml_Dlg
{
64 GtkWidget
*optmenuCSS
;
65 GtkWidget
*optmenuName
;
66 GtkWidget
*checkBanding
;
67 GtkWidget
*checkLinkEMail
;
68 GtkWidget
*checkAttributes
;
69 GtkWidget
*labelOutBook
;
70 GtkWidget
*labelOutFile
;
79 static struct _AddressFileSelection _exp_html_file_selector_
;
81 static ExportHtmlCtl
*_exportCtl_
= NULL
;
82 static AddressCache
*_addressCache_
= NULL
;
85 * Display message in status field.
86 * \param msg Message to display.
88 static void export_html_status_show( gchar
*msg
) {
89 if( exphtml_dlg
.statusbar
!= NULL
) {
91 GTK_STATUSBAR(exphtml_dlg
.statusbar
),
92 exphtml_dlg
.status_cid
);
95 GTK_STATUSBAR(exphtml_dlg
.statusbar
),
96 exphtml_dlg
.status_cid
, msg
);
102 * Select and display status message appropriate for the page being displayed.
104 static void export_html_message( void ) {
108 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
109 if( pageNum
== PAGE_FILE_INFO
) {
110 sMsg
= _( "Please specify output directory and file to create." );
112 else if( pageNum
== PAGE_FORMAT
) {
113 sMsg
= _( "Select stylesheet and formatting." );
115 else if( pageNum
== PAGE_FINISH
) {
116 sMsg
= _( "File exported successfully." );
118 export_html_status_show( sMsg
);
122 * Callback function to cancel HTML file selection dialog.
123 * \param widget Widget (button).
124 * \param data User data.
126 static void export_html_cancel( GtkWidget
*widget
, gpointer data
) {
129 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
130 if( pageNum
!= PAGE_FINISH
) {
131 exphtml_dlg
.cancelled
= TRUE
;
137 * Callback function to handle dialog close event.
138 * \param widget Widget (dialog).
139 * \param event Event object.
140 * \param data User data.
142 static gint
export_html_delete_event( GtkWidget
*widget
, GdkEventAny
*event
, gpointer data
) {
143 export_html_cancel( widget
, data
);
148 * Callback function to respond to dialog key press events.
149 * \param widget Widget.
150 * \param event Event object.
151 * \param data User data.
153 static gboolean
export_html_key_pressed( GtkWidget
*widget
, GdkEventKey
*event
, gpointer data
) {
154 if (event
&& event
->keyval
== GDK_Escape
) {
155 export_html_cancel( widget
, data
);
161 * Test whether we can move off file page.
162 * \return <i>TRUE</i> if OK to move off page.
164 static gboolean
exp_html_move_file( void ) {
165 gchar
*sFile
, *msg
, *reason
;
168 sFile
= gtk_editable_get_chars( GTK_EDITABLE(exphtml_dlg
.entryHtml
), 0, -1 );
169 g_strchug( sFile
); g_strchomp( sFile
);
170 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
), sFile
);
171 exporthtml_parse_filespec( _exportCtl_
, sFile
);
174 /* Test for directory */
175 if( exporthtml_test_dir( _exportCtl_
) ) {
179 /* Prompt to create */
180 msg
= g_strdup_printf( _(
181 "HTML Output Directory '%s'\n" \
182 "does not exist. OK to create new directory?" ),
183 _exportCtl_
->dirOutput
);
184 aval
= alertpanel( _("Create Directory" ),
185 msg
, GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
);
187 if( aval
!= G_ALERTALTERNATE
) return FALSE
;
189 /* Create directory */
190 if( ! exporthtml_create_dir( _exportCtl_
) ) {
191 reason
= exporthtml_get_create_msg( _exportCtl_
);
192 msg
= g_strdup_printf( _(
193 "Could not create output directory for HTML file:\n%s" ),
195 aval
= alertpanel_full(_("Failed to Create Directory"), msg
,
196 GTK_STOCK_CLOSE
, NULL
, NULL
, FALSE
,
197 NULL
, ALERT_ERROR
, G_ALERTDEFAULT
);
206 * Test whether we can move off format page.
207 * \return <i>TRUE</i> if OK to move off page.
209 static gboolean
exp_html_move_format( void ) {
210 gboolean retVal
= FALSE
;
214 id
= combobox_get_active_data(GTK_COMBO_BOX(exphtml_dlg
.optmenuCSS
));
215 exporthtml_set_stylesheet( _exportCtl_
, id
);
217 /* Set name format */
218 id
= combobox_get_active_data(GTK_COMBO_BOX(exphtml_dlg
.optmenuName
));
219 exporthtml_set_name_format( _exportCtl_
, id
);
221 exporthtml_set_banding( _exportCtl_
,
222 gtk_toggle_button_get_active(
223 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkBanding
) ) );
224 exporthtml_set_link_email( _exportCtl_
,
225 gtk_toggle_button_get_active(
226 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkLinkEMail
) ) );
227 exporthtml_set_attributes( _exportCtl_
,
228 gtk_toggle_button_get_active(
229 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkAttributes
) ) );
232 exporthtml_process( _exportCtl_
, _addressCache_
);
233 if( _exportCtl_
->retVal
== MGU_SUCCESS
) {
237 export_html_status_show( _( "Error creating HTML file" ) );
243 * Display finish page.
245 static void exp_html_finish_show( void ) {
246 gtk_label_set_text( GTK_LABEL(exphtml_dlg
.labelOutFile
), _exportCtl_
->path
);
247 gtk_widget_set_sensitive( exphtml_dlg
.btnNext
, FALSE
);
248 gtk_widget_grab_focus( exphtml_dlg
.btnCancel
);
252 * Callback function to select previous page.
253 * \param widget Widget (button).
255 static void export_html_prev( GtkWidget
*widget
) {
258 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
259 if( pageNum
== PAGE_FORMAT
) {
260 /* Goto file page stuff */
261 gtk_notebook_set_current_page(
262 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FILE_INFO
);
263 gtk_widget_set_sensitive( exphtml_dlg
.btnPrev
, FALSE
);
265 else if( pageNum
== PAGE_FINISH
) {
266 /* Goto format page */
267 gtk_notebook_set_current_page(
268 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FORMAT
);
269 gtk_widget_set_sensitive( exphtml_dlg
.btnNext
, TRUE
);
271 export_html_message();
275 * Callback function to select previous page.
276 * \param widget Widget (button).
278 static void export_html_next( GtkWidget
*widget
) {
281 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
282 if( pageNum
== PAGE_FILE_INFO
) {
283 /* Goto format page */
284 if( exp_html_move_file() ) {
285 gtk_notebook_set_current_page(
286 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FORMAT
);
287 gtk_widget_set_sensitive( exphtml_dlg
.btnPrev
, TRUE
);
289 export_html_message();
291 else if( pageNum
== PAGE_FORMAT
) {
292 /* Goto finish page */
293 if( exp_html_move_format() ) {
294 gtk_notebook_set_current_page(
295 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FINISH
);
296 gtk_button_set_label(GTK_BUTTON(exphtml_dlg
.btnCancel
),
298 exp_html_finish_show();
299 exporthtml_save_settings( _exportCtl_
);
300 export_html_message();
306 * Open file with web browser.
307 * \param widget Widget (button).
308 * \param data User data.
310 static void export_html_browse( GtkWidget
*widget
, gpointer data
) {
313 uri
= g_strconcat( "file://", _exportCtl_
->path
, NULL
);
314 open_uri( uri
, prefs_common
.uri_cmd
);
319 * Create HTML file selection dialog.
320 * \param afs Address file selection data.
322 static void exp_html_file_select_create( AddressFileSelection
*afs
) {
323 gchar
*file
= filesel_select_file_save(_("Select HTML output file"), NULL
);
326 afs
->cancelled
= TRUE
;
328 afs
->cancelled
= FALSE
;
329 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
), file
);
335 * Callback function to display HTML file selection dialog.
337 static void exp_html_file_select( void ) {
338 exp_html_file_select_create( & _exp_html_file_selector_
);
342 * Format notebook file specification page.
343 * \param pageNum Page (tab) number.
344 * \param pageLbl Page (tab) label.
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
= gtkut_get_browse_file_btn(_("B_rowse"));
397 gtk_table_attach(GTK_TABLE(table
), btnFile
, 2, 3, top
, (top
+ 1),
400 gtk_widget_show_all(vbox
);
403 g_signal_connect(G_OBJECT(btnFile
), "clicked",
404 G_CALLBACK(exp_html_file_select
), NULL
);
406 exphtml_dlg
.labelBook
= labelBook
;
407 exphtml_dlg
.entryHtml
= entryHtml
;
411 * Format notebook format page.
412 * \param pageNum Page (tab) number.
413 * \param pageLbl Page (tab) label.
415 static void export_html_page_format( gint pageNum
, gchar
*pageLbl
) {
419 GtkWidget
*optmenuCSS
;
420 GtkWidget
*optmenuName
;
423 GtkWidget
*checkBanding
;
424 GtkWidget
*checkLinkEMail
;
425 GtkWidget
*checkAttributes
;
429 vbox
= gtk_vbox_new(FALSE
, 8);
430 gtk_container_add( GTK_CONTAINER( exphtml_dlg
.notebook
), vbox
);
431 gtk_container_set_border_width( GTK_CONTAINER (vbox
), BORDER_WIDTH
);
433 label
= gtk_label_new( pageLbl
);
434 gtk_widget_show( label
);
435 gtk_notebook_set_tab_label(
436 GTK_NOTEBOOK( exphtml_dlg
.notebook
),
437 gtk_notebook_get_nth_page(
438 GTK_NOTEBOOK( exphtml_dlg
.notebook
), pageNum
),
441 table
= gtk_table_new( 5, 3, FALSE
);
442 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
443 gtk_container_set_border_width( GTK_CONTAINER(table
), 8 );
444 gtk_table_set_row_spacings(GTK_TABLE(table
), 8);
445 gtk_table_set_col_spacings(GTK_TABLE(table
), 8 );
449 label
= gtk_label_new( _( "Stylesheet" ) );
450 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
452 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
454 optmenuCSS
= gtkut_sc_combobox_create(NULL
, TRUE
);
455 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuCSS
)));
457 COMBOBOX_ADD(menu
, _("None"), EXPORT_HTML_ID_NONE
);
458 COMBOBOX_ADD(menu
, _("Default"), EXPORT_HTML_ID_DEFAULT
);
459 COMBOBOX_ADD(menu
, _("Full"), EXPORT_HTML_ID_FULL
);
460 COMBOBOX_ADD(menu
, _("Custom"), EXPORT_HTML_ID_CUSTOM
);
461 COMBOBOX_ADD(menu
, _("Custom-2"), EXPORT_HTML_ID_CUSTOM2
);
462 COMBOBOX_ADD(menu
, _("Custom-3"), EXPORT_HTML_ID_CUSTOM3
);
463 COMBOBOX_ADD(menu
, _("Custom-4"), EXPORT_HTML_ID_CUSTOM4
);
465 gtk_table_attach(GTK_TABLE(table
), optmenuCSS
, 1, 2, top
, (top
+ 1),
470 label
= gtk_label_new( _( "Full Name Format" ) );
471 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
473 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
475 optmenuName
= gtkut_sc_combobox_create(NULL
, TRUE
);
476 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuName
)));
478 COMBOBOX_ADD(menu
, _("First Name, Last Name"), EXPORT_HTML_FIRST_LAST
);
479 COMBOBOX_ADD(menu
, _("Last Name, First Name"), EXPORT_HTML_LAST_FIRST
);
481 gtk_table_attach(GTK_TABLE(table
), optmenuName
, 1, 2, top
, (top
+ 1),
486 checkBanding
= gtk_check_button_new_with_label( _( "Color Banding" ) );
487 gtk_table_attach(GTK_TABLE(table
), checkBanding
, 1, 2, top
, (top
+ 1),
492 checkLinkEMail
= gtk_check_button_new_with_label( _( "Format Email Links" ) );
493 gtk_table_attach(GTK_TABLE(table
), checkLinkEMail
, 1, 2, top
, (top
+ 1),
498 checkAttributes
= gtk_check_button_new_with_label( _( "Format User Attributes" ) );
499 gtk_table_attach(GTK_TABLE(table
), checkAttributes
, 1, 2, top
, (top
+ 1),
502 gtk_widget_show_all(vbox
);
504 exphtml_dlg
.optmenuCSS
= optmenuCSS
;
505 exphtml_dlg
.optmenuName
= optmenuName
;
506 exphtml_dlg
.checkBanding
= checkBanding
;
507 exphtml_dlg
.checkLinkEMail
= checkLinkEMail
;
508 exphtml_dlg
.checkAttributes
= checkAttributes
;
512 * Format notebook finish page.
513 * \param pageNum Page (tab) number.
514 * \param pageLbl Page (tab) label.
516 static void export_html_page_finish( gint pageNum
, gchar
*pageLbl
) {
520 GtkWidget
*labelBook
;
521 GtkWidget
*labelFile
;
522 GtkWidget
*btnBrowse
;
525 vbox
= gtk_vbox_new(FALSE
, 8);
526 gtk_container_add( GTK_CONTAINER( exphtml_dlg
.notebook
), vbox
);
527 gtk_container_set_border_width( GTK_CONTAINER (vbox
), BORDER_WIDTH
);
529 label
= gtk_label_new( pageLbl
);
530 gtk_widget_show( label
);
531 gtk_notebook_set_tab_label(
532 GTK_NOTEBOOK( exphtml_dlg
.notebook
),
533 gtk_notebook_get_nth_page( GTK_NOTEBOOK( exphtml_dlg
.notebook
), pageNum
), label
);
535 table
= gtk_table_new( 3, 3, FALSE
);
536 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
537 gtk_container_set_border_width( GTK_CONTAINER(table
), 8 );
538 gtk_table_set_row_spacings(GTK_TABLE(table
), 8);
539 gtk_table_set_col_spacings(GTK_TABLE(table
), 8 );
543 label
= gtk_label_new( _( "Address Book :" ) );
544 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
545 gtk_misc_set_alignment(GTK_MISC(label
), 1, 0.5);
547 labelBook
= gtk_label_new("Full name of address book goes here");
548 gtk_table_attach(GTK_TABLE(table
), labelBook
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
549 gtk_misc_set_alignment(GTK_MISC(labelBook
), 0, 0.5);
553 label
= gtk_label_new( _( "File Name :" ) );
554 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
555 gtk_misc_set_alignment(GTK_MISC(label
), 1, 0.5);
557 labelFile
= gtk_label_new("File name goes here");
558 gtk_table_attach(GTK_TABLE(table
), labelFile
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
559 gtk_misc_set_alignment(GTK_MISC(labelFile
), 0, 0.5);
563 btnBrowse
= gtk_button_new_with_label( _( "Open with Web Browser" ) );
564 gtk_table_attach(GTK_TABLE(table
), btnBrowse
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
566 gtk_widget_show_all(vbox
);
568 /* Button handlers */
569 g_signal_connect(G_OBJECT(btnBrowse
), "clicked",
570 G_CALLBACK(export_html_browse
), NULL
);
572 exphtml_dlg
.labelOutBook
= labelBook
;
573 exphtml_dlg
.labelOutFile
= labelFile
;
577 * Create main dialog decorations (excluding notebook pages).
579 static void export_html_dialog_create( void ) {
587 GtkWidget
*btnCancel
;
589 GtkWidget
*statusbar
;
591 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "exphtmldlg");
592 gtk_widget_set_size_request(window
, -1, -1 );
593 gtk_container_set_border_width( GTK_CONTAINER(window
), 0 );
594 gtk_window_set_title( GTK_WINDOW(window
),
595 _("Export Address Book to HTML File") );
596 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER
);
597 gtk_window_set_modal(GTK_WINDOW(window
), TRUE
);
598 g_signal_connect(G_OBJECT(window
), "delete_event",
599 G_CALLBACK(export_html_delete_event
),
601 g_signal_connect(G_OBJECT(window
), "key_press_event",
602 G_CALLBACK(export_html_key_pressed
),
605 vbox
= gtk_vbox_new(FALSE
, 4);
606 gtk_widget_show(vbox
);
607 gtk_container_add(GTK_CONTAINER(window
), vbox
);
609 vnbox
= gtk_vbox_new(FALSE
, 4);
610 gtk_container_set_border_width(GTK_CONTAINER(vnbox
), 4);
611 gtk_widget_show(vnbox
);
612 gtk_box_pack_start(GTK_BOX(vbox
), vnbox
, TRUE
, TRUE
, 0);
615 notebook
= gtk_notebook_new();
616 gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook
), FALSE
); /* Hide */
617 /* gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook), TRUE ); */
618 gtk_widget_show(notebook
);
619 gtk_box_pack_start(GTK_BOX(vnbox
), notebook
, TRUE
, TRUE
, 0);
620 gtk_container_set_border_width(GTK_CONTAINER(notebook
), 6);
623 hsbox
= gtk_hbox_new(FALSE
, 0);
624 gtk_box_pack_end(GTK_BOX(vbox
), hsbox
, FALSE
, FALSE
, BORDER_WIDTH
);
625 statusbar
= gtk_statusbar_new();
626 gtk_box_pack_start(GTK_BOX(hsbox
), statusbar
, TRUE
, TRUE
, BORDER_WIDTH
);
629 gtkut_stock_button_set_create(&hbbox
, &btnPrev
, GTK_STOCK_GO_BACK
,
630 &btnNext
, GTK_STOCK_GO_FORWARD
,
631 &btnCancel
, GTK_STOCK_CANCEL
);
632 gtk_box_pack_end(GTK_BOX(vbox
), hbbox
, FALSE
, FALSE
, 0);
633 gtk_container_set_border_width(GTK_CONTAINER(hbbox
), 2);
634 gtk_widget_grab_default(btnNext
);
636 /* Button handlers */
637 g_signal_connect(G_OBJECT(btnPrev
), "clicked",
638 G_CALLBACK(export_html_prev
), NULL
);
639 g_signal_connect(G_OBJECT(btnNext
), "clicked",
640 G_CALLBACK(export_html_next
), NULL
);
641 g_signal_connect(G_OBJECT(btnCancel
), "clicked",
642 G_CALLBACK(export_html_cancel
), NULL
);
644 gtk_widget_show_all(vbox
);
646 exphtml_dlg
.window
= window
;
647 exphtml_dlg
.notebook
= notebook
;
648 exphtml_dlg
.btnPrev
= btnPrev
;
649 exphtml_dlg
.btnNext
= btnNext
;
650 exphtml_dlg
.btnCancel
= btnCancel
;
651 exphtml_dlg
.statusbar
= statusbar
;
652 exphtml_dlg
.status_cid
= gtk_statusbar_get_context_id(
653 GTK_STATUSBAR(statusbar
), "Export HTML Dialog" );
657 * Create export HTML dialog.
659 static void export_html_create( void ) {
660 export_html_dialog_create();
661 export_html_page_file( PAGE_FILE_INFO
, _( "File Info" ) );
662 export_html_page_format( PAGE_FORMAT
, _( "Format" ) );
663 export_html_page_finish( PAGE_FINISH
, _( "Finish" ) );
664 gtk_widget_show_all( exphtml_dlg
.window
);
668 * Populate fields from control data.
669 * \param ctl Export control data.
671 static void export_html_fill_fields( ExportHtmlCtl
*ctl
) {
672 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
), "" );
674 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
),
678 combobox_select_by_data(
679 GTK_COMBO_BOX(exphtml_dlg
.optmenuCSS
), ctl
->stylesheet
);
680 combobox_select_by_data(
681 GTK_COMBO_BOX(exphtml_dlg
.optmenuName
), ctl
->nameFormat
);
682 gtk_toggle_button_set_active(
683 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkBanding
), ctl
->banding
);
684 gtk_toggle_button_set_active(
685 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkLinkEMail
), ctl
->linkEMail
);
686 gtk_toggle_button_set_active(
687 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkAttributes
), ctl
->showAttribs
);
691 * Process export address dialog.
692 * \param cache Address book/data source cache.
694 void addressbook_exp_html( AddressCache
*cache
) {
695 /* Set references to control data */
696 _addressCache_
= cache
;
698 _exportCtl_
= exporthtml_create();
699 exporthtml_load_settings( _exportCtl_
);
702 if( ! exphtml_dlg
.window
)
703 export_html_create();
705 gtk_button_set_label(GTK_BUTTON(exphtml_dlg
.btnCancel
),
707 exphtml_dlg
.cancelled
= FALSE
;
708 gtk_widget_show(exphtml_dlg
.window
);
709 manage_window_set_transient(GTK_WINDOW(exphtml_dlg
.window
));
711 gtk_label_set_text( GTK_LABEL(exphtml_dlg
.labelBook
), cache
->name
);
712 gtk_label_set_text( GTK_LABEL(exphtml_dlg
.labelOutBook
), cache
->name
);
713 export_html_fill_fields( _exportCtl_
);
715 gtk_widget_grab_default(exphtml_dlg
.btnNext
);
716 gtk_notebook_set_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FILE_INFO
);
717 gtk_widget_set_sensitive( exphtml_dlg
.btnPrev
, FALSE
);
718 gtk_widget_set_sensitive( exphtml_dlg
.btnNext
, TRUE
);
720 export_html_message();
721 gtk_widget_grab_focus(exphtml_dlg
.entryHtml
);
724 gtk_widget_hide(exphtml_dlg
.window
);
725 exporthtml_free( _exportCtl_
);
728 _addressCache_
= NULL
;
732 * ============================================================================
734 * ============================================================================