comparison pidgin/gtkblist.c @ 23969:5045f2ce9cff

disapproval of revision 'f5ca7968e3f6be8f81d068232d389e0b1dab784b'
author Kevin Stange <kevin@simguy.net>
date Thu, 11 Sep 2008 20:25:47 +0000
parents bedb72eb2ef7
children aa8ddc4e12af f68accaa3fea
comparison
equal deleted inserted replaced
23967:bedb72eb2ef7 23969:5045f2ce9cff
65 #include <gdk/gdkkeysyms.h> 65 #include <gdk/gdkkeysyms.h>
66 #include <gtk/gtk.h> 66 #include <gtk/gtk.h>
67 #include <gdk/gdk.h> 67 #include <gdk/gdk.h>
68 68
69 #define HEADLINE_CLOSE_SIZE 12 69 #define HEADLINE_CLOSE_SIZE 12
70 #define STEPS 50
71 70
72 typedef struct 71 typedef struct
73 { 72 {
74 PurpleAccount *account; 73 PurpleAccount *account;
75 74
166 165
167 typedef enum { 166 typedef enum {
168 PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE = 1 << 0, /* Whether there's pending message in a conversation */ 167 PIDGIN_BLIST_NODE_HAS_PENDING_MESSAGE = 1 << 0, /* Whether there's pending message in a conversation */
169 } PidginBlistNodeFlags; 168 } PidginBlistNodeFlags;
170 169
171 typedef enum {
172 RECENT_STATUS_NONE = 0,
173 RECENT_STATUS_SIGN_ON,
174 RECENT_STATUS_SIGN_OFF
175 } RecentStatus;
176
177 typedef struct _pidgin_blist_node { 170 typedef struct _pidgin_blist_node {
178 GtkTreeRowReference *row; 171 GtkTreeRowReference *row;
179 gboolean contact_expanded; 172 gboolean contact_expanded;
180 RecentStatus recent_signonoff; 173 gboolean recent_signonoff;
181 gint recent_signonoff_timer; 174 gint recent_signonoff_timer;
182 gint recent_signonoff_steps;
183 struct { 175 struct {
184 PurpleConversation *conv; 176 PurpleConversation *conv;
185 time_t last_message; /* timestamp for last displayed message */ 177 time_t last_message; /* timestamp for last displayed message */
186 PidginBlistNodeFlags flags; 178 PidginBlistNodeFlags flags;
187 } conv; 179 } conv;
3744 } 3736 }
3745 3737
3746 p = purple_buddy_get_presence(buddy); 3738 p = purple_buddy_get_presence(buddy);
3747 trans = purple_presence_is_idle(p); 3739 trans = purple_presence_is_idle(p);
3748 3740
3749 /*if (PURPLE_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff) 3741 if (PURPLE_BUDDY_IS_ONLINE(buddy) && gtkbuddynode && gtkbuddynode->recent_signonoff)
3750 icon = PIDGIN_STOCK_STATUS_LOGIN; 3742 icon = PIDGIN_STOCK_STATUS_LOGIN;
3751 else if (gtkbuddynode && gtkbuddynode->recent_signonoff) 3743 else if (gtkbuddynode && gtkbuddynode->recent_signonoff)
3752 icon = PIDGIN_STOCK_STATUS_LOGOUT; 3744 icon = PIDGIN_STOCK_STATUS_LOGOUT;
3753 else */if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE)) 3745 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_UNAVAILABLE))
3754 if (trans) 3746 if (trans)
3755 icon = PIDGIN_STOCK_STATUS_BUSY_I; 3747 icon = PIDGIN_STOCK_STATUS_BUSY_I;
3756 else 3748 else
3757 icon = PIDGIN_STOCK_STATUS_BUSY; 3749 icon = PIDGIN_STOCK_STATUS_BUSY;
3758 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY)) 3750 else if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_AWAY))
6044 { 6036 {
6045 PurplePresence *presence; 6037 PurplePresence *presence;
6046 GdkPixbuf *status, *avatar, *emblem, *prpl_icon; 6038 GdkPixbuf *status, *avatar, *emblem, *prpl_icon;
6047 char *mark; 6039 char *mark;
6048 char *idle = NULL; 6040 char *idle = NULL;
6049 struct _pidgin_blist_node *gtknode = ((PurpleBlistNode*)buddy)->ui_data;
6050 gboolean expanded = ((struct _pidgin_blist_node *)(node->parent->ui_data))->contact_expanded; 6041 gboolean expanded = ((struct _pidgin_blist_node *)(node->parent->ui_data))->contact_expanded;
6051 gboolean selected = (gtkblist->selected_node == node); 6042 gboolean selected = (gtkblist->selected_node == node);
6052 gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons"); 6043 gboolean biglist = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/blist/show_buddy_icons");
6053 int size;
6054 presence = purple_buddy_get_presence(buddy); 6044 presence = purple_buddy_get_presence(buddy);
6055 6045
6056 if (editing_blist) 6046 if (editing_blist)
6057 return; 6047 return;
6058 6048
6059 status = pidgin_blist_get_status_icon((PurpleBlistNode*)buddy, 6049 status = pidgin_blist_get_status_icon((PurpleBlistNode*)buddy,
6060 biglist ? PIDGIN_STATUS_ICON_LARGE : PIDGIN_STATUS_ICON_SMALL); 6050 biglist ? PIDGIN_STATUS_ICON_LARGE : PIDGIN_STATUS_ICON_SMALL);
6061
6062 size = biglist ? 16 : 11;
6063 if (gtknode->recent_signonoff == RECENT_STATUS_SIGN_ON) {
6064 size = size / 2 + (size / 2 + (STEPS - gtknode->recent_signonoff_steps)) % (size / 2);
6065 } else if (gtknode->recent_signonoff == RECENT_STATUS_SIGN_OFF) {
6066 size = size - (STEPS - gtknode->recent_signonoff_steps) % (size / 2);
6067 }
6068 status = gdk_pixbuf_scale_simple(status, size, size, GDK_INTERP_BILINEAR);
6069 6051
6070 /* Speed it up if we don't want buddy icons. */ 6052 /* Speed it up if we don't want buddy icons. */
6071 if(biglist) 6053 if(biglist)
6072 avatar = pidgin_blist_get_buddy_icon((PurpleBlistNode *)buddy, TRUE, TRUE); 6054 avatar = pidgin_blist_get_buddy_icon((PurpleBlistNode *)buddy, TRUE, TRUE);
6073 else 6055 else
6196 IDLE_VISIBLE_COLUMN, FALSE, 6178 IDLE_VISIBLE_COLUMN, FALSE,
6197 BGCOLOR_COLUMN, NULL, 6179 BGCOLOR_COLUMN, NULL,
6198 BUDDY_ICON_COLUMN, NULL, 6180 BUDDY_ICON_COLUMN, NULL,
6199 CONTACT_EXPANDER_COLUMN, TRUE, 6181 CONTACT_EXPANDER_COLUMN, TRUE,
6200 CONTACT_EXPANDER_VISIBLE_COLUMN, TRUE, 6182 CONTACT_EXPANDER_VISIBLE_COLUMN, TRUE,
6201 GROUP_EXPANDER_VISIBLE_COLUMN, FALSE, 6183 GROUP_EXPANDER_VISIBLE_COLUMN, FALSE,
6202 -1); 6184 -1);
6203 g_free(mark); 6185 g_free(mark);
6204 if(status) 6186 if(status)
6205 g_object_unref(status); 6187 g_object_unref(status);
6206 } else { 6188 } else {
7148 } 7130 }
7149 7131
7150 static gboolean buddy_signonoff_timeout_cb(PurpleBuddy *buddy) 7132 static gboolean buddy_signonoff_timeout_cb(PurpleBuddy *buddy)
7151 { 7133 {
7152 struct _pidgin_blist_node *gtknode = ((PurpleBlistNode*)buddy)->ui_data; 7134 struct _pidgin_blist_node *gtknode = ((PurpleBlistNode*)buddy)->ui_data;
7153 gboolean cont = TRUE; 7135
7154 7136 gtknode->recent_signonoff = FALSE;
7155 if (--gtknode->recent_signonoff_steps == 0) { 7137 gtknode->recent_signonoff_timer = 0;
7156 gtknode->recent_signonoff = RECENT_STATUS_NONE;
7157 gtknode->recent_signonoff_timer = 0;
7158 cont = FALSE;
7159 }
7160 7138
7161 pidgin_blist_update(NULL, (PurpleBlistNode*)buddy); 7139 pidgin_blist_update(NULL, (PurpleBlistNode*)buddy);
7162 7140
7163 return cont; 7141 return FALSE;
7164 } 7142 }
7165 7143
7166 static void buddy_signonoff_cb(PurpleBuddy *buddy) 7144 static void buddy_signonoff_cb(PurpleBuddy *buddy)
7167 { 7145 {
7168 struct _pidgin_blist_node *gtknode; 7146 struct _pidgin_blist_node *gtknode;
7171 pidgin_blist_new_node((PurpleBlistNode*)buddy); 7149 pidgin_blist_new_node((PurpleBlistNode*)buddy);
7172 } 7150 }
7173 7151
7174 gtknode = ((PurpleBlistNode*)buddy)->ui_data; 7152 gtknode = ((PurpleBlistNode*)buddy)->ui_data;
7175 7153
7176 gtknode->recent_signonoff = PURPLE_BUDDY_IS_ONLINE(buddy) ? RECENT_STATUS_SIGN_ON : RECENT_STATUS_SIGN_OFF; 7154 gtknode->recent_signonoff = TRUE;
7177 7155
7178 if(gtknode->recent_signonoff_timer > 0) 7156 if(gtknode->recent_signonoff_timer > 0)
7179 purple_timeout_remove(gtknode->recent_signonoff_timer); 7157 purple_timeout_remove(gtknode->recent_signonoff_timer);
7180 gtknode->recent_signonoff_steps = STEPS; 7158 gtknode->recent_signonoff_timer = purple_timeout_add(10000,
7181 gtknode->recent_signonoff_timer = purple_timeout_add(100,
7182 (GSourceFunc)buddy_signonoff_timeout_cb, buddy); 7159 (GSourceFunc)buddy_signonoff_timeout_cb, buddy);
7183 } 7160 }
7184 7161
7185 void pidgin_blist_init(void) 7162 void pidgin_blist_init(void)
7186 { 7163 {
7653 7630
7654 if (menuitem != gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts/Manage Accounts"))) 7631 if (menuitem != gtk_item_factory_get_widget(gtkblist->ift, N_("/Accounts/Manage Accounts")))
7655 gtk_widget_destroy(menuitem); 7632 gtk_widget_destroy(menuitem);
7656 } 7633 }
7657 7634
7658 if (!(accounts = purple_accounts_get_all())) 7635 for (accounts = purple_accounts_get_all(); accounts; accounts = accounts->next) {
7659 return;
7660
7661 for (; accounts; accounts = accounts->next) {
7662 char *buf = NULL; 7636 char *buf = NULL;
7663 GtkWidget *image = NULL; 7637 GtkWidget *image = NULL;
7664 PurpleAccount *account = NULL; 7638 PurpleAccount *account = NULL;
7665 GdkPixbuf *pixbuf = NULL; 7639 GdkPixbuf *pixbuf = NULL;
7666 7640