diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/plugin.c | 18 | ||||
-rw-r--r-- | src/plugin.h | 10 | ||||
-rw-r--r-- | src/sylpheed-marshal.list | 5 | ||||
-rw-r--r-- | src/textview.c | 18 |
4 files changed, 43 insertions, 8 deletions
diff --git a/src/plugin.c b/src/plugin.c index 6a656f06..d9d67e1d 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2010 Hiroyuki Yamamoto + * Copyright (C) 1999-2011 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,6 +24,7 @@ #include "plugin.h" #include "utils.h" #include "folder.h" +#include "sylpheed-marshal.h" G_DEFINE_TYPE(SylPlugin, syl_plugin, G_TYPE_OBJECT); @@ -34,6 +35,7 @@ enum { SUMMARYVIEW_MENU_POPUP, COMPOSE_CREATED, COMPOSE_DESTROY, + TEXTVIEW_MENU_POPUP, LAST_SIGNAL }; @@ -155,6 +157,20 @@ static void syl_plugin_class_init(SylPluginClass *klass) G_TYPE_NONE, 1, G_TYPE_POINTER); + plugin_signals[TEXTVIEW_MENU_POPUP] = + g_signal_new("textview-menu-popup", + G_TYPE_FROM_CLASS(gobject_class), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET(SylPluginClass, + textview_menu_popup), + NULL, NULL, + sylpheed_marshal_VOID__POINTER_POINTER_STRING_STRING, + G_TYPE_NONE, + 4, + G_TYPE_POINTER, + G_TYPE_POINTER, + G_TYPE_STRING, + G_TYPE_STRING); } void syl_plugin_signal_connect(const gchar *name, GCallback callback, diff --git a/src/plugin.h b/src/plugin.h index ba30f226..f21026fe 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2010 Hiroyuki Yamamoto + * Copyright (C) 1999-2011 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,7 +45,7 @@ typedef void (*SylPluginLoadFunc) (void); typedef void (*SylPluginUnloadFunc) (void); typedef void (*SylPluginCallbackFunc) (void); -#define SYL_PLUGIN_INTERFACE_VERSION 0x0106 +#define SYL_PLUGIN_INTERFACE_VERSION 0x0107 struct _SylPlugin { @@ -64,6 +64,12 @@ struct _SylPluginClass void (* compose_created) (GObject *obj, gpointer compose); void (* compose_destroy) (GObject *obj, gpointer compose); + + void (* textview_menu_popup) (GObject *obj, + GtkMenu *menu, + GtkTextView *textview, + const gchar *uri, + const gchar *selected_text); }; struct _SylPluginInfo diff --git a/src/sylpheed-marshal.list b/src/sylpheed-marshal.list index 7e722df0..9c87ba0c 100644 --- a/src/sylpheed-marshal.list +++ b/src/sylpheed-marshal.list @@ -1,2 +1,3 @@ -NONE:POINTER -NONE:INT,POINTER +VOID:POINTER +VOID:INT,POINTER +VOID:POINTER,POINTER,STRING,STRING diff --git a/src/textview.c b/src/textview.c index 55c2e85d..edb668fa 100644 --- a/src/textview.c +++ b/src/textview.c @@ -1,6 +1,6 @@ /* * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client - * Copyright (C) 1999-2007 Hiroyuki Yamamoto + * Copyright (C) 1999-2011 Hiroyuki Yamamoto * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -56,6 +56,7 @@ #include "displayheader.h" #include "filesel.h" #include "alertpanel.h" +#include "plugin.h" typedef struct _RemoteURI RemoteURI; @@ -1991,6 +1992,7 @@ static void textview_populate_popup(GtkWidget *widget, GtkMenu *menu, gboolean on_link; RemoteURI *uri; GdkPixbuf *pixbuf; + gchar *selected_text; buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); @@ -2011,13 +2013,17 @@ static void textview_populate_popup(GtkWidget *widget, GtkMenu *menu, ADD_MENU(_("Sa_ve this image as..."), textview_popup_menu_activate_image_cb); } + + selected_text = gtkut_text_view_get_selection(GTK_TEXT_VIEW(widget)); + + uri = NULL; on_link = textview_get_link_tag_bounds(textview, &iter, &start, &end); if (!on_link) - return; + goto finish; uri = textview_get_uri(textview, &start, &end); if (!uri) - return; + goto finish; separator = gtk_separator_menu_item_new(); gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator); @@ -2039,6 +2045,12 @@ static void textview_populate_popup(GtkWidget *widget, GtkMenu *menu, ADD_MENU(_("Copy this _link"), textview_popup_menu_activate_copy_cb); } + +finish: + syl_plugin_signal_emit("textview-menu-popup", menu, + GTK_TEXT_VIEW(widget), uri ? uri->uri : NULL, + selected_text); + g_free(selected_text); } static void textview_popup_menu_activate_open_uri_cb(GtkMenuItem *menuitem, |