pidgin/purple-plugin-pack

Add some preferences to the irssi plugin.
org.guifications.plugins
2008-06-09, rekkanoryo
0f4a7f4135d4
Parents 32e5454382fc
Children f6353d79c4b9
Add some preferences to the irssi plugin.
--- a/irssi/Makefile.am Tue May 20 06:06:17 2008 -0400
+++ b/irssi/Makefile.am Mon Jun 09 00:27:46 2008 -0400
@@ -1,5 +1,6 @@
HEADER_FILES = \
datechange.h \
+ irssi.h \
lastlog.h \
layout.h \
textfmt.h \
--- a/irssi/datechange.c Tue May 20 06:06:17 2008 -0400
+++ b/irssi/datechange.c Mon Jun 09 00:27:46 2008 -0400
@@ -27,7 +27,7 @@
#include <plugin.h>
#include <cmds.h>
-#include "datechange.h"
+#include "irssi.h"
/******************************************************************************
* Globals
@@ -85,8 +85,8 @@
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 *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
--- a/irssi/irssi.c Tue May 20 06:06:17 2008 -0400
+++ b/irssi/irssi.c Mon Jun 09 00:27:46 2008 -0400
@@ -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@reaperworld.com>\n" \
- "\tJohn Bailey <rekkanoryo@rekkanoryo.org>\n" \
- "\tSadrul Habib Chowdhury <sadrul@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 @@
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 @@
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 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)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/irssi/irssi.h Mon Jun 09 00:27:46 2008 -0400
@@ -0,0 +1,41 @@
+/*
+ * irssi - Implements several irssi features for Purple
+ * Copyright (C) 2005-2008 Gary Kramlich <grim@reaperworld.com>
+ * Copyright (C) 2006-2008 John Bailey <rekkanoryo@rekkanoryo.org>
+ * Copyright (C) 2006-2008 Sadrul Habib Chowdhury <sadrul@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@reaperworld.com>\n" \
+ "\tJohn Bailey <rekkanoryo@rekkanoryo.org>\n" \
+ "\tSadrul Habib Chowdhury <sadrul@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"
+