2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2002-2009 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>
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_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 );
164 g_strchug( sFile
); g_strchomp( sFile
);
165 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
), sFile
);
166 exporthtml_parse_filespec( _exportCtl_
, sFile
);
169 /* Test for directory */
170 if( exporthtml_test_dir( _exportCtl_
) ) {
174 /* Prompt to create */
175 msg
= g_strdup_printf( _(
176 "HTML Output Directory '%s'\n" \
177 "does not exist. OK to create new directory?" ),
178 _exportCtl_
->dirOutput
);
179 aval
= alertpanel( _("Create Directory" ),
180 msg
, GTK_STOCK_NO
, GTK_STOCK_YES
, NULL
);
182 if( aval
!= G_ALERTALTERNATE
) return FALSE
;
184 /* Create directory */
185 if( ! exporthtml_create_dir( _exportCtl_
) ) {
186 reason
= exporthtml_get_create_msg( _exportCtl_
);
187 msg
= g_strdup_printf( _(
188 "Could not create output directory for HTML file:\n%s" ),
190 aval
= alertpanel_full(_("Failed to Create Directory"), msg
,
191 GTK_STOCK_CLOSE
, NULL
, NULL
, FALSE
,
192 NULL
, ALERT_ERROR
, G_ALERTDEFAULT
);
201 * Test whether we can move off format page.
202 * \return <i>TRUE</i> if OK to move off page.
204 static gboolean
exp_html_move_format( void ) {
205 gboolean retVal
= FALSE
;
209 id
= combobox_get_active_data(GTK_COMBO_BOX(exphtml_dlg
.optmenuCSS
));
210 exporthtml_set_stylesheet( _exportCtl_
, id
);
212 /* Set name format */
213 id
= combobox_get_active_data(GTK_COMBO_BOX(exphtml_dlg
.optmenuName
));
214 exporthtml_set_name_format( _exportCtl_
, id
);
216 exporthtml_set_banding( _exportCtl_
,
217 gtk_toggle_button_get_active(
218 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkBanding
) ) );
219 exporthtml_set_link_email( _exportCtl_
,
220 gtk_toggle_button_get_active(
221 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkLinkEMail
) ) );
222 exporthtml_set_attributes( _exportCtl_
,
223 gtk_toggle_button_get_active(
224 GTK_TOGGLE_BUTTON( exphtml_dlg
.checkAttributes
) ) );
227 exporthtml_process( _exportCtl_
, _addressCache_
);
228 if( _exportCtl_
->retVal
== MGU_SUCCESS
) {
232 export_html_status_show( _( "Error creating HTML file" ) );
238 * Display finish page.
240 static void exp_html_finish_show( void ) {
241 gtk_label_set_text( GTK_LABEL(exphtml_dlg
.labelOutFile
), _exportCtl_
->path
);
242 gtk_widget_set_sensitive( exphtml_dlg
.btnNext
, FALSE
);
243 gtk_widget_grab_focus( exphtml_dlg
.btnCancel
);
247 * Callback function to select previous page.
248 * \param widget Widget (button).
250 static void export_html_prev( GtkWidget
*widget
) {
253 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
254 if( pageNum
== PAGE_FORMAT
) {
255 /* Goto file page stuff */
256 gtk_notebook_set_current_page(
257 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FILE_INFO
);
258 gtk_widget_set_sensitive( exphtml_dlg
.btnPrev
, FALSE
);
260 else if( pageNum
== PAGE_FINISH
) {
261 /* Goto format page */
262 gtk_notebook_set_current_page(
263 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FORMAT
);
264 gtk_widget_set_sensitive( exphtml_dlg
.btnNext
, TRUE
);
266 export_html_message();
270 * Callback function to select previous page.
271 * \param widget Widget (button).
273 static void export_html_next( GtkWidget
*widget
) {
276 pageNum
= gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg
.notebook
) );
277 if( pageNum
== PAGE_FILE_INFO
) {
278 /* Goto format page */
279 if( exp_html_move_file() ) {
280 gtk_notebook_set_current_page(
281 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FORMAT
);
282 gtk_widget_set_sensitive( exphtml_dlg
.btnPrev
, TRUE
);
284 export_html_message();
286 else if( pageNum
== PAGE_FORMAT
) {
287 /* Goto finish page */
288 if( exp_html_move_format() ) {
289 gtk_notebook_set_current_page(
290 GTK_NOTEBOOK(exphtml_dlg
.notebook
), PAGE_FINISH
);
291 gtk_button_set_label(GTK_BUTTON(exphtml_dlg
.btnCancel
),
293 exp_html_finish_show();
294 exporthtml_save_settings( _exportCtl_
);
295 export_html_message();
301 * Open file with web browser.
302 * \param widget Widget (button).
303 * \param data User data.
305 static void export_html_browse( GtkWidget
*widget
, gpointer data
) {
308 uri
= g_filename_to_uri(_exportCtl_
->path
, NULL
, NULL
);
309 open_uri( uri
, prefs_common_get_uri_cmd() );
314 * Create HTML file selection dialog.
315 * \param afs Address file selection data.
317 static void exp_html_file_select_create( AddressFileSelection
*afs
) {
318 gchar
*file
= filesel_select_file_save(_("Select HTML output file"), NULL
);
321 afs
->cancelled
= TRUE
;
323 afs
->cancelled
= FALSE
;
324 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg
.entryHtml
), file
);
330 * Callback function to display HTML file selection dialog.
332 static void exp_html_file_select( void ) {
333 exp_html_file_select_create( & _exp_html_file_selector_
);
337 * Format notebook file specification page.
338 * \param pageNum Page (tab) number.
339 * \param pageLbl Page (tab) label.
341 static void export_html_page_file( gint pageNum
, gchar
*pageLbl
) {
345 GtkWidget
*labelBook
;
346 GtkWidget
*entryHtml
;
350 vbox
= gtk_vbox_new(FALSE
, 8);
351 gtk_container_add( GTK_CONTAINER( exphtml_dlg
.notebook
), vbox
);
352 gtk_container_set_border_width( GTK_CONTAINER (vbox
), BORDER_WIDTH
);
354 label
= gtk_label_new( pageLbl
);
355 gtk_widget_show( label
);
356 gtk_notebook_set_tab_label(
357 GTK_NOTEBOOK( exphtml_dlg
.notebook
),
358 gtk_notebook_get_nth_page(
359 GTK_NOTEBOOK( exphtml_dlg
.notebook
), pageNum
),
362 table
= gtk_table_new( 3, 3, FALSE
);
363 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
364 gtk_container_set_border_width( GTK_CONTAINER(table
), 8 );
365 gtk_table_set_row_spacings(GTK_TABLE(table
), 8);
366 gtk_table_set_col_spacings(GTK_TABLE(table
), 8 );
370 label
= gtk_label_new( _( "Address Book" ) );
371 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
373 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
375 labelBook
= gtk_label_new( "Address book name goes here" );
376 gtk_table_attach(GTK_TABLE(table
), labelBook
, 1, 2, top
, (top
+ 1),
377 GTK_EXPAND
|GTK_SHRINK
|GTK_FILL
, 0, 0, 0);
378 gtk_misc_set_alignment(GTK_MISC(labelBook
), 0, 0.5);
382 label
= gtk_label_new( _( "HTML Output File" ) );
383 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
385 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
387 entryHtml
= gtk_entry_new();
388 gtk_table_attach(GTK_TABLE(table
), entryHtml
, 1, 2, top
, (top
+ 1),
389 GTK_EXPAND
|GTK_SHRINK
|GTK_FILL
, 0, 0, 0);
391 btnFile
= gtkut_get_browse_file_btn(_("B_rowse"));
392 gtk_table_attach(GTK_TABLE(table
), btnFile
, 2, 3, top
, (top
+ 1),
395 gtk_widget_show_all(vbox
);
398 g_signal_connect(G_OBJECT(btnFile
), "clicked",
399 G_CALLBACK(exp_html_file_select
), NULL
);
401 exphtml_dlg
.labelBook
= labelBook
;
402 exphtml_dlg
.entryHtml
= entryHtml
;
406 * Format notebook format page.
407 * \param pageNum Page (tab) number.
408 * \param pageLbl Page (tab) label.
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
;
424 vbox
= gtk_vbox_new(FALSE
, 8);
425 gtk_container_add( GTK_CONTAINER( exphtml_dlg
.notebook
), vbox
);
426 gtk_container_set_border_width( GTK_CONTAINER (vbox
), BORDER_WIDTH
);
428 label
= gtk_label_new( pageLbl
);
429 gtk_widget_show( label
);
430 gtk_notebook_set_tab_label(
431 GTK_NOTEBOOK( exphtml_dlg
.notebook
),
432 gtk_notebook_get_nth_page(
433 GTK_NOTEBOOK( exphtml_dlg
.notebook
), pageNum
),
436 table
= gtk_table_new( 5, 3, FALSE
);
437 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
438 gtk_container_set_border_width( GTK_CONTAINER(table
), 8 );
439 gtk_table_set_row_spacings(GTK_TABLE(table
), 8);
440 gtk_table_set_col_spacings(GTK_TABLE(table
), 8 );
444 label
= gtk_label_new( _( "Stylesheet" ) );
445 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
447 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
449 optmenuCSS
= gtkut_sc_combobox_create(NULL
, TRUE
);
450 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuCSS
)));
452 COMBOBOX_ADD(menu
, _("None"), EXPORT_HTML_ID_NONE
);
453 COMBOBOX_ADD(menu
, _("Default"), EXPORT_HTML_ID_DEFAULT
);
454 COMBOBOX_ADD(menu
, _("Full"), EXPORT_HTML_ID_FULL
);
455 COMBOBOX_ADD(menu
, _("Custom"), EXPORT_HTML_ID_CUSTOM
);
456 COMBOBOX_ADD(menu
, _("Custom-2"), EXPORT_HTML_ID_CUSTOM2
);
457 COMBOBOX_ADD(menu
, _("Custom-3"), EXPORT_HTML_ID_CUSTOM3
);
458 COMBOBOX_ADD(menu
, _("Custom-4"), EXPORT_HTML_ID_CUSTOM4
);
460 gtk_table_attach(GTK_TABLE(table
), optmenuCSS
, 1, 2, top
, (top
+ 1),
465 label
= gtk_label_new( _( "Full Name Format" ) );
466 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1),
468 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
470 optmenuName
= gtkut_sc_combobox_create(NULL
, TRUE
);
471 menu
= GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuName
)));
473 COMBOBOX_ADD(menu
, _("First Name, Last Name"), EXPORT_HTML_FIRST_LAST
);
474 COMBOBOX_ADD(menu
, _("Last Name, First Name"), EXPORT_HTML_LAST_FIRST
);
476 gtk_table_attach(GTK_TABLE(table
), optmenuName
, 1, 2, top
, (top
+ 1),
481 checkBanding
= gtk_check_button_new_with_label( _( "Color Banding" ) );
482 gtk_table_attach(GTK_TABLE(table
), checkBanding
, 1, 2, top
, (top
+ 1),
487 checkLinkEMail
= gtk_check_button_new_with_label( _( "Format Email Links" ) );
488 gtk_table_attach(GTK_TABLE(table
), checkLinkEMail
, 1, 2, top
, (top
+ 1),
493 checkAttributes
= gtk_check_button_new_with_label( _( "Format User Attributes" ) );
494 gtk_table_attach(GTK_TABLE(table
), checkAttributes
, 1, 2, top
, (top
+ 1),
497 gtk_widget_show_all(vbox
);
499 exphtml_dlg
.optmenuCSS
= optmenuCSS
;
500 exphtml_dlg
.optmenuName
= optmenuName
;
501 exphtml_dlg
.checkBanding
= checkBanding
;
502 exphtml_dlg
.checkLinkEMail
= checkLinkEMail
;
503 exphtml_dlg
.checkAttributes
= checkAttributes
;
507 * Format notebook finish page.
508 * \param pageNum Page (tab) number.
509 * \param pageLbl Page (tab) label.
511 static void export_html_page_finish( gint pageNum
, gchar
*pageLbl
) {
515 GtkWidget
*labelBook
;
516 GtkWidget
*labelFile
;
517 GtkWidget
*btnBrowse
;
520 vbox
= gtk_vbox_new(FALSE
, 8);
521 gtk_container_add( GTK_CONTAINER( exphtml_dlg
.notebook
), vbox
);
522 gtk_container_set_border_width( GTK_CONTAINER (vbox
), BORDER_WIDTH
);
524 label
= gtk_label_new( pageLbl
);
525 gtk_widget_show( label
);
526 gtk_notebook_set_tab_label(
527 GTK_NOTEBOOK( exphtml_dlg
.notebook
),
528 gtk_notebook_get_nth_page( GTK_NOTEBOOK( exphtml_dlg
.notebook
), pageNum
), label
);
530 table
= gtk_table_new( 3, 3, FALSE
);
531 gtk_box_pack_start(GTK_BOX(vbox
), table
, FALSE
, FALSE
, 0);
532 gtk_container_set_border_width( GTK_CONTAINER(table
), 8 );
533 gtk_table_set_row_spacings(GTK_TABLE(table
), 8);
534 gtk_table_set_col_spacings(GTK_TABLE(table
), 8 );
538 label
= gtk_label_new( _( "Address Book :" ) );
539 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
540 gtk_misc_set_alignment(GTK_MISC(label
), 1, 0.5);
542 labelBook
= gtk_label_new("Full name of address book goes here");
543 gtk_table_attach(GTK_TABLE(table
), labelBook
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
544 gtk_misc_set_alignment(GTK_MISC(labelBook
), 0, 0.5);
548 label
= gtk_label_new( _( "File Name :" ) );
549 gtk_table_attach(GTK_TABLE(table
), label
, 0, 1, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
550 gtk_misc_set_alignment(GTK_MISC(label
), 1, 0.5);
552 labelFile
= gtk_label_new("File name goes here");
553 gtk_table_attach(GTK_TABLE(table
), labelFile
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
554 gtk_misc_set_alignment(GTK_MISC(labelFile
), 0, 0.5);
558 btnBrowse
= gtk_button_new_with_label( _( "Open with Web Browser" ) );
559 gtk_table_attach(GTK_TABLE(table
), btnBrowse
, 1, 2, top
, (top
+ 1), GTK_FILL
, 0, 0, 0);
561 gtk_widget_show_all(vbox
);
563 /* Button handlers */
564 g_signal_connect(G_OBJECT(btnBrowse
), "clicked",
565 G_CALLBACK(export_html_browse
), NULL
);
567 exphtml_dlg
.labelOutBook
= labelBook
;
568 exphtml_dlg
.labelOutFile
= labelFile
;
572 * Create main dialog decorations (excluding notebook pages).
574 static void export_html_dialog_create( void ) {
582 GtkWidget
*btnCancel
;
584 GtkWidget
*statusbar
;
586 window
= gtkut_window_new(GTK_WINDOW_TOPLEVEL
, "exphtmldlg");
587 gtk_widget_set_size_request(window
, -1, -1 );
588 gtk_container_set_border_width( GTK_CONTAINER(window
), 0 );
589 gtk_window_set_title( GTK_WINDOW(window
),
590 _("Export Address Book to HTML File") );
591 gtk_window_set_position(GTK_WINDOW(window
), GTK_WIN_POS_CENTER
);
592 gtk_window_set_modal(GTK_WINDOW(window
), TRUE
);
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
));
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 exporthtml_free( _exportCtl_
);
723 _addressCache_
= NULL
;
727 * ============================================================================
729 * ============================================================================