Fix a typo error, thanks to Milan Obuch.
[claws.git] / src / exphtmldlg.c
bloba089e21c9162f47614ac6ea9cd8fefd1dfd5a2f2
1 /*
2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3 * Copyright (C) 2002-2022 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.
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #include "claws-features.h"
26 #endif
28 #include "defs.h"
30 #include <glib.h>
31 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
33 #include <gtk/gtk.h>
35 #include "gtkutils.h"
36 #include "prefs_common.h"
37 #include "alertpanel.h"
38 #include "mgutils.h"
39 #include "addrcache.h"
40 #include "addressitem.h"
41 #include "exporthtml.h"
42 #include "utils.h"
43 #include "manage_window.h"
44 #include "filesel.h"
45 #include "combobox.h"
47 #define PAGE_FILE_INFO 0
48 #define PAGE_FORMAT 1
49 #define PAGE_FINISH 2
51 /**
52 * Dialog object.
54 static struct _ExpHtml_Dlg {
55 GtkWidget *window;
56 GtkWidget *notebook;
57 GtkWidget *labelBook;
58 GtkWidget *entryHtml;
59 GtkWidget *optmenuCSS;
60 GtkWidget *optmenuName;
61 GtkWidget *checkBanding;
62 GtkWidget *checkLinkEMail;
63 GtkWidget *checkAttributes;
64 GtkWidget *labelOutBook;
65 GtkWidget *labelOutFile;
66 GtkWidget *btnPrev;
67 GtkWidget *btnNext;
68 GtkWidget *btnCancel;
69 GtkWidget *statusbar;
70 gint status_cid;
71 gboolean cancelled;
72 } exphtml_dlg;
74 static struct _AddressFileSelection _exp_html_file_selector_;
76 static ExportHtmlCtl *_exportCtl_ = NULL;
77 static AddressCache *_addressCache_ = NULL;
79 /**
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 ) {
85 gtk_statusbar_pop(
86 GTK_STATUSBAR(exphtml_dlg.statusbar),
87 exphtml_dlg.status_cid );
88 if( msg ) {
89 gtk_statusbar_push(
90 GTK_STATUSBAR(exphtml_dlg.statusbar),
91 exphtml_dlg.status_cid, msg );
96 /**
97 * Select and display status message appropriate for the page being displayed.
99 static void export_html_message( void ) {
100 gchar *sMsg = NULL;
101 gint pageNum;
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 ) {
122 gint pageNum;
124 pageNum = gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) );
125 if( pageNum != PAGE_FINISH ) {
126 exphtml_dlg.cancelled = TRUE;
128 gtk_main_quit();
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 );
139 return TRUE;
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 );
152 return FALSE;
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;
161 AlertValue aval;
163 sFile = gtk_editable_get_chars( GTK_EDITABLE(exphtml_dlg.entryHtml), 0, -1 );
164 g_strstrip( sFile );
165 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml), sFile );
166 exporthtml_parse_filespec( _exportCtl_, sFile );
167 g_free( sFile );
169 /* Test for directory */
170 if( g_file_test(_exportCtl_->dirOutput,
171 G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR) ) {
172 return TRUE;
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, NULL, _("_No"), NULL, _("_Yes"), NULL, NULL,
182 ALERTFOCUS_FIRST );
183 g_free( msg );
184 if( aval != G_ALERTALTERNATE ) return FALSE;
186 /* Create directory */
187 if( ! exporthtml_create_dir( _exportCtl_ ) ) {
188 reason = exporthtml_get_create_msg( _exportCtl_ );
189 msg = g_strdup_printf( _(
190 "Could not create output directory for HTML file:\n%s" ),
191 reason );
192 aval = alertpanel_full(_("Failed to Create Directory"), msg,
193 "window-close", _("_Close"), NULL, NULL,
194 NULL, NULL, ALERTFOCUS_FIRST, FALSE,
195 NULL, ALERT_ERROR);
196 g_free( msg );
197 return FALSE;
200 return TRUE;
204 * Test whether we can move off format page.
205 * \return <i>TRUE</i> if OK to move off page.
207 static gboolean exp_html_move_format( void ) {
208 gboolean retVal = FALSE;
209 gint id;
211 /* Set stylesheet */
212 id = combobox_get_active_data(GTK_COMBO_BOX(exphtml_dlg.optmenuCSS));
213 exporthtml_set_stylesheet( _exportCtl_, id );
215 /* Set name format */
216 id = combobox_get_active_data(GTK_COMBO_BOX(exphtml_dlg.optmenuName));
217 exporthtml_set_name_format( _exportCtl_, id );
219 exporthtml_set_banding( _exportCtl_,
220 gtk_toggle_button_get_active(
221 GTK_TOGGLE_BUTTON( exphtml_dlg.checkBanding ) ) );
222 exporthtml_set_link_email( _exportCtl_,
223 gtk_toggle_button_get_active(
224 GTK_TOGGLE_BUTTON( exphtml_dlg.checkLinkEMail ) ) );
225 exporthtml_set_attributes( _exportCtl_,
226 gtk_toggle_button_get_active(
227 GTK_TOGGLE_BUTTON( exphtml_dlg.checkAttributes ) ) );
229 /* Process export */
230 exporthtml_process( _exportCtl_, _addressCache_ );
231 if( _exportCtl_->retVal == MGU_SUCCESS ) {
232 retVal = TRUE;
234 else {
235 export_html_status_show( _( "Error creating HTML file" ) );
237 return retVal;
241 * Display finish page.
243 static void exp_html_finish_show( void ) {
244 gtk_label_set_text( GTK_LABEL(exphtml_dlg.labelOutFile), _exportCtl_->path );
245 gtk_widget_set_sensitive( exphtml_dlg.btnNext, FALSE );
246 gtk_widget_grab_focus( exphtml_dlg.btnCancel );
250 * Callback function to select previous page.
251 * \param widget Widget (button).
253 static void export_html_prev( GtkWidget *widget ) {
254 gint pageNum;
256 pageNum = gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) );
257 if( pageNum == PAGE_FORMAT ) {
258 /* Goto file page stuff */
259 gtk_notebook_set_current_page(
260 GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FILE_INFO );
261 gtk_widget_set_sensitive( exphtml_dlg.btnPrev, FALSE );
263 else if( pageNum == PAGE_FINISH ) {
264 /* Goto format page */
265 gtk_notebook_set_current_page(
266 GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FORMAT );
267 gtk_widget_set_sensitive( exphtml_dlg.btnNext, TRUE );
269 export_html_message();
273 * Callback function to select previous page.
274 * \param widget Widget (button).
276 static void export_html_next( GtkWidget *widget ) {
277 gint pageNum;
279 pageNum = gtk_notebook_get_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook) );
280 if( pageNum == PAGE_FILE_INFO ) {
281 /* Goto format page */
282 if( exp_html_move_file() ) {
283 gtk_notebook_set_current_page(
284 GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FORMAT );
285 gtk_widget_set_sensitive( exphtml_dlg.btnPrev, TRUE );
287 export_html_message();
289 else if( pageNum == PAGE_FORMAT ) {
290 /* Goto finish page */
291 if( exp_html_move_format() ) {
292 gtk_notebook_set_current_page(
293 GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FINISH );
294 gtk_button_set_label(GTK_BUTTON(exphtml_dlg.btnCancel),
295 _("_Close"));
296 gtk_button_set_image(GTK_BUTTON(exphtml_dlg.btnCancel),
297 gtk_image_new_from_icon_name("window-close", GTK_ICON_SIZE_BUTTON));
299 exp_html_finish_show();
300 exporthtml_save_settings( _exportCtl_ );
301 export_html_message();
307 * Open file with web browser.
308 * \param widget Widget (button).
309 * \param data User data.
311 static void export_html_browse( GtkWidget *widget, gpointer data ) {
312 gchar *uri;
314 uri = g_filename_to_uri(_exportCtl_->path, NULL, NULL);
315 open_uri( uri, prefs_common_get_uri_cmd() );
316 g_free( uri );
320 * Create HTML file selection dialog.
321 * \param afs Address file selection data.
323 static void exp_html_file_select_create( AddressFileSelection *afs ) {
324 gchar *file = filesel_select_file_save(_("Select HTML output file"), NULL);
326 if (file == NULL)
327 afs->cancelled = TRUE;
328 else {
329 afs->cancelled = FALSE;
330 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml), file );
331 g_free(file);
336 * Callback function to display HTML file selection dialog.
338 static void exp_html_file_select( void ) {
339 exp_html_file_select_create( & _exp_html_file_selector_ );
343 * Format notebook file specification page.
344 * \param pageNum Page (tab) number.
345 * \param pageLbl Page (tab) label.
347 static void export_html_page_file( gint pageNum, gchar *pageLbl ) {
348 GtkWidget *vbox;
349 GtkWidget *table;
350 GtkWidget *label;
351 GtkWidget *labelBook;
352 GtkWidget *entryHtml;
353 GtkWidget *btnFile;
355 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 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 ),
365 label );
367 table = gtk_grid_new();
368 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
369 gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
370 gtk_grid_set_row_spacing(GTK_GRID(table), 8);
371 gtk_grid_set_column_spacing(GTK_GRID(table), 8);
373 /* First row */
374 label = gtk_label_new( _( "Address Book" ) );
375 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
376 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
378 labelBook = gtk_label_new( "Address book name goes here" );
379 gtk_label_set_xalign(GTK_LABEL(labelBook), 0.0);
380 gtk_grid_attach(GTK_GRID(table), labelBook, 1, 0, 1, 1);
382 /* Second row */
383 label = gtk_label_new( _( "HTML Output File" ) );
384 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
385 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
387 entryHtml = gtk_entry_new();
388 gtk_grid_attach(GTK_GRID(table), entryHtml, 1, 1, 1, 1);
389 gtk_widget_set_hexpand(entryHtml, TRUE);
390 gtk_widget_set_halign(entryHtml, GTK_ALIGN_FILL);
392 btnFile = gtkut_get_browse_file_btn(_("B_rowse"));
393 gtk_grid_attach(GTK_GRID(table), btnFile, 2, 1, 1, 1);
395 gtk_widget_show_all(vbox);
397 /* Button handler */
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 ) {
411 GtkWidget *vbox;
412 GtkWidget *table;
413 GtkWidget *label;
414 GtkWidget *optmenuCSS;
415 GtkWidget *optmenuName;
416 GtkListStore *menu;
417 GtkTreeIter iter;
418 GtkWidget *checkBanding;
419 GtkWidget *checkLinkEMail;
420 GtkWidget *checkAttributes;
422 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
423 gtk_container_add( GTK_CONTAINER( exphtml_dlg.notebook ), vbox );
424 gtk_container_set_border_width( GTK_CONTAINER (vbox), BORDER_WIDTH );
426 label = gtk_label_new( pageLbl );
427 gtk_widget_show( label );
428 gtk_notebook_set_tab_label(
429 GTK_NOTEBOOK( exphtml_dlg.notebook ),
430 gtk_notebook_get_nth_page(
431 GTK_NOTEBOOK( exphtml_dlg.notebook ), pageNum ),
432 label );
434 table = gtk_grid_new();
435 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
436 gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
437 gtk_grid_set_row_spacing(GTK_GRID(table), 8);
438 gtk_grid_set_column_spacing(GTK_GRID(table), 8);
440 /* First row */
441 label = gtk_label_new( _( "Stylesheet" ) );
442 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
443 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
445 optmenuCSS = gtkut_sc_combobox_create(NULL, TRUE);
446 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuCSS)));
448 COMBOBOX_ADD(menu, _("None"), EXPORT_HTML_ID_NONE);
449 COMBOBOX_ADD(menu, _("Default"), EXPORT_HTML_ID_DEFAULT);
450 COMBOBOX_ADD(menu, _("Full"), EXPORT_HTML_ID_FULL);
451 COMBOBOX_ADD(menu, _("Custom"), EXPORT_HTML_ID_CUSTOM);
452 COMBOBOX_ADD(menu, _("Custom-2"), EXPORT_HTML_ID_CUSTOM2);
453 COMBOBOX_ADD(menu, _("Custom-3"), EXPORT_HTML_ID_CUSTOM3);
454 COMBOBOX_ADD(menu, _("Custom-4"), EXPORT_HTML_ID_CUSTOM4);
456 gtk_grid_attach(GTK_GRID(table), optmenuCSS, 1, 0, 1, 1);
458 /* Second row */
459 label = gtk_label_new( _( "Full Name Format" ) );
460 gtk_label_set_xalign(GTK_LABEL(label), 0.0);
461 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
463 optmenuName = gtkut_sc_combobox_create(NULL, TRUE);
464 menu = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(optmenuName)));
466 COMBOBOX_ADD(menu, _("First Name, Last Name"), EXPORT_HTML_FIRST_LAST);
467 COMBOBOX_ADD(menu, _("Last Name, First Name"), EXPORT_HTML_LAST_FIRST);
469 gtk_grid_attach(GTK_GRID(table), optmenuName, 1, 1, 1, 1);
471 /* Third row */
472 checkBanding = gtk_check_button_new_with_label( _( "Color Banding" ) );
473 gtk_grid_attach(GTK_GRID(table), checkBanding, 1, 2, 1, 1);
475 /* Fourth row */
476 checkLinkEMail = gtk_check_button_new_with_label( _( "Format Email Links" ) );
477 gtk_grid_attach(GTK_GRID(table), checkLinkEMail, 1, 3, 1, 1);
479 /* Fifth row */
480 checkAttributes = gtk_check_button_new_with_label( _( "Format User Attributes" ) );
481 gtk_grid_attach(GTK_GRID(table), checkAttributes, 1, 4, 1, 1);
483 gtk_widget_show_all(vbox);
485 exphtml_dlg.optmenuCSS = optmenuCSS;
486 exphtml_dlg.optmenuName = optmenuName;
487 exphtml_dlg.checkBanding = checkBanding;
488 exphtml_dlg.checkLinkEMail = checkLinkEMail;
489 exphtml_dlg.checkAttributes = checkAttributes;
493 * Format notebook finish page.
494 * \param pageNum Page (tab) number.
495 * \param pageLbl Page (tab) label.
497 static void export_html_page_finish( gint pageNum, gchar *pageLbl ) {
498 GtkWidget *vbox;
499 GtkWidget *table;
500 GtkWidget *label;
501 GtkWidget *labelBook;
502 GtkWidget *labelFile;
503 GtkWidget *btnBrowse;
505 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 8);
506 gtk_container_add( GTK_CONTAINER( exphtml_dlg.notebook ), vbox );
507 gtk_container_set_border_width( GTK_CONTAINER (vbox), BORDER_WIDTH );
509 label = gtk_label_new( pageLbl );
510 gtk_widget_show( label );
511 gtk_notebook_set_tab_label(
512 GTK_NOTEBOOK( exphtml_dlg.notebook ),
513 gtk_notebook_get_nth_page( GTK_NOTEBOOK( exphtml_dlg.notebook ), pageNum ), label );
515 table = gtk_grid_new();
516 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
517 gtk_container_set_border_width( GTK_CONTAINER(table), 8 );
518 gtk_grid_set_row_spacing(GTK_GRID(table), 8);
519 gtk_grid_set_column_spacing(GTK_GRID(table), 8);
521 /* First row */
522 label = gtk_label_new( _( "Address Book:" ) );
523 gtk_label_set_xalign(GTK_LABEL(label), 1.0);
524 gtk_grid_attach(GTK_GRID(table), label, 0, 0, 1, 1);
526 labelBook = gtk_label_new("Full name of address book goes here");
527 gtk_label_set_xalign(GTK_LABEL(labelBook), 0.0);
528 gtk_grid_attach(GTK_GRID(table), labelBook, 1, 0, 1, 1);
530 /* Second row */
531 label = gtk_label_new( _( "File Name:" ) );
532 gtk_label_set_xalign(GTK_LABEL(label), 1.0);
533 gtk_grid_attach(GTK_GRID(table), label, 0, 1, 1, 1);
535 labelFile = gtk_label_new("File name goes here");
536 gtk_label_set_xalign(GTK_LABEL(labelFile), 0.0);
537 gtk_grid_attach(GTK_GRID(table), labelFile, 1, 1, 1, 1);
539 /* Third row */
540 btnBrowse = gtk_button_new_with_label( _( "Open with Web Browser" ) );
541 gtk_grid_attach(GTK_GRID(table), btnBrowse, 1, 2, 1, 1);
543 gtk_widget_show_all(vbox);
545 /* Button handlers */
546 g_signal_connect(G_OBJECT(btnBrowse), "clicked",
547 G_CALLBACK(export_html_browse), NULL);
549 exphtml_dlg.labelOutBook = labelBook;
550 exphtml_dlg.labelOutFile = labelFile;
554 * Create main dialog decorations (excluding notebook pages).
556 static void export_html_dialog_create( void ) {
557 GtkWidget *window;
558 GtkWidget *vbox;
559 GtkWidget *vnbox;
560 GtkWidget *notebook;
561 GtkWidget *hbbox;
562 GtkWidget *btnPrev;
563 GtkWidget *btnNext;
564 GtkWidget *btnCancel;
565 GtkWidget *hsbox;
566 GtkWidget *statusbar;
568 window = gtkut_window_new(GTK_WINDOW_TOPLEVEL, "exphtmldlg");
569 gtk_widget_set_size_request(window, -1, -1 );
570 gtk_container_set_border_width( GTK_CONTAINER(window), 0 );
571 gtk_window_set_title( GTK_WINDOW(window),
572 _("Export Address Book to HTML File") );
573 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
574 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG);
575 g_signal_connect(G_OBJECT(window), "delete_event",
576 G_CALLBACK(export_html_delete_event),
577 NULL );
578 g_signal_connect(G_OBJECT(window), "key_press_event",
579 G_CALLBACK(export_html_key_pressed),
580 NULL );
582 vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
583 gtk_widget_show(vbox);
584 gtk_container_add(GTK_CONTAINER(window), vbox);
586 vnbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 4);
587 gtk_container_set_border_width(GTK_CONTAINER(vnbox), 4);
588 gtk_widget_show(vnbox);
589 gtk_box_pack_start(GTK_BOX(vbox), vnbox, TRUE, TRUE, 0);
591 /* Notebook */
592 notebook = gtk_notebook_new();
593 gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook), FALSE ); /* Hide */
594 /* gtk_notebook_set_show_tabs( GTK_NOTEBOOK(notebook), TRUE ); */
595 gtk_widget_show(notebook);
596 gtk_box_pack_start(GTK_BOX(vnbox), notebook, TRUE, TRUE, 0);
597 gtk_container_set_border_width(GTK_CONTAINER(notebook), 6);
599 /* Status line */
600 hsbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
601 gtk_box_pack_end(GTK_BOX(vbox), hsbox, FALSE, FALSE, BORDER_WIDTH);
602 statusbar = gtk_statusbar_new();
603 gtk_box_pack_start(GTK_BOX(hsbox), statusbar, TRUE, TRUE, BORDER_WIDTH);
605 /* Button panel */
606 gtkut_stock_button_set_create(&hbbox, &btnPrev, "go-previous", _("_Previous"),
607 &btnNext, "go-next", _("_Next"),
608 &btnCancel, NULL, _("_Cancel"));
609 gtk_box_pack_end(GTK_BOX(vbox), hbbox, FALSE, FALSE, 0);
610 gtk_container_set_border_width(GTK_CONTAINER(hbbox), 2);
611 gtk_widget_grab_default(btnNext);
613 /* Button handlers */
614 g_signal_connect(G_OBJECT(btnPrev), "clicked",
615 G_CALLBACK(export_html_prev), NULL);
616 g_signal_connect(G_OBJECT(btnNext), "clicked",
617 G_CALLBACK(export_html_next), NULL);
618 g_signal_connect(G_OBJECT(btnCancel), "clicked",
619 G_CALLBACK(export_html_cancel), NULL);
621 gtk_widget_show_all(vbox);
623 exphtml_dlg.window = window;
624 exphtml_dlg.notebook = notebook;
625 exphtml_dlg.btnPrev = btnPrev;
626 exphtml_dlg.btnNext = btnNext;
627 exphtml_dlg.btnCancel = btnCancel;
628 exphtml_dlg.statusbar = statusbar;
629 exphtml_dlg.status_cid = gtk_statusbar_get_context_id(
630 GTK_STATUSBAR(statusbar), "Export HTML Dialog" );
634 * Create export HTML dialog.
636 static void export_html_create( void ) {
637 export_html_dialog_create();
638 export_html_page_file( PAGE_FILE_INFO, _( "File Info" ) );
639 export_html_page_format( PAGE_FORMAT, _( "Format" ) );
640 export_html_page_finish( PAGE_FINISH, _( "Finish" ) );
641 gtk_widget_show_all( exphtml_dlg.window );
645 * Populate fields from control data.
646 * \param ctl Export control data.
648 static void export_html_fill_fields( ExportHtmlCtl *ctl ) {
649 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml), "" );
650 if( ctl->path ) {
651 gtk_entry_set_text( GTK_ENTRY(exphtml_dlg.entryHtml),
652 ctl->path );
655 combobox_select_by_data(
656 GTK_COMBO_BOX(exphtml_dlg.optmenuCSS), ctl->stylesheet );
657 combobox_select_by_data(
658 GTK_COMBO_BOX(exphtml_dlg.optmenuName), ctl->nameFormat );
659 gtk_toggle_button_set_active(
660 GTK_TOGGLE_BUTTON( exphtml_dlg.checkBanding ), ctl->banding );
661 gtk_toggle_button_set_active(
662 GTK_TOGGLE_BUTTON( exphtml_dlg.checkLinkEMail ), ctl->linkEMail );
663 gtk_toggle_button_set_active(
664 GTK_TOGGLE_BUTTON( exphtml_dlg.checkAttributes ), ctl->showAttribs );
668 * Process export address dialog.
669 * \param cache Address book/data source cache.
671 void addressbook_exp_html( AddressCache *cache ) {
672 /* Set references to control data */
673 _addressCache_ = cache;
675 _exportCtl_ = exporthtml_create();
676 exporthtml_load_settings( _exportCtl_ );
678 /* Setup GUI */
679 if( ! exphtml_dlg.window )
680 export_html_create();
682 gtk_button_set_label(GTK_BUTTON(exphtml_dlg.btnCancel),
683 _("_Cancel"));
684 exphtml_dlg.cancelled = FALSE;
685 gtk_widget_show(exphtml_dlg.window);
686 manage_window_set_transient(GTK_WINDOW(exphtml_dlg.window));
687 gtk_window_set_modal(GTK_WINDOW(exphtml_dlg.window), TRUE);
688 gtk_label_set_text( GTK_LABEL(exphtml_dlg.labelBook), cache->name );
689 gtk_label_set_text( GTK_LABEL(exphtml_dlg.labelOutBook), cache->name );
690 export_html_fill_fields( _exportCtl_ );
692 gtk_widget_grab_default(exphtml_dlg.btnNext);
693 gtk_notebook_set_current_page( GTK_NOTEBOOK(exphtml_dlg.notebook), PAGE_FILE_INFO );
694 gtk_widget_set_sensitive( exphtml_dlg.btnPrev, FALSE );
695 gtk_widget_set_sensitive( exphtml_dlg.btnNext, TRUE );
697 export_html_message();
698 gtk_widget_grab_focus(exphtml_dlg.entryHtml);
700 gtk_main();
701 gtk_widget_hide(exphtml_dlg.window);
702 gtk_window_set_modal(GTK_WINDOW(exphtml_dlg.window), FALSE);
703 exporthtml_free( _exportCtl_ );
704 _exportCtl_ = NULL;
706 _addressCache_ = NULL;
710 * ============================================================================
711 * End of Source.
712 * ============================================================================