org.guifications.plugins: 7775e4a7ba416a8e3da2560f8c1769581b430738

grim at guifications.org grim at guifications.org
Wed Apr 16 21:50:06 CDT 2008


-----------------------------------------------------------------
Revision: 7775e4a7ba416a8e3da2560f8c1769581b430738
Ancestor: 5747964c20cad5b60a0aad2212b1cb139dae036d
Author: grim at guifications.org
Date: 2008-04-17T02:47:56
Branch: org.guifications.plugins

Added files:
        msglen/.incomplete msglen/.pidgin-plugin msglen/Makefile.am
        msglen/Makefile.mingw msglen/msglen.c
Added directories:
        msglen
Modified files:
        configure.ac

ChangeLog: 

adding a message length plugin, this kind of works, but not really, i really need to just finish the things i start


-----------------------------------------------------------------
This revision's diffstat output:
 configure.ac          |    1 
 msglen/Makefile.am    |   27 ++++++
 msglen/Makefile.mingw |   12 ++
 msglen/msglen.c       |  217 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 257 insertions(+)
-------------- next part --------------
============================================================
--- msglen/.incomplete	da39a3ee5e6b4b0d3255bfef95601890afd80709
+++ msglen/.incomplete	da39a3ee5e6b4b0d3255bfef95601890afd80709
============================================================
--- msglen/.pidgin-plugin	da39a3ee5e6b4b0d3255bfef95601890afd80709
+++ msglen/.pidgin-plugin	da39a3ee5e6b4b0d3255bfef95601890afd80709
============================================================
--- msglen/Makefile.am	e1ba5d37465510306a92e5307fef165ce07aca27
+++ msglen/Makefile.am	e1ba5d37465510306a92e5307fef165ce07aca27
@@ -0,0 +1,27 @@
+EXTRA_DIST = .pidgin-plugin .incomplete Makefile.mingw
+
+msglendir = $(PIDGIN_LIBDIR)
+
+msglen_la_LDFLAGS = -module -avoid-version
+
+if HAVE_PIDGIN
+
+msglen_LTLIBRARIES = msglen.la
+
+msglen_la_SOURCES = \
+	msglen.c
+
+msglen_la_LIBADD = \
+	$(GTK_LIBS) \
+	$(PIDGIN_LIBS)
+
+endif
+
+AM_CPPFLAGS = \
+	-DLIBDIR=\"$(PIDGIN_LIBDIR)\" \
+	-DDATADIR=\"$(PIDGIN_DATADIR)\" \
+	-DPIXMAPSDIR=\"$(PIDGIN_PIXMAPSDIR)\" \
+	$(DEBUG_CFLAGS) \
+	$(PIDGIN_CFLAGS) \
+	$(GTK_CFLAGS)
+
============================================================
--- msglen/Makefile.mingw	9ccf7fe52849ac70be4cb99693985c0800d24b66
+++ msglen/Makefile.mingw	9ccf7fe52849ac70be4cb99693985c0800d24b66
@@ -0,0 +1,12 @@
+#
+# Makefile.mingw
+#
+# Description: Makefile for convbadger plugin.
+#
+
+PP_TOP :=		..
+
+PP = msglen
+
+include $(PP_TOP)/win_pp.mak
+
============================================================
--- msglen/msglen.c	8d95dbc5954eed64a2e68e4b66b7f64d01c31488
+++ msglen/msglen.c	8d95dbc5954eed64a2e68e4b66b7f64d01c31488
@@ -0,0 +1,217 @@
+/*
+ * msglen - Adds the current message's length to the menutray of a conversation
+ * Copyright (C) 2008 Gary Kramlich <grim at reaperworld.com>
+ *
+ * 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.
+ */
+
+/* If you can't figure out what this line is for, DON'T TOUCH IT. */
+#include "../common/pp_internal.h"
+
+#include <gtk/gtk.h>
+
+#include <conversation.h>
+#include <signals.h>
+
+#include <gtkconv.h>
+#include <gtkmenutray.h>
+#include <gtkplugin.h>
+#include <gtkutils.h>
+
+/******************************************************************************
+ * Structs
+ *****************************************************************************/
+typedef struct {
+	PurpleConversation *conv;
+	PidginWindow *win;
+	GtkWidget *label;
+} MsgLenData;
+
+/******************************************************************************
+ * Globals
+ *****************************************************************************/
+static GHashTable *data = NULL;
+
+/******************************************************************************
+ * helpers
+ *****************************************************************************/
+static void
+msg_len_data_free(MsgLenData *mld) {
+	mld->win = NULL;
+	mld->conv = NULL;
+
+	if(mld->label && GTK_IS_LABEL(mld->label))
+		gtk_widget_destroy(mld->label);
+
+	g_free(mld);
+
+	mld = NULL;
+}
+
+static void
+msg_len_data_free_helper(gpointer k, gpointer v, gpointer d) {
+	MsgLenData *mld = (MsgLenData *)v;
+
+	msg_len_data_free(mld);
+}
+
+static void
+msg_len_update(PidginWindow *win, PurpleConversation *conv) {
+	PidginConversation *gtkconv = NULL;
+	MsgLenData *mld = NULL;
+	gchar *text = NULL;
+	gint count = 0;
+
+	g_return_if_fail(win);
+	g_return_if_fail(conv);
+
+	mld = g_hash_table_lookup(data, conv);
+
+	if(mld == NULL) {
+		mld = g_new0(MsgLenData, 1);
+
+		mld->win = win;
+		mld->conv
+
+		mld->label = gtk_label_new("");
+		pidgin_menu_tray_append(PIDGIN_MENU_TRAY(win->menu.tray), mld->label,
+								NULL);
+		gtk_widget_show(mld->label);
+
+		g_signal_connect_swapped(G_OBJECT(mld->label), "destroy",
+								 G_CALLBACK(g_nullify_pointer), &mld->label);
+	}
+
+	mld->conv = conv;
+
+	gtkconv = PIDGIN_CONVERSATION(conv);
+	count = gtk_text_buffer_get_char_count(gtkconv->entry_buffer);
+
+	text = g_strdup_printf("%d", count);
+	gtk_label_set_text(GTK_LABEL(mld->label), text);
+	g_free(text);
+
+	g_hash_table_insert(data, win, mld);
+}
+
+/******************************************************************************
+ * Callbacks
+ *****************************************************************************/
+static void
+msg_len_conv_created_cb(PurpleConversation *conv, gpointer data) {
+	PidginConversation *pconv = PIDGIN_CONVERSATION(conv);
+	PidginWindow *win = pidgin_conv_get_window(pconv);
+
+	purple_debug_info("msglen", "created\n");
+
+	msg_len_update(win, conv);
+}
+
+static void
+msg_len_conv_destroyed_cb(PurpleConversation *conv, gpointer data) {
+	purple_debug_info("msglen", "destroyed\n");
+}
+
+static void
+msg_len_conv_switched_cb(PurpleConversation *conv, gpointer data) {
+	PidginConversation *pconv = PIDGIN_CONVERSATION(conv);
+	PidginWindow *win = pidgin_conv_get_window(pconv);
+
+	purple_debug_info("msglen", "switched\n");
+
+	msg_len_update(win, conv);
+}
+
+/******************************************************************************
+ * Plugin Stuff
+ *****************************************************************************/
+static gboolean
+plugin_load(PurplePlugin *plugin) {
+	void *conv_handle = purple_conversations_get_handle();
+
+	data = g_hash_table_new_full(g_direct_hash, g_direct_equal,
+								 NULL, NULL);
+
+	purple_signal_connect(conv_handle, "conversation-created", plugin,
+						  PURPLE_CALLBACK(msg_len_conv_created_cb), NULL);
+	purple_signal_connect(conv_handle, "deleting-conversation", plugin,
+						  PURPLE_CALLBACK(msg_len_conv_destroyed_cb), NULL);
+
+	purple_signal_connect(pidgin_conversations_get_handle(),
+						  "conversation-switched", plugin,
+						  PURPLE_CALLBACK(msg_len_conv_switched_cb), NULL);
+
+	return TRUE;
+}
+
+static gboolean
+plugin_unload(PurplePlugin *plugin) {
+	g_hash_table_foreach(data, msg_len_data_free_helper, NULL);
+
+	g_hash_table_destroy(data);
+
+	data = NULL;
+
+	return TRUE;
+}
+
+static PurplePluginInfo info = {
+	PURPLE_PLUGIN_MAGIC,
+	PURPLE_MAJOR_VERSION,
+	PURPLE_MINOR_VERSION,
+	PURPLE_PLUGIN_STANDARD,
+	PIDGIN_PLUGIN_TYPE,
+	0,
+	NULL,
+	PURPLE_PRIORITY_DEFAULT,
+
+	"gtk-plugin_pack-msglen",
+	NULL,
+	PP_VERSION,
+	NULL,
+	NULL,
+	"Gary Kramlich <grim at reaperworld.com>",	
+	PP_WEBSITE,	
+
+	plugin_load,
+	plugin_unload,
+	NULL,
+
+	NULL,
+	NULL,
+	NULL,
+	NULL,
+
+	NULL,
+	NULL,
+	NULL,
+	NULL
+};
+
+
+static void
+init_plugin(PurplePlugin *plugin) {
+#ifdef ENABLE_NLS
+	bindtextdomain(GETTEXT_PACKAGE, PP_LOCALEDIR);
+	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+#endif /* ENABLE_NLS */
+
+	info.name = _("Message Length");
+	info.summary = _("Shows the length of your current message in the menu "
+					 "tray");
+	info.description = info.summary;
+}
+
+PURPLE_INIT_PLUGIN(msg_len, init_plugin, info)
============================================================
--- configure.ac	d0a62dd5aa8b5c9a952953f01f2afe36028301a9
+++ configure.ac	5bbf4c0bdf0a2cc167781389aa0b1c403ae798d3
@@ -366,6 +366,7 @@ AC_OUTPUT([
 	lastseen/Makefile
 	listhandler/Makefile
 	manualsize/Makefile
+	msglen/Makefile
 	mystatusbox/Makefile
 	napster/Makefile
 	nicksaid/Makefile


More information about the Plugins-commits mailing list