Revision: 1070 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1070&view=re... Author: eht16 Date: 2009-11-29 22:01:40 +0000 (Sun, 29 Nov 2009)
Log Message: ----------- Add a property to the AoTasks class to prepare configurable tasks tokens.
Modified Paths: -------------- trunk/geany-plugins/addons/ChangeLog trunk/geany-plugins/addons/src/addons.c trunk/geany-plugins/addons/src/ao_tasks.c trunk/geany-plugins/addons/src/ao_tasks.h
Modified: trunk/geany-plugins/addons/ChangeLog =================================================================== --- trunk/geany-plugins/addons/ChangeLog 2009-11-29 21:35:35 UTC (rev 1069) +++ trunk/geany-plugins/addons/ChangeLog 2009-11-29 22:01:40 UTC (rev 1070) @@ -10,6 +10,9 @@ Update the task list only for changed documents and on document closing, simply delete matching TODO tasks instead of updating all. This is major speed up of the whole tasks processing. + * src/addons.c, src/ao_tasks.c, src/ao_tasks.h: + Add a property to the AoTasks class to prepare configurable + tasks tokens.
2009-11-28 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/geany-plugins/addons/src/addons.c =================================================================== --- trunk/geany-plugins/addons/src/addons.c 2009-11-29 21:35:35 UTC (rev 1069) +++ trunk/geany-plugins/addons/src/addons.c 2009-11-29 22:01:40 UTC (rev 1070) @@ -213,7 +213,7 @@ ao_info->systray = ao_systray_new(ao_info->enable_systray); ao_info->bookmarklist = ao_bookmark_list_new(ao_info->enable_bookmarklist); ao_info->markword = ao_mark_word_new(ao_info->enable_markword); - ao_info->tasks = ao_tasks_new(ao_info->enable_tasks); + ao_info->tasks = ao_tasks_new(ao_info->enable_tasks, "TODO;FIXME");
/* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "addons", KB_COUNT, NULL);
Modified: trunk/geany-plugins/addons/src/ao_tasks.c =================================================================== --- trunk/geany-plugins/addons/src/ao_tasks.c 2009-11-29 21:35:35 UTC (rev 1069) +++ trunk/geany-plugins/addons/src/ao_tasks.c 2009-11-29 22:01:40 UTC (rev 1070) @@ -32,10 +32,6 @@ #include <gdk/gdkkeysyms.h>
-/* TODO make tokens configurable */ -const gchar *tokens[] = { "TODO", "FIXME", NULL }; - - typedef struct _AoTasksPrivate AoTasksPrivate;
#define AO_TASKS_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ @@ -61,12 +57,15 @@
GtkWidget *page; GtkWidget *popup_menu; + + gchar **tokens; };
enum { PROP_0, - PROP_ENABLE_TASKS + PROP_ENABLE_TASKS, + PROP_TOKENS };
enum @@ -104,6 +103,15 @@ priv->enable_tasks = new_val; break; } + case PROP_TOKENS: + { + const gchar *t = g_value_get_string(value); + if (! NZV(t)) + t = "TODO;FIXME"; /* fallback */ + g_strfreev(priv->tokens); + priv->tokens = g_strsplit(t, ";", -1); + break; + } default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); break; @@ -128,14 +136,28 @@ "Whether to show list of defined tasks", TRUE, G_PARAM_WRITABLE)); + + g_object_class_install_property(g_object_class, + PROP_TOKENS, + g_param_spec_string( + "tokens", + "tokens", + "The tokens to scan documents for", + NULL, + G_PARAM_WRITABLE)); }
static void ao_tasks_finalize(GObject *object) { + AoTasksPrivate *priv; + g_return_if_fail(object != NULL); g_return_if_fail(IS_AO_TASKS(object));
+ priv = AO_TASKS_GET_PRIVATE(object); + g_strfreev(priv->tokens); + ao_tasks_hide(AO_TASKS(object));
G_OBJECT_CLASS(ao_tasks_parent_class)->finalize(object); @@ -411,7 +433,7 @@ { guint lines, line; gchar *line_buf, *context, *display_name, *tooltip; - const gchar **token; + gchar **token; AoTasksPrivate *priv = AO_TASKS_GET_PRIVATE(t);
if (doc->is_valid) @@ -421,7 +443,7 @@ for (line = 0; line < lines; line++) { line_buf = g_strstrip(sci_get_line(doc->editor->sci, line)); - token = tokens; + token = priv->tokens; while (*token != NULL) { if (NZV(*token) && strstr(line_buf, *token) != NULL) @@ -486,11 +508,12 @@
priv->page = NULL; priv->popup_menu = NULL; + priv->tokens = NULL; priv->active = FALSE; }
-AoTasks *ao_tasks_new(gboolean enable) +AoTasks *ao_tasks_new(gboolean enable, const gchar *tokens) { - return g_object_new(AO_TASKS_TYPE, "enable-tasks", enable, NULL); + return g_object_new(AO_TASKS_TYPE, "tokens", tokens, "enable-tasks", enable, NULL); }
Modified: trunk/geany-plugins/addons/src/ao_tasks.h =================================================================== --- trunk/geany-plugins/addons/src/ao_tasks.h 2009-11-29 21:35:35 UTC (rev 1069) +++ trunk/geany-plugins/addons/src/ao_tasks.h 2009-11-29 22:01:40 UTC (rev 1070) @@ -36,7 +36,7 @@ typedef struct _AoTasksClass AoTasksClass;
GType ao_tasks_get_type (void); -AoTasks* ao_tasks_new (gboolean enable); +AoTasks* ao_tasks_new (gboolean enable, const gchar *tokens); void ao_tasks_update (AoTasks *t, GeanyDocument *cur_doc); void ao_tasks_remove (AoTasks *t, GeanyDocument *cur_doc); void ao_tasks_activate (AoTasks *t);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.