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 static 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_widget_set_sensitive(uri_label
, FALSE
);
122 gtk_table_attach(GTK_TABLE (table2
), uri_label
, 0, 1, 0, 1,
123 (GtkAttachOptions
) (GTK_FILL
),
124 (GtkAttachOptions
) (0), 0, 2);
125 gtk_label_set_justify(GTK_LABEL (uri_label
), GTK_JUSTIFY_RIGHT
);
126 gtk_misc_set_alignment(GTK_MISC (uri_label
), 1, 0.5);
128 uri_combo
= gtk_combo_new ();
129 gtk_widget_show (uri_combo
);
131 gtk_widget_set_sensitive(uri_combo
, FALSE
);
133 gtk_table_attach (GTK_TABLE (table2
), uri_combo
, 1, 2, 0, 1,
134 GTK_EXPAND
| GTK_FILL
, 0, 0, 0);
135 gtkut_combo_set_items (GTK_COMBO (uri_combo
),
137 "galeon --new-tab '%s'",
139 "mozilla -remote 'openurl(%s,new-window)'",
140 "netscape -remote 'openURL(%s, new-window)'",
142 "gnome-moz-remote --newwin '%s'",
143 "kfmclient openURL '%s'",
144 "opera -newwindow '%s'",
148 uri_entry
= GTK_COMBO (uri_combo
)->entry
;
149 gtk_entry_set_text(GTK_ENTRY(uri_entry
), prefs_common
.uri_cmd
? prefs_common
.uri_cmd
: "");
151 exteditor_label
= gtk_label_new (_("Text editor"));
152 gtk_widget_show(exteditor_label
);
154 gtk_table_attach(GTK_TABLE (table2
), exteditor_label
, 0, 1, 1, 2,
155 (GtkAttachOptions
) (GTK_FILL
),
156 (GtkAttachOptions
) (0), 0, 2);
157 gtk_label_set_justify(GTK_LABEL (exteditor_label
), GTK_JUSTIFY_RIGHT
);
158 gtk_misc_set_alignment(GTK_MISC (exteditor_label
), 1, 0.5);
160 exteditor_combo
= gtk_combo_new ();
161 gtk_widget_show (exteditor_combo
);
162 gtk_table_attach (GTK_TABLE (table2
), exteditor_combo
, 1, 2, 1, 2,
163 GTK_EXPAND
| GTK_FILL
, 0, 0, 0);
164 gtkut_combo_set_items (GTK_COMBO (exteditor_combo
),
169 "mgedit --no-fork %s",
175 exteditor_entry
= GTK_COMBO (exteditor_combo
)->entry
;
176 gtk_entry_set_text(GTK_ENTRY(exteditor_entry
),
177 prefs_common
.ext_editor_cmd
? prefs_common
.ext_editor_cmd
: "");
179 astextviewer_label
= gtk_label_new(_("Command for 'Display as text'"));
180 gtk_widget_show(astextviewer_label
);
182 gtk_table_attach(GTK_TABLE (table2
), astextviewer_label
, 0, 1, 2, 3,
183 (GtkAttachOptions
) (GTK_FILL
),
184 (GtkAttachOptions
) (0), 0, 2);
185 gtk_label_set_justify(GTK_LABEL (astextviewer_label
), GTK_JUSTIFY_RIGHT
);
186 gtk_misc_set_alignment(GTK_MISC (astextviewer_label
), 1, 0.5);
188 astextviewer_entry
= gtk_entry_new ();
189 gtk_widget_show(astextviewer_entry
);
190 gtk_tooltips_set_tip(GTK_TOOLTIPS(tooltip
), astextviewer_entry
,
191 _("This option enables MIME parts to be displayed in the "
192 "message view via a script when using the 'Display as text' "
193 "contextual menu item"),
196 gtk_table_attach(GTK_TABLE (table2
), astextviewer_entry
, 1, 2, 2, 3,
197 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
198 (GtkAttachOptions
) (0), 0, 0);
199 gtk_entry_set_text(GTK_ENTRY(astextviewer_entry
),
200 prefs_common
.mime_textviewer
? prefs_common
.mime_textviewer
: "");
202 printcmd_label
= gtk_label_new (_("Print command"));
203 #ifndef USE_GNOMEPRINT
204 gtk_widget_show(printcmd_label
);
206 gtk_table_attach(GTK_TABLE (table2
), printcmd_label
, 0, 1, 3, 4,
207 (GtkAttachOptions
) (GTK_FILL
),
208 (GtkAttachOptions
) (0), 0, 2);
209 gtk_label_set_justify(GTK_LABEL (printcmd_label
), GTK_JUSTIFY_RIGHT
);
210 gtk_misc_set_alignment(GTK_MISC (printcmd_label
), 1, 0.5);
212 printcmd_entry
= gtk_entry_new ();
213 #ifndef USE_GNOMEPRINT
214 gtk_widget_show(printcmd_entry
);
216 gtk_table_attach(GTK_TABLE (table2
), printcmd_entry
, 1, 2, 3, 4,
217 (GtkAttachOptions
) (GTK_EXPAND
| GTK_FILL
),
218 (GtkAttachOptions
) (0), 0, 0);
219 gtk_entry_set_text(GTK_ENTRY(printcmd_entry
), prefs_common
.print_cmd
? prefs_common
.print_cmd
: "");
222 prefs_ext_prog
->window
= GTK_WIDGET(window
);
223 prefs_ext_prog
->uri_entry
= uri_entry
;
224 prefs_ext_prog
->exteditor_entry
= exteditor_entry
;
225 prefs_ext_prog
->astextviewer_entry
= astextviewer_entry
;
226 prefs_ext_prog
->printcmd_entry
= printcmd_entry
;
228 prefs_ext_prog
->page
.widget
= table
;
231 static void prefs_ext_prog_save(PrefsPage
*_page
)
233 ExtProgPage
*ext_prog
= (ExtProgPage
*) _page
;
235 prefs_common
.uri_cmd
= gtk_editable_get_chars
236 (GTK_EDITABLE(ext_prog
->uri_entry
), 0, -1);
237 prefs_common
.print_cmd
= gtk_editable_get_chars
238 (GTK_EDITABLE(ext_prog
->printcmd_entry
), 0, -1);
239 prefs_common
.ext_editor_cmd
= gtk_editable_get_chars
240 (GTK_EDITABLE(ext_prog
->exteditor_entry
), 0, -1);
241 prefs_common
.mime_textviewer
= gtk_editable_get_chars
242 (GTK_EDITABLE(ext_prog
->astextviewer_entry
), 0, -1);
245 static void prefs_ext_prog_destroy_widget(PrefsPage
*_page
)
247 /* ExtProgPage *ext_prog = (ExtProgPage *) _page; */
251 ExtProgPage
*prefs_ext_prog
;
253 void prefs_ext_prog_init(void)
256 static gchar
*path
[3];
258 path
[0] = _("Message View");
259 path
[1] = _("External Programs");
262 page
= g_new0(ExtProgPage
, 1);
263 page
->page
.path
= path
;
264 page
->page
.create_widget
= prefs_ext_prog_create_widget
;
265 page
->page
.destroy_widget
= prefs_ext_prog_destroy_widget
;
266 page
->page
.save_page
= prefs_ext_prog_save
;
267 page
->page
.weight
= 155.0;
268 prefs_gtk_register_page((PrefsPage
*) page
);
269 prefs_ext_prog
= page
;
272 void prefs_ext_prog_done(void)
274 prefs_gtk_unregister_page((PrefsPage
*) prefs_ext_prog
);
275 g_free(prefs_ext_prog
);