annotate src/buddy.c @ 4703:e4dda06a3143

[gaim-migrate @ 5014] Changed a bunch of the window titles from "Gaim - What this window is" to "What this window is". It's better like this. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 11 Mar 2003 08:17:22 +0000
parents cb5b23dfd82b
children 56c70997fe5c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1 /*
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
2 * gaim
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
3 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
5 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
9 * (at your option) any later version.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
10 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
11 * This program is distributed in the hope that it will be useful,
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
14 * GNU General Public License for more details.
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
15 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
17 * along with this program; if not, write to the Free Software
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
19 *
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
20 */
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
21
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 342
diff changeset
22 #ifdef HAVE_CONFIG_H
2090
b66aca8e8dce [gaim-migrate @ 2100]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2048
diff changeset
23 #include <config.h>
349
b402a23f35df [gaim-migrate @ 359]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 342
diff changeset
24 #endif
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 350
diff changeset
25 #ifdef GAIM_PLUGINS
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
26 #ifndef _WIN32
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 350
diff changeset
27 #include <dlfcn.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
28 #endif
391
be408b41c172 [gaim-migrate @ 401]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 350
diff changeset
29 #endif /* GAIM_PLUGINS */
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
30 #include <string.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
31 #include <stdio.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
32 #include <stdlib.h>
3159
fce1883cc608 [gaim-migrate @ 3175]
Sean Egan <seanegan@gmail.com>
parents: 3154
diff changeset
33 #include <ctype.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
34 #include <math.h>
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
35 #include <time.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
36 #include <ctype.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
37
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
38 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
39 #include <gdk/gdkwin32.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
40 #else
1233
728a90516211 [gaim-migrate @ 1243]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1230
diff changeset
41 #include <unistd.h>
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
42 #include <gdk/gdkx.h>
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
43 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
44
1634
d029dc28a61e [gaim-migrate @ 1644]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1625
diff changeset
45 #include <gdk/gdkkeysyms.h>
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
46 #include <gtk/gtk.h>
1030
38452403563b [gaim-migrate @ 1040]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1002
diff changeset
47 #include "prpl.h"
4561
9df99116840a [gaim-migrate @ 4842]
Nathan Walp <nwalp@pidgin.im>
parents: 4553
diff changeset
48 #include "sound.h"
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
49 #include "gaim.h"
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
50 #include "gtklist.h"
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
51 #include "gtkft.h"
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
52
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
53 #ifdef _WIN32
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
54 #include "win32dep.h"
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
55 #endif
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3570
diff changeset
56
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
57 static struct gaim_gtk_buddy_list *gtkblist = NULL;
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
58
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
59 /* Docklet nonsense */
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
60 static gboolean gaim_gtk_blist_obscured = FALSE;
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
61
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
62 static void gaim_gtk_blist_update(struct gaim_buddy_list *list, GaimBlistNode *node);
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
63
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
64 /***************************************************
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
65 * Callbacks *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
66 ***************************************************/
3869
061ed70be441 [gaim-migrate @ 4021]
Rob Flynn <gaim@robflynn.com>
parents: 3859
diff changeset
67
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
68 static void gaim_gtk_blist_destroy_cb()
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
69 {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
70 if (docklet_count)
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
71 gaim_blist_set_visible(FALSE);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
72 else
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
73 do_quit();
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
74 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
75
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
76 static void gtk_blist_menu_im_cb(GtkWidget *w, struct buddy *b)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
77 {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
78 gaim_conversation_new(GAIM_CONV_IM, b->account, b->name);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
79 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
80
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
81 static void gtk_blist_menu_alias_cb(GtkWidget *w, struct buddy *b)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
82 {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
83 alias_dialog_bud(b);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
84 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
85
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
86 static void gtk_blist_menu_bp_cb(GtkWidget *w, struct buddy *b)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
87 {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
88 show_new_bp(b->name, b->account->gc, b->idle,
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
89 b->uc & UC_UNAVAILABLE, NULL);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
90 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
91
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
92 static void gtk_blist_menu_showlog_cb(GtkWidget *w, struct buddy *b)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
93 {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
94 show_log(b->name);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
95 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
96
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
97 static void gtk_blist_show_systemlog_cb()
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
98 {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
99 show_log(NULL);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
100 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
101
4692
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
102 static void gtk_blist_button_im_cb(GtkWidget *w, GtkTreeView *tv)
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
103 {
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
104 GtkTreeIter iter;
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
105 GtkTreeModel *model = gtk_tree_view_get_model(tv);
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
106 GtkTreeSelection *sel = gtk_tree_view_get_selection(tv);
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
107
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
108 if(gtk_tree_selection_get_selected(sel, &model, &iter)){
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
109 GaimBlistNode *node;
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
110
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
111 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
112 if (GAIM_BLIST_NODE_IS_BUDDY(node))
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
113 gaim_conversation_new(GAIM_CONV_IM, ((struct buddy*)node)->account, ((struct buddy*)node)->name);
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
114 }
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
115 }
4692
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
116
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
117 static void gtk_blist_button_info_cb(GtkWidget *w, GtkTreeView *tv)
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
118 {
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
119 GtkTreeIter iter;
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
120 GtkTreeModel *model = gtk_tree_view_get_model(tv);
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
121 GtkTreeSelection *sel = gtk_tree_view_get_selection(tv);
4692
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
122
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
123 if(gtk_tree_selection_get_selected(sel, &model, &iter)){
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
124 GaimBlistNode *node;
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
125
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
126 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
127 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
128 serv_get_info(((struct buddy*)node)->account->gc, ((struct buddy*)node)->name);
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
129 return;
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
130 }
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
131 }
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
132 show_info_dialog();
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
133 }
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
134
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
135 static void gtk_blist_button_chat_cb(GtkWidget *w, gpointer data)
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
136 {
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
137 /* FIXME: someday, we can check to see if we've selected a chat node */
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
138 join_chat();
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
139 }
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
140
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
141 static void gtk_blist_button_away_cb(GtkWidget *w, gpointer data)
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
142 {
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
143 gtk_menu_popup(GTK_MENU(awaymenu), NULL, NULL, NULL, NULL, 1, GDK_CURRENT_TIME);
4692
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
144 }
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
145
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
146 static void gtk_blist_row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer data) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
147 GaimBlistNode *node;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
148 GtkTreeIter iter;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
149 GValue val = { 0, };
3154
a0a0b00f214b [gaim-migrate @ 3170]
Sean Egan <seanegan@gmail.com>
parents: 3152
diff changeset
150
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
151 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
152
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
153 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
154 node = g_value_get_pointer(&val);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
155
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
156 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
157 gaim_conversation_new(GAIM_CONV_IM, ((struct buddy*)node)->account, ((struct buddy*)node)->name);
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
158 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
159 if (gtk_tree_view_row_expanded(tv, path))
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
160 gtk_tree_view_collapse_row(tv, path);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
161 else
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
162 gtk_tree_view_expand_row(tv,path,FALSE);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
163 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
164 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
165
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
166 static void gaim_proto_menu_cb(GtkMenuItem *item, struct buddy *b)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
167 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
168 struct proto_buddy_menu *pbm = g_object_get_data(G_OBJECT(item), "gaimcallback");
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
169 if (pbm->callback)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
170 pbm->callback(pbm->gc, b->name);
1396
df7c3cacac92 [gaim-migrate @ 1406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1392
diff changeset
171 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
172
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
173 static gboolean gtk_blist_button_press_cb(GtkWidget *tv, GdkEventButton *event, gpointer null)
1391
d606da211acb [gaim-migrate @ 1401]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1376
diff changeset
174 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
175 GtkTreePath *path;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
176 GaimBlistNode *node;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
177 GValue val = { 0, };
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
178 GtkTreeIter iter;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
179 GtkWidget *menu, *menuitem;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
180 GtkWidget *image;
4702
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
181 GtkTreeSelection *sel;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
182 GList *list;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
183 struct prpl *prpl;
1391
d606da211acb [gaim-migrate @ 1401]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1376
diff changeset
184
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
185 if (event->button != 3)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
186 return FALSE;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
187
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
188 /* Here we figure out which node was clicked */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
189 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL))
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
190 return FALSE;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
191 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, path);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
192 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
193 node = g_value_get_pointer(&val);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
194
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
195 if (!GAIM_BLIST_NODE_IS_BUDDY(node))
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
196 return FALSE;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
197
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
198 menu = gtk_menu_new();
3251
b3c7af7286de [gaim-migrate @ 3269]
Jim Seymour <jseymour>
parents: 3204
diff changeset
199
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
200 /* Protocol specific options */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
201 prpl = find_prpl(((struct buddy*)node)->account->protocol);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
202 if (prpl) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
203 list = prpl->buddy_menu(((struct buddy*)node)->account->gc, ((struct buddy*)node)->name);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
204 while (list) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
205 struct proto_buddy_menu *pbm = list->data;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
206 menuitem = gtk_menu_item_new_with_mnemonic(pbm->label);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
207 g_object_set_data(G_OBJECT(menuitem), "gaimcallback", pbm);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
208 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gaim_proto_menu_cb), node);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
209 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
210 list = list->next;
3313
b0d5ce77f7dd [gaim-migrate @ 3331]
Jim Seymour <jseymour>
parents: 3279
diff changeset
211 }
3251
b3c7af7286de [gaim-migrate @ 3269]
Jim Seymour <jseymour>
parents: 3204
diff changeset
212 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
213
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
214 menuitem = gtk_image_menu_item_new_with_mnemonic("_IM");
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
215 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_im_cb), node);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
216 image = gtk_image_new_from_stock(GAIM_STOCK_IM, GTK_ICON_SIZE_MENU);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
217 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menuitem), image);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
218 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
219
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
220 menuitem = gtk_image_menu_item_new_with_mnemonic("_Alias");
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
221 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_alias_cb), node);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
222 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
223
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
224 menuitem = gtk_image_menu_item_new_with_mnemonic("Add Buddy _Pounce");
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
225 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_bp_cb), node);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
226 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
227
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
228 menuitem = gtk_image_menu_item_new_with_mnemonic("View _Log");
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
229 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(gtk_blist_menu_showlog_cb), node);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
230 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
231
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
232 gtk_widget_show_all(menu);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
233
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
234 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
235
4702
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
236 #if (1) /* This code only exists because GTK doesn't work. If we return FALSE here, as would be normal
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
237 * the event propoagates down and somehow gets interpreted as the start of a drag event. */
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
238 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv));
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
239 gtk_tree_selection_select_path(sel, path);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
240 return TRUE;
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
241 #endif
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
242 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
243
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
244 static void gaim_gtk_blist_reordered_cb(GtkTreeModel *model,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
245 GtkTreePath *path,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
246 GtkTreeIter *iter,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
247 gint *neworder,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
248 gpointer null)
3111
319a66fc131f [gaim-migrate @ 3125]
Sean Egan <seanegan@gmail.com>
parents: 3104
diff changeset
249 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
250 debug_printf("This doesn't work because GTK is broken\n");
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
251
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
252 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
253
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
254 /* This is called 10 seconds after the buddy logs in. It removes the "logged in" icon and replaces it with
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
255 * the normal status icon */
1072
81d19577285a [gaim-migrate @ 1082]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1070
diff changeset
256
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
257 static gboolean gaim_reset_present_icon(GaimBlistNode *b)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
258 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
259 ((struct buddy*)b)->present = 1;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
260 gaim_gtk_blist_update(NULL, b);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
261 return FALSE;
577
aa9a8bcddd80 [gaim-migrate @ 587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 544
diff changeset
262 }
aa9a8bcddd80 [gaim-migrate @ 587]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 544
diff changeset
263
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
264 static void gaim_gtk_blist_add_buddy_cb()
935
5e6ca3dd4d02 [gaim-migrate @ 945]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 921
diff changeset
265 {
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
266 GtkTreeSelection *sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkblist->treeview));
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
267 GtkTreeIter iter;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
268 GaimBlistNode *node;
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
269
4692
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
270 if(gtk_tree_selection_get_selected(sel, NULL, &iter)){
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
271 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &node, -1);
4691
d78f7cb8ae4f [gaim-migrate @ 5002]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
272 if (GAIM_BLIST_NODE_IS_BUDDY(node))
d78f7cb8ae4f [gaim-migrate @ 5002]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
273 show_add_buddy(NULL, NULL, ((struct group*)node->parent)->name, NULL);
d78f7cb8ae4f [gaim-migrate @ 5002]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
274 else if (GAIM_BLIST_NODE_IS_GROUP(node))
d78f7cb8ae4f [gaim-migrate @ 5002]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
275 show_add_buddy(NULL, NULL, ((struct group*)node)->name, NULL);
d78f7cb8ae4f [gaim-migrate @ 5002]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
276 }
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
277 else {
4692
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
278 show_add_buddy(NULL, NULL, NULL, NULL);
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
279 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
280 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
281
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
282 static void gaim_gtk_blist_update_toolbar_icons (GtkWidget *widget, gpointer data) {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
283 if (GTK_IS_IMAGE(widget)) {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
284 if (blist_options & OPT_BLIST_SHOW_BUTTON_XPM)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
285 gtk_widget_show(widget);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
286 else
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
287 gtk_widget_hide(widget);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
288 } else if (GTK_IS_CONTAINER(widget)) {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
289 gtk_container_foreach(GTK_CONTAINER(widget), gaim_gtk_blist_update_toolbar_icons, NULL);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
290 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
291 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
292
4702
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
293 static void gaim_gtk_blist_drag_data_get_cb (GtkWidget *widget,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
294 GdkDragContext *dc,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
295 GtkSelectionData *data,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
296 guint info,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
297 guint time,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
298 gpointer *null)
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
299 {
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
300 if (data->target == gdk_atom_intern("GAIM_BUDDY", FALSE)) {
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
301 GtkTreeRowReference *ref = g_object_get_data(G_OBJECT(dc), "gtk-tree-view-source-row");
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
302 GtkTreePath *sourcerow = gtk_tree_row_reference_get_path(ref);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
303 GtkTreeIter iter;
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
304 GaimBlistNode *node = NULL;
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
305 GValue val = {0};
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
306 gtk_tree_model_get_iter(GTK_TREE_MODEL(gtkblist->treemodel), &iter, sourcerow);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
307 gtk_tree_model_get_value (GTK_TREE_MODEL(gtkblist->treemodel), &iter, NODE_COLUMN, &val);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
308 node = g_value_get_pointer(&val);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
309 if (GAIM_BLIST_NODE_IS_BUDDY(node))
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
310 gtk_selection_data_set (data,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
311 gdk_atom_intern ("GAIM_BUDDY", FALSE),
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
312 8, /* bits */
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
313 (void*)&node,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
314 sizeof (node));
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
315 }
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
316
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
317 }
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
318
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
319 static void gaim_gtk_blist_drag_data_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
320 GtkSelectionData *sd, guint info, guint t)
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
321 {
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
322 if (sd->target == gdk_atom_intern("GAIM_BUDDY", FALSE)) {
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
323 struct buddy *b = NULL;
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
324 GtkTreePath *path = NULL;
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
325 memcpy(&b, sd->data, sizeof(b));
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
326 gtk_tree_view_get_dest_row_at_pos(widget, x, y, &path, GTK_TREE_VIEW_DROP_INTO_OR_AFTER);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
327 }
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
328 }
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
329
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
330 /***************************************************
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
331 * Crap *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
332 ***************************************************/
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
333 static GtkItemFactoryEntry blist_menu[] =
1929
d51ea669d84e [gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1918
diff changeset
334 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
335 /* Buddies menu */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
336 { N_("/_Buddies"), NULL, NULL, 0, "<Branch>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
337 { N_("/Buddies/_Add A Buddy..."), "<CTL>B", gaim_gtk_blist_add_buddy_cb, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
338 "<StockItem>", GTK_STOCK_ADD },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
339 { N_("/Buddies/New _Instant Message..."), "<CTL>I", show_im_dialog, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
340 "<StockItem>", GAIM_STOCK_IM },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
341 { N_("/Buddies/Join a _Chat..."), "<CTL>C", join_chat, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
342 "<StockItem>", GAIM_STOCK_CHAT },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
343 { N_("/Buddies/sep1"), NULL, NULL, 0, "<Separator>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
344 { N_("/Buddies/Get _User Info..."), "<CTL>J", show_info_dialog, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
345 "<StockItem>", GAIM_STOCK_INFO },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
346 { N_("/Buddies/sep2"), NULL, NULL, 0, "<Separator>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
347 { N_("/Buddies/_Signoff"), "<CTL>D", signoff_all, 0, NULL },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
348 { N_("/Buddies/_Quit"), "<CTL>Q", do_quit, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
349 "<StockItem>", GTK_STOCK_QUIT },
1929
d51ea669d84e [gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1918
diff changeset
350
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
351 /* Tools */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
352 { N_("/_Tools"), NULL, NULL, 0, "<Branch>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
353 { N_("/Tools/_Away"), NULL, NULL, 0, "<Branch>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
354 { N_("/Tools/Buddy _Pounce"), NULL, NULL, 0, "<Branch>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
355 { N_("/Tools/sep1"), NULL, NULL, 0, "<Separator>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
356 { N_("/Tools/A_ccounts"), "<CTL>A", account_editor, 0, NULL },
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
357 { N_("/Tools/Preferences"), "<CTL>P", show_prefs, 0,
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
358 "<StockItem>", GTK_STOCK_PREFERENCES },
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
359 { N_("/Tools/_File Transfers"), NULL, gaim_show_xfer_dialog, 0,
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
360 "<StockItem>", GTK_STOCK_REVERT_TO_SAVED },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
361 { N_("/Tools/sep2"), NULL, NULL, 0, "<Separator>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
362 { N_("/Tools/P_rotocol Actions"), NULL, NULL, 0, "<Branch>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
363 { N_("/Tools/Pr_ivacy"), NULL, show_privacy_options, 0, NULL },
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
364 { N_("/Tools/View System _Log"), NULL, gtk_blist_show_systemlog_cb, 0, NULL },
3251
b3c7af7286de [gaim-migrate @ 3269]
Jim Seymour <jseymour>
parents: 3204
diff changeset
365
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
366 /* Help */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
367 { N_("/_Help"), NULL, NULL, 0, "<Branch>" },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
368 { N_("/Help/Online _Help"), "F1", NULL, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
369 "<StockItem>", GTK_STOCK_HELP },
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
370 { N_("/Help/_Debug Window"), NULL, show_debug, 0, NULL },
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
371 { N_("/Help/_About"), NULL, show_about, 0, NULL },
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
372
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
373 };
1929
d51ea669d84e [gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1918
diff changeset
374
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
375 /*********************************************************
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
376 * Private Utility functions *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
377 *********************************************************/
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
378
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
379 static GdkPixbuf *gaim_gtk_blist_get_status_icon(struct buddy *b)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
380 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
381 GdkPixbuf *status = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
382 GdkPixbuf *scale = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
383 GdkPixbuf *emblem = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
384 gchar *filename = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
385 const char *protoname = NULL;
1929
d51ea669d84e [gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1918
diff changeset
386
4691
d78f7cb8ae4f [gaim-migrate @ 5002]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
387 char *se = NULL, *sw = NULL ,*nw = NULL ,*ne = NULL;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
388
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
389 int scalesize = 30;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
390
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
391 struct prpl* prpl = find_prpl(b->account->protocol);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
392 if (prpl->list_icon)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
393 protoname = prpl->list_icon(b->account, b);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
394 if (prpl->list_emblems)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
395 prpl->list_emblems(b, &se, &sw, &nw, &ne);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
396
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
397 if (!(blist_options & OPT_BLIST_SHOW_ICONS)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
398 scalesize = 15;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
399 sw = nw = ne = NULL; /* So that only the se icon will composite */
1929
d51ea669d84e [gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1918
diff changeset
400 }
d51ea669d84e [gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1918
diff changeset
401
4701
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
402
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
403 if (b->present == 2) {
4701
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
404 struct gaim_gtk_blist_node *gtknode;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
405 /* If b->present is 2, that means this buddy has just signed on. We use the "login" icon for the
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
406 * status, and we set a timeout to change it to a normal icon after 10 seconds. */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
407 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "login.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
408 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
409 g_free(filename);
4701
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
410
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
411 gtknode = GAIM_GTK_BLIST_NODE((GaimBlistNode*)b);
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
412 gtknode->timer = g_timeout_add(10000, (GSourceFunc)gaim_reset_present_icon, b);
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
413
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
414 /* "Hey, what's all this crap?" you ask. Status icons will be themeable too, and
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
415 then it will look up protoname from the theme */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
416 } else {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
417 char *image = g_strdup_printf("%s.png", protoname);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
418 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
419 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
420 g_free(image);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
421 g_free(filename);
1929
d51ea669d84e [gaim-migrate @ 1939]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1918
diff changeset
422
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
423 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
424
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
425 if (!status)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
426 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
427
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
428 scale = gdk_pixbuf_scale_simple(status, scalesize, scalesize, GDK_INTERP_BILINEAR);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
429
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
430 /* Emblems */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
431
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
432 /* Each protocol can specify up to four "emblems" to composite over the base icon. "away", "busy", "mobile user"
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
433 * are all examples of states represented by emblems. I'm not even really sure I like this yet. */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
434
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
435 /* XXX Clean this crap up, yo. */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
436 if (se) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
437 char *image = g_strdup_printf("%s.png", se);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
438 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
439 g_free(image);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
440 emblem = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
441 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
442 if (emblem) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
443 if (blist_options & OPT_BLIST_SHOW_ICONS)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
444 gdk_pixbuf_composite (emblem,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
445 scale, 15, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
446 15, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
447 15, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
448 1, 1,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
449 GDK_INTERP_BILINEAR,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
450 255);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
451 else
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
452 gdk_pixbuf_composite (emblem,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
453 scale, 0, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
454 15, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
455 0, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
456 1, 1,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
457 GDK_INTERP_BILINEAR,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
458 255);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
459 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
460 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
461 if (sw) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
462 char *image = g_strdup_printf("%s.png", sw);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
463 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
464 g_free(image);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
465 emblem = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
466 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
467 if (emblem) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
468 gdk_pixbuf_composite (emblem,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
469 scale, 0, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
470 15, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
471 0, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
472 1, 1,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
473 GDK_INTERP_BILINEAR,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
474 255);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
475 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
476 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
477 if (nw) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
478 char *image = g_strdup_printf("%s.png", nw);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
479 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
480 g_free(image);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
481 emblem = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
482 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
483 if (emblem) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
484 gdk_pixbuf_composite (emblem,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
485 scale, 0, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
486 15, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
487 0, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
488 1, 1,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
489 GDK_INTERP_BILINEAR,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
490 255);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
491 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
492 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
493 if (ne) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
494 char *image = g_strdup_printf("%s.png", ne);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
495 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
496 g_free(image);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
497 emblem = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
498 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
499 if (emblem) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
500 gdk_pixbuf_composite (emblem,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
501 scale, 15, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
502 15, 15,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
503 15, 0,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
504 1, 1,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
505 GDK_INTERP_BILINEAR,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
506 255);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
507 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
508 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
509
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
510
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
511 /* Idle gray buddies affects the whole row. This converts the status icon to greyscale. */
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
512 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
513 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0, FALSE);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
514 return scale;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
515 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
516
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
517 static GdkPixbuf *gaim_gtk_blist_get_buddy_icon(struct buddy *b)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
518 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
519 /* This just opens a file from ~/.gaim/icons/screenname. This needs to change to be more gooder. */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
520 char *file = g_build_filename(gaim_user_dir(), "icons", normalize(b->name), NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
521 GdkPixbuf *buf = gdk_pixbuf_new_from_file(file, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
522
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
523 if (!(blist_options & OPT_BLIST_SHOW_ICONS))
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
524 return NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
525
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
526 if (buf) {
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
527 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
528 gdk_pixbuf_saturate_and_pixelate(buf, buf, 0, FALSE);
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
529 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
530 return gdk_pixbuf_scale_simple(buf,30,30, GDK_INTERP_BILINEAR);
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
531 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
532 return NULL;
2986
1c6a3516e1ff [gaim-migrate @ 2999]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
533 }
1c6a3516e1ff [gaim-migrate @ 2999]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
534
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
535 static gchar *gaim_gtk_blist_get_name_markup(struct buddy *b)
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
536 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
537 char *name = gaim_get_buddy_alias(b);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
538 char *esc = g_markup_escape_text(name, strlen(name)), *text = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
539 /* XXX Clean up this crap */
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
540
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
541 int ihrs, imin;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
542 char *idletime = "";
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
543 char *warning = idletime;
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
544 time_t t;
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
545
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
546 if (!(blist_options & OPT_BLIST_SHOW_ICONS)) {
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
547 if (b->idle > 0 && blist_options & OPT_BLIST_GREY_IDLERS) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
548 text = g_strdup_printf("<span color='gray'>%s</span>",
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
549 esc);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
550 g_free(esc);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
551 return text;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
552 } else {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
553 return esc;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
554 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
555 }
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
556
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
557 time(&t);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
558 ihrs = (t - b->idle) / 3600;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
559 imin = ((t - b->idle) / 60) % 60;
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
560
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
561 if (b->idle) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
562 if (ihrs)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
563 idletime = g_strdup_printf(_("Idle (%dh%02dm)"), ihrs, imin);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
564 else
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
565 idletime = g_strdup_printf(_("Idle (%dm)"), imin);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
566 }
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
567
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
568 if (b->evil > 0)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
569 warning = g_strdup_printf(_("Warned (%d%%)"), b->evil);
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
570
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
571 if (b->idle && blist_options & OPT_BLIST_GREY_IDLERS)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
572 text = g_strdup_printf("<span color='grey'>%s</span>\n<span color='gray' size='smaller'>%s %s</span>",
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
573 esc,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
574 idletime, warning);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
575 else
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
576 text = g_strdup_printf("%s\n<span color='gray' size='smaller'>%s %s</span>", esc, idletime, warning);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
577
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
578 if (idletime[0])
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
579 g_free(idletime);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
580 if (warning[0])
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
581 g_free(warning);
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
582
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
583 return text;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
584 }
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
585
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
586 /**********************************************************************************
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
587 * Public API Functions *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
588 **********************************************************************************/
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
589 static void gaim_gtk_blist_new_list(struct gaim_buddy_list *blist)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
590 {
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
591 blist->ui_data = g_new0(struct gaim_gtk_buddy_list, 1);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
592 }
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
593
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
594 static void gaim_gtk_blist_new_node(GaimBlistNode *node)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
595 {
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
596 node->ui_data = g_new0(struct gaim_gtk_blist_node, 1);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
597 }
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
598
4702
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
599 enum {DRAG_BUDDY, DRAG_ROW};
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
600
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
601 static void gaim_gtk_blist_show(struct gaim_buddy_list *list)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
602 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
603 GtkItemFactory *ift;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
604 GtkCellRenderer *rend;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
605 GtkTreeViewColumn *column;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
606 GtkWidget *sw;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
607 GtkWidget *button;
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
608 GtkSizeGroup *sg;
4702
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
609 GtkTargetEntry gte[] = {{"GAIM_BUDDY", GTK_TARGET_SAME_APP, DRAG_ROW},
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
610 {"application/x-im-contact", 0, DRAG_BUDDY}};
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
611
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
612 if (gtkblist) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
613 gtk_widget_show(gtkblist->window);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
614 return;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
615 }
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
616
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
617 gtkblist = GAIM_GTK_BLIST(list);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
618
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
619 gtkblist->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
620 gtk_window_set_title(GTK_WINDOW(gtkblist->window), _("Buddy List"));
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
621
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
622 gtkblist->vbox = gtk_vbox_new(FALSE, 6);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
623 gtk_container_add(GTK_CONTAINER(gtkblist->window), gtkblist->vbox);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
624
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
625 g_signal_connect(G_OBJECT(gtkblist->window), "delete_event", G_CALLBACK(gaim_gtk_blist_destroy_cb), NULL);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
626
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
627 /******************************* Menu bar *************************************/
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
628 ift = gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<GaimMain>", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
629 gtk_item_factory_create_items(ift, sizeof(blist_menu) / sizeof(*blist_menu),
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
630 blist_menu, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
631 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtk_item_factory_get_widget(ift, "<GaimMain>"), FALSE, FALSE, 0);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
632
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
633 awaymenu = gtk_item_factory_get_widget(ift, "/Tools/Away");
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
634 do_away_menu();
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
635
4696
abec345c8c92 [gaim-migrate @ 5007]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
636 bpmenu = gtk_item_factory_get_widget(ift, "/Tools/Buddy Pounce");
abec345c8c92 [gaim-migrate @ 5007]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
637 do_bp_menu();
abec345c8c92 [gaim-migrate @ 5007]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
638
abec345c8c92 [gaim-migrate @ 5007]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
639 protomenu = gtk_item_factory_get_widget(ift, "/Tools/Protocol Actions");
abec345c8c92 [gaim-migrate @ 5007]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
640 do_proto_menu();
abec345c8c92 [gaim-migrate @ 5007]
Nathan Walp <nwalp@pidgin.im>
parents: 4695
diff changeset
641
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
642 /****************************** GtkTreeView **********************************/
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
643 sw = gtk_scrolled_window_new(NULL,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
644 gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
645 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
646 gtk_widget_set_size_request(sw, 200, 200);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
647
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
648 gtkblist->treemodel = gtk_tree_store_new(BLIST_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
649 G_TYPE_STRING, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_POINTER);
4702
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
650
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
651 gtkblist->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(gtkblist->treemodel));
4702
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
652
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
653 /* Set up dnd */
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
654 gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(gtkblist->treeview), GDK_BUTTON1_MASK, gte,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
655 2, GDK_ACTION_COPY);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
656 gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(gtkblist->treeview), gte, 2,
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
657 GDK_ACTION_COPY | GDK_ACTION_MOVE);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
658 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-received", gaim_gtk_blist_drag_data_rcv_cb, NULL);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
659 g_signal_connect(G_OBJECT(gtkblist->treeview), "drag-data-get", gaim_gtk_blist_drag_data_get_cb, NULL);
cb5b23dfd82b [gaim-migrate @ 5013]
Sean Egan <seanegan@gmail.com>
parents: 4701
diff changeset
660
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
661
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
662 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(gtkblist->treeview), FALSE);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
663
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
664 rend = gtk_cell_renderer_pixbuf_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
665 column = gtk_tree_view_column_new_with_attributes("Status", rend, "pixbuf", STATUS_ICON_COLUMN, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
666 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
667
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
668 rend = gtk_cell_renderer_text_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
669 column = gtk_tree_view_column_new_with_attributes("Name", rend, "markup", NAME_COLUMN, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
670 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
671
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
672 rend = gtk_cell_renderer_text_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
673 column = gtk_tree_view_column_new_with_attributes("Warning", rend, "text", WARNING_COLUMN, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
674 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
675
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
676 rend = gtk_cell_renderer_text_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
677 column = gtk_tree_view_column_new_with_attributes("Idle", rend, "text", IDLE_COLUMN, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
678 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column);
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
679
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
680 rend = gtk_cell_renderer_pixbuf_new();
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
681 column = gtk_tree_view_column_new_with_attributes("Buddy Icon", rend, "pixbuf", BUDDY_ICON_COLUMN, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
682 g_object_set(rend, "xalign", 1.0, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
683 gtk_tree_view_append_column(GTK_TREE_VIEW(gtkblist->treeview), column);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
684
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
685 g_signal_connect(G_OBJECT(gtkblist->treeview), "row-activated", G_CALLBACK(gtk_blist_row_activated_cb), NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
686 g_signal_connect(G_OBJECT(gtkblist->treeview), "button-press-event", G_CALLBACK(gtk_blist_button_press_cb), NULL);
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
687
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
688 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), sw, TRUE, TRUE, 0);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
689 gtk_container_add(GTK_CONTAINER(sw), gtkblist->treeview);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
690
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
691 /**************************** Button Box **************************************/
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
692
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
693 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
694 gtkblist->bbox = gtk_hbox_new(TRUE, 0);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
695 gtk_box_pack_start(GTK_BOX(gtkblist->vbox), gtkblist->bbox, FALSE, FALSE, 0);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
696 button = gaim_pixbuf_button_from_stock(_("IM"), GAIM_STOCK_IM, GAIM_BUTTON_VERTICAL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
697 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
698 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
699 gtk_size_group_add_widget(sg, button);
4692
a81443d3516b [gaim-migrate @ 5003]
Sean Egan <seanegan@gmail.com>
parents: 4691
diff changeset
700 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_im_cb),
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
701 gtkblist->treeview);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
702
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
703 button = gaim_pixbuf_button_from_stock(_("Get Info"), GAIM_STOCK_INFO, GAIM_BUTTON_VERTICAL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
704 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
705 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
706 gtk_size_group_add_widget(sg, button);
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
707 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_info_cb),
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
708 gtkblist->treeview);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
709
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
710 button = gaim_pixbuf_button_from_stock(_("Chat"), GAIM_STOCK_CHAT, GAIM_BUTTON_VERTICAL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
711 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
712 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
713 gtk_size_group_add_widget(sg, button);
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
714 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_chat_cb), NULL);
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
715
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
716 button = gaim_pixbuf_button_from_stock(_("Away"), GAIM_STOCK_AWAY, GAIM_BUTTON_VERTICAL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
717 gtk_box_pack_start(GTK_BOX(gtkblist->bbox), button, FALSE, FALSE, 0);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
718 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
4694
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
719 gtk_size_group_add_widget(sg, button);
8f523dbb970e [gaim-migrate @ 5005]
Nathan Walp <nwalp@pidgin.im>
parents: 4692
diff changeset
720 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(gtk_blist_button_away_cb), NULL);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
721
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
722 /* OK... let's show this bad boy. */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
723 gaim_gtk_blist_refresh(list);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
724 gtk_widget_show_all(gtkblist->window);
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
725
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
726 gaim_gtk_blist_update_toolbar();
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
727
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
728 }
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
729
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
730 void gaim_gtk_blist_refresh(struct gaim_buddy_list *list)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
731 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
732 GaimBlistNode *group = list->root;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
733 GaimBlistNode *buddy;
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
734
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
735 while (group) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
736 gaim_gtk_blist_update(list, group);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
737 buddy = group->child;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
738 while (buddy) {
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
739 gaim_gtk_blist_update(list, buddy);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
740 buddy = buddy->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
741 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
742 group = group->next;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
743 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
744 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
745
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
746 static gboolean get_iter_from_node_helper(GaimBlistNode *node, GtkTreeIter *iter, GtkTreeIter *root) {
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
747 do {
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
748 GaimBlistNode *n;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
749 GtkTreeIter child;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
750
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
751 gtk_tree_model_get(GTK_TREE_MODEL(gtkblist->treemodel), root, NODE_COLUMN, &n, -1);
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
752 if(n == node) {
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
753 *iter = *root;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
754 return TRUE;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
755 }
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
756
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
757 if(gtk_tree_model_iter_children(GTK_TREE_MODEL(gtkblist->treemodel), &child, root)) {
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
758 if(get_iter_from_node_helper(node,iter,&child))
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
759 return TRUE;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
760 }
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
761 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(gtkblist->treemodel), root));
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
762
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
763 return FALSE;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
764 }
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
765
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
766 static gboolean get_iter_from_node(GaimBlistNode *node, GtkTreeIter *iter) {
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
767 GtkTreeIter root;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
768
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
769 if (!gtkblist)
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
770 return FALSE;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
771
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
772 if(!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(gtkblist->treemodel), &root))
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
773 return FALSE;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
774
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
775 return get_iter_from_node_helper(node, iter, &root);
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
776 }
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
777
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
778 void gaim_gtk_blist_update_toolbar() {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
779 if (!gtkblist)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
780 return;
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
781
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
782 gtk_container_foreach(GTK_CONTAINER(gtkblist->bbox), gaim_gtk_blist_update_toolbar_icons, NULL);
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
783
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
784 if (blist_options & OPT_BLIST_NO_BUTTONS)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
785 gtk_widget_hide(gtkblist->bbox);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
786 else
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
787 gtk_widget_show_all(gtkblist->bbox);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
788 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
789
4701
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
790 static void gaim_gtk_blist_remove(struct gaim_buddy_list *list, GaimBlistNode *node)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
791 {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
792 struct gaim_gtk_blist_node *gtknode;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
793 GtkTreeIter iter;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
794
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
795 if (!node->ui_data)
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
796 return;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
797
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
798 gtknode = (struct gaim_gtk_blist_node *)node->ui_data;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
799
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
800 if (gtknode->timer > 0) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
801 g_source_remove(gtknode->timer);
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
802 gtknode->timer = 0;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
803 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
804
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
805 if (get_iter_from_node(node, &iter)) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
806 gtk_tree_store_remove(gtkblist->treemodel, &iter);
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
807 if(GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_blist_get_group_online_count((struct group *)node->parent) == 0) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
808 GtkTreeIter groupiter;
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
809 if(get_iter_from_node(node->parent, &groupiter))
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
810 gtk_tree_store_remove(gtkblist->treemodel, &groupiter);
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
811 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
812 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
813 }
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
814
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
815
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
816 static void gaim_gtk_blist_update(struct gaim_buddy_list *list, GaimBlistNode *node)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
817 {
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
818 struct gaim_gtk_blist_node *gtknode;
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
819 GtkTreeIter iter;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
820 gboolean expand = FALSE;
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
821 gboolean new_entry = FALSE;
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
822
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
823 if (!gtkblist)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
824 return;
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
825
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
826 gtknode = GAIM_GTK_BLIST_NODE(node);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
827
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
828
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
829 if (!get_iter_from_node(node, &iter)) { /* This is a newly added node */
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
830 new_entry = TRUE;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
831 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
832 if (((struct buddy*)node)->present) {
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
833 GtkTreeIter groupiter;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
834 GaimBlistNode *oldersibling;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
835 GtkTreeIter oldersiblingiter;
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
836
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
837 if(node->parent && !get_iter_from_node(node->parent, &groupiter)) {
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
838 /* This buddy's group has not yet been added. We do that here */
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
839 char *mark = g_strdup_printf("<span weight='bold'>%s</span>", ((struct group*)node->parent)->name);
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
840 oldersibling = node->parent->prev;
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
841
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
842 /* We traverse backwards through the buddy list to find the node in the tree to insert it after */
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
843 while (oldersibling && !get_iter_from_node(oldersibling, &oldersiblingiter))
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
844 oldersibling = oldersibling->prev;
4690
e19f91053ad0 [gaim-migrate @ 5001]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
845
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
846 /* This is where we create the node and add it. */
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
847 gtk_tree_store_insert_after(gtkblist->treemodel, &groupiter, NULL, oldersibling ? &oldersiblingiter : NULL);
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
848 gtk_tree_store_set(gtkblist->treemodel, &groupiter,
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
849 STATUS_ICON_COLUMN, gtk_widget_render_icon
4691
d78f7cb8ae4f [gaim-migrate @ 5002]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
850 (gtkblist->treeview,GTK_STOCK_OPEN,GTK_ICON_SIZE_SMALL_TOOLBAR,NULL),
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
851 NAME_COLUMN, mark,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
852 NODE_COLUMN, node->parent,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
853 -1);
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
854
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
855 expand = TRUE;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
856 }
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
857
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
858 oldersibling = node->prev;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
859 while (oldersibling && !get_iter_from_node(oldersibling, &oldersiblingiter))
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
860 oldersibling = oldersibling->prev;
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
861
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
862 gtk_tree_store_insert_after(gtkblist->treemodel, &iter, &groupiter, oldersibling ? &oldersiblingiter : NULL);
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
863
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
864 if (expand) { /* expand was set to true if this is the first element added to a group. In such case
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
865 * we expand the group node */
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
866 GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter);
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
867 gtk_tree_view_expand_row(GTK_TREE_VIEW(gtkblist->treeview), path, TRUE);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
868 }
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
869 }
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
870 }
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
871 }
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
872
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
873 if (GAIM_BLIST_NODE_IS_BUDDY(node) && ((struct buddy*)node)->present) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
874 GdkPixbuf *status, *avatar;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
875 char *mark;
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
876 char *warning = NULL, *idle = NULL;
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
877
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
878 status = gaim_gtk_blist_get_status_icon((struct buddy*)node);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
879 avatar = gaim_gtk_blist_get_buddy_icon((struct buddy*)node);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
880 mark = gaim_gtk_blist_get_name_markup((struct buddy*)node);
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
881
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
882 if ((((struct buddy*)node)->idle > 0) &&
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
883 (!(blist_options & OPT_BLIST_SHOW_ICONS) && (blist_options & OPT_BLIST_SHOW_IDLETIME))) {
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
884 time_t t;
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
885 int ihrs, imin;
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
886 time(&t);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
887 ihrs = (t - ((struct buddy *)node)->idle) / 3600;
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
888 imin = ((t - ((struct buddy*)node)->idle) / 60) % 60;
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
889 idle = g_strdup_printf("%d:%02d", ihrs, imin);
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
890 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
891
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
892 if ((((struct buddy*)node)->evil > 0) &&
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
893 (!(blist_options & OPT_BLIST_SHOW_ICONS) && (blist_options & OPT_BLIST_SHOW_WARN))) {
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
894 warning = g_strdup_printf("%d%%", ((struct buddy*)node)->evil);
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
895 }
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
896
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
897 gtk_tree_store_set(gtkblist->treemodel, &iter,
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
898 STATUS_ICON_COLUMN, status,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
899 NAME_COLUMN, mark,
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
900 WARNING_COLUMN, warning,
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
901 IDLE_COLUMN, idle,
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
902 BUDDY_ICON_COLUMN, avatar,
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
903 NODE_COLUMN, node,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
904 -1);
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
905
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
906 g_free(mark);
4697
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
907 if (idle)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
908 g_free(idle);
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
909 if (warning)
4be12ff42986 [gaim-migrate @ 5008]
Sean Egan <seanegan@gmail.com>
parents: 4696
diff changeset
910 g_free(warning);
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
911
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
912 if (status != NULL)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
913 g_object_unref(status);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
914
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
915 if (avatar != NULL)
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
916 g_object_unref(avatar);
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
917
4701
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
918 } else if (GAIM_BLIST_NODE_IS_BUDDY(node) && !new_entry) {
ac7ca2bd6d4f [gaim-migrate @ 5012]
Nathan Walp <nwalp@pidgin.im>
parents: 4699
diff changeset
919 gaim_gtk_blist_remove(list, node);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
920 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
921 }
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
922
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
923 static void gaim_gtk_blist_destroy(struct gaim_buddy_list *list)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
924 {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
925 gtk_widget_destroy(gtkblist->window);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
926 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
927
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
928 static void gaim_gtk_blist_set_visible(struct gaim_buddy_list *list, gboolean show)
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
929 {
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
930 if (show) {
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
931 gtk_window_present(GTK_WINDOW(gtkblist->window));
4698
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
932 } else {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
933 if (!connections || docklet_count) {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
934 #ifdef _WIN32
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
935 wgaim_systray_minimize(blist);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
936 #endif
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
937 gtk_widget_hide(gtkblist->window);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
938 } else {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
939 gtk_window_iconify(GTK_WINDOW(gtkblist->window));
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
940 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
941 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
942 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
943
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
944 void gaim_gtk_blist_docklet_toggle() {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
945 /* Useful for the docklet plugin and also for the win32 tray icon*/
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
946 /* This is called when one of those is clicked--it will show/hide the
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
947 buddy list/login window--depending on which is active */
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
948 if (connections && gtkblist) {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
949 if (GTK_WIDGET_VISIBLE(gtkblist->window)) {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
950 gaim_blist_set_visible(GAIM_WINDOW_ICONIFIED(gtkblist->window) || gaim_gtk_blist_obscured);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
951 } else {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
952 #if _WIN32
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
953 wgaim_systray_maximize(blist);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
954 #endif
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
955 gaim_blist_set_visible(TRUE);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
956 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
957 } else if (connections) {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
958 /* we're logging in or something... do nothing */
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
959 debug_printf("docklet_toggle called with connections but no blist!\n");
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
960 } else {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
961 if (GTK_WIDGET_VISIBLE(mainwindow)) {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
962 if (GAIM_WINDOW_ICONIFIED(mainwindow)) {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
963 gtk_window_present(GTK_WINDOW(mainwindow));
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
964 } else {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
965 #if _WIN32
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
966 wgaim_systray_minimize(mainwindow);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
967 #endif
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
968 gtk_widget_hide(mainwindow);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
969 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
970 } else {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
971 #if _WIN32
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
972 wgaim_systray_maximize(mainwindow);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
973 #endif
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
974 gtk_window_present(GTK_WINDOW(mainwindow));
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
975 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
976 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
977 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
978
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
979 void gaim_gtk_blist_docklet_add()
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
980 {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
981 docklet_count++;
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
982 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
983
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
984 void gaim_gtk_blist_docklet_remove()
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
985 {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
986 docklet_count--;
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
987 if (!docklet_count) {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
988 if (connections) {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
989 gaim_blist_set_visible(TRUE);
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
990 } else {
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
991 gtk_window_present(GTK_WINDOW(gtkblist->window));
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
992 }
aa2ceea841b4 [gaim-migrate @ 5009]
Sean Egan <seanegan@gmail.com>
parents: 4697
diff changeset
993 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
994 }
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
995
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
996 static struct gaim_blist_ui_ops blist_ui_ops =
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
997 {
4695
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
998 gaim_gtk_blist_new_list,
4bdd9a5fd026 [gaim-migrate @ 5006]
Christian Hammond <chipx86@chipx86.com>
parents: 4694
diff changeset
999 gaim_gtk_blist_new_node,
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1000 gaim_gtk_blist_show,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1001 gaim_gtk_blist_update,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1002 gaim_gtk_blist_remove,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1003 gaim_gtk_blist_destroy,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1004 gaim_gtk_blist_set_visible
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1005 };
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1006
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1007
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1008 struct gaim_blist_ui_ops *gaim_get_gtk_blist_ui_ops()
2372
2927c2c26fe6 [gaim-migrate @ 2385]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2334
diff changeset
1009 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1010 return &blist_ui_ops;
1037
1c663beef29d [gaim-migrate @ 1047]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1036
diff changeset
1011 }
1c663beef29d [gaim-migrate @ 1047]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1036
diff changeset
1012
3131
bb7527b5f426 [gaim-migrate @ 3146]
Rob Flynn <gaim@robflynn.com>
parents: 3111
diff changeset
1013
bb7527b5f426 [gaim-migrate @ 3146]
Rob Flynn <gaim@robflynn.com>
parents: 3111
diff changeset
1014
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1015 /*********************************************************************
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1016 * Public utility functions *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1017 *********************************************************************/
1058
4927ce25d8cc [gaim-migrate @ 1068]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1057
diff changeset
1018
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1019 GdkPixbuf *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1020 create_prpl_icon(struct gaim_account *account)
4553
d03fcb3f4be2 [gaim-migrate @ 4833]
Christian Hammond <chipx86@chipx86.com>
parents: 4525
diff changeset
1021 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1022 struct prpl *prpl = find_prpl(account->protocol);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1023 GdkPixbuf *status = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1024 char *filename = NULL;
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1025 const char *protoname = prpl->list_icon(account, NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1026 /* "Hey, what's all this crap?" you ask. Status icons will be themeable too, and
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1027 then it will look up protoname from the theme */
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1028 if (!strcmp(protoname, "aim")) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1029 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "aim.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1030 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1031 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1032 } else if (!strcmp(protoname, "yahoo")) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1033 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "yahoo.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1034 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1035 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1036 } else if (!strcmp(protoname, "msn")) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1037 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "msn.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1038 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1039 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1040 } else if (!strcmp(protoname, "jabber")) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1041 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "jabber.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1042 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1043 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1044 } else if (!strcmp(protoname, "icq")) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1045 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "icq.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1046 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1047 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1048 } else if (!strcmp(protoname, "gadu-gadu")) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1049 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "gadugadu.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1050 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1051 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1052 } else if (!strcmp(protoname, "napster")) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1053 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "napster.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1054 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1055 g_free(filename);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1056 } else if (!strcmp(protoname, "irc")) {
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1057 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "irc.png", NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1058 status = gdk_pixbuf_new_from_file(filename,NULL);
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1059 g_free(filename);
960
fa681641643d [gaim-migrate @ 970]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 945
diff changeset
1060 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4635
diff changeset
1061 return status;
1
2846a03bda67 [gaim-migrate @ 10]
Rob Flynn <gaim@robflynn.com>
parents:
diff changeset
1062 }
4699
2222cd30008a [gaim-migrate @ 5010]
Nathan Walp <nwalp@pidgin.im>
parents: 4698
diff changeset
1063