Support more folding icon styles: arrows, +/- and no lines
[geany-mirror.git] / plugins / export.c
blobd670e02ee6c08b13ee7fc2dbd5068b54db63283d
1 /*
2 * export.c - this file is part of Geany, a fast and lightweight IDE
4 * Copyright 2007-2010 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
5 * Copyright 2007-2010 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20 * MA 02110-1301, USA.
22 * $Id$
25 /* Export plugin. */
27 #include <ctype.h>
28 #include <math.h>
30 #include "geanyplugin.h"
33 GeanyData *geany_data;
34 GeanyFunctions *geany_functions;
36 PLUGIN_VERSION_CHECK(GEANY_API_VERSION)
37 PLUGIN_SET_INFO(_("Export"), _("Exports the current file into different formats."), VERSION,
38 _("The Geany developer team"))
41 static GtkWidget *main_menu_item = NULL;
44 #define ROTATE_RGB(color) \
45 (((color) & 0xFF0000) >> 16) + ((color) & 0x00FF00) + (((color) & 0x0000FF) << 16)
46 #define TEMPLATE_HTML "\
47 <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\
48 \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n\
49 <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n\
50 \n\
51 <head>\n\
52 <title>{export_filename}</title>\n\
53 <meta http-equiv=\"content-type\" content=\"text/html;charset=utf-8\" />\n\
54 <meta name=\"generator\" content=\"Geany " VERSION "\" />\n\
55 <meta name=\"date\" content=\"{export_date}\" />\n\
56 <style type=\"text/css\">\n\
57 {export_styles}\n\
58 </style>\n\
59 </head>\n\
60 \n\
61 <body>\n\
62 <p>\n\
63 {export_content}\n\
64 </p>\n\
65 </body>\n\
66 </html>\n"
68 #define TEMPLATE_LATEX "\
69 % {export_filename} (LaTeX code generated by Geany " VERSION " on {export_date})\n\
70 \\documentclass[a4paper]{article}\n\
71 \\usepackage[a4paper,margin=2cm]{geometry}\n\
72 \\usepackage[utf8]{inputenc}\n\
73 \\usepackage[T1]{fontenc}\n\
74 \\usepackage{color}\n\
75 \\setlength{\\parindent}{0em}\n\
76 \\setlength{\\parskip}{2ex plus1ex minus0.5ex}\n\
77 {export_styles}\n\
78 \\begin{document}\
79 \n\
80 \\ttfamily\n\
81 \\setlength{\\fboxrule}{0pt}\n\
82 \\setlength{\\fboxsep}{0pt}\n\
83 {export_content}\
84 \\end{document}\n"
87 enum
89 FORE = 0,
90 BACK,
91 BOLD,
92 ITALIC,
93 USED,
94 MAX_TYPES
97 enum
99 DATE_TYPE_DEFAULT,
100 DATE_TYPE_HTML
103 typedef void (*ExportFunc) (GeanyDocument *doc, const gchar *filename, gboolean use_zoom);
104 typedef struct
106 GeanyDocument *doc;
107 gboolean have_zoom_level_checkbox;
108 ExportFunc export_func;
109 } ExportInfo;
111 static void on_file_save_dialog_response(GtkDialog *dialog, gint response, gpointer user_data);
112 static void write_html_file(GeanyDocument *doc, const gchar *filename, gboolean use_zoom);
113 static void write_latex_file(GeanyDocument *doc, const gchar *filename, gboolean use_zoom);
116 /* converts a RGB colour into a LaTeX compatible representation, taken from SciTE */
117 static gchar* get_tex_rgb(gint rgb_colour)
119 /* texcolor[rgb]{0,0.5,0}{....} */
120 gdouble rf = (rgb_colour % 256) / 256.0;
121 gdouble gf = ((rgb_colour & - 16711936) / 256) / 256.0;
122 gdouble bf = ((rgb_colour & 0xff0000) / 65536) / 256.0;
123 gint r = (gint) (rf * 10 + 0.5);
124 gint g = (gint) (gf * 10 + 0.5);
125 gint b = (gint) (bf * 10 + 0.5);
127 return g_strdup_printf("%d.%d, %d.%d, %d.%d", r / 10, r % 10, g / 10, g % 10, b / 10, b % 10);
131 /* convert a style number (0..127) into a string representation (aa, ab, .., ba, bb, .., zy, zz) */
132 static gchar *get_tex_style(gint style)
134 static gchar buf[4];
135 int i = 0;
139 buf[i] = (style % 26) + 'a';
140 style /= 26;
141 i++;
142 } while (style > 0);
143 buf[i] = '\0';
145 return buf;
149 static void create_file_save_as_dialog(const gchar *extension, ExportFunc func,
150 gboolean show_zoom_level_checkbox)
152 GtkWidget *dialog;
153 GeanyDocument *doc;
154 ExportInfo *exi;
156 if (extension == NULL)
157 return;
159 doc = document_get_current();
161 exi = g_new(ExportInfo, 1);
162 exi->doc = doc;
163 exi->export_func = func;
164 exi->have_zoom_level_checkbox = FALSE;
166 dialog = gtk_file_chooser_dialog_new(_("Export File"), GTK_WINDOW(geany->main_widgets->window),
167 GTK_FILE_CHOOSER_ACTION_SAVE, NULL, NULL);
168 gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
169 gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
170 gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
171 gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
172 gtk_widget_set_name(dialog, "GeanyExportDialog");
174 gtk_dialog_add_buttons(GTK_DIALOG(dialog),
175 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
176 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
178 if (show_zoom_level_checkbox)
180 GtkWidget *vbox, *check_zoom_level;
182 vbox = gtk_vbox_new(FALSE, 0);
183 check_zoom_level = gtk_check_button_new_with_mnemonic(_("_Use current zoom level"));
184 ui_widget_set_tooltip_text(check_zoom_level,
185 _("Renders the font size of the document together with the current zoom level"));
186 gtk_box_pack_start(GTK_BOX(vbox), check_zoom_level, FALSE, FALSE, 0);
187 gtk_widget_show_all(vbox);
188 gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), vbox);
190 g_object_set_data_full(G_OBJECT(dialog), "check_zoom_level",
191 g_object_ref(check_zoom_level), (GDestroyNotify) g_object_unref);
193 exi->have_zoom_level_checkbox = TRUE;
196 g_signal_connect(dialog, "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL);
197 g_signal_connect(dialog, "response", G_CALLBACK(on_file_save_dialog_response), exi);
199 gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(geany->main_widgets->window));
201 /* if the current document has a filename we use it as the default. */
202 gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog));
203 if (doc->file_name != NULL)
205 gchar *base_name = g_path_get_basename(doc->file_name);
206 gchar *short_name = utils_remove_ext_from_filename(base_name);
207 gchar *file_name;
208 gchar *locale_filename;
209 gchar *locale_dirname;
210 gchar *suffix = "";
212 if (g_str_has_suffix(doc->file_name, extension))
213 suffix = "_export";
215 file_name = g_strconcat(short_name, suffix, extension, NULL);
216 locale_filename = utils_get_locale_from_utf8(doc->file_name);
217 locale_dirname = g_path_get_dirname(locale_filename);
218 /* set the current name to base_name.html which probably doesn't exist yet so
219 * gtk_file_chooser_set_filename() can't be used and we need
220 * gtk_file_chooser_set_current_folder() additionally */
221 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_dirname);
222 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), file_name);
223 g_free(locale_filename);
224 g_free(short_name);
225 g_free(file_name);
226 g_free(base_name);
228 else
230 const gchar *default_open_path = geany->prefs->default_open_path;
231 gchar *fname = g_strconcat(GEANY_STRING_UNTITLED, extension, NULL);
233 gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(dialog));
234 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), fname);
236 /* use default startup directory(if set) if no files are open */
237 if (NZV(default_open_path) && g_path_is_absolute(default_open_path))
239 gchar *locale_path = utils_get_locale_from_utf8(default_open_path);
240 gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_path);
241 g_free(locale_path);
243 g_free(fname);
245 gtk_dialog_run(GTK_DIALOG(dialog));
249 static void on_menu_create_latex_activate(GtkMenuItem *menuitem, gpointer user_data)
251 create_file_save_as_dialog(".tex", write_latex_file, FALSE);
255 static void on_menu_create_html_activate(GtkMenuItem *menuitem, gpointer user_data)
257 create_file_save_as_dialog(".html", write_html_file, TRUE);
261 static void write_data(const gchar *filename, const gchar *data)
263 gint error_nr = utils_write_file(filename, data);
264 gchar *utf8_filename = utils_get_utf8_from_locale(filename);
266 if (error_nr == 0)
267 ui_set_statusbar(TRUE, _("Document successfully exported as '%s'."), utf8_filename);
268 else
269 ui_set_statusbar(TRUE, _("File '%s' could not be written (%s)."),
270 utf8_filename, g_strerror(error_nr));
272 g_free(utf8_filename);
276 static gchar *get_date(gint type)
278 gchar *format;
280 if (type == DATE_TYPE_HTML)
281 /* needs testing */
282 #ifdef _GNU_SOURCE
283 format = "%Y-%m-%dT%H:%M:%S%z";
284 #else
285 format = "%Y-%m-%dT%H:%M:%S";
286 #endif
287 else
288 format = "%c";
290 return utils_get_date_time(format, NULL);
294 static void on_file_save_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
296 ExportInfo *exi = user_data;
298 if (response == GTK_RESPONSE_ACCEPT && exi != NULL)
300 gchar *new_filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
301 gchar *utf8_filename;
302 gboolean use_zoom_level = FALSE;
304 if (exi->have_zoom_level_checkbox)
306 use_zoom_level = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
307 ui_lookup_widget(GTK_WIDGET(dialog), "check_zoom_level")));
310 utf8_filename = utils_get_utf8_from_locale(new_filename);
312 /* check if file exists and ask whether to overwrite or not */
313 if (g_file_test(new_filename, G_FILE_TEST_EXISTS))
315 if (dialogs_show_question(
316 _("The file '%s' already exists. Do you want to overwrite it?"),
317 utf8_filename) == FALSE)
318 return;
321 exi->export_func(exi->doc, new_filename, use_zoom_level);
323 g_free(utf8_filename);
324 g_free(new_filename);
326 g_free(exi);
327 gtk_widget_destroy(GTK_WIDGET(dialog));
331 static void write_latex_file(GeanyDocument *doc, const gchar *filename, gboolean use_zoom)
333 GeanyEditor *editor = doc->editor;
334 gint i, doc_len, style = -1, old_style = 0, column = 0;
335 gchar c, c_next, *tmp, *date;
336 /* 0 - fore, 1 - back, 2 - bold, 3 - italic, 4 - font size, 5 - used(0/1) */
337 gint styles[STYLE_MAX + 1][MAX_TYPES];
338 gboolean block_open = FALSE;
339 GString *body;
340 GString *cmds;
341 GString *latex;
342 gint style_max = pow(2, scintilla_send_message(doc->editor->sci, SCI_GETSTYLEBITS, 0, 0));
344 /* first read all styles from Scintilla */
345 for (i = 0; i < style_max; i++)
347 styles[i][FORE] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETFORE, i, 0);
348 styles[i][BACK] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBACK, i, 0);
349 styles[i][BOLD] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBOLD, i, 0);
350 styles[i][ITALIC] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETITALIC, i, 0);
351 styles[i][USED] = 0;
354 /* read the document and write the LaTeX code */
355 body = g_string_new("");
356 doc_len = sci_get_length(doc->editor->sci);
357 for (i = 0; i < doc_len; i++)
359 style = sci_get_style_at(doc->editor->sci, i);
360 c = sci_get_char_at(doc->editor->sci, i);
361 c_next = sci_get_char_at(doc->editor->sci, i + 1);
363 if (style != old_style || ! block_open)
365 old_style = style;
366 styles[style][USED] = 1;
367 if (block_open)
369 g_string_append(body, "}\n");
370 block_open = FALSE;
372 g_string_append_printf(body, "\\style%s{", get_tex_style(style));
374 block_open = TRUE;
376 /* escape the current character if necessary else just add it */
377 switch (c)
379 case '\r':
380 case '\n':
382 if (c == '\r' && c_next == '\n')
383 continue; /* when using CR/LF skip CR and add the line break with LF */
385 if (block_open)
387 g_string_append(body, "}");
388 block_open = FALSE;
390 g_string_append(body, " \\\\\n");
391 column = -1;
392 break;
394 case '\t':
396 gint tab_width = sci_get_tab_width(editor->sci);
397 gint tab_stop = tab_width - (column % tab_width);
399 column += tab_stop - 1; /* -1 because we add 1 at the end of the loop */
400 g_string_append_printf(body, "\\hspace*{%dem}", tab_stop);
401 break;
403 case ' ':
405 if (c_next == ' ')
407 g_string_append(body, "{\\hspace*{1em}}");
408 i++; /* skip the next character */
410 else
411 g_string_append_c(body, ' ');
412 break;
414 case '{':
415 case '}':
416 case '_':
417 case '&':
418 case '$':
419 case '#':
420 case '%':
422 g_string_append_printf(body, "\\%c", c);
423 break;
425 case '\\':
427 g_string_append(body, "\\symbol{92}");
428 break;
430 case '~':
432 g_string_append(body, "\\symbol{126}");
433 break;
435 case '^':
437 g_string_append(body, "\\symbol{94}");
438 break;
440 /** TODO still don't work for "---" or "----" */
441 case '-': /* mask "--" */
443 if (c_next == '-')
445 g_string_append(body, "-\\/-");
446 i++; /* skip the next character */
448 else
449 g_string_append_c(body, '-');
451 break;
453 case '<': /* mask "<<" */
455 if (c_next == '<')
457 g_string_append(body, "<\\/<");
458 i++; /* skip the next character */
460 else
461 g_string_append_c(body, '<');
463 break;
465 case '>': /* mask ">>" */
467 if (c_next == '>')
469 g_string_append(body, ">\\/>");
470 i++; /* skip the next character */
472 else
473 g_string_append_c(body, '>');
475 break;
477 default: g_string_append_c(body, c);
479 column++;
481 if (block_open)
483 g_string_append(body, "}\n");
484 block_open = FALSE;
487 /* force writing of style 0 (used at least for line breaks) */
488 styles[0][USED] = 1;
490 /* write used styles in the header */
491 cmds = g_string_new("");
492 for (i = 0; i <= STYLE_MAX; i++)
494 if (styles[i][USED])
496 g_string_append_printf(cmds,
497 "\\newcommand{\\style%s}[1]{\\noindent{", get_tex_style(i));
498 if (styles[i][BOLD])
499 g_string_append(cmds, "\\textbf{");
500 if (styles[i][ITALIC])
501 g_string_append(cmds, "\\textit{");
503 tmp = get_tex_rgb(styles[i][FORE]);
504 g_string_append_printf(cmds, "\\textcolor[rgb]{%s}{", tmp);
505 g_free(tmp);
506 tmp = get_tex_rgb(styles[i][BACK]);
507 g_string_append_printf(cmds, "\\fcolorbox[rgb]{0, 0, 0}{%s}{", tmp);
508 g_string_append(cmds, "#1}}");
509 g_free(tmp);
511 if (styles[i][BOLD])
512 g_string_append_c(cmds, '}');
513 if (styles[i][ITALIC])
514 g_string_append_c(cmds, '}');
515 g_string_append(cmds, "}}\n");
519 date = get_date(DATE_TYPE_DEFAULT);
520 /* write all */
521 latex = g_string_new(TEMPLATE_LATEX);
522 utils_string_replace_all(latex, "{export_content}", body->str);
523 utils_string_replace_all(latex, "{export_styles}", cmds->str);
524 utils_string_replace_all(latex, "{export_date}", date);
525 if (doc->file_name == NULL)
526 utils_string_replace_all(latex, "{export_filename}", GEANY_STRING_UNTITLED);
527 else
528 utils_string_replace_all(latex, "{export_filename}", doc->file_name);
530 write_data(filename, latex->str);
532 g_string_free(body, TRUE);
533 g_string_free(cmds, TRUE);
534 g_string_free(latex, TRUE);
535 g_free(date);
539 static void write_html_file(GeanyDocument *doc, const gchar *filename, gboolean use_zoom)
541 GeanyEditor *editor = doc->editor;
542 gint i, doc_len, style = -1, old_style = 0, column = 0;
543 gchar c, c_next, *date;
544 /* 0 - fore, 1 - back, 2 - bold, 3 - italic, 4 - font size, 5 - used(0/1) */
545 gint styles[STYLE_MAX + 1][MAX_TYPES];
546 gboolean span_open = FALSE;
547 const gchar *font_name;
548 gint font_size;
549 PangoFontDescription *font_desc;
550 GString *body;
551 GString *css;
552 GString *html;
553 gint style_max = pow(2, scintilla_send_message(doc->editor->sci, SCI_GETSTYLEBITS, 0, 0));
555 /* first read all styles from Scintilla */
556 for (i = 0; i < style_max; i++)
558 styles[i][FORE] = ROTATE_RGB(scintilla_send_message(doc->editor->sci, SCI_STYLEGETFORE, i, 0));
559 styles[i][BACK] = ROTATE_RGB(scintilla_send_message(doc->editor->sci, SCI_STYLEGETBACK, i, 0));
560 styles[i][BOLD] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETBOLD, i, 0);
561 styles[i][ITALIC] = scintilla_send_message(doc->editor->sci, SCI_STYLEGETITALIC, i, 0);
562 styles[i][USED] = 0;
565 /* read Geany's font and font size */
566 font_desc = pango_font_description_from_string(geany->interface_prefs->editor_font);
567 font_name = pango_font_description_get_family(font_desc);
568 /*font_size = pango_font_description_get_size(font_desc) / PANGO_SCALE;*/
569 /* take the zoom level also into account */
570 font_size = scintilla_send_message(doc->editor->sci, SCI_STYLEGETSIZE, 0, 0);
571 if (use_zoom)
572 font_size += scintilla_send_message(doc->editor->sci, SCI_GETZOOM, 0, 0);
574 /* read the document and write the HTML body */
575 body = g_string_new("");
576 doc_len = sci_get_length(doc->editor->sci);
577 for (i = 0; i < doc_len; i++)
579 style = sci_get_style_at(doc->editor->sci, i);
580 c = sci_get_char_at(doc->editor->sci, i);
581 /* sci_get_char_at() takes care of index boundaries and return 0 if i is too high */
582 c_next = sci_get_char_at(doc->editor->sci, i + 1);
584 if ((style != old_style || ! span_open) && ! isspace(c))
586 old_style = style;
587 styles[style][USED] = 1;
588 if (span_open)
590 g_string_append(body, "</span>");
592 g_string_append_printf(body, "<span class=\"style_%d\">", style);
594 span_open = TRUE;
596 /* escape the current character if necessary else just add it */
597 switch (c)
599 case '\r':
600 case '\n':
602 if (c == '\r' && c_next == '\n')
603 continue; /* when using CR/LF skip CR and add the line break with LF */
605 if (span_open)
607 g_string_append(body, "</span>");
608 span_open = FALSE;
610 g_string_append(body, "<br />\n");
611 column = -1;
612 break;
614 case '\t':
616 gint j;
617 gint tab_width = sci_get_tab_width(editor->sci);
618 gint tab_stop = tab_width - (column % tab_width);
620 column += tab_stop - 1; /* -1 because we add 1 at the end of the loop */
621 for (j = 0; j < tab_stop; j++)
623 g_string_append(body, "&nbsp;");
625 break;
627 case ' ':
629 g_string_append(body, "&nbsp;");
630 break;
632 case '<':
634 g_string_append(body, "&lt;");
635 break;
637 case '>':
639 g_string_append(body, "&gt;");
640 break;
642 case '&':
644 g_string_append(body, "&amp;");
645 break;
647 default: g_string_append_c(body, c);
649 column++;
651 if (span_open)
653 g_string_append(body, "</span>");
654 span_open = FALSE;
657 /* write used styles in the header */
658 css = g_string_new("");
659 g_string_append_printf(css,
660 "\tbody\n\t{\n\t\tfont-family: %s, monospace;\n\t\tfont-size: %dpt;\n\t}\n",
661 font_name, font_size);
663 for (i = 0; i <= STYLE_MAX; i++)
665 if (styles[i][USED])
667 g_string_append_printf(css,
668 "\t.style_%d\n\t{\n\t\tcolor: #%06x;\n\t\tbackground-color: #%06x;\n%s%s\t}\n",
669 i, styles[i][FORE], styles[i][BACK],
670 (styles[i][BOLD]) ? "\t\tfont-weight: bold;\n" : "",
671 (styles[i][ITALIC]) ? "\t\tfont-style: italic;\n" : "");
675 date = get_date(DATE_TYPE_HTML);
676 /* write all */
677 html = g_string_new(TEMPLATE_HTML);
678 utils_string_replace_all(html, "{export_date}", date);
679 utils_string_replace_all(html, "{export_content}", body->str);
680 utils_string_replace_all(html, "{export_styles}", css->str);
681 if (doc->file_name == NULL)
682 utils_string_replace_all(html, "{export_filename}", GEANY_STRING_UNTITLED);
683 else
684 utils_string_replace_all(html, "{export_filename}", doc->file_name);
686 write_data(filename, html->str);
688 pango_font_description_free(font_desc);
689 g_string_free(body, TRUE);
690 g_string_free(css, TRUE);
691 g_string_free(html, TRUE);
692 g_free(date);
696 void plugin_init(GeanyData *data)
698 GtkWidget *menu_export;
699 GtkWidget *menu_export_menu;
700 GtkWidget *menu_create_html;
701 GtkWidget *menu_create_latex;
703 menu_export = gtk_image_menu_item_new_with_mnemonic(_("_Export"));
704 gtk_container_add(GTK_CONTAINER(geany->main_widgets->tools_menu), menu_export);
706 menu_export_menu = gtk_menu_new ();
707 gtk_menu_item_set_submenu(GTK_MENU_ITEM(menu_export), menu_export_menu);
709 /* HTML */
710 menu_create_html = gtk_menu_item_new_with_mnemonic(_("As _HTML"));
711 gtk_container_add(GTK_CONTAINER (menu_export_menu), menu_create_html);
713 g_signal_connect(menu_create_html, "activate", G_CALLBACK(on_menu_create_html_activate), NULL);
715 /* LaTeX */
716 menu_create_latex = gtk_menu_item_new_with_mnemonic(_("As _LaTeX"));
717 gtk_container_add(GTK_CONTAINER (menu_export_menu), menu_create_latex);
719 g_signal_connect(menu_create_latex, "activate",
720 G_CALLBACK(on_menu_create_latex_activate), NULL);
722 /* disable menu_item when there are no documents open */
723 ui_add_document_sensitive(menu_export);
724 main_menu_item = menu_export;
726 gtk_widget_show_all(menu_export);
730 void plugin_cleanup(void)
732 gtk_widget_destroy(main_menu_item);