aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2011-01-20 08:10:35 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2011-01-20 08:10:35 +0000
commit09cd68cbee77e56de1b7fd1be9367ea6822f0148 (patch)
treea58a7e7a32de3ece5f957129f7548aedcd127f91
parentf4b080cdddb753774b0a3b84ffaf5a5c7fd3978f (diff)
added 'textview-menu-popup' signal for plug-ins.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2811 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog9
-rw-r--r--PLUGIN.ja.txt17
-rw-r--r--PLUGIN.txt16
-rw-r--r--configure.in4
-rw-r--r--plugin/test/test.c37
-rw-r--r--plugin/test/test.h2
-rw-r--r--src/plugin.c18
-rw-r--r--src/plugin.h10
-rw-r--r--src/sylpheed-marshal.list5
-rw-r--r--src/textview.c18
10 files changed, 123 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 944006d4..8ffe25b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2011-01-19
+ * src/sylpheed-marshal.list
+ src/textview.c
+ src/plugin.[ch]
+ PLUGIN.txt
+ PLUGIN.ja.txt: added "textview-menu-popup" signal for plug-ins.
+ * plugin/test/test.[ch]: use "textview-menu-popup" signal.
+
+2011-01-19
+
* libsylph/filter.[ch]
src/inc.c
src/summaryview.c: check the return value of junk filter command
diff --git a/PLUGIN.ja.txt b/PLUGIN.ja.txt
index 46a329a2..341c1fc5 100644
--- a/PLUGIN.ja.txt
+++ b/PLUGIN.ja.txt
@@ -171,6 +171,22 @@ void (* compose_destroy) (GObject *obj, gpointer compose);
Compose メッセージ作成ウィンドウが破棄される直前に発行されるシグナルです。
-------------------------------------------------------------------------
+void (* textview_menu_popup) (GObject *obj,
+ GtkMenu *menu,
+ GtkTextView *textview,
+ const gchar *uri,
+ const gchar *selected_text);
+
+TextView でコンテキストメニューをポップアップするときに発行される
+シグナルです。ここで渡された GtkMenu に対して任意のメニュー項目を
+追加することができます。
+メニューオブジェクトは閉じられると自動的に破棄されます。
+
+menu: コンテキストメニューオブジェクト
+textview: GtkTextView オブジェクト
+uri: URI の上でメニューを表示した場合その URI 文字列
+selected_text: テキストビューでテキストが選択されている場合、その文字列
+-------------------------------------------------------------------------
* libsylph-0
@@ -261,6 +277,7 @@ test プラグインは Sylpheed プラグインの基本的な構造に加え
- アプリケーション初期化、終了、フォルダビューのコンテキストメニュー
ポップアップ、メッセージ作成ウィンドウ作成、メッセージ作成ウィンドウ破棄
のイベントを捕捉してメッセージを表示
+- テキストビューのコンテキストメニュー表示イベントを捕捉してメニュー項目を追加
Attachment Tool Plug-in
-----------------------
diff --git a/PLUGIN.txt b/PLUGIN.txt
index b4123b42..11fd51ef 100644
--- a/PLUGIN.txt
+++ b/PLUGIN.txt
@@ -169,6 +169,21 @@ void (* compose_destroy) (GObject *obj, gpointer compose);
Emitted just before 'Compose' message composition window is destroyed.
-------------------------------------------------------------------------
+void (* textview_menu_popup) (GObject *obj,
+ GtkMenu *menu,
+ GtkTextView *textview,
+ const gchar *uri,
+ const gchar *selected_text);
+
+Emitted on popup of the context menu of TextView.
+You can add any menu items to the passed GtkMenu.
+The menu object will be destroyed when closed.
+
+menu: context menu object
+textview: GtkTextView object
+uri: URI string if the menu popups on an URI
+selected_text: string if a string is selected on the text view
+-------------------------------------------------------------------------
* libsylph-0
@@ -259,6 +274,7 @@ following process:
- Capture the following events and show messages: application initialization
and exiting, folder view context menu popup, creating and destroying compose
window
+- Capture the text view context menu popup event and add a menu item
Attachment Tool Plug-in
-----------------------
diff --git a/configure.in b/configure.in
index cd480351..53066b1f 100644
--- a/configure.in
+++ b/configure.in
@@ -9,8 +9,8 @@ MINOR_VERSION=1
MICRO_VERSION=0
INTERFACE_AGE=0
BINARY_AGE=0
-EXTRA_VERSION=beta7
-BUILD_REVISION=1111
+EXTRA_VERSION=rc
+BUILD_REVISION=1112
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl define if this is a development release
diff --git a/plugin/test/test.c b/plugin/test/test.c
index b8bfa7a1..f0e0fdf5 100644
--- a/plugin/test/test.c
+++ b/plugin/test/test.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
@@ -27,7 +27,7 @@
static SylPluginInfo info = {
"Test Plugin",
- "3.0.99",
+ "3.1.0",
"Hiroyuki Yamamoto",
"Test plug-in for Sylpheed plug-in system"
};
@@ -40,6 +40,11 @@ static void folderview_menu_popup_cb(GObject *obj, GtkItemFactory *ifactory,
static void summaryview_menu_popup_cb(GObject *obj, GtkItemFactory *ifactory,
gpointer data);
+static void textview_menu_popup_cb(GObject *obj, GtkMenu *menu,
+ GtkTextView *textview,
+ const gchar *uri,
+ const gchar *selected_text);
+
static void menu_selected_cb(void);
static void compose_created_cb(GObject *obj, gpointer compose);
@@ -87,6 +92,8 @@ void plugin_load(void)
G_CALLBACK(folderview_menu_popup_cb), NULL);
syl_plugin_signal_connect("summaryview-menu-popup",
G_CALLBACK(summaryview_menu_popup_cb), NULL);
+ syl_plugin_signal_connect("textview-menu-popup",
+ G_CALLBACK(textview_menu_popup_cb), NULL);
syl_plugin_signal_connect("compose-created",
G_CALLBACK(compose_created_cb), NULL);
syl_plugin_signal_connect("compose-destroy",
@@ -147,6 +154,32 @@ static void summaryview_menu_popup_cb(GObject *obj, GtkItemFactory *ifactory,
gtk_widget_set_sensitive(widget, TRUE);
}
+static void activate_menu_cb(GtkMenuItem *menuitem, gpointer data)
+{
+ g_print("menu activated\n");
+}
+
+static void textview_menu_popup_cb(GObject *obj, GtkMenu *menu,
+ GtkTextView *textview,
+ const gchar *uri,
+ const gchar *selected_text)
+{
+ GtkWidget *separator, *menuitem;
+
+ g_print("test: %p: textview menu popup\n", obj);
+ g_print("test: %p: uri: %s, text: %s\n", obj, uri ? uri : "(none)",
+ selected_text ? selected_text : "(none)");
+
+ separator = gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), separator);
+ gtk_widget_show(separator);
+
+ menuitem = gtk_menu_item_new_with_mnemonic("Test menu");
+ g_signal_connect(menuitem, "activate", G_CALLBACK(activate_menu_cb), NULL);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+ gtk_widget_show(menuitem);
+}
+
static void menu_selected_cb(void)
{
gint sel;
diff --git a/plugin/test/test.h b/plugin/test/test.h
index 9a559b3a..253c9155 100644
--- a/plugin/test/test.h
+++ b/plugin/test/test.h
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2009 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
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,