1 /*
2 * This is a plug-in for GIMP.
3 *
4 * Generates clickable image maps.
5 *
6 * Copyright (C) 1998-2002 Maurits Rijk lpeek.mrijk@consunet.nl
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 *
21 */
22
23 #include "config.h"
24
25 #include <stdarg.h>
26 #include <stdio.h>
27
28 #include <gtk/gtk.h>
29
30 #include "imap_default_dialog.h"
31 #include "imap_main.h"
32 #include "imap_source.h"
33
34 #include "libgimp/stdplugins-intl.h"
35
36 static void save_to_view (GtkTextBuffer *buffer,
37 const char *format,
38 ...) G_GNUC_PRINTF(2,3);
39
40 static void
save_to_view(GtkTextBuffer * buffer,const char * format,...)41 save_to_view(GtkTextBuffer *buffer, const char* format, ...)
42 {
43 va_list ap;
44 char scratch[1024];
45 GtkTextIter iter;
46
47 va_start(ap, format);
48 vsprintf(scratch, format, ap);
49 va_end(ap);
50
51 gtk_text_buffer_get_end_iter(buffer, &iter);
52 gtk_text_buffer_insert(buffer, &iter, scratch, -1);
53 }
54
55 void
do_source_dialog(void)56 do_source_dialog(void)
57 {
58 static DefaultDialog_t *dialog;
59 static GtkWidget *text;
60 static GtkTextBuffer *buffer;
61
62 if (!dialog)
63 {
64 GtkWidget *swin;
65
66 dialog = make_default_dialog(_("View Source"));
67 default_dialog_hide_cancel_button(dialog);
68 default_dialog_hide_apply_button(dialog);
69
70 buffer = gtk_text_buffer_new(NULL);
71
72 text = gtk_text_view_new_with_buffer(buffer);
73 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
74 gtk_widget_show(text);
75
76 swin = gtk_scrolled_window_new(NULL, NULL);
77 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(swin),
78 GTK_SHADOW_IN);
79 gtk_widget_set_size_request(swin, 400, 300);
80 gtk_box_pack_start(GTK_BOX(dialog->vbox), swin, TRUE, TRUE, 0);
81 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
82 GTK_POLICY_AUTOMATIC,
83 GTK_POLICY_AUTOMATIC);
84 gtk_widget_show(swin);
85 gtk_container_add(GTK_CONTAINER(swin), text);
86 }
87 gtk_text_buffer_set_text(buffer, "", -1);
88 dump_output(buffer, (OutputFunc_t) save_to_view);
89
90 default_dialog_show(dialog);
91 }
92