2 * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2002-2015 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/>.
20 * Export address book to HTML file.
25 #include "claws-features.h"
31 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
36 #include "prefs_common.h"
37 #include "alertpanel.h"
39 #include "addrcache.h"
40 #include "addressitem.h"
41 #include "exporthtml.h"
43 #include "manage_window.h"
47 #define PAGE_FILE_INFO 0
54 static struct _ExpHtml_Dlg
{
59 GtkWidget
*optmenuCSS
;
60 GtkWidget
*optmenuName
;
61 GtkWidget
*checkBanding
;
62 GtkWidget
*checkLinkEMail
;
63 GtkWidget
*checkAttributes
;
64 GtkWidget
*labelOutBook
;
65 GtkWidget
*labelOutFile
;
74 static struct _AddressFileSelection _exp_html_file_selector_
;
76 static ExportHtmlCtl
*_exportCtl_
= NULL
;
77 static AddressCache
*_addressCache_
= NULL
;
80 * Display message in status field.
81 * \param msg Message to display.
83 static void export_html_status_show( gchar
*msg
) {
84 if( exphtml_dlg
.statusbar
!= NULL
) {
86 GTK_STATUSBAR(exphtml_dlg
.statusbar
),
87 exphtml_dlg
.status_cid
);
90 GTK_STATUSBAR(exphtml_dlg
.statusbar
),
91 exphtml_dlg
.status_cid
, msg
);
97 * Select and display status message appropriate for the page being displayed.
99 static void export_html_message( void ) {
103 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
104 if( pageNum
== PAGE_FILE_INFO
) {
105 sMsg
= _( "Please specify output directory and file to create." );
107 else if( pageNum
== PAGE_FORMAT
) {
108 sMsg
= _( "Select stylesheet and formatting." );
110 else if( pageNum
== PAGE_FINISH
) {
111 sMsg
= _( "File exported successfully." );
113 export_html_status_show( sMsg
);
117 * Callback function to cancel HTML file selection dialog.
118 * \param widget Widget (button).
119 * \param data User data.
121 static void export_html_cancel( GtkWidget
*widget
, gpointer data
) {
124 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
125 if( pageNum
!= PAGE_FINISH
) {
126 exphtml_dlg
.cancelled
= TRUE
;
132 * Callback function to handle dialog close event.
133 * \param widget Widget (dialog).
134 * \param event Event object.
135 * \param data User data.
137 static gint
export_html_delete_event( GtkWidget
*widget
, GdkEventAny
*event
, gpointer data
) {
138 export_html_cancel( widget
, data
);
143 * Callback function to respond to dialog key press events.
144 * \param widget Widget.
145 * \param event Event object.
146 * \param data User data.
148 static gboolean
export_html_key_pressed( GtkWidget
*widget
, GdkEventKey
*event
, gpointer data
) {
149 if (event
&& event
->keyval
== GDK_KEY_Escape
) {
150 export_html_cancel( widget
, data
);
156 * Test whether we can move off file page.
157 * \return <i>TRUE</i> if OK to move off page.
159 static gboolean
exp_html_move_file( void ) {
160 gchar
*sFile
, *msg
, *reason
;
163 sFile
= gtk_editable_get_chars( GTK_EDITABLE(exphtml_dlg
.entryHtml
), 0, -1 );
165 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
), sFile
);
166 exporthtml_parse_filespec( _exportCtl_
, sFile
);
169 /* Test for directory */
170 if( g_file_test(_exportCtl_
->dirOutput
,
171 G_FILE_TEST_EXISTS
| G_FILE_TEST_IS_DIR
) ) {
175 /* Prompt to create */
176 msg
= g_strdup_printf( _(
177 "The HTML output directory '%s'\n" \
178 "does not exist. Do you want to create it?" ),
179 _exportCtl_
->dirOutput
);
180 aval
= alertpanel( _("Create directory" ),
181 msg
, GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
);
183 if( aval
!= G_ALERTALTERNATE
) return FALSE
;
185 /* Create directory */
186 if( ! exporthtml_create_dir( _exportCtl_
) ) {
187 reason
= exporthtml_get_create_msg( _exportCtl_
);
188 msg
= g_strdup_printf( _(
189 "Could not create output directory for HTML file:\n%s" ),
191 aval
= alertpanel_full(_("Failed to Create Directory"), msg
,
192 GTK_STOCK_CLOSE
, NULL
, NULL
, FALSE
,
193 NULL
, ALERT_ERROR
, G_ALERTDEFAULT
);
202 * Test whether we can move off format page.
203 * \return <i>TRUE</i> if OK to move off page.
205 static gboolean
exp_html_move_format( void ) {
206 gboolean retVal
= FALSE
;
210 id
= combobox_get_active_data(GTK_COMBO_BOX(exphtml_dlg
.optmenuCSS
));
211 exporthtml_set_stylesheet( _exportCtl_
, id
);
213 /* Set name format */
214 id
= combobox_get_active_data(GTK_COMBO_BOX(exphtml_dlg
.optmenuName
));
215 exporthtml_set_name_format( _exportCtl_
, id
);
217 exporthtml_set_banding( _exportCtl_
,
218 gtk_toggle_button_get_active(
219 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkBanding
) ) );
220 exporthtml_set_link_email( _exportCtl_
,
221 gtk_toggle_button_get_active(
222 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkLinkEMail
) ) );
223 exporthtml_set_attributes( _exportCtl_
,
224 gtk_toggle_button_get_active(
225 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkAttributes
) ) );
228 exporthtml_process( _exportCtl_
, _addressCache_
);
229 if( _exportCtl_
->retVal
== MGU_SUCCESS
) {
233 export_html_status_show( _( "Error creating HTML file" ) );
239 * Display finish page.
241 static void exp_html_finish_show( void ) {
242 gtk_label_set_text( GTK_LABEL(exphtml_dlg
.labelOutFile
), _exportCtl_
->path
);
243 gtk_widget_set_sensitive( exphtml_dlg
.btnNext
, FALSE
);
244 gtk_widget_grab_focus( exphtml_dlg
.btnCancel
);
248 * Callback function to select previous page.
249 * \param widget Widget (button).
251 static void export_html_prev( GtkWidget
*widget
) {
254 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
255 if( pageNum
== PAGE_FORMAT
) {
256 /* Goto file page stuff */
257 gtk_notebook_set_current_page(
258 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FILE_INFO
);
259 gtk_widget_set_sensitive( exphtml_dlg
.btnPrev
, FALSE
);
261 else if( pageNum
== PAGE_FINISH
) {
262 /* Goto format page */
263 gtk_notebook_set_current_page(
264 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FORMAT
);
265 gtk_widget_set_sensitive( exphtml_dlg
.btnNext
, TRUE
);
267 export_html_message();
271 * Callback function to select previous page.
272 * \param widget Widget (button).
274 static void export_html_next( GtkWidget
*widget
) {
277 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
278 if( pageNum
== PAGE_FILE_INFO
) {
279 /* Goto format page */
280 if( exp_html_move_file() ) {
281 gtk_notebook_set_current_page(
282 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FORMAT
);
283 gtk_widget_set_sensitive( exphtml_dlg
.btnPrev
, TRUE
);
285 export_html_message();
287 else if( pageNum
== PAGE_FORMAT
) {
288 /* Goto finish page */
289 if( exp_html_move_format() ) {
290 gtk_notebook_set_current_page(
291 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FINISH
);
292 gtk_button_set_label(GTK_BUTTON(exphtml_dlg
.btnCancel
),
294 exp_html_finish_show();
295 exporthtml_save_settings( _exportCtl_
);
296 export_html_message();
302 * Open file with web browser.
303 * \param widget Widget (button).
304 * \param data User data.
306 static void export_html_browse( GtkWidget
*widget
, gpointer data
) {
309 uri
= g_filename_to_uri(_exportCtl_
->path
, NULL
, NULL
);
310 open_uri( uri
, prefs_common_get_uri_cmd() );
315 * Create HTML file selection dialog.
316 * \param afs Address file selection data.
318 static void exp_html_file_select_create( AddressFileSelection
*afs
) {
319 gchar
*file
= filesel_select_file_save(_("Select HTML output file"), NULL
);
322 afs
->cancelled
= TRUE
;
324 afs
->cancelled
= FALSE
;
325 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
), file
);
331 * Callback function to display HTML file selection dialog.
333 static void exp_html_file_select( void ) {
334 exp_html_file_select_create( & _exp_html_file_selector_
);
338 * Format notebook file specification page.
339 * \param pageNum Page (tab) number.
340 * \param pageLbl Page (tab) label.
342 static void export_html_page_file( gint pageNum
, gchar
*pageLbl
) {
346 GtkWidget
*labelBook
;
347 GtkWidget
*entryHtml
;
351 vbox
= gtk_vbox_new(FALSE
, 8);
352 gtk_container_add( GTK_CONTAINER( exphtml_dlg
.notebook
), vbox
);
353 gtk_container_set_border_width( GTK_CONTAINER (vbox
), BORDER_WIDTH
);
355 label
= gtk_label_new( pageLbl
);
356 gtk_widget_show( label
);
357 gtk_notebook_set_tab_label(
358 GTK_NOTEBOOK( exphtml_dlg
.notebook
),
359 gtk_notebook_get_nth_page(
360 GTK_NOTEBOOK( exphtml_dlg
.notebook
), pageNum
),
363 table
= gtk_table_new( 3, 3, FALSE
);
364 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
365 gtk_container_set_border_width( GTK_CONTAINER(table
), 8 );
366 gtk_table_set_row_spacings(GTK_TABLE(table
), 8);
367 gtk_table_set_col_spacings(GTK_TABLE(table
), 8 );
371 label
= gtk_label_new( _( "Address Book" ) );
372 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
374 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
376 labelBook
= gtk_label_new( "Address book name goes here" );
377 gtk_table_attach(GTK_TABLE(table
), labelBook
, 1, 2, top
, (top
+ 1),
378 GTK_EXPAND
|GTK_SHRINK
|GTK_FILL
, 0, 0, 0);
379 gtk_misc_set_alignment(GTK_MISC(labelBook
), 0, 0.5);
383 label
= gtk_label_new( _( "HTML Output File" ) );
384 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
386 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
388 entryHtml
= gtk_entry_new();
389 gtk_table_attach(GTK_TABLE(table
), entryHtml
, 1, 2, top
, (top
+ 1),
390 GTK_EXPAND
|GTK_SHRINK
|GTK_FILL
, 0, 0, 0);
392 btnFile
= gtkut_get_browse_file_btn(_("B_rowse"));
393 gtk_table_attach(GTK_TABLE(table
), btnFile
, 2, 3, top
, (top
+ 1),
396 gtk_widget_show_all(vbox
);
399 g_signal_connect(G_OBJECT(btnFile
), "clicked",
400 G_CALLBACK(exp_html_file_select
), NULL
);
402 exphtml_dlg
.labelBook
= labelBook
;
403 exphtml_dlg
.entryHtml
= entryHtml
;
407 * Format notebook format page.
408 * \param pageNum Page (tab) number.
409 * \param pageLbl Page (tab) label.
411 static void export_html_page_format( gint pageNum
, gchar
*pageLbl
) {
415 GtkWidget
*optmenuCSS
;
416 GtkWidget
*optmenuName
;
419 GtkWidget
*checkBanding
;
420 GtkWidget
*checkLinkEMail
;
421 GtkWidget
*checkAttributes
;
425 vbox
= gtk_vbox_new(FALSE
, 8);
426 gtk_container_add( GTK_CONTAINER( exphtml_dlg
.notebook
), vbox
);
427 gtk_container_set_border_width( GTK_CONTAINER (vbox
), BORDER_WIDTH
);
429 label
= gtk_label_new( pageLbl
);
430 gtk_widget_show( label
);
431 gtk_notebook_set_tab_label(
432 GTK_NOTEBOOK( exphtml_dlg
.notebook
),
433 gtk_notebook_get_nth_page(
434 GTK_NOTEBOOK( exphtml_dlg
.notebook
), pageNum
),
437 table
= gtk_table_new( 5, 3, FALSE
);
438 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
439 gtk_container_set_border_width( GTK_CONTAINER(table
), 8 );
440 gtk_table_set_row_spacings(GTK_TABLE(table
), 8);
441 gtk_table_set_col_spacings(GTK_TABLE(table
), 8 );
445 label
= gtk_label_new( _( "Stylesheet" ) );
446 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
448 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
450 optmenuCSS
= gtkut_sc_combobox_create(NULL
, TRUE
);
451 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuCSS
)));
453 COMBOBOX_ADD(menu
, _("None"), EXPORT_HTML_ID_NONE
);
454 COMBOBOX_ADD(menu
, _("Default"), EXPORT_HTML_ID_DEFAULT
);
455 COMBOBOX_ADD(menu
, _("Full"), EXPORT_HTML_ID_FULL
);
456 COMBOBOX_ADD(menu
, _("Custom"), EXPORT_HTML_ID_CUSTOM
);
457 COMBOBOX_ADD(menu
, _("Custom-2"), EXPORT_HTML_ID_CUSTOM2
);
458 COMBOBOX_ADD(menu
, _("Custom-3"), EXPORT_HTML_ID_CUSTOM3
);
459 COMBOBOX_ADD(menu
, _("Custom-4"), EXPORT_HTML_ID_CUSTOM4
);
461 gtk_table_attach(GTK_TABLE(table
), optmenuCSS
, 1, 2, top
, (top
+ 1),
466 label
= gtk_label_new( _( "Full Name Format" ) );
467 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
469 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
471 optmenuName
= gtkut_sc_combobox_create(NULL
, TRUE
);
472 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuName
)));
474 COMBOBOX_ADD(menu
, _("First Name, Last Name"), EXPORT_HTML_FIRST_LAST
);
475 COMBOBOX_ADD(menu
, _("Last Name, First Name"), EXPORT_HTML_LAST_FIRST
);
477 gtk_table_attach(GTK_TABLE(table
), optmenuName
, 1, 2, top
, (top
+ 1),
482 checkBanding
= gtk_check_button_new_with_label( _( "Color Banding" ) );
483 gtk_table_attach(GTK_TABLE(table
), checkBanding
, 1, 2, top
, (top
+ 1),
488 checkLinkEMail
= gtk_check_button_new_with_label( _( "Format Email Links" ) );
489 gtk_table_attach(GTK_TABLE(table
), checkLinkEMail
, 1, 2, top
, (top
+ 1),
494 checkAttributes
= gtk_check_button_new_with_label( _( "Format User Attributes" ) );
495 gtk_table_attach(GTK_TABLE(table
), checkAttributes
, 1, 2, top
, (top
+ 1),
498 gtk_widget_show_all(vbox
);
500 exphtml_dlg
.optmenuCSS
= optmenuCSS
;
501 exphtml_dlg
.optmenuName
= optmenuName
;
502 exphtml_dlg
.checkBanding
= checkBanding
;
503 exphtml_dlg
.checkLinkEMail
= checkLinkEMail
;
504 exphtml_dlg
.checkAttributes
= checkAttributes
;
508 * Format notebook finish page.
509 * \param pageNum Page (tab) number.
510 * \param pageLbl Page (tab) label.
512 static void export_html_page_finish( gint pageNum
, gchar
*pageLbl
) {
516 GtkWidget
*labelBook
;
517 GtkWidget
*labelFile
;
518 GtkWidget
*btnBrowse
;
521 vbox
= gtk_vbox_new(FALSE
, 8);
522 gtk_container_add( GTK_CONTAINER( exphtml_dlg
.notebook
), vbox
);
523 gtk_container_set_border_width( GTK_CONTAINER (vbox
), BORDER_WIDTH
);
525 label
= gtk_label_new( pageLbl
);
526 gtk_widget_show( label
);
527 gtk_notebook_set_tab_label(
528 GTK_NOTEBOOK( exphtml_dlg
.notebook
),
529 gtk_notebook_get_nth_page( GTK_NOTEBOOK( exphtml_dlg
.notebook
), pageNum
), label
);
531 table
= gtk_table_new( 3, 3, FALSE
);
532 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
533 gtk_container_set_border_width( GTK_CONTAINER(table
), 8 );
534 gtk_table_set_row_spacings(GTK_TABLE(table
), 8);
535 gtk_table_set_col_spacings(GTK_TABLE(table
), 8 );
539 label
= gtk_label_new( _( "Address Book:" ) );
540 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
541 gtk_misc_set_alignment(GTK_MISC(label
), 1, 0.5);
543 labelBook
= gtk_label_new("Full name of address book goes here");
544 gtk_table_attach(GTK_TABLE(table
), labelBook
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
545 gtk_misc_set_alignment(GTK_MISC(labelBook
), 0, 0.5);
549 label
= gtk_label_new( _( "File Name:" ) );
550 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
551 gtk_misc_set_alignment(GTK_MISC(label
), 1, 0.5);
553 labelFile
= gtk_label_new("File name goes here");
554 gtk_table_attach(GTK_TABLE(table
), labelFile
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
555 gtk_misc_set_alignment(GTK_MISC(labelFile
), 0, 0.5);
559 btnBrowse
= gtk_button_new_with_label( _( "Open with Web Browser" ) );
560 gtk_table_attach(GTK_TABLE(table
), btnBrowse
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
562 gtk_widget_show_all(vbox
);
564 /* Button handlers */
565 g_signal_connect(G_OBJECT(btnBrowse
), "clicked",
566 G_CALLBACK(export_html_browse
), NULL
);
568 exphtml_dlg
.labelOutBook
= labelBook
;
569 exphtml_dlg
.labelOutFile
= labelFile
;
573 * Create main dialog decorations (excluding notebook pages).
575 static void export_html_dialog_create( void ) {
583 GtkWidget
*btnCancel
;
585 GtkWidget
*statusbar
;
587 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "exphtmldlg");
588 gtk_widget_set_size_request(window
, -1, -1 );
589 gtk_container_set_border_width( GTK_CONTAINER(window
), 0 );
590 gtk_window_set_title( GTK_WINDOW(window
),
591 _("Export Address Book to HTML File") );
592 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER
);
593 g_signal_connect(G_OBJECT(window
), "delete_event",
594 G_CALLBACK(export_html_delete_event
),
596 g_signal_connect(G_OBJECT(window
), "key_press_event",
597 G_CALLBACK(export_html_key_pressed
),
600 vbox
= gtk_vbox_new(FALSE
, 4);
601 gtk_widget_show(vbox
);
602 gtk_container_add(GTK_CONTAINER(window
), vbox
);
604 vnbox
= gtk_vbox_new(FALSE
, 4);
605 gtk_container_set_border_width(GTK_CONTAINER(vnbox
), 4);
606 gtk_widget_show(vnbox
);
607 gtk_box_pack_start(GTK_BOX(vbox
), vnbox
, TRUE
, TRUE
, 0);
610 notebook
= gtk_notebook_new();
611 gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook
), FALSE
); /* Hide */
612 /* gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook), TRUE ); */
613 gtk_widget_show(notebook
);
614 gtk_box_pack_start(GTK_BOX(vnbox
), notebook
, TRUE
, TRUE
, 0);
615 gtk_container_set_border_width(GTK_CONTAINER(notebook
), 6);
618 hsbox
= gtk_hbox_new(FALSE
, 0);
619 gtk_box_pack_end(GTK_BOX(vbox
), hsbox
, FALSE
, FALSE
, BORDER_WIDTH
);
620 statusbar
= gtk_statusbar_new();
621 gtk_box_pack_start(GTK_BOX(hsbox
), statusbar
, TRUE
, TRUE
, BORDER_WIDTH
);
624 gtkut_stock_button_set_create(&hbbox
, &btnPrev
, GTK_STOCK_GO_BACK
,
625 &btnNext
, GTK_STOCK_GO_FORWARD
,
626 &btnCancel
, GTK_STOCK_CANCEL
);
627 gtk_box_pack_end(GTK_BOX(vbox
), hbbox
, FALSE
, FALSE
, 0);
628 gtk_container_set_border_width(GTK_CONTAINER(hbbox
), 2);
629 gtk_widget_grab_default(btnNext
);
631 /* Button handlers */
632 g_signal_connect(G_OBJECT(btnPrev
), "clicked",
633 G_CALLBACK(export_html_prev
), NULL
);
634 g_signal_connect(G_OBJECT(btnNext
), "clicked",
635 G_CALLBACK(export_html_next
), NULL
);
636 g_signal_connect(G_OBJECT(btnCancel
), "clicked",
637 G_CALLBACK(export_html_cancel
), NULL
);
639 gtk_widget_show_all(vbox
);
641 exphtml_dlg
.window
= window
;
642 exphtml_dlg
.notebook
= notebook
;
643 exphtml_dlg
.btnPrev
= btnPrev
;
644 exphtml_dlg
.btnNext
= btnNext
;
645 exphtml_dlg
.btnCancel
= btnCancel
;
646 exphtml_dlg
.statusbar
= statusbar
;
647 exphtml_dlg
.status_cid
= gtk_statusbar_get_context_id(
648 GTK_STATUSBAR(statusbar
), "Export HTML Dialog" );
652 * Create export HTML dialog.
654 static void export_html_create( void ) {
655 export_html_dialog_create();
656 export_html_page_file( PAGE_FILE_INFO
, _( "File Info" ) );
657 export_html_page_format( PAGE_FORMAT
, _( "Format" ) );
658 export_html_page_finish( PAGE_FINISH
, _( "Finish" ) );
659 gtk_widget_show_all( exphtml_dlg
.window
);
663 * Populate fields from control data.
664 * \param ctl Export control data.
666 static void export_html_fill_fields( ExportHtmlCtl
*ctl
) {
667 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
), "" );
669 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
),
673 combobox_select_by_data(
674 GTK_COMBO_BOX(exphtml_dlg
.optmenuCSS
), ctl
->stylesheet
);
675 combobox_select_by_data(
676 GTK_COMBO_BOX(exphtml_dlg
.optmenuName
), ctl
->nameFormat
);
677 gtk_toggle_button_set_active(
678 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkBanding
), ctl
->banding
);
679 gtk_toggle_button_set_active(
680 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkLinkEMail
), ctl
->linkEMail
);
681 gtk_toggle_button_set_active(
682 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkAttributes
), ctl
->showAttribs
);
686 * Process export address dialog.
687 * \param cache Address book/data source cache.
689 void addressbook_exp_html( AddressCache
*cache
) {
690 /* Set references to control data */
691 _addressCache_
= cache
;
693 _exportCtl_
= exporthtml_create();
694 exporthtml_load_settings( _exportCtl_
);
697 if( ! exphtml_dlg
.window
)
698 export_html_create();
700 gtk_button_set_label(GTK_BUTTON(exphtml_dlg
.btnCancel
),
702 exphtml_dlg
.cancelled
= FALSE
;
703 gtk_widget_show(exphtml_dlg
.window
);
704 manage_window_set_transient(GTK_WINDOW(exphtml_dlg
.window
));
705 gtk_window_set_modal(GTK_WINDOW(exphtml_dlg
.window
), TRUE
);
706 gtk_label_set_text( GTK_LABEL(exphtml_dlg
.labelBook
), cache
->name
);
707 gtk_label_set_text( GTK_LABEL(exphtml_dlg
.labelOutBook
), cache
->name
);
708 export_html_fill_fields( _exportCtl_
);
710 gtk_widget_grab_default(exphtml_dlg
.btnNext
);
711 gtk_notebook_set_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FILE_INFO
);
712 gtk_widget_set_sensitive( exphtml_dlg
.btnPrev
, FALSE
);
713 gtk_widget_set_sensitive( exphtml_dlg
.btnNext
, TRUE
);
715 export_html_message();
716 gtk_widget_grab_focus(exphtml_dlg
.entryHtml
);
719 gtk_widget_hide(exphtml_dlg
.window
);
720 gtk_window_set_modal(GTK_WINDOW(exphtml_dlg
.window
), FALSE
);
721 exporthtml_free( _exportCtl_
);
724 _addressCache_
= NULL
;
728 * ============================================================================
730 * ============================================================================