Revision: 1100 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1100&view=re... Author: eht16 Date: 2010-01-01 22:27:24 +0000 (Fri, 01 Jan 2010)
Log Message: ----------- Implement a Delete menu item for the tasks list popup menu to easily delete tasks (closes #2911105).
Modified Paths: -------------- trunk/geany-plugins/addons/ChangeLog trunk/geany-plugins/addons/src/ao_tasks.c
Modified: trunk/geany-plugins/addons/ChangeLog =================================================================== --- trunk/geany-plugins/addons/ChangeLog 2010-01-01 22:26:15 UTC (rev 1099) +++ trunk/geany-plugins/addons/ChangeLog 2010-01-01 22:27:24 UTC (rev 1100) @@ -4,6 +4,9 @@ Update copyright information. * src/ao_bookmarklist.c: Fix warning if the bookmark list is disabled. + * src/ao_tasks.c: + Implement a Delete menu item for the tasks list popup menu to easily + delete tasks (closes #2911105).
2009-12-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: trunk/geany-plugins/addons/src/ao_tasks.c =================================================================== --- trunk/geany-plugins/addons/src/ao_tasks.c 2010-01-01 22:26:15 UTC (rev 1099) +++ trunk/geany-plugins/addons/src/ao_tasks.c 2010-01-01 22:27:24 UTC (rev 1100) @@ -57,6 +57,7 @@
GtkWidget *page; GtkWidget *popup_menu; + GtkWidget *popup_menu_delete_button;
gchar **tokens; }; @@ -201,6 +202,10 @@ else if (event->button == 3) { AoTasksPrivate *priv = AO_TASKS_GET_PRIVATE(data); + gboolean has_selection = gtk_tree_selection_get_selected( + gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->tree)), NULL, NULL); + gtk_widget_set_sensitive(priv->popup_menu_delete_button, has_selection); + gtk_menu_popup(GTK_MENU(priv->popup_menu), NULL, NULL, NULL, NULL, event->button, event->time); /* don't return TRUE here, otherwise the selection won't be changed */ @@ -249,6 +254,47 @@ }
+static void popup_delete_item_click_cb(GtkWidget *button, AoTasks *t) +{ + AoTasksPrivate *priv = AO_TASKS_GET_PRIVATE(t); + GtkTreeIter iter; + GtkTreeModel *model; + GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(priv->tree)); + gchar *filename; + gint line, start, end; + GeanyDocument *doc; + + if (! gtk_tree_selection_get_selected(selection, &model, &iter)) + return; + + /* get task information */ + gtk_tree_model_get(model, &iter, + TLIST_COL_FILENAME, &filename, + TLIST_COL_LINE, &line, + -1); + + /* find the document of this task item */ + doc = document_find_by_filename(filename); + g_free(filename); + + if (doc == NULL) + return; + + line--; /* display line vs. document line */ + + start = sci_get_position_from_line(doc->editor->sci, line); + end = sci_get_position_from_line(doc->editor->sci, line + 1); + if (end == -1) + end = sci_get_length(doc->editor->sci); + + /* create a selection over this line and then delete it */ + scintilla_send_message(doc->editor->sci, SCI_SETSEL, start, end); + scintilla_send_message(doc->editor->sci, SCI_CLEAR, 0, 0); + /* update the task list */ + ao_tasks_update(t, doc); +} + + static void popup_update_item_click_cb(GtkWidget *button, AoTasks *t) { ao_tasks_update(t, NULL); @@ -264,9 +310,20 @@ static GtkWidget *create_popup_menu(AoTasks *t) { GtkWidget *item, *menu; + AoTasksPrivate *priv = AO_TASKS_GET_PRIVATE(t);
menu = gtk_menu_new();
+ item = gtk_image_menu_item_new_from_stock(GTK_STOCK_DELETE, NULL); + priv->popup_menu_delete_button = item; + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + g_signal_connect(item, "activate", G_CALLBACK(popup_delete_item_click_cb), t); + + item = gtk_separator_menu_item_new(); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + item = ui_image_menu_item_new(GTK_STOCK_REFRESH, _("_Update")); gtk_widget_show(item); gtk_container_add(GTK_CONTAINER(menu), item);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.