Revision: 1067 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1067&view=re... Author: eht16 Date: 2009-11-29 13:08:03 +0000 (Sun, 29 Nov 2009)
Log Message: ----------- Add a simple popup menu to update the Tasks list and hide the Messages window.
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 2009-11-28 17:01:43 UTC (rev 1066) +++ trunk/geany-plugins/addons/ChangeLog 2009-11-29 13:08:03 UTC (rev 1067) @@ -1,3 +1,10 @@ +2009-11-29 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * src/ao_tasks.c: + Add a simple popup menu to update the Tasks list and hide + the Messages window. + + 2009-11-28 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/Makefile.am, src/tasks.c, src/tasks.h, src/ao_tasks.h,
Modified: trunk/geany-plugins/addons/src/ao_tasks.c =================================================================== --- trunk/geany-plugins/addons/src/ao_tasks.c 2009-11-28 17:01:43 UTC (rev 1066) +++ trunk/geany-plugins/addons/src/ao_tasks.c 2009-11-29 13:08:03 UTC (rev 1067) @@ -32,7 +32,7 @@ #include <gdk/gdkkeysyms.h>
-/* Make tokens configurable */ +/* TODO make tokens configurable */ const gchar *tokens[] = { "TODO", "FIXME", NULL };
@@ -59,6 +59,7 @@ GtkWidget *tree;
GtkWidget *page; + GtkWidget *popup_menu; };
enum @@ -173,6 +174,13 @@ { /* allow reclicking of a treeview item */ g_idle_add(ao_tasks_selection_changed_cb, widget); } + else if (event->button == 3) + { + AoTasksPrivate *priv = AO_TASKS_GET_PRIVATE(data); + 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 */ + } return FALSE; }
@@ -186,6 +194,16 @@ { g_idle_add(ao_tasks_selection_changed_cb, widget); } + if ((event->keyval == GDK_F10 && event->state & GDK_SHIFT_MASK) || event->keyval == GDK_Menu) + { + GdkEventButton button_event; + + button_event.time = event->time; + button_event.button = 3; + + ao_tasks_button_press_cb(widget, &button_event, data); + return TRUE; + } return FALSE; }
@@ -199,9 +217,50 @@ gtk_widget_destroy(priv->page); priv->page = NULL; } + if (priv->popup_menu) + { + gtk_widget_destroy(priv->popup_menu); + priv->popup_menu = NULL; + } }
+static void popup_update_item_click_cb(GtkWidget *button, AoTasks *t) +{ + ao_tasks_update(t, NULL); +} + + +static void popup_hide_item_click_cb(GtkWidget *button, AoTasks *t) +{ + keybindings_send_command(GEANY_KEY_GROUP_VIEW, GEANY_KEYS_VIEW_MESSAGEWINDOW); +} + + +static GtkWidget *create_popup_menu(AoTasks *t) +{ + GtkWidget *item, *menu; + + menu = gtk_menu_new(); + + item = ui_image_menu_item_new(GTK_STOCK_REFRESH, _("_Update")); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + g_signal_connect(item, "activate", G_CALLBACK(popup_update_item_click_cb), t); + + item = gtk_separator_menu_item_new(); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + + item = gtk_menu_item_new_with_mnemonic(_("_Hide Message Window")); + gtk_widget_show(item); + gtk_container_add(GTK_CONTAINER(menu), item); + g_signal_connect(item, "activate", G_CALLBACK(popup_hide_item_click_cb), t); + + return menu; +} + + static void ao_tasks_show(AoTasks *t) { GtkCellRenderer *text_renderer; @@ -272,6 +331,8 @@ priv->page, gtk_label_new(_("Tasks")));
+ priv->popup_menu = create_popup_menu(t); + /* initial update */ ao_tasks_update(t, NULL); }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.