diff --git a/ChangeLog b/ChangeLog index de88a798f..785ceeb3e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,10 @@ * src/editor.c: Attempt to make editor_find_current_word() Unicode-safe. Note: this can be done better. + * doc/plugins.dox, src/editor.c, src/geanyobject.c, src/geanyobject.h, + src/plugindata.h: + Add plugin signal "populate-edit-menu" to notify plugins when the + editing menu is shown. 2008-06-27 Nick Treleaven diff --git a/doc/plugins.dox b/doc/plugins.dox index 4326fea31..e4bee4fa8 100644 --- a/doc/plugins.dox +++ b/doc/plugins.dox @@ -159,6 +159,22 @@ PluginCallback plugin_callbacks[] = * @param user_data user data. * @endsignaldef * + * @signaldef populate-edit-menu + * @signalproto + * void user_function(GObject *obj, const gchar *word, gint pos, GeanyDocument *doc, + * gpointer user_data); + * @endsignalproto + * @signaldesc + * Sent before the popup menu of the editing widget is shown. This can be used to modify or extend + * the popup menu. You can access the menu pointer using @a main_widgets->editor_menu. + * @param obj a GeanyObject instance, should be ignored. + * @param word the current word (in UTF-8 encoding) below the cursor position + where the popup menu will be opened. + * @param click_pos the cursor position where the popup will be opened. + * @param doc the current document. + * @param user_data user data. + * @endsignaldef + * * * * @page howto Plugin Howto diff --git a/src/editor.c b/src/editor.c index c075fd4dd..46a93751b 100644 --- a/src/editor.c +++ b/src/editor.c @@ -47,6 +47,7 @@ #include "dialogs.h" #include "symbols.h" #include "callbacks.h" +#include "geanyobject.h" /* holds word under the mouse or keyboard cursor */ @@ -109,6 +110,12 @@ on_editor_button_press_event (GtkWidget *widget, ui_update_popup_goto_items((current_word[0] != '\0') ? TRUE : FALSE); ui_update_popup_copy_items(doc); ui_update_insert_include_item(doc, 0); + + if (geany_object) + { + g_signal_emit_by_name(geany_object, "populate-edit-menu", + current_word, editor_info.click_pos, doc); + } gtk_menu_popup(GTK_MENU(main_widgets.editor_menu), NULL, NULL, NULL, NULL, event->button, event->time); diff --git a/src/geanyobject.c b/src/geanyobject.c index 436e6fdfb..c526558ae 100644 --- a/src/geanyobject.c +++ b/src/geanyobject.c @@ -143,6 +143,15 @@ static void create_signals(GObjectClass *g_object_class) NULL, NULL, gtk_marshal_NONE__NONE, G_TYPE_NONE, 0); + geany_object_signals[GCB_POPULATE_EDIT_MENU] = g_signal_new ( + "populate-edit-menu", + G_OBJECT_CLASS_TYPE (g_object_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (GeanyObjectClass, populate_edit_menu), + NULL, NULL, + gtk_marshal_NONE__STRING_INT_POINTER, + G_TYPE_NONE, 3, + G_TYPE_STRING, G_TYPE_INT, G_TYPE_POINTER); } diff --git a/src/geanyobject.h b/src/geanyobject.h index 66b1d267b..e199c5fd3 100644 --- a/src/geanyobject.h +++ b/src/geanyobject.h @@ -41,6 +41,7 @@ typedef enum GCB_PROJECT_OPEN, GCB_PROJECT_SAVE, GCB_PROJECT_CLOSE, + GCB_POPULATE_EDIT_MENU, GCB_MAX } GeanyCallbackId; @@ -77,6 +78,7 @@ struct _GeanyObjectClass void (*project_open)(GKeyFile *keyfile); void (*project_save)(GKeyFile *keyfile); void (*project_close)(void); + void (*populate_edit_menu)(const gchar *word, gint click_pos, GeanyDocument *doc); }; GType geany_object_get_type (void); diff --git a/src/plugindata.h b/src/plugindata.h index 9e6224338..231ac359f 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -36,7 +36,7 @@ /* The API version should be incremented whenever any plugin data types below are * modified or appended to. */ -static const gint api_version = 71; +static const gint api_version = 72; /* The ABI version should be incremented whenever existing fields in the plugin * data types below have to be changed or reordered. It should stay the same if fields