Mercurial > pidgin
changeset 21687:3f87c3265740
Add preferences to the newline plugin to allow enabling separately for IMs
and Chats.
Fixes: 9b03ab350711290846t424e302fh1eb5e3fe6d7c3872@mail.gmail.com
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 29 Nov 2007 19:04:44 +0000 |
parents | 280f622cb9b0 |
children | 33285f8f68ba |
files | libpurple/plugins/newline.c |
diffstat | 1 files changed, 40 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/plugins/newline.c Thu Nov 29 15:47:24 2007 +0000 +++ b/libpurple/plugins/newline.c Thu Nov 29 19:04:44 2007 +0000 @@ -31,6 +31,12 @@ addnewline_msg_cb(PurpleAccount *account, char *sender, char **message, PurpleConversation *conv, int *flags, void *data) { + if (((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) && + !purple_prefs_get_bool("/plugins/core/newline/im")) || + ((purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) && + !purple_prefs_get_bool("/plugins/core/newline/chat"))) + return FALSE; + if (g_ascii_strncasecmp(*message, "/me ", strlen("/me "))) { char *tmp = g_strdup_printf("<br/>%s", *message); g_free(*message); @@ -40,6 +46,25 @@ return FALSE; } +static PurplePluginPrefFrame * +get_plugin_pref_frame(PurplePlugin *plugin) { + PurplePluginPrefFrame *frame; + PurplePluginPref *ppref; + + frame = purple_plugin_pref_frame_new(); + + ppref = purple_plugin_pref_new_with_name_and_label( + "/plugins/core/newline/im", _("Add new line in IMs")); + purple_plugin_pref_frame_add(frame, ppref); + + ppref = purple_plugin_pref_new_with_name_and_label( + "/plugins/core/newline/chat", _("Add new line in Chats")); + purple_plugin_pref_frame_add(frame, ppref); + + return frame; +} + + static gboolean plugin_load(PurplePlugin *plugin) { @@ -53,6 +78,17 @@ return TRUE; } +static PurplePluginUiInfo prefs_info = { + get_plugin_pref_frame, + 0, /* page_num (Reserved) */ + NULL, /* frame (Reserved) */ + /* Padding */ + NULL, + NULL, + NULL, + NULL +}; + static PurplePluginInfo info = { PURPLE_PLUGIN_MAGIC, /**< magic */ @@ -80,7 +116,7 @@ NULL, /**< ui_info */ NULL, /**< extra_info */ - NULL, /**< prefs_info */ + &prefs_info, /**< prefs_info */ NULL, /**< actions */ /* padding */ @@ -92,6 +128,9 @@ static void init_plugin(PurplePlugin *plugin) { + purple_prefs_add_none("/plugins/core/newline"); + purple_prefs_add_bool("/plugins/core/newline/im", TRUE); + purple_prefs_add_bool("/plugins/core/newline/chat", TRUE); } PURPLE_INIT_PLUGIN(lastseen, init_plugin, info)