From 108f51c24634425ea9b7b5c04ce18ca39567fcc9 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Sun, 2 Sep 2007 15:42:17 -0500 Subject: [PATCH] Allow better filters for user tools --- moo/mooedit/glade/mooedittools.glade | 51 +++--- moo/mooedit/mooeditaction.c | 51 ++---- moo/mooedit/mooeditfiltersettings.c | 224 +++++++++++++++++++++++++ moo/mooedit/mooeditfiltersettings.h | 20 ++- moo/mooedit/mooeditwindow.c | 72 ++++---- moo/mooedit/mooeditwindow.h | 4 +- moo/mooedit/moousertools-prefs.c | 10 +- moo/mooedit/moousertools-prefs.h | 2 +- moo/mooedit/moousertools.c | 67 +++----- moo/mooedit/moousertools.h | 2 +- moo/moopython/plugins/python.py | 2 +- moo/moopython/pygtk/mooedit-pygtk.defs | 6 +- 12 files changed, 351 insertions(+), 160 deletions(-) diff --git a/moo/mooedit/glade/mooedittools.glade b/moo/mooedit/glade/mooedittools.glade index deeacbdc..2c959949 100644 --- a/moo/mooedit/glade/mooedittools.glade +++ b/moo/mooedit/glade/mooedittools.glade @@ -17,6 +17,7 @@ True + False GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC GTK_SHADOW_IN @@ -36,8 +37,9 @@ True - False New item + False + 0 True @@ -53,8 +55,9 @@ True - False Delete item + False + 0 True @@ -72,8 +75,9 @@ True - False Move item up + False + 0 True @@ -91,8 +95,9 @@ True - False Move item down + False + 0 True @@ -128,12 +133,19 @@ True 5 2 + + + + + + True Enabled True False + 0 True @@ -155,7 +167,7 @@ - + True @@ -191,29 +203,6 @@ - - - 1 - Filter: - - - 3 - 4 - GTK_FILL - - - - - - - - 1 - 2 - 3 - 4 - - - True @@ -273,6 +262,7 @@ + True False @@ -285,11 +275,12 @@ True window2 - + True True + False GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC GTK_SHADOW_ETCHED_IN @@ -465,6 +456,7 @@ Something True + False GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC GTK_SHADOW_ETCHED_IN @@ -490,6 +482,7 @@ Something True + False GTK_POLICY_AUTOMATIC GTK_POLICY_AUTOMATIC GTK_SHADOW_ETCHED_IN diff --git a/moo/mooedit/mooeditaction.c b/moo/mooedit/mooeditaction.c index ac0c1a73..7a839031 100644 --- a/moo/mooedit/mooeditaction.c +++ b/moo/mooedit/mooeditaction.c @@ -15,6 +15,7 @@ #include "mooedit/mooeditaction.h" #include "mooedit/mooeditaction-factory.h" #include "mooedit/mooedit-private.h" +#include "mooedit/mooeditfiltersettings.h" #include #include @@ -28,7 +29,7 @@ typedef enum { struct _MooEditActionPrivate { MooEdit *doc; - GSList *langs; + MooEditFilter *file_filter; GRegex *filters[N_FILTERS]; }; @@ -48,7 +49,7 @@ G_DEFINE_TYPE (MooEditAction, moo_edit_action, MOO_TYPE_ACTION) enum { PROP_0, PROP_DOC, - PROP_LANGS, + PROP_FILE_FILTER, PROP_FILTER_SENSITIVE, PROP_FILTER_VISIBLE }; @@ -72,8 +73,7 @@ moo_edit_action_finalize (GObject *object) if (action->priv->filters[i]) unuse_filter_regex (action->priv->filters[i]); - g_slist_foreach (action->priv->langs, (GFunc) g_free, NULL); - g_slist_free (action->priv->langs); + _moo_edit_filter_free (action->priv->file_filter); G_OBJECT_CLASS(moo_edit_action_parent_class)->finalize (object); } @@ -118,20 +118,12 @@ moo_edit_action_get_property (GObject *object, static void -string_slist_free (GSList *list) +moo_edit_action_set_file_filter (MooEditAction *action, + const char *string) { - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); -} - - -static void -moo_edit_action_set_langs (MooEditAction *action, - const char *string) -{ - string_slist_free (action->priv->langs); - action->priv->langs = _moo_edit_parse_langs (string); - g_object_notify (G_OBJECT (action), "langs"); + _moo_edit_filter_free (action->priv->file_filter); + action->priv->file_filter = _moo_edit_filter_new (string); + g_object_notify (G_OBJECT (action), "file-filter"); } @@ -173,8 +165,8 @@ moo_edit_action_set_property (GObject *object, g_object_notify (object, "doc"); break; - case PROP_LANGS: - moo_edit_action_set_langs (action, g_value_get_string (value)); + case PROP_FILE_FILTER: + moo_edit_action_set_file_filter (action, g_value_get_string (value)); break; case PROP_FILTER_SENSITIVE: @@ -234,25 +226,18 @@ get_current_line (MooEdit *doc) static gboolean moo_edit_action_check_visible_real (MooEditAction *action) { - MooLang *lang; gboolean visible = TRUE; GRegex *filter = action->priv->filters[FILTER_VISIBLE]; if (!action->priv->doc) return gtk_action_get_visible (GTK_ACTION (action)); - if (!action->priv->langs && !filter) + if (!action->priv->file_filter && !filter) return gtk_action_get_visible (GTK_ACTION (action)); - if (visible && action->priv->langs) - { - lang = moo_text_view_get_lang (MOO_TEXT_VIEW (action->priv->doc)); - - if (!g_slist_find_custom (action->priv->langs, - _moo_lang_id (lang), - (GCompareFunc) strcmp)) + if (visible && action->priv->file_filter) + if (!_moo_edit_filter_match (action->priv->file_filter, action->priv->doc)) visible = FALSE; - } if (visible && filter) { @@ -315,10 +300,10 @@ moo_edit_action_class_init (MooEditActionClass *klass) G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, - PROP_LANGS, - g_param_spec_string ("langs", - "langs", - "langs", + PROP_FILE_FILTER, + g_param_spec_string ("file-filter", + "file-filter", + "file-filter", NULL, G_PARAM_WRITABLE)); diff --git a/moo/mooedit/mooeditfiltersettings.c b/moo/mooedit/mooeditfiltersettings.c index 1b50ec5d..ad21e0d4 100644 --- a/moo/mooedit/mooeditfiltersettings.c +++ b/moo/mooedit/mooeditfiltersettings.c @@ -14,11 +14,16 @@ #define MOOEDIT_COMPILATION #include "mooedit/mooeditfiltersettings.h" #include "mooedit/mooeditprefs.h" +#include "mooedit/mooeditaction.h" #include "mooutils/mooprefs.h" #include "mooutils/mooutils-misc.h" #include "mooutils/mooutils-debug.h" #include #include +#ifndef __WIN32__ +#include +#endif + MOO_DEBUG_INIT(filters, FALSE) @@ -27,6 +32,20 @@ MOO_DEBUG_INIT(filters, FALSE) #define PROP_FILTER "filter" #define PROP_CONFIG "config" +typedef enum { + MOO_EDIT_FILTER_LANGS, + MOO_EDIT_FILTER_GLOBS, + MOO_EDIT_FILTER_REGEX +} MooEditFilterType; + +struct _MooEditFilter { + MooEditFilterType type; + union { + GSList *langs; + GSList *globs; + GRegex *regex; + } u; +}; typedef struct { GRegex *regex; @@ -44,6 +63,211 @@ static char *filter_settings_store_get_setting (FilterSettingsStore *store, const char *filename); +MooEditFilter * +_moo_edit_filter_new (const char *string) +{ + g_return_val_if_fail (string && string[0], NULL); + + if (!strncmp (string, "langs:", strlen ("langs:"))) + return _moo_edit_filter_new_langs (string + strlen ("langs:")); + if (!strncmp (string, "globs:", strlen ("globs:"))) + return _moo_edit_filter_new_globs (string + strlen ("globs:")); + if (!strncmp (string, "regex:", strlen ("regex:"))) + return _moo_edit_filter_new_regex (string + strlen ("regex:")); + + return _moo_edit_filter_new_globs (string); +} + +MooEditFilter * +_moo_edit_filter_new_langs (const char *string) +{ + MooEditFilter *filt; + + g_return_val_if_fail (string != NULL, NULL); + + filt = g_new0 (MooEditFilter, 1); + filt->type = MOO_EDIT_FILTER_LANGS; + filt->u.langs = _moo_edit_parse_langs (string); + + return filt; +} + +MooEditFilter * +_moo_edit_filter_new_regex (const char *string) +{ + MooEditFilter *filt; + GRegex *regex; + GError *error = NULL; + + g_return_val_if_fail (string != NULL, NULL); + + regex = g_regex_new (string, G_REGEX_OPTIMIZE, 0, &error); + + if (!regex) + { + g_warning ("%s: invalid regex '%s': %s", G_STRFUNC, + string, error->message); + g_error_free (NULL); + return NULL; + } + + filt = g_new0 (MooEditFilter, 1); + filt->type = MOO_EDIT_FILTER_REGEX; + filt->u.regex = regex; + + return filt; +} + +static GSList * +parse_globs (const char *string) +{ + char **pieces, **p; + GSList *list = NULL; + + if (!string) + return NULL; + + pieces = g_strsplit_set (string, " \t\r\n;,", 0); + + if (!pieces) + return NULL; + + for (p = pieces; *p != NULL; ++p) + { + g_strstrip (*p); + + if (**p) + list = g_slist_prepend (list, g_strdup (*p)); + } + + g_strfreev (pieces); + return g_slist_reverse (list); +} + +MooEditFilter * +_moo_edit_filter_new_globs (const char *string) +{ + MooEditFilter *filt; + + g_return_val_if_fail (string != NULL, NULL); + + filt = g_new0 (MooEditFilter, 1); + filt->type = MOO_EDIT_FILTER_GLOBS; + filt->u.globs = parse_globs (string); + + return filt; +} + +void +_moo_edit_filter_free (MooEditFilter *filter) +{ + if (filter) + { + switch (filter->type) + { + case MOO_EDIT_FILTER_GLOBS: + case MOO_EDIT_FILTER_LANGS: + g_slist_foreach (filter->u.langs, (GFunc) g_free, NULL); + g_slist_free (filter->u.langs); + break; + case MOO_EDIT_FILTER_REGEX: + g_regex_unref (filter->u.regex); + break; + } + + g_free (filter); + } +} + + +static gboolean +moo_edit_filter_check_globs (GSList *globs, + MooEdit *doc) +{ + char *name = NULL; + + name = moo_edit_get_filename (doc); + + if (name) + { + char *tmp = name; + name = g_path_get_basename (tmp); + g_free (tmp); + } + + while (globs) + { + if (name) + { + if (fnmatch (globs->data, name, 0) == 0) + { + g_free (name); + return TRUE; + } + } + else + { + if (!strcmp (globs->data, "*")) + return TRUE; + } + + globs = globs->next; + } + + g_free (name); + return FALSE; +} + +static gboolean +moo_edit_filter_check_langs (GSList *langs, + MooEdit *doc) +{ + MooLang *lang; + const char *id; + + lang = moo_text_view_get_lang (MOO_TEXT_VIEW (doc)); + id = _moo_lang_id (lang); + + while (langs) + { + if (!strcmp (langs->data, id)) + return TRUE; + langs = langs->next; + } + + return FALSE; +} + +static gboolean +moo_edit_filter_check_regex (GRegex *regex, + MooEdit *doc) +{ + const char *name = moo_edit_get_display_name (doc); + g_return_val_if_fail (name != NULL, FALSE); + return g_regex_match (regex, name, 0, NULL); +} + +gboolean +_moo_edit_filter_match (MooEditFilter *filter, + MooEdit *doc) +{ + g_return_val_if_fail (filter != NULL, FALSE); + g_return_val_if_fail (MOO_IS_EDIT (doc), FALSE); + + switch (filter->type) + { + case MOO_EDIT_FILTER_GLOBS: + return moo_edit_filter_check_globs (filter->u.globs, doc); + case MOO_EDIT_FILTER_LANGS: + return moo_edit_filter_check_langs (filter->u.langs, doc); + case MOO_EDIT_FILTER_REGEX: + return moo_edit_filter_check_regex (filter->u.regex, doc); + } + + g_return_val_if_reached (FALSE); +} + + static void filter_setting_free (FilterSetting *setting) { diff --git a/moo/mooedit/mooeditfiltersettings.h b/moo/mooedit/mooeditfiltersettings.h index e31a58c0..79447248 100644 --- a/moo/mooedit/mooeditfiltersettings.h +++ b/moo/mooedit/mooeditfiltersettings.h @@ -18,17 +18,27 @@ #ifndef MOO_EDIT_FILTER_SETTINGS_H #define MOO_EDIT_FILTER_SETTINGS_H -#include +#include G_BEGIN_DECLS -void _moo_edit_filter_settings_load (void); +typedef struct _MooEditFilter MooEditFilter; -GSList *_moo_edit_filter_settings_get_strings (void); -void _moo_edit_filter_settings_set_strings (GSList *strings); +MooEditFilter *_moo_edit_filter_new (const char *string); +MooEditFilter *_moo_edit_filter_new_langs (const char *string); +MooEditFilter *_moo_edit_filter_new_regex (const char *string); +MooEditFilter *_moo_edit_filter_new_globs (const char *string); +void _moo_edit_filter_free (MooEditFilter *filter); +gboolean _moo_edit_filter_match (MooEditFilter *filter, + MooEdit *doc); -char *_moo_edit_filter_settings_get_for_file (const char *filename); +void _moo_edit_filter_settings_load (void); + +GSList *_moo_edit_filter_settings_get_strings (void); +void _moo_edit_filter_settings_set_strings (GSList *strings); + +char *_moo_edit_filter_settings_get_for_file (const char *filename); G_END_DECLS diff --git a/moo/mooedit/mooeditwindow.c b/moo/mooedit/mooeditwindow.c index 810a454a..d5d0a042 100644 --- a/moo/mooedit/mooeditwindow.c +++ b/moo/mooedit/mooeditwindow.c @@ -19,6 +19,7 @@ #include "mooedit/statusbar-glade.h" #include "mooedit/mooedit-private.h" #include "mooedit/mooeditor-private.h" +#include "mooedit/mooeditfiltersettings.h" #include "mooedit/moolang.h" #include "mooedit/mootextbuffer.h" #include "mooedit/mooeditprefs.h" @@ -129,7 +130,7 @@ static void moo_edit_window_get_property (GObject *object, GParamSpec *pspec); -static gboolean moo_edit_window_close (MooEditWindow *window); +static gboolean moo_edit_window_close (MooWindow *window); static void setup_notebook (MooEditWindow *window); static void update_window_title (MooEditWindow *window); @@ -304,7 +305,7 @@ moo_edit_window_class_init (MooEditWindowClass *klass) gobject_class->set_property = moo_edit_window_set_property; gobject_class->get_property = moo_edit_window_get_property; gtkobject_class->destroy = moo_edit_window_destroy; - window_class->close = (gboolean (*) (MooWindow*)) moo_edit_window_close; + window_class->close = moo_edit_window_close; moo_edit_tab_atom = gdk_atom_intern ("MOO_EDIT_TAB", FALSE); text_uri_atom = gdk_atom_intern ("text/uri-list", FALSE); @@ -1185,9 +1186,10 @@ moo_edit_window_close_all (MooEditWindow *window) static gboolean -moo_edit_window_close (MooEditWindow *window) +moo_edit_window_close (MooWindow *window) { - moo_editor_close_window (window->priv->editor, window, TRUE); + MooEditWindow *edit_window = MOO_EDIT_WINDOW (window); + moo_editor_close_window (edit_window->priv->editor, edit_window, TRUE); return TRUE; } @@ -3394,32 +3396,6 @@ moo_edit_window_remove_action_check (const char *action_id, } -static gboolean -check_action_langs (G_GNUC_UNUSED GtkAction *action, - G_GNUC_UNUSED MooEditWindow *window, - MooEdit *doc, - gpointer langs_list) -{ - gboolean value = FALSE; - - if (doc) - { - MooLang *lang = moo_text_view_get_lang (MOO_TEXT_VIEW (doc)); - value = NULL != g_slist_find_custom (langs_list, _moo_lang_id (lang), - (GCompareFunc) strcmp); - } - - return value; -} - -static void -string_list_free (gpointer list) -{ - g_slist_foreach (list, (GFunc) g_free, NULL); - g_slist_free (list); -} - - GSList * _moo_edit_parse_langs (const char *string) { @@ -3446,23 +3422,39 @@ _moo_edit_parse_langs (const char *string) return g_slist_reverse (list); } -void -moo_edit_window_set_action_langs (const char *action_id, - MooActionCheckType type, - const char *langs) + +static gboolean +check_action_filter (G_GNUC_UNUSED GtkAction *action, + G_GNUC_UNUSED MooEditWindow *window, + MooEdit *doc, + gpointer filter) { - GSList *langs_list; + gboolean value = FALSE; + + if (doc) + value = _moo_edit_filter_match (filter, doc); + + return value; +} + +void +moo_edit_window_set_action_filter (const char *action_id, + MooActionCheckType type, + const char *filter_string) +{ + MooEditFilter *filter = NULL; g_return_if_fail (action_id != NULL); g_return_if_fail (type < N_ACTION_CHECKS); - langs_list = _moo_edit_parse_langs (langs); + if (filter_string) + filter = _moo_edit_filter_new (filter_string); - if (langs_list) + if (filter) moo_edit_window_set_action_check (action_id, type, - check_action_langs, - langs_list, - string_list_free); + check_action_filter, + filter, + (GDestroyNotify) _moo_edit_filter_free); else moo_edit_window_remove_action_check (action_id, type); } diff --git a/moo/mooedit/mooeditwindow.h b/moo/mooedit/mooeditwindow.h index bc8c5e8e..24daf18a 100644 --- a/moo/mooedit/mooeditwindow.h +++ b/moo/mooedit/mooeditwindow.h @@ -73,9 +73,9 @@ void moo_edit_window_set_action_check (const char *action_id, MooActionCheckFunc func, gpointer data, GDestroyNotify notify); -void moo_edit_window_set_action_langs (const char *action_id, +void moo_edit_window_set_action_filter (const char *action_id, MooActionCheckType type, - const char *langs); + const char *filter); MooEdit *moo_edit_window_get_active_doc (MooEditWindow *window); void moo_edit_window_set_active_doc (MooEditWindow *window, diff --git a/moo/mooedit/moousertools-prefs.c b/moo/mooedit/moousertools-prefs.c index c063dee2..6532a862 100644 --- a/moo/mooedit/moousertools-prefs.c +++ b/moo/mooedit/moousertools-prefs.c @@ -101,7 +101,7 @@ new_row (MooPrefsDialogPage *page, GtkTreeViewColumn *column; info = _moo_user_tool_info_new (); - info->cmd_factory = moo_command_factory_lookup ("moo-script"); + info->cmd_factory = moo_command_factory_lookup ("lua"); info->cmd_data = info->cmd_factory ? moo_command_data_new (info->cmd_factory->n_keys) : NULL; info->name = g_strdup (_("New Command")); info->options = g_strdup ("need-doc"); @@ -161,7 +161,7 @@ update_widgets (MooPrefsDialogPage *page, _moo_command_display_set (helper, info->cmd_factory, info->cmd_data); gtk_toggle_button_set_active (GET_WID ("enabled"), info->enabled); - set_text (page, "langs", info->langs); + set_text (page, "filter", info->filter); set_text (page, "options", info->options); _moo_user_tool_info_unref (info); @@ -169,7 +169,7 @@ update_widgets (MooPrefsDialogPage *page, else { gtk_toggle_button_set_active (GET_WID ("enabled"), FALSE); - set_text (page, "langs", NULL); + set_text (page, "filter", NULL); set_text (page, "options", NULL); _moo_command_display_set (helper, NULL, NULL); } @@ -228,7 +228,7 @@ update_model (MooPrefsDialogPage *page, changed = TRUE; } - changed = get_text (page, "langs", &info->langs) || changed; + changed = get_text (page, "filter", &info->filter) || changed; changed = get_text (page, "options", &info->options) || changed; if (changed) @@ -406,7 +406,7 @@ main_page_apply (MooPrefsDialogPage *main_page) GtkWidget * -_moo_user_tools_prefs_page_new (void) +moo_user_tools_prefs_page_new (void) { MooPrefsDialogPage *page; MooPrefsDialogPage *page_menu, *page_context; diff --git a/moo/mooedit/moousertools-prefs.h b/moo/mooedit/moousertools-prefs.h index 779fce59..acbf703d 100644 --- a/moo/mooedit/moousertools-prefs.h +++ b/moo/mooedit/moousertools-prefs.h @@ -19,7 +19,7 @@ G_BEGIN_DECLS -GtkWidget *_moo_user_tools_prefs_page_new (void); +GtkWidget *moo_user_tools_prefs_page_new (void); G_END_DECLS diff --git a/moo/mooedit/moousertools.c b/moo/mooedit/moousertools.c index 9cb08ef1..f84e60ac 100644 --- a/moo/mooedit/moousertools.c +++ b/moo/mooedit/moousertools.c @@ -17,7 +17,6 @@ #include "mooedit/mooeditor.h" #include "mooedit/mooeditaction.h" #include "mooedit/mooeditaction-factory.h" -#include "mooedit/mookeyfile.h" #include "mooutils/mooutils-misc.h" #include "mooutils/mooutils-debug.h" #include "mooutils/mooaccel.h" @@ -33,6 +32,7 @@ #define KEY_ACCEL "accel" #define KEY_MENU "menu" #define KEY_LANGS "langs" +#define KEY_FILTER "filter" #define KEY_POSITION "position" #define KEY_COMMAND "command" #define KEY_NAME "name" @@ -333,8 +333,8 @@ load_tool (MooUserToolInfo *info) check_sensitive_func, NULL, NULL); - if (info->langs) - moo_edit_window_set_action_langs (info->id, MOO_ACTION_CHECK_ACTIVE, info->langs); + if (info->filter) + moo_edit_window_set_action_filter (info->id, MOO_ACTION_CHECK_ACTIVE, info->filter); break; @@ -346,7 +346,7 @@ load_tool (MooUserToolInfo *info) "label", info->name, "accel", info->accel, "command", cmd, - "langs", info->langs, + "file-filter", info->filter, NULL); break; } @@ -448,6 +448,7 @@ parse_item (MooKeyFileItem *item, char *os; char *position = NULL; MooUserToolInfo *info; + char *langs; if (strcmp (moo_key_file_item_name (item), ITEM_TOOL)) { @@ -486,7 +487,6 @@ parse_item (MooKeyFileItem *item, info->accel = moo_key_file_item_steal (item, KEY_ACCEL); info->menu = moo_key_file_item_steal (item, KEY_MENU); - info->langs = moo_key_file_item_steal (item, KEY_LANGS); position = moo_key_file_item_steal (item, KEY_POSITION); if (position) @@ -502,6 +502,16 @@ parse_item (MooKeyFileItem *item, g_free (position); } + if ((langs = moo_key_file_item_steal (item, KEY_LANGS))) + { + info->filter = g_strdup_printf ("langs: %s", langs); + g_free (langs); + } + else + { + info->filter = moo_key_file_item_steal (item, KEY_FILTER); + } + info->cmd_data = _moo_command_parse_item (item, info->name, file, &info->cmd_factory, &info->options); @@ -666,45 +676,22 @@ static void generate_id (MooUserToolInfo *info, GHashTable *ids) { - char *base, *name; + guint i; g_return_if_fail (info->id == NULL); - if (info->name) - name = get_name (info->name); - else - name = NULL; - - base = g_strdup_printf ("MooUserTool_%s", name ? name : ""); - g_strcanon (base, G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "_", '_'); - - if (!g_hash_table_lookup (ids, base)) + for (i = 0; ; ++i) { - info->id = base; - base = NULL; - } - else - { - guint i = 0; + char *id = g_strdup_printf ("MooUserTool%u", i); - while (TRUE) + if (!g_hash_table_lookup (ids, id)) { - char *tmp = g_strdup_printf ("%s_%u", base, i); - - if (!g_hash_table_lookup (ids, tmp)) - { - info->id = tmp; - break; - } - - g_free (tmp); - - i += 1; + info->id = id; + break; } - } - g_free (name); - g_free (base); + g_free (id); + } } static void @@ -776,7 +763,7 @@ info_equal (MooUserToolInfo *info1, _moo_str_equal (info1->name, info2->name) && _moo_str_equal (info1->accel, info2->accel) && _moo_str_equal (info1->menu, info2->menu) && - _moo_str_equal (info1->langs, info2->langs) && + _moo_str_equal (info1->filter, info2->filter) && _moo_str_equal (info1->options, info2->options) && _moo_command_factory_data_equal (info1->cmd_factory, info1->cmd_data, info2->cmd_data); } @@ -874,8 +861,8 @@ _moo_edit_save_user_tools (MooUserToolType type, moo_key_file_item_set (item, KEY_ACCEL, info->accel); if (info->menu && info->menu[0]) moo_key_file_item_set (item, KEY_MENU, info->menu); - if (info->langs && info->langs[0]) - moo_key_file_item_set (item, KEY_LANGS, info->langs); + if (info->filter && info->filter[0]) + moo_key_file_item_set (item, KEY_FILTER, info->filter); if (!info->enabled) moo_key_file_item_set_bool (item, KEY_ENABLED, info->enabled); if (info->position != MOO_USER_TOOL_POS_END) @@ -938,7 +925,7 @@ _moo_user_tool_info_unref (MooUserToolInfo *info) g_free (info->name); g_free (info->accel); g_free (info->menu); - g_free (info->langs); + g_free (info->filter); g_free (info->options); g_free (info->file); diff --git a/moo/mooedit/moousertools.h b/moo/mooedit/moousertools.h index 7437a5d9..1da2350a 100644 --- a/moo/mooedit/moousertools.h +++ b/moo/mooedit/moousertools.h @@ -48,7 +48,7 @@ typedef struct { char *name; char *accel; char *menu; - char *langs; + char *filter; char *options; MooUserToolPosition position; MooUserToolOSType os_type; diff --git a/moo/moopython/plugins/python.py b/moo/moopython/plugins/python.py index b54c3163..178f29d0 100644 --- a/moo/moopython/plugins/python.py +++ b/moo/moopython/plugins/python.py @@ -43,7 +43,7 @@ class Plugin(moo.edit.Plugin): stock_id=moo.utils.STOCK_EXECUTE, accel="F9", callback=self.run_file) - moo.edit.window_set_action_langs("RunFile", moo.edit.ACTION_CHECK_SENSITIVE, "python") + moo.edit.window_set_action_filter("RunFile", moo.edit.ACTION_CHECK_SENSITIVE, "langs:python") xml.add_item(self.ui_merge_id, "ToolsMenu", "RunFile", "RunFile", -1) diff --git a/moo/moopython/pygtk/mooedit-pygtk.defs b/moo/moopython/pygtk/mooedit-pygtk.defs index d1681af1..20ffd092 100644 --- a/moo/moopython/pygtk/mooedit-pygtk.defs +++ b/moo/moopython/pygtk/mooedit-pygtk.defs @@ -543,13 +543,13 @@ ) -(define-function window_set_action_langs - (c-name "moo_edit_window_set_action_langs") +(define-function window_set_action_filter + (c-name "moo_edit_window_set_action_filter") (return-type "none") (parameters '("const-char*" "action_id") '("MooActionCheckType" "type") - '("const-char*" "langs") + '("const-char*" "filter") ) )