org.guifications.plugins: 5971b0c06702206abab0949a76b5fa69d8477058
grim at guifications.org
grim at guifications.org
Thu Jul 3 03:15:04 CDT 2008
-----------------------------------------------------------------
Revision: 5971b0c06702206abab0949a76b5fa69d8477058
Ancestor: 3e52de5a8b56711393f126806c660aad6ba74895
Author: grim at guifications.org
Date: 2008-07-03T08:14:49
Branch: org.guifications.plugins
Modified files:
ChangeLog msglen/msglen.c msglen/plugins.cfg
ChangeLog:
Got the message length plugin working... Should be good, needs a bit more testing, but everything _should_ be good...
-----------------------------------------------------------------
This revision's diffstat output:
ChangeLog | 1 +
msglen/msglen.c | 45 ++++++++++++++++++++++++++++++++-------------
msglen/plugins.cfg | 2 +-
3 files changed, 34 insertions(+), 14 deletions(-)
-------------- next part --------------
============================================================
--- ChangeLog 6aa8a0cb1576126f914fa92af54eab91ba2281ce
+++ ChangeLog 2c715b0faf1453af8101e918ab67ce00f2440ae4
@@ -11,6 +11,7 @@ Version 2.4.0mtn:
* 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
============================================================
--- msglen/msglen.c 8d95dbc5954eed64a2e68e4b66b7f64d01c31488
+++ msglen/msglen.c 038681eab61ec0e29c90f58bbe44437903948bf9
@@ -67,6 +67,18 @@ msg_len_data_free_helper(gpointer k, gpo
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 @@ msg_len_update(PidginWindow *win, Purple
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 @@ msg_len_update(PidginWindow *win, Purple
g_signal_connect_swapped(G_OBJECT(mld->label), "destroy",
G_CALLBACK(g_nullify_pointer), &mld->label);
- }
- mld->conv = conv;
+ g_signal_connect(G_OBJECT(gtkconv->entry), "key-release-event",
+ G_CALLBACK(msg_len_key_released_cb), mld);
+ }
- 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 @@ plugin_load(PurplePlugin *plugin) {
*****************************************************************************/
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 @@ plugin_load(PurplePlugin *plugin) {
"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,
}
PURPLE_INIT_PLUGIN(msg_len, init_plugin, info)
+
============================================================
--- msglen/plugins.cfg 8f559b867f8e7f805c466bad72187c9f4e8f8bc2
+++ msglen/plugins.cfg 7ea67988aa80171a21940eac2c7f47e57f241d6b
@@ -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
More information about the Plugins-commits
mailing list