2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2004 Hiroyuki Yamamoto & 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 2 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, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30 #include <glib/gi18n.h>
32 #include <gdk/gdkkeysyms.h>
35 #include "prefs_common.h"
36 #include "prefs_gtk.h"
38 #include "gtk/gtkutils.h"
39 #include "gtk/prefswindow.h"
41 #include "manage_window.h"
43 typedef struct _ExtProgPage
47 GtkWidget
*window
; /* do not modify */
53 GtkWidget
*printcmd_label
;
54 GtkWidget
*printcmd_entry
;
56 GtkWidget
*exteditor_label
;
57 GtkWidget
*exteditor_combo
;
58 GtkWidget
*exteditor_entry
;
60 GtkWidget
*astextviewer_label
;
61 GtkWidget
*astextviewer_entry
;
64 void prefs_ext_prog_create_widget(PrefsPage
*_page
, GtkWindow
*window
,
67 ExtProgPage
*prefs_ext_prog
= (ExtProgPage
*) _page
;
71 GtkWidget
*hint_label
;
76 GtkWidget
*exteditor_label
;
77 GtkWidget
*exteditor_combo
;
78 GtkWidget
*exteditor_entry
;
79 GtkWidget
*astextviewer_label
;
80 GtkWidget
*astextviewer_entry
;
81 GtkWidget
*printcmd_label
;
82 GtkWidget
*printcmd_entry
;
85 tooltip
= gtk_tooltips_new();
87 table
= gtk_table_new(2, 1, FALSE
);
88 gtk_widget_show(table
);
89 gtk_container_set_border_width(GTK_CONTAINER(table
), 8);
90 gtk_table_set_row_spacings(GTK_TABLE(table
), 4);
91 gtk_table_set_col_spacings(GTK_TABLE(table
), 8);
93 vbox
= gtk_vbox_new(TRUE
, 0);
94 gtk_widget_show(vbox
);
96 gtk_table_attach(GTK_TABLE (table
), vbox
, 0, 1, 0, 1,
97 (GtkAttachOptions
) (GTK_SHRINK
),
98 (GtkAttachOptions
) (0), 0, 0);
100 hint_label
= gtk_label_new(_("%s will be replaced with file name / URI"));
101 gtk_label_set_justify (GTK_LABEL (hint_label
), GTK_JUSTIFY_LEFT
);
102 gtkut_widget_set_small_font_size (hint_label
);
103 gtk_widget_show(hint_label
);
104 gtk_box_pack_start(GTK_BOX (vbox
),
105 hint_label
, FALSE
, FALSE
, 4);
107 table2
= gtk_table_new(6, 2, FALSE
);
108 gtk_widget_show(table2
);
109 gtk_container_set_border_width(GTK_CONTAINER(table2
), 8);
110 gtk_table_set_row_spacings(GTK_TABLE(table2
), 4);
111 gtk_table_set_col_spacings(GTK_TABLE(table2
), 8);
113 gtk_table_attach(GTK_TABLE (table
), table2
, 0, 1, 1, 2,
114 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
115 (GtkAttachOptions
) (0), 0, 0);
117 uri_label
= gtk_label_new (_("Web browser"));
118 gtk_widget_show(uri_label
);
120 gtk_table_attach(GTK_TABLE (table2
), uri_label
, 0, 1, 0, 1,
121 (GtkAttachOptions
) (GTK_FILL
),
122 (GtkAttachOptions
) (0), 0, 2);
123 gtk_label_set_justify(GTK_LABEL (uri_label
), GTK_JUSTIFY_RIGHT
);
124 gtk_misc_set_alignment(GTK_MISC (uri_label
), 1, 0.5);
126 uri_combo
= gtk_combo_new ();
127 gtk_widget_show (uri_combo
);
128 gtk_table_attach (GTK_TABLE (table2
), uri_combo
, 1, 2, 0, 1,
129 GTK_EXPAND
| GTK_FILL
, 0, 0, 0);
130 gtkut_combo_set_items (GTK_COMBO (uri_combo
),
132 "galeon --new-tab '%s'",
134 "mozilla -remote 'openurl(%s,new-window)'",
135 "netscape -remote 'openURL(%s, new-window)'",
137 "gnome-moz-remote --newwin '%s'",
138 "kfmclient openURL '%s'",
139 "opera -newwindow '%s'",
143 uri_entry
= GTK_COMBO (uri_combo
)->entry
;
144 gtk_entry_set_text(GTK_ENTRY(uri_entry
), prefs_common
.uri_cmd
? prefs_common
.uri_cmd
: "");
146 exteditor_label
= gtk_label_new (_("Text editor"));
147 gtk_widget_show(exteditor_label
);
149 gtk_table_attach(GTK_TABLE (table2
), exteditor_label
, 0, 1, 1, 2,
150 (GtkAttachOptions
) (GTK_FILL
),
151 (GtkAttachOptions
) (0), 0, 2);
152 gtk_label_set_justify(GTK_LABEL (exteditor_label
), GTK_JUSTIFY_RIGHT
);
153 gtk_misc_set_alignment(GTK_MISC (exteditor_label
), 1, 0.5);
155 exteditor_combo
= gtk_combo_new ();
156 gtk_widget_show (exteditor_combo
);
157 gtk_table_attach (GTK_TABLE (table2
), exteditor_combo
, 1, 2, 1, 2,
158 GTK_EXPAND
| GTK_FILL
, 0, 0, 0);
159 gtkut_combo_set_items (GTK_COMBO (exteditor_combo
),
163 "mgedit --no-fork %s",
169 exteditor_entry
= GTK_COMBO (exteditor_combo
)->entry
;
170 gtk_entry_set_text(GTK_ENTRY(exteditor_entry
),
171 prefs_common
.ext_editor_cmd
? prefs_common
.ext_editor_cmd
: "");
173 astextviewer_label
= gtk_label_new(_("Command for 'Display as text'"));
174 gtk_widget_show(astextviewer_label
);
176 gtk_table_attach(GTK_TABLE (table2
), astextviewer_label
, 0, 1, 2, 3,
177 (GtkAttachOptions
) (GTK_FILL
),
178 (GtkAttachOptions
) (0), 0, 2);
179 gtk_label_set_justify(GTK_LABEL (astextviewer_label
), GTK_JUSTIFY_RIGHT
);
180 gtk_misc_set_alignment(GTK_MISC (astextviewer_label
), 1, 0.5);
182 astextviewer_entry
= gtk_entry_new ();
183 gtk_widget_show(astextviewer_entry
);
184 gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltip
), astextviewer_entry
,
185 _("This option enables MIME parts to be displayed in the "
186 "message view via a script when using the 'Display as text' "
187 "contextual menu item"),
190 gtk_table_attach(GTK_TABLE (table2
), astextviewer_entry
, 1, 2, 2, 3,
191 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
192 (GtkAttachOptions
) (0), 0, 0);
193 gtk_entry_set_text(GTK_ENTRY(astextviewer_entry
),
194 prefs_common
.mime_textviewer
? prefs_common
.mime_textviewer
: "");
196 printcmd_label
= gtk_label_new (_("Print command"));
197 #ifndef USE_GNOMEPRINT
198 gtk_widget_show(printcmd_label
);
200 gtk_table_attach(GTK_TABLE (table2
), printcmd_label
, 0, 1, 3, 4,
201 (GtkAttachOptions
) (GTK_FILL
),
202 (GtkAttachOptions
) (0), 0, 2);
203 gtk_label_set_justify(GTK_LABEL (printcmd_label
), GTK_JUSTIFY_RIGHT
);
204 gtk_misc_set_alignment(GTK_MISC (printcmd_label
), 1, 0.5);
206 printcmd_entry
= gtk_entry_new ();
207 #ifndef USE_GNOMEPRINT
208 gtk_widget_show(printcmd_entry
);
210 gtk_table_attach(GTK_TABLE (table2
), printcmd_entry
, 1, 2, 3, 4,
211 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
212 (GtkAttachOptions
) (0), 0, 0);
213 gtk_entry_set_text(GTK_ENTRY(printcmd_entry
), prefs_common
.print_cmd
? prefs_common
.print_cmd
: "");
216 prefs_ext_prog
->window
= GTK_WIDGET(window
);
217 prefs_ext_prog
->uri_entry
= uri_entry
;
218 prefs_ext_prog
->exteditor_entry
= exteditor_entry
;
219 prefs_ext_prog
->astextviewer_entry
= astextviewer_entry
;
220 prefs_ext_prog
->printcmd_entry
= printcmd_entry
;
222 prefs_ext_prog
->page
.widget
= table
;
225 void prefs_ext_prog_save(PrefsPage
*_page
)
227 ExtProgPage
*ext_prog
= (ExtProgPage
*) _page
;
229 prefs_common
.uri_cmd
= gtk_editable_get_chars
230 (GTK_EDITABLE(ext_prog
->uri_entry
), 0, -1);
231 prefs_common
.print_cmd
= gtk_editable_get_chars
232 (GTK_EDITABLE(ext_prog
->printcmd_entry
), 0, -1);
233 prefs_common
.ext_editor_cmd
= gtk_editable_get_chars
234 (GTK_EDITABLE(ext_prog
->exteditor_entry
), 0, -1);
235 prefs_common
.mime_textviewer
= gtk_editable_get_chars
236 (GTK_EDITABLE(ext_prog
->astextviewer_entry
), 0, -1);
239 static void prefs_ext_prog_destroy_widget(PrefsPage
*_page
)
241 /* ExtProgPage *ext_prog = (ExtProgPage *) _page; */
245 ExtProgPage
*prefs_ext_prog
;
247 void prefs_ext_prog_init(void)
250 static gchar
*path
[3];
252 path
[0] = _("Message View");
253 path
[1] = _("External Programs");
256 page
= g_new0(ExtProgPage
, 1);
257 page
->page
.path
= path
;
258 page
->page
.create_widget
= prefs_ext_prog_create_widget
;
259 page
->page
.destroy_widget
= prefs_ext_prog_destroy_widget
;
260 page
->page
.save_page
= prefs_ext_prog_save
;
261 page
->page
.weight
= 155.0;
262 prefs_gtk_register_page((PrefsPage
*) page
);
263 prefs_ext_prog
= page
;
266 void prefs_ext_prog_done(void)
268 prefs_gtk_unregister_page((PrefsPage
*) prefs_ext_prog
);
269 g_free(prefs_ext_prog
);