aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-01-21 06:08:37 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2010-01-21 06:08:37 +0000
commit441b184056b95fcf0ce22a1f61c7e8ce779949cc (patch)
tree5aafb212cfe30532551871503d8fca9054b14502 /src
parent596eb7f3b00034bbc0a8b1001c2ca6c8743312d0 (diff)
added new plug-in APIs for compose window.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2436 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/compose.c21
-rw-r--r--src/compose.h5
-rw-r--r--src/main.c7
-rw-r--r--src/plugin.c76
-rw-r--r--src/plugin.h23
5 files changed, 130 insertions, 2 deletions
diff --git a/src/compose.c b/src/compose.c
index 41ab17a9..3b528c19 100644
--- a/src/compose.c
+++ b/src/compose.c
@@ -133,6 +133,7 @@
#include "quote_fmt.h"
#include "template.h"
#include "undo.h"
+#include "plugin.h"
#if USE_GPGME
# include "rfc2015.h"
@@ -803,6 +804,8 @@ Compose *compose_new(PrefsAccount *account, FolderItem *item,
compose_connect_changed_callbacks(compose);
compose_set_title(compose);
+ syl_plugin_signal_emit("compose-created", compose);
+
if (prefs_common.enable_autosave && prefs_common.autosave_itv > 0)
compose->autosave_tag =
g_timeout_add(prefs_common.autosave_itv * 60 * 1000,
@@ -908,6 +911,8 @@ void compose_reply(MsgInfo *msginfo, FolderItem *item, ComposeMode mode,
procmsg_msginfo_free(replyinfo);
+ syl_plugin_signal_emit("compose-created", compose);
+
if (prefs_common.enable_autosave && prefs_common.autosave_itv > 0)
compose->autosave_tag =
g_timeout_add(prefs_common.autosave_itv * 60 * 1000,
@@ -1041,6 +1046,8 @@ void compose_forward(GSList *mlist, FolderItem *item, gboolean as_attach,
else
gtk_widget_grab_focus(compose->newsgroups_entry);
+ syl_plugin_signal_emit("compose-created", compose);
+
if (prefs_common.enable_autosave && prefs_common.autosave_itv > 0)
compose->autosave_tag =
g_timeout_add(prefs_common.autosave_itv * 60 * 1000,
@@ -1110,6 +1117,8 @@ void compose_redirect(MsgInfo *msginfo, FolderItem *item)
compose_connect_changed_callbacks(compose);
compose_set_title(compose);
+
+ syl_plugin_signal_emit("compose-created", compose);
}
void compose_reedit(MsgInfo *msginfo)
@@ -1208,6 +1217,8 @@ void compose_reedit(MsgInfo *msginfo)
menu_set_active(ifactory, "/Tools/Request disposition notification", TRUE);
}
+ syl_plugin_signal_emit("compose-created", compose);
+
if (prefs_common.enable_autosave && prefs_common.autosave_itv > 0)
compose->autosave_tag =
g_timeout_add(prefs_common.autosave_itv * 60 * 1000,
@@ -1318,6 +1329,14 @@ void compose_entry_append(Compose *compose, const gchar *text,
gtk_editable_insert_text(GTK_EDITABLE(entry), text, -1, &pos);
}
+gchar *compose_entry_get_text(Compose *compose, ComposeEntryType type)
+{
+ GtkEntry *entry;
+
+ entry = compose_get_entry(compose, type);
+ return gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1);
+}
+
static void compose_entries_set(Compose *compose, const gchar *mailto)
{
gchar *to = NULL;
@@ -6008,6 +6027,8 @@ static void compose_destroy(Compose *compose)
if (compose->autosave_tag > 0)
g_source_remove(compose->autosave_tag);
+ syl_plugin_signal_emit("compose-destroy", compose);
+
/* NOTE: address_completion_end() does nothing with the window
* however this may change. */
address_completion_end(compose->window);
diff --git a/src/compose.h b/src/compose.h
index 10b4900b..d73c94b9 100644
--- a/src/compose.h
+++ b/src/compose.h
@@ -132,12 +132,11 @@ struct _Compose
GtkWidget *tmpl_menu;
-#if USE_GTKSPELL
+ /* GtkSpell */
GtkWidget *spell_menu;
gchar *spell_lang;
gboolean check_spell;
GSList *dict_list;
-#endif
ComposeMode mode;
@@ -233,6 +232,8 @@ void compose_entry_set (Compose *compose,
void compose_entry_append (Compose *compose,
const gchar *text,
ComposeEntryType type);
+gchar *compose_entry_get_text (Compose *compose,
+ ComposeEntryType type);
void compose_lock (Compose *compose);
void compose_unlock (Compose *compose);
diff --git a/src/main.c b/src/main.c
index 65a0e475..d250cedc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1125,6 +1125,13 @@ static void plugin_init(void)
messageview_create_with_new_window);
syl_plugin_add_symbol("messageview_show", messageview_show);
+ syl_plugin_add_symbol("compose_new", compose_new);
+ syl_plugin_add_symbol("compose_entry_set", compose_entry_set);
+ syl_plugin_add_symbol("compose_entry_append", compose_entry_append);
+ syl_plugin_add_symbol("compose_entry_get_text", compose_entry_get_text);
+ syl_plugin_add_symbol("compose_lock", compose_lock);
+ syl_plugin_add_symbol("compose_unlock", compose_unlock);
+
syl_plugin_add_symbol("foldersel_folder_sel",
foldersel_folder_sel);
syl_plugin_add_symbol("foldersel_folder_sel_full",
diff --git a/src/plugin.c b/src/plugin.c
index 51968572..108573b7 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -31,6 +31,8 @@ enum {
PLUGIN_LOAD,
PLUGIN_UNLOAD,
FOLDERVIEW_MENU_POPUP,
+ COMPOSE_CREATED,
+ COMPOSE_DESTROY,
LAST_SIGNAL
};
@@ -103,6 +105,26 @@ static void syl_plugin_class_init(SylPluginClass *klass)
G_TYPE_NONE,
1,
G_TYPE_POINTER);
+ plugin_signals[COMPOSE_CREATED] =
+ g_signal_new("compose-created",
+ G_TYPE_FROM_CLASS(gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(SylPluginClass, compose_created),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+ plugin_signals[COMPOSE_DESTROY] =
+ g_signal_new("compose-destroy",
+ G_TYPE_FROM_CLASS(gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET(SylPluginClass, compose_destroy),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__POINTER,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
}
void syl_plugin_signal_connect(const gchar *name, GCallback callback,
@@ -648,6 +670,60 @@ void syl_plugin_open_message_by_new_window(MsgInfo *msginfo)
}
}
+
+gpointer syl_plugin_compose_new(PrefsAccount *account, FolderItem *item,
+ const gchar *mailto, GPtrArray *attach_files)
+{
+ gpointer (*func)(PrefsAccount *, FolderItem *, const gchar *,
+ GPtrArray *);
+
+ func = syl_plugin_lookup_symbol("compose_new");
+ return SAFE_CALL_ARG4_RET(func, account, item, mailto, attach_files);
+}
+
+void syl_plugin_compose_entry_set(gpointer compose, const gchar *text,
+ gint type)
+{
+ void (*func)(gpointer, const gchar *, gint);
+
+ func = syl_plugin_lookup_symbol("compose_entry_set");
+ SAFE_CALL_ARG3(func, compose, text, type);
+}
+
+void syl_plugin_compose_entry_append(gpointer compose, const gchar *text,
+ gint type)
+{
+ void (*func)(gpointer, const gchar *, gint);
+
+ func = syl_plugin_lookup_symbol("compose_entry_append");
+ SAFE_CALL_ARG3(func, compose, text, type);
+}
+
+gchar *syl_plugin_compose_entry_get_text(gpointer compose, gint type)
+{
+ gchar * (*func)(gpointer, gint);
+
+ func = syl_plugin_lookup_symbol("compose_entry_get_text");
+ return SAFE_CALL_ARG2_RET(func, compose, type);
+}
+
+void syl_plugin_compose_lock(gpointer compose)
+{
+ void (*func)(gpointer);
+
+ func = syl_plugin_lookup_symbol("compose_lock");
+ SAFE_CALL_ARG1(func, compose);
+}
+
+void syl_plugin_compose_unlock(gpointer compose)
+{
+ void (*func)(gpointer);
+
+ func = syl_plugin_lookup_symbol("compose_unlock");
+ SAFE_CALL_ARG1(func, compose);
+}
+
+
FolderItem *syl_plugin_folder_sel(Folder *cur_folder, gint sel_type,
const gchar *default_folder)
{
diff --git a/src/plugin.h b/src/plugin.h
index 94ea652d..50f5738b 100644
--- a/src/plugin.h
+++ b/src/plugin.h
@@ -58,7 +58,11 @@ struct _SylPluginClass
void (* plugin_load) (GObject *obj, GModule *module);
void (* plugin_unload) (GObject *obj, GModule *module);
+
void (* folderview_menu_popup) (GObject *obj, gpointer ifactory);
+
+ void (* compose_created) (GObject *obj, gpointer compose);
+ void (* compose_destroy) (GObject *obj, gpointer compose);
};
struct _SylPluginInfo
@@ -155,6 +159,25 @@ gpointer syl_plugin_messageview_create_with_new_window
(void);
void syl_plugin_open_message_by_new_window (MsgInfo *msginfo);
+/* Compose */
+gpointer syl_plugin_compose_new (PrefsAccount *account,
+ FolderItem *item,
+ const gchar *mailto,
+ GPtrArray *attach_files);
+
+/* entry type:
+ 0: To 1: Cc 2: Bcc 3: Reply-To 4: Subject 5: Newsgroups 6: Followup-To */
+void syl_plugin_compose_entry_set (gpointer compose,
+ const gchar *text,
+ gint type);
+void syl_plugin_compose_entry_append (gpointer compose,
+ const gchar *text,
+ gint type);
+gchar *syl_plugin_compose_entry_get_text (gpointer compose,
+ gint type);
+void syl_plugin_compose_lock (gpointer compose);
+void syl_plugin_compose_unlock (gpointer compose);
+
/* Others */
FolderItem *syl_plugin_folder_sel (Folder *cur_folder,
gint sel_type,