org.guifications.plugins: 8f79c912ab5995822f9eeae0cbe69140ee15d3ce

rekkanoryo at guifications.org rekkanoryo at guifications.org
Sun Jun 8 19:25:10 CDT 2008


-----------------------------------------------------------------
Revision: 8f79c912ab5995822f9eeae0cbe69140ee15d3ce
Ancestor: 18b50623a6bb3b224180f903f09978db31cae820
Author: rekkanoryo at guifications.org
Date: 2008-06-09T00:27:46
Branch: org.guifications.plugins

Added files:
        irssi/irssi.h
Modified files:
        irssi/Makefile.am irssi/datechange.c irssi/irssi.c

ChangeLog: 

Add some preferences to the irssi plugin.

-----------------------------------------------------------------
This revision's diffstat output:
 Makefile.am  |    1 +
 datechange.c |   32 +++++++++++++++++---------------
 irssi.c      |   57 ++++++++++++++++++++++++++++++++++++++++++---------------
 irssi.h      |   41 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 101 insertions(+), 30 deletions(-)
-------------- next part --------------
============================================================
--- irssi/irssi.h	fed820a8216014f8421d79213b9f6934f677a087
+++ irssi/irssi.h	fed820a8216014f8421d79213b9f6934f677a087
@@ -0,0 +1,41 @@
+/*
+ * irssi - Implements several irssi features for Purple
+ * Copyright (C) 2005-2008 Gary Kramlich <grim at reaperworld.com>
+ * Copyright (C) 2006-2008 John Bailey <rekkanoryo at rekkanoryo.org>
+ * Copyright (C) 2006-2008 Sadrul Habib Chowdhury <sadrul at users.sourceforge.net>
+ *
+ * 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 the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02111-1301, USA.
+ */
+
+#define PLUGIN_ID			"gtk-plugin_pack-irssi"
+#define PLUGIN_STATIC_NAME	"irssi"
+#define PLUGIN_AUTHOR		"\n" \
+							"\tGary Kramlich <grim at reaperworld.com>\n" \
+							"\tJohn Bailey <rekkanoryo at rekkanoryo.org>\n" \
+							"\tSadrul Habib Chowdhury <sadrul at users.sourceforge.net>"
+
+#define PREFS_ROOT_PARENT	"/pidgin/plugins"
+#define PREFS_ROOT			"/pidgin/plugins/" PLUGIN_ID
+#define TEXTFMT_PREF		PREFS_ROOT "/textfmt"
+#define DATECHANGE_PREF		PREFS_ROOT "/datechange"
+#define SENDNEWYEAR_PREF	PREFS_ROOT "/happynewyear"
+
+#include "datechange.h"
+#include "lastlog.h"
+#include "layout.h"
+#include "textfmt.h"
+#include "window.h"
+
============================================================
--- irssi/Makefile.am	ab40ddd9c4bf5e33475cef3f655dae701c5f5ed3
+++ irssi/Makefile.am	d49b18f75534d90f5f39378d83ff15bc3c209827
@@ -1,5 +1,6 @@ HEADER_FILES = \
 HEADER_FILES = \
 	datechange.h \
+	irssi.h \
 	lastlog.h \
 	layout.h \
 	textfmt.h \
============================================================
--- irssi/datechange.c	9c947eda4d2e98024134e394d85fe39012ea72ea
+++ irssi/datechange.c	7dc48c3c9fc9a51fb4ca7db4ebf95719c5387dde
@@ -27,7 +27,7 @@
 #include <plugin.h>
 #include <cmds.h>
 
-#include "datechange.h"
+#include "irssi.h"
 
 /******************************************************************************
  * Globals
@@ -85,8 +85,8 @@ irssi_datechange_timeout_cb(gpointer dat
 		purple_conversation_write(conv, NULL, message,
 				PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_ACTIVE_ONLY,
 				t);
-		if ((irssi_datechange_get_day(&t) == 1) &&
-				(irssi_datechange_get_month(&t) == 0))
+		if ((irssi_datechange_get_day(&t) == 1) && (irssi_datechange_get_month(&t) == 0) &&
+				purple_prefs_get_bool(SENDNEWYEAR_PREF))
 		{
 			const gchar *new_year = _("Happy New Year");
 			if(conv->type == PURPLE_CONV_TYPE_IM)
@@ -110,20 +110,22 @@ irssi_datechange_init(PurplePlugin *plug
 irssi_datechange_init(PurplePlugin *plugin) {
 	time_t t;
 
-	if(irssi_datechange_timeout_id != 0)
-		purple_timeout_remove(irssi_datechange_timeout_id);
+	if(purple_prefs_get_bool(DATECHANGE_PREF)) {
+		if(irssi_datechange_timeout_id != 0)
+			purple_timeout_remove(irssi_datechange_timeout_id);
 	
-	t = time(NULL);
-	lastday = irssi_datechange_get_day(&t);
+		t = time(NULL);
+		lastday = irssi_datechange_get_day(&t);
 
-	/* set this to get called every 30 seconds.
-	 *
-	 * Yes we only care about a day change, but i'd rather get it in the first
-	 * 30 seconds of the change rather than nearly a min later.
-	 */
-	irssi_datechange_timeout_id = g_timeout_add(30000,
-												irssi_datechange_timeout_cb,
-												NULL);
+		/* set this to get called every 30 seconds.
+		 *
+		 * Yes we only care about a day change, but i'd rather get it in the first
+		 * 30 seconds of the change rather than nearly a min later.
+		 */
+		irssi_datechange_timeout_id = g_timeout_add(30000,
+													irssi_datechange_timeout_cb,
+													NULL);
+	}
 }
 
 void
