1 /* Perl plugin -- Perl Support for Claws Mail
3 * Copyright (C) 2004-2007 Holger Berndt
5 * Sylpheed and Claws Mail are GTK based, lightweight, and fast e-mail clients
6 * Copyright (C) 1999-2007 Hiroyuki Yamamoto and the Claws Mail Team
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.
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.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include "claws-features.h"
28 #include <glib/gi18n.h>
34 #include "common/utils.h"
35 #include "mainwindow.h"
36 #include "prefs_common.h"
40 #include "perl_plugin.h"
43 static void perl_filter_edit(GtkAction
*,gpointer
);
46 static GtkActionEntry mainwindow_tools_perl_edit
[] = {{
47 "Tools/EditPerlRules",
48 NULL
, N_("Edit perl filter rules (ext)..."), NULL
, NULL
, G_CALLBACK(perl_filter_edit
)
51 static gint main_menu_id
= 0;
54 void perl_gtk_init(void)
58 mainwin
= mainwindow_get_mainwindow();
60 gtk_action_group_add_actions(mainwin
->action_group
, mainwindow_tools_perl_edit
,
61 1, (gpointer
)mainwin
);
62 MENUITEM_ADDUI_ID_MANAGER(mainwin
->ui_manager
, "/Menu/Tools", "EditPerlRules",
63 "Tools/EditPerlRules", GTK_UI_MANAGER_MENUITEM
,
67 void perl_gtk_done(void)
71 mainwin
= mainwindow_get_mainwindow();
73 if(mainwin
&& !claws_is_exiting()) {
74 MENUITEM_REMUI_MANAGER(mainwin
->ui_manager
,mainwin
->action_group
, "Tools/EditPerlRules", main_menu_id
);
79 static void perl_filter_edit(GtkAction
*action
, gpointer callback_data
)
86 perlfilter
= g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S
, PERLFILTER
, NULL
);
87 if (prefs_common_get_ext_editor_cmd() &&
88 (pp
= strchr(prefs_common_get_ext_editor_cmd(), '%')) &&
89 *(pp
+ 1) == 's' && !strchr(pp
+ 2, '%')) {
90 g_snprintf(buf
, sizeof(buf
), prefs_common_get_ext_editor_cmd(), perlfilter
);
93 if (prefs_common_get_ext_editor_cmd())
94 g_warning("Perl plugin: external editor command-line is invalid: `%s'",
95 prefs_common_get_ext_editor_cmd());
96 g_snprintf(buf
, sizeof(buf
), "emacs %s", perlfilter
);
99 cmdline
= strsplit_with_quote(buf
, " ", 1024);
100 execute_detached(cmdline
);