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>
33 #include <glib/gi18n.h>
36 #include "common/utils.h"
37 #include "mainwindow.h"
38 #include "prefs_common.h"
42 #include "perl_plugin.h"
45 static void perl_filter_edit(GtkAction *,gpointer);
48 static GtkActionEntry mainwindow_tools_perl_edit[] = {{
49 "Tools/EditPerlRules",
50 NULL, N_("Edit perl filter rules (ext)..."), NULL, NULL, G_CALLBACK(perl_filter_edit)
53 static gint main_menu_id = 0;
56 void perl_gtk_init(void)
60 mainwin = mainwindow_get_mainwindow();
62 gtk_action_group_add_actions(mainwin->action_group, mainwindow_tools_perl_edit,
63 1, (gpointer)mainwin);
64 MENUITEM_ADDUI_ID_MANAGER(mainwin->ui_manager, "/Menu/Tools", "EditPerlRules",
65 "Tools/EditPerlRules", GTK_UI_MANAGER_MENUITEM,
69 void perl_gtk_done(void)
73 mainwin = mainwindow_get_mainwindow();
75 if(mainwin && !claws_is_exiting()) {
76 MENUITEM_REMUI_MANAGER(mainwin->ui_manager,mainwin->action_group, "Tools/EditPerlRules", main_menu_id);
81 static void perl_filter_edit(GtkAction *action, gpointer callback_data)
88 perlfilter = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, PERLFILTER, NULL);
89 if (prefs_common_get_ext_editor_cmd() &&
90 (pp = strchr(prefs_common_get_ext_editor_cmd(), '%')) &&
91 *(pp + 1) == 's' && !strchr(pp + 2, '%')) {
92 g_snprintf(buf, sizeof(buf), prefs_common_get_ext_editor_cmd(), perlfilter);
95 if (prefs_common_get_ext_editor_cmd())
96 g_warning("Perl Plugin: External editor command-line is invalid: `%s'",
97 prefs_common_get_ext_editor_cmd());
98 g_snprintf(buf, sizeof(buf), "emacs %s", perlfilter);
101 cmdline = strsplit_with_quote(buf, " ", 1024);
102 execute_detached(cmdline);