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