Revision: 1102 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1102&view=re... Author: eht16 Date: 2010-01-01 22:30:09 +0000 (Fri, 01 Jan 2010)
Log Message: ----------- Add an option to define whether all open documents or only the current document should be scanned for tasks (closes #2911086).
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 2010-01-01 22:28:39 UTC (rev 1101) +++ trunk/geany-plugins/addons/ChangeLog 2010-01-01 22:30:09 UTC (rev 1102) @@ -9,6 +9,9 @@ delete tasks (closes #2911105). List tasks only once per line even if there were more than one matching token. + * src/addons.c, src/ao_tasks.c, src/ao_tasks.h: + Add an option to define whether all open documents or only the + current document should be scanned for tasks (closes #2911086).
2009-12-08 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 2010-01-01 22:28:39 UTC (rev 1101) +++ trunk/geany-plugins/addons/src/addons.c 2010-01-01 22:30:09 UTC (rev 1102) @@ -66,6 +66,7 @@ gboolean enable_markword;
gchar *tasks_token_list; + gboolean tasks_scan_all_documents;
/* instances and variables of components */ AoDocList *doclist; @@ -145,6 +146,7 @@ g_return_if_fail(doc != NULL && doc->is_valid);
ao_bookmark_list_update(ao_info->bookmarklist, doc); + ao_tasks_update_single(ao_info->tasks, doc); }
@@ -200,6 +202,8 @@ "addons", "enable_openuri", FALSE); ao_info->enable_tasks = utils_get_setting_boolean(config, "addons", "enable_tasks", TRUE); + ao_info->tasks_scan_all_documents = utils_get_setting_boolean(config, + "addons", "tasks_scan_all_documents", FALSE); ao_info->tasks_token_list = utils_get_setting_string(config, "addons", "tasks_token_list", "TODO;FIXME"); ao_info->enable_systray = utils_get_setting_boolean(config, @@ -217,7 +221,8 @@ 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_token_list); + ao_info->tasks = ao_tasks_new(ao_info->enable_tasks, + ao_info->tasks_token_list, ao_info->tasks_scan_all_documents);
/* setup keybindings */ key_group = plugin_set_key_group(geany_plugin, "addons", KB_COUNT, NULL); @@ -230,6 +235,15 @@ }
+static void ao_configure_tasks_toggled_cb(GtkToggleButton *togglebutton, gpointer data) +{ + gboolean sens = gtk_toggle_button_get_active(togglebutton); + + gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), "check_tasks_scan_mode"), sens); + gtk_widget_set_sensitive(g_object_get_data(G_OBJECT(data), "entry_tasks_tokens"), sens); +} + + static void ao_configure_response_cb(GtkDialog *dialog, gint response, gpointer user_data) { if (response == GTK_RESPONSE_OK || response == GTK_RESPONSE_APPLY) @@ -244,6 +258,8 @@ g_object_get_data(G_OBJECT(dialog), "check_openuri")))); ao_info->enable_tasks = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( g_object_get_data(G_OBJECT(dialog), "check_tasks")))); + ao_info->tasks_scan_all_documents = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( + g_object_get_data(G_OBJECT(dialog), "check_tasks_scan_mode")))); g_free(ao_info->tasks_token_list); ao_info->tasks_token_list = g_strdup(gtk_entry_get_text(GTK_ENTRY( g_object_get_data(G_OBJECT(dialog), "entry_tasks_tokens")))); @@ -253,8 +269,6 @@ g_object_get_data(G_OBJECT(dialog), "check_bookmarklist")))); ao_info->enable_markword = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( g_object_get_data(G_OBJECT(dialog), "check_markword")))); - ao_info->enable_tasks = (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON( - g_object_get_data(G_OBJECT(dialog), "check_tasks"))));
g_key_file_load_from_file(config, ao_info->config_file, G_KEY_FILE_NONE, NULL); g_key_file_set_boolean(config, "addons", @@ -262,6 +276,8 @@ g_key_file_set_boolean(config, "addons", "enable_openuri", ao_info->enable_openuri); g_key_file_set_boolean(config, "addons", "enable_tasks", ao_info->enable_tasks); g_key_file_set_string(config, "addons", "tasks_token_list", ao_info->tasks_token_list); + g_key_file_set_boolean(config, "addons", "tasks_scan_all_documents", + ao_info->tasks_scan_all_documents); g_key_file_set_boolean(config, "addons", "enable_systray", ao_info->enable_systray); g_key_file_set_boolean(config, "addons", "enable_bookmarklist", ao_info->enable_bookmarklist); @@ -275,6 +291,7 @@ g_object_set(ao_info->markword, "enable-markword", ao_info->enable_markword, NULL); g_object_set(ao_info->tasks, "enable-tasks", ao_info->enable_tasks, + "scan-all-documents", ao_info->tasks_scan_all_documents, "tokens", ao_info->tasks_token_list, NULL);
@@ -299,8 +316,8 @@ GtkWidget *plugin_configure(GtkDialog *dialog) { GtkWidget *vbox, *check_doclist, *check_openuri, *check_tasks, *check_systray; - GtkWidget *check_bookmarklist, *check_markword; - GtkWidget *entry_tasks_tokens, *label_tasks_tokens, *tokens_hbox; + GtkWidget *check_bookmarklist, *check_markword, *frame_tasks, *vbox_tasks; + GtkWidget *check_tasks_scan_mode, *entry_tasks_tokens, *label_tasks_tokens, *tokens_hbox;
vbox = gtk_vbox_new(FALSE, 6);
@@ -321,8 +338,15 @@ _("Show available Tasks in the Messages Window")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_tasks), ao_info->enable_tasks); - gtk_box_pack_start(GTK_BOX(vbox), check_tasks, FALSE, FALSE, 3); + g_signal_connect(check_tasks, "toggled", G_CALLBACK(ao_configure_tasks_toggled_cb), dialog);
+ check_tasks_scan_mode = gtk_check_button_new_with_label( + _("Show tasks of all documents")); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_tasks_scan_mode), + ao_info->tasks_scan_all_documents); + ui_widget_set_tooltip_text(check_tasks_scan_mode, + _("Whether to show the tasks of all open documents in the list or only those of the current document.")); + entry_tasks_tokens = gtk_entry_new(); if (NZV(ao_info->tasks_token_list)) gtk_entry_set_text(GTK_ENTRY(entry_tasks_tokens), ao_info->tasks_token_list); @@ -336,8 +360,16 @@ tokens_hbox = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(tokens_hbox), label_tasks_tokens, FALSE, FALSE, 3); gtk_box_pack_start(GTK_BOX(tokens_hbox), entry_tasks_tokens, TRUE, TRUE, 3); - gtk_box_pack_start(GTK_BOX(vbox), tokens_hbox, TRUE, TRUE, 3);
+ vbox_tasks = gtk_vbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_tasks), check_tasks_scan_mode, FALSE, FALSE, 3); + gtk_box_pack_start(GTK_BOX(vbox_tasks), tokens_hbox, TRUE, TRUE, 3); + + frame_tasks = gtk_frame_new(NULL); + gtk_frame_set_label_widget(GTK_FRAME(frame_tasks), check_tasks); + gtk_container_add(GTK_CONTAINER(frame_tasks), vbox_tasks); + gtk_box_pack_start(GTK_BOX(vbox), frame_tasks, TRUE, TRUE, 3); + check_systray = gtk_check_button_new_with_label( _("Show status icon in the Notification Area")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_systray), @@ -360,11 +392,14 @@ g_object_set_data(G_OBJECT(dialog), "check_openuri", check_openuri); g_object_set_data(G_OBJECT(dialog), "check_tasks", check_tasks); g_object_set_data(G_OBJECT(dialog), "entry_tasks_tokens", entry_tasks_tokens); + g_object_set_data(G_OBJECT(dialog), "check_tasks_scan_mode", check_tasks_scan_mode); g_object_set_data(G_OBJECT(dialog), "check_systray", check_systray); g_object_set_data(G_OBJECT(dialog), "check_bookmarklist", check_bookmarklist); g_object_set_data(G_OBJECT(dialog), "check_markword", check_markword); g_signal_connect(dialog, "response", G_CALLBACK(ao_configure_response_cb), NULL);
+ ao_configure_tasks_toggled_cb(GTK_TOGGLE_BUTTON(check_tasks), dialog); + gtk_widget_show_all(vbox);
#if ! GTK_CHECK_VERSION(2, 10, 0)
Modified: trunk/geany-plugins/addons/src/ao_tasks.c =================================================================== --- trunk/geany-plugins/addons/src/ao_tasks.c 2010-01-01 22:28:39 UTC (rev 1101) +++ trunk/geany-plugins/addons/src/ao_tasks.c 2010-01-01 22:30:09 UTC (rev 1102) @@ -60,13 +60,16 @@ GtkWidget *popup_menu_delete_button;
gchar **tokens; + + gboolean scan_all_documents; };
enum { PROP_0, PROP_ENABLE_TASKS, - PROP_TOKENS + PROP_TOKENS, + PROP_SCAN_ALL_DOCUMENTS };
enum @@ -104,6 +107,11 @@ priv->enable_tasks = new_val; break; } + case PROP_SCAN_ALL_DOCUMENTS: + { + priv->scan_all_documents = g_value_get_boolean(value); + break; + } case PROP_TOKENS: { const gchar *t = g_value_get_string(value); @@ -131,6 +139,15 @@ g_type_class_add_private(klass, sizeof(AoTasksPrivate));
g_object_class_install_property(g_object_class, + PROP_SCAN_ALL_DOCUMENTS, + g_param_spec_boolean( + "scan-all-documents", + "scan-all-documents", + "Whether to show tasks for all open documents", + TRUE, + G_PARAM_WRITABLE)); + + g_object_class_install_property(g_object_class, PROP_ENABLE_TASKS, g_param_spec_boolean( "enable-tasks", @@ -540,6 +557,21 @@ }
+void ao_tasks_update_single(AoTasks *t, GeanyDocument *cur_doc) +{ + AoTasksPrivate *priv = AO_TASKS_GET_PRIVATE(t); + + if (! priv->active) + return; + + if (! priv->scan_all_documents) + { + gtk_list_store_clear(priv->store); + ao_tasks_update(t, cur_doc); + } +} + + void ao_tasks_update(AoTasks *t, GeanyDocument *cur_doc) { AoTasksPrivate *priv = AO_TASKS_GET_PRIVATE(t); @@ -547,6 +579,14 @@ if (! priv->active) return;
+ if (! priv->scan_all_documents && cur_doc == NULL) + { + /* clear all */ + gtk_list_store_clear(priv->store); + /* get the current document */ + cur_doc = document_get_current(); + } + if (cur_doc != NULL) { /* TODO handle renaming of files, probably we need a new signal for this */ @@ -578,7 +618,10 @@ }
-AoTasks *ao_tasks_new(gboolean enable, const gchar *tokens) +AoTasks *ao_tasks_new(gboolean enable, const gchar *tokens, gboolean scan_all_documents) { - return g_object_new(AO_TASKS_TYPE, "tokens", tokens, "enable-tasks", enable, NULL); + return g_object_new(AO_TASKS_TYPE, + "scan-all-documents", scan_all_documents, + "tokens", tokens, + "enable-tasks", enable, NULL); }
Modified: trunk/geany-plugins/addons/src/ao_tasks.h =================================================================== --- trunk/geany-plugins/addons/src/ao_tasks.h 2010-01-01 22:28:39 UTC (rev 1101) +++ trunk/geany-plugins/addons/src/ao_tasks.h 2010-01-01 22:30:09 UTC (rev 1102) @@ -36,8 +36,11 @@ typedef struct _AoTasksClass AoTasksClass;
GType ao_tasks_get_type (void); -AoTasks* ao_tasks_new (gboolean enable, const gchar *tokens); +AoTasks* ao_tasks_new (gboolean enable, + const gchar *tokens, + gboolean scan_all_documents); void ao_tasks_update (AoTasks *t, GeanyDocument *cur_doc); +void ao_tasks_update_single (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.