pidgin/purple-plugin-pack

Parents 05708390e9b2
Children dbf77be7c544
Got the message length plugin working... Should be good, needs a bit more testing, but everything _should_ be good...
--- a/ChangeLog Thu Jul 03 07:39:46 2008 -0400
+++ b/ChangeLog Thu Jul 03 08:14:49 2008 -0400
@@ -11,6 +11,7 @@
* Added preferences to the irssi plugin that allow changing its behavior
* Fixed the preference strings in slashexec so mnemonics are no longer
incorrectly interpreted from the strings.
+ * Added Message Length plugin
Version 2.3.0: 03/17/08
* Fixed a typo in irc-more's source that allowed a potential double-free
--- a/msglen/msglen.c Thu Jul 03 07:39:46 2008 -0400
+++ b/msglen/msglen.c Thu Jul 03 08:14:49 2008 -0400
@@ -67,6 +67,18 @@
msg_len_data_free(mld);
}
+static void msg_len_update(PidginWindow *win, PurpleConversation *conv);
+
+static gboolean
+msg_len_key_released_cb(GtkWidget *w, GdkEventKey *e, gpointer d) {
+ MsgLenData *mld = (MsgLenData *)d;
+
+ if(d)
+ msg_len_update(mld->win, mld->conv);
+
+ return FALSE;
+}
+
static void
msg_len_update(PidginWindow *win, PurpleConversation *conv) {
PidginConversation *gtkconv = NULL;
@@ -77,13 +89,15 @@
g_return_if_fail(win);
g_return_if_fail(conv);
+ gtkconv = PIDGIN_CONVERSATION(conv);
+
mld = g_hash_table_lookup(data, conv);
if(mld == NULL) {
mld = g_new0(MsgLenData, 1);
mld->win = win;
- mld->conv
+ mld->conv = conv;
mld->label = gtk_label_new("");
pidgin_menu_tray_append(PIDGIN_MENU_TRAY(win->menu.tray), mld->label,
@@ -92,45 +106,41 @@
g_signal_connect_swapped(G_OBJECT(mld->label), "destroy",
G_CALLBACK(g_nullify_pointer), &mld->label);
+
+ g_signal_connect(G_OBJECT(gtkconv->entry), "key-release-event",
+ G_CALLBACK(msg_len_key_released_cb), mld);
}
- 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);
+ g_hash_table_insert(data, conv, mld);
}
/******************************************************************************
* Callbacks
*****************************************************************************/
static void
-msg_len_conv_created_cb(PurpleConversation *conv, gpointer data) {
+msg_len_conv_created_cb(PurpleConversation *conv, gpointer d) {
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");
+msg_len_conv_destroyed_cb(PurpleConversation *conv, gpointer d) {
+ g_hash_table_remove(data, conv);
}
static void
-msg_len_conv_switched_cb(PurpleConversation *conv, gpointer data) {
+msg_len_conv_switched_cb(PurpleConversation *conv, gpointer d) {
PidginConversation *pconv = PIDGIN_CONVERSATION(conv);
PidginWindow *win = pidgin_conv_get_window(pconv);
- purple_debug_info("msglen", "switched\n");
-
msg_len_update(win, conv);
}
@@ -139,6 +149,7 @@
*****************************************************************************/
static gboolean
plugin_load(PurplePlugin *plugin) {
+ GList *convs = NULL;
void *conv_handle = purple_conversations_get_handle();
data = g_hash_table_new_full(g_direct_hash, g_direct_equal,
@@ -153,6 +164,13 @@
"conversation-switched", plugin,
PURPLE_CALLBACK(msg_len_conv_switched_cb), NULL);
+ for(convs = purple_get_conversations(); convs; convs = convs->next) {
+ PurpleConversation *conv = (PurpleConversation *)convs->data;
+ PidginConversation *gtkconv = PIDGIN_CONVERSATION(conv);
+
+ msg_len_update(gtkconv->win, conv);
+ }
+
return TRUE;
}
@@ -215,3 +233,4 @@
}
PURPLE_INIT_PLUGIN(msg_len, init_plugin, info)
+
--- a/msglen/plugins.cfg Thu Jul 03 07:39:46 2008 -0400
+++ b/msglen/plugins.cfg Thu Jul 03 08:14:49 2008 -0400
@@ -1,5 +1,5 @@
[Message Length]
-type=incomplete
+type=default
depends=pidgin
provides=msglen
summary=Shows the length of your current message in the menu tray