============================================================
--- irssi/irssi.c	c8a1cb945ca0fe24b770d5c2bcc5a54532ad7d1a
+++ irssi/irssi.c	265c3bfac4ac25a05eed83a5a87ceaf4eb7f0bca
@@ -23,22 +23,11 @@
 /* If you can't figure out what this line is for, DON'T TOUCH IT. */
 #include "../common/pp_internal.h"
 
-/* define these so the plugin info struct way at the bottom is cleaner */
-#define PLUGIN_ID			"gtk-plugin_pack-irssi"
-#define PLUGIN_STATIC_NAME	"irssi"
-#define PLUGIN_AUTHOR		"\n" \
-							"\tGary Kramlich <grim at reaperworld.com>\n" \
-							"\tJohn Bailey <rekkanoryo at rekkanoryo.org>\n" \
-							"\tSadrul Habib Chowdhury <sadrul at users.sourceforge.net>"
-
+/* Pidgin headers */
 #include <gtkplugin.h>
 
-/* irssi headers */
-#include "datechange.h"
-#include "lastlog.h"
-#include "layout.h"
-#include "textfmt.h"
-#include "window.h"
+/* Local plugin headers */
+#include "irssi.h"
 
 static gboolean
 irssi_load(PurplePlugin *plugin) {
@@ -62,6 +51,38 @@ irssi_unload(PurplePlugin *plugin) {
 	return TRUE;
 }
 
+static PurplePluginPrefFrame *
+irssi_pref_frame(PurplePlugin *plugin) {
+	PurplePluginPrefFrame *frame;
+	PurplePluginPref *pref;
+
+	frame = purple_plugin_pref_frame_new();
+
+	pref = purple_plugin_pref_new_with_label(_("Enable Features:"));
+	purple_plugin_pref_frame_add(frame, pref);
+
+	pref = purple_plugin_pref_new_with_name_and_label(TEXTFMT_PREF, _("Text Formatting"));
+	purple_plugin_pref_frame_add(frame, pref);
+
+	pref = purple_plugin_pref_new_with_name_and_label(DATECHANGE_PREF, _("Date Change Notification"));
+	purple_plugin_pref_frame_add(frame, pref);
+
+	pref = purple_plugin_pref_new_with_name_and_label(SENDNEWYEAR_PREF, _("Happy New Year Message"));
+	purple_plugin_pref_frame_add(frame, pref);
+
+	return frame;
+}
+
+static PurplePluginUiInfo irssi_prefs_info = {
+	irssi_pref_frame,
+	0,
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+	NULL
+};
+
 static PurplePluginInfo irssi_info = { /* this tells Purple about the plugin */
 	PURPLE_PLUGIN_MAGIC,			/* Magic				*/
 	PURPLE_MAJOR_VERSION,			/* Purple Major Version	*/
@@ -86,7 +107,7 @@ static PurplePluginInfo irssi_info = { /
 
 	NULL,							/* ui_info				*/
 	NULL,							/* extra_info			*/
-	NULL,							/* prefs_info			*/
+	&irssi_prefs_info,				/* prefs_info			*/
 	NULL,							/* actions				*/
 	NULL,							/* reserved 1			*/
 	NULL,							/* reserved 2			*/
@@ -113,6 +134,12 @@ irssi_init(PurplePlugin *plugin) {
 			"irssi to be used in Purple.  It lets you know in all open "
 			"conversations when the day has changed, adds the lastlog command, "
 			"adds the window command, etc.  The day changed message is not logged.");
+
+	purple_prefs_add_none(PREFS_ROOT_PARENT);
+	purple_prefs_add_none(PREFS_ROOT);
+	purple_prefs_add_bool(TEXTFMT_PREF, TRUE);
+	purple_prefs_add_bool(DATECHANGE_PREF, TRUE);
+	purple_prefs_add_bool(SENDNEWYEAR_PREF, TRUE);
 }
 
 PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, irssi_init, irssi_info)


More information about the Plugins-commits mailing list