annotate console/gntblist.c @ 14709:3b5c732458ec

[gaim-migrate @ 17463] Show the glib-errors/warnings in the debug window. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Thu, 12 Oct 2006 01:03:18 +0000
parents ef94c6b853ab
children b15c2eaeb67f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14558
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
1 /**
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
2 * @file gntblist.c GNT BuddyList API
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
3 * @ingroup gntui
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
4 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
5 * gaim
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
6 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
9 * source distribution.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
10 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
11 * This program is free software; you can redistribute it and/or modify
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
12 * it under the terms of the GNU General Public License as published by
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
14 * (at your option) any later version.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
15 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
16 * This program is distributed in the hope that it will be useful,
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
19 * GNU General Public License for more details.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
20 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
21 * You should have received a copy of the GNU General Public License
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
22 * along with this program; if not, write to the Free Software
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14493
diff changeset
24 */
13877
765bbdf29d04 [gaim-migrate @ 16354]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
25 #include <account.h>
765bbdf29d04 [gaim-migrate @ 16354]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
26 #include <blist.h>
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
27 #include <notify.h>
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
28 #include <request.h>
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
29 #include <savedstatuses.h>
13877
765bbdf29d04 [gaim-migrate @ 16354]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
30 #include <server.h>
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
31 #include <signal.h>
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
32 #include <status.h>
13877
765bbdf29d04 [gaim-migrate @ 16354]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13869
diff changeset
33 #include <util.h>
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
34 #include "debug.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36 #include "gntgaim.h"
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 #include "gntbox.h"
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
38 #include "gntcombobox.h"
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
39 #include "gntentry.h"
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
40 #include "gntlabel.h"
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
41 #include "gntline.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 #include "gnttree.h"
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
43 #include "gntwindow.h"
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
45 #include "gntblist.h"
14388
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14385
diff changeset
46 #include "gntconv.h"
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
47 #include "gntstatus.h"
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
48 #include <string.h>
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
49
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
50 #define PREF_ROOT "/gaim/gnt/blist"
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
51 #define TYPING_TIMEOUT 4000
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
52
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
53 typedef struct
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
54 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
55 GntWidget *window;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
56 GntWidget *tree;
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
57
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
58 GntWidget *tooltip;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
59 GaimBlistNode *tnode; /* Who is the tooltip being displayed for? */
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
60 GaimBuddy *tagged;
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
61
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
62 GntWidget *context;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
63 GaimBlistNode *cnode;
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
64
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
65 /* XXX: I am KISSing */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
66 GntWidget *status; /* Dropdown with the statuses */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
67 GntWidget *statustext; /* Status message */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
68 int typing;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
69 } GGBlist;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
70
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
71 typedef enum
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
72 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
73 STATUS_PRIMITIVE = 0,
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
74 STATUS_SAVED_POPULAR,
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
75 STATUS_SAVED_ALL,
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
76 STATUS_SAVED_NEW
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
77 } StatusType;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
78
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
79 typedef struct
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
80 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
81 StatusType type;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
82 union
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
83 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
84 GaimStatusPrimitive prim;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
85 GaimSavedStatus *saved;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
86 } u;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
87 } StatusBoxItem;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
88
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 GGBlist *ggblist;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
91 static void add_buddy(GaimBuddy *buddy, GGBlist *ggblist);
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
92 static void add_contact(GaimContact *contact, GGBlist *ggblist);
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
93 static void add_group(GaimGroup *group, GGBlist *ggblist);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
94 static void add_chat(GaimChat *chat, GGBlist *ggblist);
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
95 static void add_node(GaimBlistNode *node, GGBlist *ggblist);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
96 static void draw_tooltip(GGBlist *ggblist);
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
97 static gboolean remove_typing_cb(gpointer null);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
98 static void remove_peripherals(GGBlist *ggblist);
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
99 static const char * get_display_name(GaimBlistNode *node);
14131
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
100 static void savedstatus_changed(GaimSavedStatus *now, GaimSavedStatus *old);
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
101
14407
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
102 static gboolean
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
103 is_contact_online(GaimContact *contact)
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
104 {
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
105 GaimBlistNode *node;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
106 for (node = ((GaimBlistNode*)contact)->child; node; node = node->next) {
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
107 if (GAIM_BUDDY_IS_ONLINE((GaimBuddy*)node))
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
108 return TRUE;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
109 }
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
110 return FALSE;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
111 }
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
112
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
113 static gboolean
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
114 is_group_online(GaimGroup *group)
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
115 {
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
116 GaimBlistNode *node;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
117 for (node = ((GaimBlistNode*)group)->child; node; node = node->next) {
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
118 if (GAIM_BLIST_NODE_IS_CHAT(node))
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
119 return TRUE;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
120 else if (is_contact_online((GaimContact*)node))
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
121 return TRUE;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
122 }
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
123 return FALSE;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
124 }
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
125
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
126 static void
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
127 new_node(GaimBlistNode *node)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
128 {
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
129 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
130
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
131 static void add_node(GaimBlistNode *node, GGBlist *ggblist)
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
132 {
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
133 if (GAIM_BLIST_NODE_IS_BUDDY(node))
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
134 add_buddy((GaimBuddy*)node, ggblist);
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
135 else if (GAIM_BLIST_NODE_IS_CONTACT(node))
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
136 add_contact((GaimContact*)node, ggblist);
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
137 else if (GAIM_BLIST_NODE_IS_GROUP(node))
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
138 add_group((GaimGroup*)node, ggblist);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
139 else if (GAIM_BLIST_NODE_IS_CHAT(node))
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
140 add_chat((GaimChat *)node, ggblist);
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
141 draw_tooltip(ggblist);
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
142 }
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
143
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
144 static void
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
145 remove_tooltip(GGBlist *ggblist)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
146 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
147 gnt_widget_destroy(ggblist->tooltip);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
148 ggblist->tooltip = NULL;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
149 ggblist->tnode = NULL;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
150 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
151
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
152 static void
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
153 node_remove(GaimBuddyList *list, GaimBlistNode *node)
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
154 {
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
155 GGBlist *ggblist = list->ui_data;
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
156
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
157 if (ggblist == NULL || node->ui_data == NULL)
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
158 return;
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
159
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
160 gnt_tree_remove(GNT_TREE(ggblist->tree), node);
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
161 node->ui_data = NULL;
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
162
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
163 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
164 GaimContact *contact = (GaimContact*)node->parent;
14407
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
165 if ((!gaim_prefs_get_bool(PREF_ROOT "/showoffline") && !is_contact_online(contact)) ||
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
166 contact->currentsize < 1)
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
167 node_remove(list, (GaimBlistNode*)contact);
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
168 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
169 GaimGroup *group = (GaimGroup*)node->parent;
14407
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
170 if ((!gaim_prefs_get_bool(PREF_ROOT "/showoffline") && !is_group_online(group)) ||
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
171 group->currentsize < 1)
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
172 node_remove(list, node->parent);
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
173 }
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
174 draw_tooltip(ggblist);
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
175 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
176
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
177 static void
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
178 node_update(GaimBuddyList *list, GaimBlistNode *node)
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
179 {
14393
81932c1ec6cf [gaim-migrate @ 17101]
Ethan Blanton <elb@pidgin.im>
parents: 14388
diff changeset
180 /* It really looks like this should never happen ... but it does.
81932c1ec6cf [gaim-migrate @ 17101]
Ethan Blanton <elb@pidgin.im>
parents: 14388
diff changeset
181 This will at least emit a warning to the log when it
81932c1ec6cf [gaim-migrate @ 17101]
Ethan Blanton <elb@pidgin.im>
parents: 14388
diff changeset
182 happens, so maybe someone will figure it out. */
81932c1ec6cf [gaim-migrate @ 17101]
Ethan Blanton <elb@pidgin.im>
parents: 14388
diff changeset
183 g_return_if_fail(node != NULL);
81932c1ec6cf [gaim-migrate @ 17101]
Ethan Blanton <elb@pidgin.im>
parents: 14388
diff changeset
184
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
185 if (list->ui_data == NULL)
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14393
diff changeset
186 return; /* XXX: this is probably the place to auto-join chats */
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
187
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
188 if (node->ui_data != NULL) {
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
189 gnt_tree_change_text(GNT_TREE(ggblist->tree), node,
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
190 0, get_display_name(node));
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
191 }
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
192
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
193 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
194 GaimBuddy *buddy = (GaimBuddy*)node;
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
195 if (gaim_account_is_connected(buddy->account) &&
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
196 (GAIM_BUDDY_IS_ONLINE(buddy) || gaim_prefs_get_bool(PREF_ROOT "/showoffline")))
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
197 add_node((GaimBlistNode*)buddy, list->ui_data);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
198 else
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
199 node_remove(gaim_get_blist(), node);
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
200
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
201 node_update(list, node->parent);
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
202 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
203 add_chat((GaimChat *)node, list->ui_data);
14407
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
204 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
205 GaimContact *contact = (GaimContact*)node;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
206 if ((!gaim_prefs_get_bool(PREF_ROOT "/showoffline") && !is_contact_online(contact)) ||
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
207 contact->currentsize < 1)
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
208 node_remove(gaim_get_blist(), node);
14708
ef94c6b853ab [gaim-migrate @ 17462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14694
diff changeset
209 else
ef94c6b853ab [gaim-migrate @ 17462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14694
diff changeset
210 add_node(node, list->ui_data);
14407
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
211 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
212 GaimGroup *group = (GaimGroup*)node;
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
213 if ((!gaim_prefs_get_bool(PREF_ROOT "/showoffline") && !is_group_online(group)) ||
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
214 group->currentsize < 1)
2a5ec27c3f0c [gaim-migrate @ 17115]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14405
diff changeset
215 node_remove(list, node);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
216 }
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
217 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
218
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
219 static void
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
220 new_list(GaimBuddyList *list)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
221 {
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
222 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
223
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
224 static void
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
225 add_buddy_cb(void *data, GaimRequestFields *allfields)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
226 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
227 const char *username = gaim_request_fields_get_string(allfields, "screenname");
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
228 const char *alias = gaim_request_fields_get_string(allfields, "alias");
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
229 const char *group = gaim_request_fields_get_string(allfields, "group");
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
230 GaimAccount *account = gaim_request_fields_get_account(allfields, "account");
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
231 const char *error = NULL;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
232 GaimGroup *grp;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
233 GaimBuddy *buddy;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
234
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
235 if (!username)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
236 error = _("You must provide a screename for the buddy.");
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
237 else if (!group)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
238 error = _("You must provide a group.");
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
239 else if (!account)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
240 error = _("You must select an account.");
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
241
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
242 if (error)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
243 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
244 gaim_notify_error(NULL, _("Error"), _("Error adding buddy"), error);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
245 return;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
246 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
247
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
248 grp = gaim_find_group(group);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
249 if (!grp)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
250 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
251 grp = gaim_group_new(group);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
252 gaim_blist_add_group(grp, NULL);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
253 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
254
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
255 buddy = gaim_buddy_new(account, username, alias);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
256 gaim_blist_add_buddy(buddy, NULL, grp, NULL);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
257 gaim_account_add_buddy(account, buddy);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
258 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
259
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
260 static void
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
261 gg_request_add_buddy(GaimAccount *account, const char *username, const char *grp, const char *alias)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
262 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
263 GaimRequestFields *fields = gaim_request_fields_new();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
264 GaimRequestFieldGroup *group = gaim_request_field_group_new(NULL);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
265 GaimRequestField *field;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
266
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
267 gaim_request_fields_add_group(fields, group);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
268
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
269 field = gaim_request_field_string_new("screenname", _("Screen Name"), username, FALSE);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
270 gaim_request_field_group_add_field(group, field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
271
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
272 field = gaim_request_field_string_new("alias", _("Alias"), alias, FALSE);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
273 gaim_request_field_group_add_field(group, field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
274
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
275 field = gaim_request_field_string_new("group", _("Group"), grp, FALSE);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
276 gaim_request_field_group_add_field(group, field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
277
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
278 field = gaim_request_field_account_new("account", _("Account"), NULL);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
279 gaim_request_field_account_set_show_all(field, FALSE);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
280 if (account)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
281 gaim_request_field_account_set_value(field, account);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
282 gaim_request_field_group_add_field(group, field);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
283
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
284 gaim_request_fields(NULL, _("Add Buddy"), NULL, _("Please enter buddy information."),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
285 fields, _("Add"), G_CALLBACK(add_buddy_cb), _("Cancel"), NULL, NULL);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
286 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
287
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
288 static void
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
289 add_chat_cb(void *data, GaimRequestFields *allfields)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
290 {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
291 GaimAccount *account;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
292 const char *alias, *name, *group;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
293 GaimChat *chat;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
294 GaimGroup *grp;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
295 GHashTable *hash = NULL;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
296 GaimConnection *gc;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
297
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
298 account = gaim_request_fields_get_account(allfields, "account");
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
299 name = gaim_request_fields_get_string(allfields, "name");
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
300 alias = gaim_request_fields_get_string(allfields, "alias");
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
301 group = gaim_request_fields_get_string(allfields, "group");
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
302
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
303 if (!gaim_account_is_connected(account) || !name || !*name)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
304 return;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
305
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
306 if (!group || !*group)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
307 group = _("Chats");
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
308
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
309 gc = gaim_account_get_connection(account);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
310
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
311 if (GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults != NULL)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
312 hash = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl)->chat_info_defaults(gc, name);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
313
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
314 chat = gaim_chat_new(account, name, hash);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
315
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
316 if (chat != NULL) {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
317 if ((grp = gaim_find_group(group)) == NULL) {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
318 grp = gaim_group_new(group);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
319 gaim_blist_add_group(grp, NULL);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
320 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
321 gaim_blist_add_chat(chat, grp, NULL);
14691
dbcdef1ab5af [gaim-migrate @ 17443]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14630
diff changeset
322 gaim_blist_alias_chat(chat, alias);
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
323 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
324 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
325
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
326 static void
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
327 gg_request_add_chat(GaimAccount *account, GaimGroup *grp, const char *alias, const char *name)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
328 {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
329 GaimRequestFields *fields = gaim_request_fields_new();
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
330 GaimRequestFieldGroup *group = gaim_request_field_group_new(NULL);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
331 GaimRequestField *field;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
332
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
333 gaim_request_fields_add_group(fields, group);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
334
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
335 field = gaim_request_field_account_new("account", _("Account"), NULL);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
336 gaim_request_field_account_set_show_all(field, FALSE);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
337 if (account)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
338 gaim_request_field_account_set_value(field, account);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
339 gaim_request_field_group_add_field(group, field);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
340
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
341 field = gaim_request_field_string_new("name", _("Name"), name, FALSE);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
342 gaim_request_field_group_add_field(group, field);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
343
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
344 field = gaim_request_field_string_new("alias", _("Alias"), alias, FALSE);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
345 gaim_request_field_group_add_field(group, field);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
346
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
347 field = gaim_request_field_string_new("group", _("Group"), grp ? grp->name : NULL, FALSE);
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
348 gaim_request_field_group_add_field(group, field);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
349
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
350 gaim_request_fields(NULL, _("Add Chat"), NULL,
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
351 _("You can edit more information from the context menu later."),
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
352 fields, _("Add"), G_CALLBACK(add_chat_cb), _("Cancel"), NULL, NULL);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
353 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
354
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
355 static void
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
356 add_group_cb(gpointer null, const char *group)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
357 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
358 GaimGroup *grp;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
359
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
360 if (!group || !*group)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
361 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
362 gaim_notify_error(NULL, _("Error"), _("Error adding group"),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
363 _("You must give a name for the group to add."));
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
364 return;
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
365 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
366
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
367 grp = gaim_find_group(group);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
368 if (!grp)
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
369 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
370 grp = gaim_group_new(group);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
371 gaim_blist_add_group(grp, NULL);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
372 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
373 else
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
374 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
375 gaim_notify_error(NULL, _("Error"), _("Error adding group"),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
376 _("A group with the name already exists."));
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
377 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
378 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
379
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
380 static void
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
381 gg_request_add_group()
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
382 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
383 gaim_request_input(NULL, _("Add Group"), NULL, _("Enter the name of the group"),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
384 NULL, FALSE, FALSE, NULL,
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
385 _("Add"), G_CALLBACK(add_group_cb), _("Cancel"), NULL, NULL);
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
386 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
387
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
388 static GaimBlistUiOps blist_ui_ops =
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
389 {
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
390 new_list,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
391 new_node,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
392 NULL,
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
393 node_update,
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
394 node_remove,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
395 NULL,
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
396 NULL,
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
397 .request_add_buddy = gg_request_add_buddy,
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
398 .request_add_chat = gg_request_add_chat,
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
399 .request_add_group = gg_request_add_group
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
400 };
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
401
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
402 static gpointer
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
403 gg_blist_get_handle()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
404 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
405 static int handle;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
406
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
407 return &handle;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
408 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
409
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
410 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
411 add_group(GaimGroup *group, GGBlist *ggblist)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
412 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
413 GaimBlistNode *node = (GaimBlistNode *)group;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
414 if (node->ui_data)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
415 return;
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
416 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group,
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
417 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), NULL, NULL);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
418 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
419
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
420 static const char *
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
421 get_display_name(GaimBlistNode *node)
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
422 {
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
423 static char text[2096];
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
424 char status[8] = " ";
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
425 const char *name = NULL;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
426
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
427 if (GAIM_BLIST_NODE_IS_CONTACT(node))
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
428 node = (GaimBlistNode*)gaim_contact_get_priority_buddy((GaimContact*)node); /* XXX: this can return NULL?! */
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
429
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
430 if (node == NULL)
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
431 return NULL;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
432
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
433 if (GAIM_BLIST_NODE_IS_BUDDY(node))
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
434 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
435 GaimBuddy *buddy = (GaimBuddy *)node;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
436 GaimStatusPrimitive prim;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
437 GaimPresence *presence;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
438 GaimStatus *now;
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
439 gboolean ascii = gnt_ascii_only();
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
440
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
441 presence = gaim_buddy_get_presence(buddy);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
442 now = gaim_presence_get_active_status(presence);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
443
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
444 prim = gaim_status_type_get_primitive(gaim_status_get_type(now));
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
445
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
446 switch(prim)
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
447 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
448 case GAIM_STATUS_OFFLINE:
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
449 strncpy(status, ascii ? "x" : "⊗", sizeof(status) - 1);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
450 break;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
451 case GAIM_STATUS_AVAILABLE:
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
452 strncpy(status, ascii ? "o" : "â—¯", sizeof(status) - 1);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
453 break;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
454 default:
13927
9309d27d780c [gaim-migrate @ 16447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13916
diff changeset
455 strncpy(status, ascii ? "." : "⊖", sizeof(status) - 1);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
456 break;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
457 }
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
458 name = gaim_buddy_get_alias(buddy);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
459 }
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
460 else if (GAIM_BLIST_NODE_IS_CHAT(node))
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
461 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
462 GaimChat *chat = (GaimChat*)node;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
463 name = gaim_chat_get_name(chat);
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13884
diff changeset
464
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13884
diff changeset
465 strncpy(status, "~", sizeof(status) - 1);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
466 }
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
467 else if (GAIM_BLIST_NODE_IS_GROUP(node))
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
468 return ((GaimGroup*)node)->name;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
469
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
470 snprintf(text, sizeof(text) - 1, "%s %s", status, name);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
471
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
472 return text;
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
473 }
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
474
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
475 static void
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
476 add_chat(GaimChat *chat, GGBlist *ggblist)
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
477 {
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
478 GaimGroup *group;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
479 GaimBlistNode *node = (GaimBlistNode *)chat;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
480 if (node->ui_data)
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
481 return;
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
482 if (!gaim_account_is_connected(chat->account))
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
483 return;
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
484
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
485 group = gaim_chat_get_group(chat);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
486 add_node((GaimBlistNode*)group, ggblist);
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
487
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
488 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat,
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
489 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
490 group, NULL);
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
491
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
492 /* XXX: This causes problem because you can close a chat window, hide the buddylist.
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
493 * When you show the buddylist, you automatically join the chat again. */
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
494 if (gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin"))
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
495 serv_join_chat(gaim_account_get_connection(chat->account), chat->components);
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
496 }
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
497
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
498 static void
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
499 add_contact(GaimContact *contact, GGBlist *ggblist)
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
500 {
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
501 GaimGroup *group;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
502 GaimBlistNode *node = (GaimBlistNode*)contact;
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
503 const char *name;
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
504
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
505 if (node->ui_data)
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
506 return;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
507
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
508 name = get_display_name(node);
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
509 if (name == NULL)
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
510 return;
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
511
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
512 group = (GaimGroup*)node->parent;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
513 add_node((GaimBlistNode*)group, ggblist);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
514
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
515 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact,
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
516 gnt_tree_create_row(GNT_TREE(ggblist->tree), name),
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
517 group, NULL);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
518
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
519 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), contact, FALSE);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
520 }
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
521
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
522 static void
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
523 add_buddy(GaimBuddy *buddy, GGBlist *ggblist)
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
524 {
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
525 GaimContact *contact;
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
526 GaimBlistNode *node = (GaimBlistNode *)buddy;
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
527 if (node->ui_data)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
528 return;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
529
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
530 contact = (GaimContact*)node->parent;
14708
ef94c6b853ab [gaim-migrate @ 17462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14694
diff changeset
531 if (!contact) /* When a new buddy is added and show-offline is set */
ef94c6b853ab [gaim-migrate @ 17462]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14694
diff changeset
532 return;
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
533 add_node((GaimBlistNode*)contact, ggblist);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
534
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
535 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy,
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
536 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
537 contact, NULL);
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
538 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) {
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
539 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM);
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
540 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, GNT_TEXT_FLAG_DIM);
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
541 } else {
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
542 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0);
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
543 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, 0);
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
544 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
545 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
546
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
547 #if 0
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
548 static void
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
549 buddy_signed_on(GaimBuddy *buddy, GGBlist *ggblist)
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
550 {
13865
d78ab363e02d [gaim-migrate @ 16331]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13864
diff changeset
551 add_node((GaimBlistNode*)buddy, ggblist);
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
552 }
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
553
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
554 static void
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
555 buddy_signed_off(GaimBuddy *buddy, GGBlist *ggblist)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
556 {
13861
55fb5cd9bac9 [gaim-migrate @ 16322]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13860
diff changeset
557 node_remove(gaim_get_blist(), (GaimBlistNode*)buddy);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
558 }
13897
eaaf73de9188 [gaim-migrate @ 16382]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13896
diff changeset
559 #endif
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
560
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
561 GaimBlistUiOps *gg_blist_get_ui_ops()
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
562 {
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
563 return &blist_ui_ops;
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
564 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
565
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
566 static void
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
567 selection_activate(GntWidget *widget, GGBlist *ggblist)
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
568 {
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
569 GntTree *tree = GNT_TREE(ggblist->tree);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
570 GaimBlistNode *node = gnt_tree_get_selection_data(tree);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
571
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
572 if (!node)
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
573 return;
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
574
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
575 if (GAIM_BLIST_NODE_IS_CONTACT(node))
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
576 node = (GaimBlistNode*)gaim_contact_get_priority_buddy((GaimContact*)node);
13943
25be562aaca8 [gaim-migrate @ 16480]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13931
diff changeset
577
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
578 if (GAIM_BLIST_NODE_IS_BUDDY(node))
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
579 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
580 GaimBuddy *buddy = (GaimBuddy *)node;
14388
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14385
diff changeset
581 GaimConversation *conv = gaim_conversation_new(GAIM_CONV_TYPE_IM,
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14385
diff changeset
582 gaim_buddy_get_account(buddy),
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14385
diff changeset
583 gaim_buddy_get_name(buddy));
f4af666fafe3 [gaim-migrate @ 17094]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14385
diff changeset
584 gg_conversation_set_active(conv);
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
585 }
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
586 else if (GAIM_BLIST_NODE_IS_CHAT(node))
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
587 {
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
588 GaimChat *chat = (GaimChat*)node;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
589 serv_join_chat(chat->account->gc, chat->components);
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
590 }
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
591 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
592
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
593 static void
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
594 remove_context_menu(GGBlist *ggblist)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
595 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
596 if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
597 gnt_widget_destroy(ggblist->context->parent);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
598 ggblist->context = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
599 ggblist->cnode = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
600 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
601
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
602 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
603 gnt_append_menu_action(GntTree *tree, GaimMenuAction *action, gpointer parent)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
604 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
605 GList *list;
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
606 if (action == NULL)
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
607 return;
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
608
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
609 gnt_tree_add_row_last(tree, action,
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
610 gnt_tree_create_row(tree, action->label), parent);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
611 for (list = action->children; list; list = list->next)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
612 gnt_append_menu_action(tree, list->data, action);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
613 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
614
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
615 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
616 append_proto_menu(GntTree *tree, GaimConnection *gc, GaimBlistNode *node)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
617 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
618 GList *list;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
619 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
620
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
621 if(!prpl_info || !prpl_info->blist_node_menu)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
622 return;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
623
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
624 for(list = prpl_info->blist_node_menu(node); list;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
625 list = g_list_delete_link(list, list))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
626 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
627 GaimMenuAction *act = (GaimMenuAction *) list->data;
14470
c8704dd8059b [gaim-migrate @ 17186]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14469
diff changeset
628 act->data = node;
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
629 gnt_append_menu_action(tree, act, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
630 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
631 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
632
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
633 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
634 add_custom_action(GntTree *tree, const char *label, GaimCallback callback,
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
635 gpointer data)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
636 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
637 GaimMenuAction *action = gaim_menu_action_new(label, callback, data, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
638 gnt_append_menu_action(tree, action, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
639 g_signal_connect_swapped(G_OBJECT(tree), "destroy",
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
640 G_CALLBACK(gaim_menu_action_free), action);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
641 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
642
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
643 static void
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
644 context_menu_toggle(GntTree *tree, GaimMenuAction *action, gpointer null)
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
645 {
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
646 gboolean sel = gnt_tree_get_choice(tree, action);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
647 gaim_blist_node_set_bool(action->data, "gnt-autojoin", sel);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
648 }
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
649
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
650 static void
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
651 chat_components_edit_ok(GaimChat *chat, GaimRequestFields *allfields)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
652 {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
653 GList *groups, *fields;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
654
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
655 for (groups = gaim_request_fields_get_groups(allfields); groups; groups = groups->next) {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
656 fields = gaim_request_field_group_get_fields(groups->data);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
657 for (; fields; fields = fields->next) {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
658 GaimRequestField *field = fields->data;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
659 const char *id;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
660 char *val;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
661
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
662 id = gaim_request_field_get_id(field);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
663 if (gaim_request_field_get_type(field) == GAIM_REQUEST_FIELD_INTEGER)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
664 val = g_strdup_printf("%d", gaim_request_field_int_get_value(field));
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
665 else
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
666 val = g_strdup(gaim_request_field_string_get_value(field));
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
667
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
668 g_hash_table_replace(chat->components, g_strdup(id), val); /* val should not be free'd */
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
669 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
670 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
671 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
672
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
673 static void
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
674 chat_components_edit(GaimChat *chat, GaimBlistNode *selected)
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
675 {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
676 GaimRequestFields *fields = gaim_request_fields_new();
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
677 GaimRequestFieldGroup *group = gaim_request_field_group_new(NULL);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
678 GaimRequestField *field;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
679 GList *parts, *iter;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
680 struct proto_chat_entry *pce;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
681
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
682 gaim_request_fields_add_group(fields, group);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
683
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
684 parts = GAIM_PLUGIN_PROTOCOL_INFO(chat->account->gc->prpl)->chat_info(chat->account->gc);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
685
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
686 for (iter = parts; iter; iter = iter->next) {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
687 pce = iter->data;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
688 if (pce->is_int) {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
689 int val;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
690 const char *str = g_hash_table_lookup(chat->components, pce->identifier);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
691 if (!str || sscanf(str, "%d", &val) != 1)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
692 val = pce->min;
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
693 field = gaim_request_field_int_new(pce->identifier, pce->label, val);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
694 } else {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
695 field = gaim_request_field_string_new(pce->identifier, pce->label,
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
696 g_hash_table_lookup(chat->components, pce->identifier), FALSE);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
697 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
698
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
699 gaim_request_field_group_add_field(group, field);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
700 g_free(pce);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
701 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
702
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
703 g_list_free(parts);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
704
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
705 gaim_request_fields(NULL, _("Edit Chat"), NULL, _("Please Update the necessary fields."),
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
706 fields, _("Edit"), G_CALLBACK(chat_components_edit_ok), _("Cancel"), NULL, chat);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
707 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
708
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
709 static void
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
710 create_chat_menu(GntTree *tree, GaimChat *chat)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
711 {
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
712 GaimMenuAction *action = gaim_menu_action_new(_("Auto-join"), NULL, chat, NULL);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
713
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
714 gnt_tree_add_choice(tree, action, gnt_tree_create_row(tree, action->label), NULL, NULL);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
715 gnt_tree_set_choice(tree, action, gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin"));
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
716
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
717 g_signal_connect_swapped(G_OBJECT(tree), "destroy",
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
718 G_CALLBACK(gaim_menu_action_free), action);
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
719
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
720 add_custom_action(tree, _("Edit Settings"), (GaimCallback)chat_components_edit, chat);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
721
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
722 g_signal_connect(G_OBJECT(tree), "toggled", G_CALLBACK(context_menu_toggle), NULL);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
723 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
724
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
725 static void
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
726 gg_add_buddy(GaimGroup *grp, GaimBlistNode *selected)
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
727 {
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
728 gaim_blist_request_add_buddy(NULL, NULL, grp ? grp->name : NULL, NULL);
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
729 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
730
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
731 static void
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
732 gg_add_group(GaimGroup *grp, GaimBlistNode *selected)
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
733 {
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
734 gaim_blist_request_add_group();
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
735 }
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
736
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
737 static void
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
738 gg_add_chat(GaimGroup *grp, GaimBlistNode *selected)
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
739 {
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
740 gaim_blist_request_add_chat(NULL, grp, NULL, NULL);
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
741 }
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
742
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
743 static void
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
744 create_group_menu(GntTree *tree, GaimGroup *group)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
745 {
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
746 add_custom_action(tree, _("Add Buddy"),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
747 GAIM_CALLBACK(gg_add_buddy), group);
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
748 add_custom_action(tree, _("Add Chat"),
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
749 GAIM_CALLBACK(gg_add_chat), group);
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
750 add_custom_action(tree, _("Add Group"),
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
751 GAIM_CALLBACK(gg_add_group), group);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
752 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
753
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
754 static void
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
755 gg_blist_get_buddy_info_cb(GaimBuddy *buddy, GaimBlistNode *selected)
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
756 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
757 serv_get_info(buddy->account->gc, gaim_buddy_get_name(buddy));
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
758 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
759
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
760 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
761 create_buddy_menu(GntTree *tree, GaimBuddy *buddy)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
762 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
763 GaimPluginProtocolInfo *prpl_info;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
764
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
765 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(buddy->account->gc->prpl);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
766 if (prpl_info && prpl_info->get_info)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
767 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
768 add_custom_action(tree, _("Get Info"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
769 GAIM_CALLBACK(gg_blist_get_buddy_info_cb), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
770 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
771
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
772 #if 0
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
773 add_custom_action(tree, _("Add Buddy Pounce"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
774 GAIM_CALLBACK(gg_blist_add_buddy_pounce_cb)), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
775
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
776 if (prpl_info && prpl_info->send_file)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
777 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
778 if (!prpl_info->can_receive_file ||
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
779 prpl_info->can_receive_file(buddy->account->gc, buddy->name))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
780 add_custom_action(tree, _("Send File"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
781 GAIM_CALLBACK(gg_blist_show_file_cb)), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
782 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
783
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
784 add_custom_action(tree, _("View Log"),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
785 GAIM_CALLBACK(gg_blist_view_log_cb)), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
786 #endif
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
787
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
788 /* Protocol actions */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
789 append_proto_menu(tree,
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
790 gaim_account_get_connection(gaim_buddy_get_account(buddy)),
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
791 (GaimBlistNode*)buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
792 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
793
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
794 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
795 append_extended_menu(GntTree *tree, GaimBlistNode *node)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
796 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
797 GList *iter;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
798
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
799 for (iter = gaim_blist_node_get_extended_menu(node);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
800 iter; iter = g_list_delete_link(iter, iter))
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
801 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
802 gnt_append_menu_action(tree, iter->data, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
803 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
804 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
805
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
806 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
807 context_menu_callback(GntTree *tree, GGBlist *ggblist)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
808 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
809 GaimMenuAction *action = gnt_tree_get_selection_data(tree);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
810 GaimBlistNode *node = ggblist->cnode;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
811
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
812 if (action)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
813 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
814 void (*callback)(GaimBlistNode *, gpointer);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
815 callback = (void (*)(GaimBlistNode *, gpointer))action->callback;
14020
13e7ba964993 [gaim-migrate @ 16617]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14018
diff changeset
816 if (callback)
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
817 callback(action->data, node);
14020
13e7ba964993 [gaim-migrate @ 16617]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14018
diff changeset
818 else
13e7ba964993 [gaim-migrate @ 16617]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14018
diff changeset
819 return;
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
820 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
821
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
822 remove_context_menu(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
823 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
824
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
825 /* Xerox'd from gtkdialogs.c:gaim_gtkdialogs_remove_contact_cb */
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
826 static void
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
827 remove_contact(GaimContact *contact)
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
828 {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
829 GaimBlistNode *bnode, *cnode;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
830 GaimGroup *group;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
831
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
832 cnode = (GaimBlistNode *)contact;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
833 group = (GaimGroup*)cnode->parent;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
834 for (bnode = cnode->child; bnode; bnode = bnode->next) {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
835 GaimBuddy *buddy = (GaimBuddy*)bnode;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
836 if (gaim_account_is_connected(buddy->account))
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
837 gaim_account_remove_buddy(buddy->account, buddy, group);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
838 }
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
839 gaim_blist_remove_contact(contact);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
840 }
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
841
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
842 static void
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
843 rename_blist_node(GaimBlistNode *node, const char *newname)
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
844 {
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
845 const char *name = newname;
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
846 if (name && !*name)
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
847 name = NULL;
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
848
14475
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
849 if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
850 GaimContact *contact = (GaimContact*)node;
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
851 GaimBuddy *buddy = gaim_contact_get_priority_buddy(contact);
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
852 gaim_blist_alias_contact(contact, name);
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
853 gaim_blist_alias_buddy(buddy, name);
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
854 serv_alias_buddy(buddy);
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
855 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
856 gaim_blist_alias_buddy((GaimBuddy*)node, name);
14475
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
857 serv_alias_buddy((GaimBuddy*)node);
feedb7828791 [gaim-migrate @ 17191]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14470
diff changeset
858 } else if (GAIM_BLIST_NODE_IS_CHAT(node))
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
859 gaim_blist_alias_chat((GaimChat*)node, name);
14691
dbcdef1ab5af [gaim-migrate @ 17443]
Stu Tomlinson <stu@nosnilmot.com>
parents: 14630
diff changeset
860 else if (GAIM_BLIST_NODE_IS_GROUP(node) && (name != NULL))
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
861 gaim_blist_rename_group((GaimGroup*)node, name);
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
862 else
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
863 g_return_if_reached();
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
864 }
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
865
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
866 static void
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
867 gg_blist_rename_node_cb(GaimBlistNode *node, GaimBlistNode *selected)
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
868 {
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
869 const char *name = NULL;
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
870 char *prompt;
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
871
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
872 if (GAIM_BLIST_NODE_IS_CONTACT(node))
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
873 name = gaim_contact_get_alias((GaimContact*)node);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
874 else if (GAIM_BLIST_NODE_IS_BUDDY(node))
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
875 name = gaim_buddy_get_contact_alias((GaimBuddy*)node);
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
876 else if (GAIM_BLIST_NODE_IS_CHAT(node))
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
877 name = gaim_chat_get_name((GaimChat*)node);
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
878 else if (GAIM_BLIST_NODE_IS_GROUP(node))
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
879 name = ((GaimGroup*)node)->name;
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
880 else
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
881 g_return_if_reached();
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
882
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
883 prompt = g_strdup_printf(_("Please enter the new name for %s"), name);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
884
14018
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
885 gaim_request_input(node, _("Rename"), prompt, _("Enter empty string to reset the name."),
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
886 name, FALSE, FALSE, NULL, _("Rename"), G_CALLBACK(rename_blist_node),
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
887 _("Cancel"), NULL, node);
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
888
35699556075f [gaim-migrate @ 16614]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14010
diff changeset
889 g_free(prompt);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
890 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
891
14063
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
892 /* Xeroxed from gtkdialogs.c:gaim_gtkdialogs_remove_group_cb*/
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
893 static void
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
894 remove_group(GaimGroup *group)
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
895 {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
896 GaimBlistNode *cnode, *bnode;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
897
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
898 cnode = ((GaimBlistNode*)group)->child;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
899
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
900 while (cnode) {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
901 if (GAIM_BLIST_NODE_IS_CONTACT(cnode)) {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
902 bnode = cnode->child;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
903 cnode = cnode->next;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
904 while (bnode) {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
905 GaimBuddy *buddy;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
906 if (GAIM_BLIST_NODE_IS_BUDDY(bnode)) {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
907 buddy = (GaimBuddy*)bnode;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
908 bnode = bnode->next;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
909 if (gaim_account_is_connected(buddy->account)) {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
910 gaim_account_remove_buddy(buddy->account, buddy, group);
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
911 gaim_blist_remove_buddy(buddy);
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
912 }
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
913 } else {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
914 bnode = bnode->next;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
915 }
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
916 }
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
917 } else if (GAIM_BLIST_NODE_IS_CHAT(cnode)) {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
918 GaimChat *chat = (GaimChat *)cnode;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
919 cnode = cnode->next;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
920 if (gaim_account_is_connected(chat->account))
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
921 gaim_blist_remove_chat(chat);
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
922 } else {
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
923 cnode = cnode->next;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
924 }
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
925 }
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
926
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
927 gaim_blist_remove_group(group);
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
928 }
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
929
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
930 static void
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
931 gg_blist_remove_node(GaimBlistNode *node)
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
932 {
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
933 if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
934 remove_contact((GaimContact*)node);
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
935 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
14063
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
936 GaimBuddy *buddy = (GaimBuddy*)node;
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
937 GaimGroup *group = gaim_buddy_get_group(buddy);
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
938 gaim_account_remove_buddy(gaim_buddy_get_account(buddy), buddy, group);
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
939 gaim_blist_remove_buddy(buddy);
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
940 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
14063
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
941 gaim_blist_remove_chat((GaimChat*)node);
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
942 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
14063
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
943 remove_group((GaimGroup*)node);
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
944 }
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
945 }
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
946
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
947 static void
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
948 gg_blist_remove_node_cb(GaimBlistNode *node, GaimBlistNode *selected)
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
949 {
14198
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
950 char *primary;
c65ed4f6eea8 [gaim-migrate @ 16870]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
951 const char *name, *sec = NULL;
14064
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
952
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
953 /* XXX: could be a contact */
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
954 if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
955 GaimContact *c = (GaimContact*)node;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
956 name = gaim_contact_get_alias(c);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
957 if (c->totalsize > 1)
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
958 sec = _("Removing this contact will also remove all the buddies in the contact");
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
959 } else if (GAIM_BLIST_NODE_IS_BUDDY(node))
14064
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
960 name = gaim_buddy_get_name((GaimBuddy*)node);
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
961 else if (GAIM_BLIST_NODE_IS_CHAT(node))
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
962 name = gaim_chat_get_name((GaimChat*)node);
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
963 else if (GAIM_BLIST_NODE_IS_GROUP(node))
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
964 {
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
965 name = ((GaimGroup*)node)->name;
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
966 sec = _("Removing this group will also remove all the buddies in the group");
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
967 }
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
968 else
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
969 return;
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
970
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
971 primary = g_strdup_printf(_("Are you sure you want to remove %s?"), name);
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
972
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
973 /* XXX: anything to do with the returned ui-handle? */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
974 gaim_request_action(node, _("Confirm Remove"),
14064
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
975 primary, sec,
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
976 1, node, 2,
14063
ccbd43daa1a3 [gaim-migrate @ 16682]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14062
diff changeset
977 _("Remove"), gg_blist_remove_node,
14064
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
978 _("Cancel"), NULL);
fec4fadf30c9 [gaim-migrate @ 16683]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14063
diff changeset
979 g_free(primary);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
980 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
981
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
982 static void
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
983 gg_blist_tag_buddy(GaimBlistNode *node)
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
984 {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
985 ggblist->tagged = (GaimBuddy *)node;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
986 gaim_debug_info("blist", "Tagged buddy\n");
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
987 }
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
988
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
989 static void
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
990 gg_blist_place_tagged(GaimBlistNode *node)
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
991 {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
992 if (GAIM_BLIST_NODE_IS_GROUP(node)) {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
993 gaim_blist_add_buddy(ggblist->tagged, NULL, (GaimGroup *)node, NULL);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
994 } else {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
995 GaimContact *contact = (GaimContact *)node;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
996 gaim_blist_add_buddy(ggblist->tagged, contact,
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
997 gaim_buddy_get_group(gaim_contact_get_priority_buddy(contact)), NULL);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
998 }
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
999 ggblist->tagged = NULL;
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1000 gaim_debug_info("blist", "Placed buddy\n");
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1001 }
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1002
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1003 static void
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1004 draw_context_menu(GGBlist *ggblist)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1005 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1006 GaimBlistNode *node = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1007 GntWidget *context = NULL, *window = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1008 GntTree *tree = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1009 int x, y, top, width;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1010 char *title = NULL;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1011
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1012 tree = GNT_TREE(ggblist->tree);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1013
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1014 if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1015 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1016 remove_context_menu(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1017 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1018
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1019 node = gnt_tree_get_selection_data(tree);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1020
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1021 if (ggblist->tooltip)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1022 remove_tooltip(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1023
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1024 ggblist->cnode = node;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1025 ggblist->context = context = gnt_tree_new();
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1026 GNT_WIDGET_SET_FLAGS(context, GNT_WIDGET_NO_BORDER);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1027 gnt_widget_set_name(context, "context menu");
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1028 g_signal_connect(G_OBJECT(context), "activate", G_CALLBACK(context_menu_callback), ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1029
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1030 if (!node) {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1031 create_group_menu(GNT_TREE(context), NULL);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1032 title = g_strdup(_("Buddy List"));
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1033 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1034 create_buddy_menu(GNT_TREE(context),
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1035 gaim_contact_get_priority_buddy((GaimContact*)node));
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1036 title = g_strdup(gaim_contact_get_alias((GaimContact*)node));
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1037 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1038 GaimBuddy *buddy = (GaimBuddy *)node;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1039 create_buddy_menu(GNT_TREE(context), buddy);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1040 title = g_strdup(gaim_buddy_get_name(buddy));
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1041 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1042 GaimChat *chat = (GaimChat*)node;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1043 create_chat_menu(GNT_TREE(context), chat);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1044 title = g_strdup(gaim_chat_get_name(chat));
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1045 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1046 GaimGroup *group = (GaimGroup *)node;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1047 create_group_menu(GNT_TREE(context), group);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1048 title = g_strdup(group->name);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1049 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1050
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1051 append_extended_menu(GNT_TREE(context), node);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1052
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1053 /* These are common for everything */
14694
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1054 if (node) {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1055 add_custom_action(GNT_TREE(context), _("Rename"),
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1056 GAIM_CALLBACK(gg_blist_rename_node_cb), node);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1057 add_custom_action(GNT_TREE(context), _("Remove"),
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1058 GAIM_CALLBACK(gg_blist_remove_node_cb), node);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1059 if (ggblist->tagged && (GAIM_BLIST_NODE_IS_CONTACT(node)
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1060 || GAIM_BLIST_NODE_IS_GROUP(node))) {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1061 add_custom_action(GNT_TREE(context), _("Place tagged"),
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1062 GAIM_CALLBACK(gg_blist_place_tagged), node);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1063 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1064 add_custom_action(GNT_TREE(context), _("Tag"),
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1065 GAIM_CALLBACK(gg_blist_tag_buddy), node);
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1066 }
8538993dbb00 [gaim-migrate @ 17446]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14691
diff changeset
1067 }
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1068
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1069 window = gnt_vbox_new(FALSE);
14062
fa8f65cd912c [gaim-migrate @ 16681]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14059
diff changeset
1070 GNT_WIDGET_SET_FLAGS(window, GNT_WIDGET_TRANSIENT);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1071 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1072 gnt_box_set_title(GNT_BOX(window), title);
14020
13e7ba964993 [gaim-migrate @ 16617]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14018
diff changeset
1073
13e7ba964993 [gaim-migrate @ 16617]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14018
diff changeset
1074 gnt_widget_set_size(context, 0, g_list_length(GNT_TREE(context)->list));
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1075 gnt_box_add_widget(GNT_BOX(window), context);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1076
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1077 /* Set the position for the popup */
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1078 gnt_widget_get_position(GNT_WIDGET(tree), &x, &y);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1079 gnt_widget_get_size(GNT_WIDGET(tree), &width, NULL);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1080 top = gnt_tree_get_selection_visible_line(tree);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1081
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1082 x += width;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1083 y += top - 1;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1084
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1085 gnt_widget_set_position(window, x, y);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1086 gnt_widget_draw(window);
13959
2ae35c0cf616 [gaim-migrate @ 16511]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13958
diff changeset
1087 g_free(title);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1088 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1089
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1090 static void
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1091 tooltip_for_buddy(GaimBuddy *buddy, GString *str)
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1092 {
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1093 GaimPlugin *prpl;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1094 GaimPluginProtocolInfo *prpl_info;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1095 GaimAccount *account;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1096
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1097 account = gaim_buddy_get_account(buddy);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1098
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1099 g_string_append_printf(str, _("Account: %s (%s)"),
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1100 gaim_account_get_username(account),
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1101 gaim_account_get_protocol_name(account));
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1102
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1103 prpl = gaim_find_prpl(gaim_account_get_protocol_id(account));
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1104 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1105 if (prpl_info && prpl_info->tooltip_text) {
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1106 GString *tip = g_string_new("");
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1107 char *strip, *br;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1108 prpl_info->tooltip_text(buddy, tip, TRUE);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1109
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1110 br = gaim_strreplace(tip->str, "\n", "<br>");
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1111 strip = gaim_markup_strip_html(br);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1112 g_string_append(str, strip);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1113 g_string_free(tip, TRUE);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1114 g_free(strip);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1115 g_free(br);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1116 }
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1117
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1118 if (gaim_prefs_get_bool("/gaim/gnt/blist/idletime")) {
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1119 GaimPresence *pre = gaim_buddy_get_presence(buddy);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1120 if (gaim_presence_is_idle(pre)) {
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1121 time_t idle = gaim_presence_get_idle_time(pre);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1122 if (idle > 0) {
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1123 char *st = gaim_str_seconds_to_string(time(NULL) - idle);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1124 g_string_append_printf(str, _("\nIdle: %s"), st);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1125 g_free(st);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1126 }
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1127 }
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1128 }
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1129 }
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1130
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1131 static void
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1132 draw_tooltip(GGBlist *ggblist)
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1133 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1134 GaimBlistNode *node;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1135 int x, y, top, width;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1136 GString *str;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1137 GntTree *tree;
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
1138 GntWidget *widget, *box;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1139 char *title = NULL;
14427
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1140 int lastseen = 0;
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1141
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1142 widget = ggblist->tree;
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1143 tree = GNT_TREE(widget);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1144
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
1145 if (!gnt_widget_has_focus(ggblist->tree))
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
1146 return;
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
1147
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1148 if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1149 return;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1150
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1151 if (ggblist->tooltip)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1152 {
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
1153 /* XXX: Once we can properly redraw on expose events, this can be removed at the end
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
1154 * to avoid the blinking*/
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1155 remove_tooltip(ggblist);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1156 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1157
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1158 node = gnt_tree_get_selection_data(tree);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1159 if (!node)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1160 return;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1161
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1162 str = g_string_new("");
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1163
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1164 if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1165 GaimBuddy *pr = gaim_contact_get_priority_buddy((GaimContact*)node);
14427
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1166 gboolean offline = !GAIM_BUDDY_IS_ONLINE(pr);
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1167 gboolean showoffline = gaim_prefs_get_bool(PREF_ROOT "/showoffline");
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1168
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1169 title = g_strdup(gaim_contact_get_alias((GaimContact*)node));
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1170 tooltip_for_buddy(pr, str);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1171 for (node = node->child; node; node = node->next) {
14427
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1172 if (offline) {
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1173 int value = gaim_blist_node_get_int(node, "last_seen");
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1174 if (value > lastseen)
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1175 lastseen = value;
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1176 }
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1177 if (node == (GaimBlistNode*)pr)
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1178 continue;
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1179 if (!showoffline && !GAIM_BUDDY_IS_ONLINE((GaimBuddy*)node))
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1180 continue;
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1181 str = g_string_append(str, "\n----------\n");
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1182 g_string_append_printf(str, _("Nickname: %s\n"), gaim_buddy_get_name((GaimBuddy*)node));
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1183 tooltip_for_buddy((GaimBuddy*)node, str);
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1184 }
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1185 } else if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1186 GaimBuddy *buddy = (GaimBuddy *)node;
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1187 tooltip_for_buddy(buddy, str);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1188 title = g_strdup(gaim_buddy_get_name(buddy));
14427
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1189 if (!GAIM_BUDDY_IS_ONLINE((GaimBuddy*)node))
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1190 lastseen = gaim_blist_node_get_int(node, "last_seen");
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1191 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) {
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1192 GaimGroup *group = (GaimGroup *)node;
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1193
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1194 g_string_append_printf(str, _("Online: %d\nTotal: %d"),
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1195 gaim_blist_get_group_online_count(group),
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1196 gaim_blist_get_group_size(group, FALSE));
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1197
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1198 title = g_strdup(group->name);
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1199 } else if (GAIM_BLIST_NODE_IS_CHAT(node)) {
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
1200 GaimChat *chat = (GaimChat *)node;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
1201 GaimAccount *account = chat->account;
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
1202
13952
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
1203 g_string_append_printf(str, _("Account: %s (%s)"),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
1204 gaim_account_get_username(account),
841a5ffbfee4 [gaim-migrate @ 16500]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13943
diff changeset
1205 gaim_account_get_protocol_name(account));
13884
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
1206
eac18261c6f0 [gaim-migrate @ 16364]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13877
diff changeset
1207 title = g_strdup(gaim_chat_get_name(chat));
14384
4a901f5d1312 [gaim-migrate @ 17090]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14379
diff changeset
1208 } else {
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1209 g_string_free(str, TRUE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1210 return;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1211 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1212
14427
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1213 if (lastseen > 0) {
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1214 char *tmp = gaim_str_seconds_to_string(time(NULL) - lastseen);
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1215 g_string_append_printf(str, _("\nLast Seen: %s ago"), tmp);
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1216 g_free(tmp);
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1217 }
1e00e8245720 [gaim-migrate @ 17137]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14407
diff changeset
1218
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1219 gnt_widget_get_position(widget, &x, &y);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1220 gnt_widget_get_size(widget, &width, NULL);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1221 top = gnt_tree_get_selection_visible_line(tree);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1222
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1223 x += width;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1224 y += top - 1;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1225
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1226 box = gnt_box_new(FALSE, FALSE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1227 gnt_box_set_toplevel(GNT_BOX(box), TRUE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1228 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_NO_SHADOW);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1229 gnt_box_set_title(GNT_BOX(box), title);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1230
13896
a621329e8c85 [gaim-migrate @ 16381]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13885
diff changeset
1231 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(str->str));
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1232
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1233 gnt_widget_set_position(box, x, y);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1234 GNT_WIDGET_UNSET_FLAGS(box, GNT_WIDGET_CAN_TAKE_FOCUS);
14042
143474e2b1cb [gaim-migrate @ 16648]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14041
diff changeset
1235 GNT_WIDGET_SET_FLAGS(box, GNT_WIDGET_TRANSIENT);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1236 gnt_widget_draw(box);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1237
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1238 g_free(title);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1239 g_string_free(str, TRUE);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1240 ggblist->tooltip = box;
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1241 ggblist->tnode = node;
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
1242
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
1243 gnt_widget_set_name(ggblist->tooltip, "tooltip");
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1244 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1245
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1246 static void
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1247 selection_changed(GntWidget *widget, gpointer old, gpointer current, GGBlist *ggblist)
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1248 {
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1249 if (ggblist->context)
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1250 remove_context_menu(ggblist);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1251 draw_tooltip(ggblist);
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1252 }
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1253
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1254 static gboolean
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1255 key_pressed(GntWidget *widget, const char *text, GGBlist *ggblist)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1256 {
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1257 gboolean stop = FALSE, ret = FALSE;
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1258 if (text[0] == 27 && text[1] == 0)
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1259 {
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1260 /* Escape was pressed */
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1261 remove_peripherals(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1262 stop = TRUE;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1263 ret = TRUE;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1264 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1265
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1266 if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1267 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1268 ret = gnt_widget_key_pressed(ggblist->context, text);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1269 stop = TRUE;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1270 }
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1271
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1272 if (text[0] == 27)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1273 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1274 if (strcmp(text + 1, GNT_KEY_POPUP) == 0)
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1275 {
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1276 draw_context_menu(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1277 stop = TRUE;
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1278 ret = TRUE;
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1279 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1280 }
14405
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14399
diff changeset
1281 else if (strcmp(text, GNT_KEY_CTRL_O) == 0)
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14399
diff changeset
1282 {
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14399
diff changeset
1283 gaim_prefs_set_bool(PREF_ROOT "/showoffline",
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14399
diff changeset
1284 !gaim_prefs_get_bool(PREF_ROOT "/showoffline"));
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14399
diff changeset
1285 ret = TRUE;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14399
diff changeset
1286 stop = TRUE;
8375ecb6152b [gaim-migrate @ 17113]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14399
diff changeset
1287 }
13885
582aaa4e287e [gaim-migrate @ 16365]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13884
diff changeset
1288
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1289 if (stop)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1290 g_signal_stop_emission_by_name(G_OBJECT(widget), "key_pressed");
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1291
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1292 return ret;
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1293 }
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1294
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1295 static void
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1296 update_buddy_display(GaimBuddy *buddy, GGBlist *ggblist)
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1297 {
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1298 GaimContact *contact;
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1299
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1300 contact = gaim_buddy_get_contact(buddy);
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1301
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
1302 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((GaimBlistNode*)buddy));
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1303 gnt_tree_change_text(GNT_TREE(ggblist->tree), contact, 0, get_display_name((GaimBlistNode*)contact));
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1304
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1305 if (ggblist->tnode == (GaimBlistNode*)buddy)
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1306 draw_tooltip(ggblist);
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1307
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1308 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) {
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1309 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM);
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1310 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, GNT_TEXT_FLAG_DIM);
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1311 } else {
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1312 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, 0);
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1313 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), contact, 0);
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1314 }
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1315 }
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1316
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1317 static void
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1318 buddy_status_changed(GaimBuddy *buddy, GaimStatus *old, GaimStatus *now, GGBlist *ggblist)
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1319 {
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1320 update_buddy_display(buddy, ggblist);
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1321 }
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1322
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1323 static void
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1324 buddy_idle_changed(GaimBuddy *buddy, int old, int new, GGBlist *ggblist)
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1325 {
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1326 update_buddy_display(buddy, ggblist);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1327 }
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1328
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1329 static void
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1330 remove_peripherals(GGBlist *ggblist)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1331 {
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1332 if (ggblist->tooltip)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1333 remove_tooltip(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1334 else if (ggblist->context)
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1335 remove_context_menu(ggblist);
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1336 }
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1337
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1338 static void
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1339 size_changed_cb(GntWidget *w, int width, int height)
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1340 {
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1341 gaim_prefs_set_int(PREF_ROOT "/size/width", width);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1342 gaim_prefs_set_int(PREF_ROOT "/size/height", height);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1343 }
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1344
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1345 static void
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1346 save_position_cb(GntWidget *w, int x, int y)
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1347 {
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1348 gaim_prefs_set_int(PREF_ROOT "/position/x", x);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1349 gaim_prefs_set_int(PREF_ROOT "/position/y", y);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1350 }
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1351
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1352 static void
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1353 reset_blist_window(GntWidget *window, gpointer null)
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1354 {
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1355 GaimBlistNode *node;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1356 gaim_signals_disconnect_by_handle(gg_blist_get_handle());
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1357 gaim_get_blist()->ui_data = NULL;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1358
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1359 node = gaim_blist_get_root();
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1360 while (node) {
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1361 node->ui_data = NULL;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1362 node = gaim_blist_node_next(node, TRUE);
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1363 }
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1364
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1365 if (ggblist->typing)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1366 g_source_remove(ggblist->typing);
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1367 remove_peripherals(ggblist);
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1368 g_free(ggblist);
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1369 ggblist = NULL;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1370 }
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1371
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1372 static void
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1373 populate_buddylist()
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1374 {
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1375 GaimBlistNode *node;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1376 GaimBuddyList *list;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1377
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1378 list = gaim_get_blist();
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1379 node = gaim_blist_get_root();
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1380 while (node)
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1381 {
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1382 node_update(list, node);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1383 node = gaim_blist_node_next(node, FALSE);
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1384 }
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1385 }
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1386
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1387 static void
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1388 destroy_status_list(GList *list)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1389 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1390 g_list_foreach(list, (GFunc)g_free, NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1391 g_list_free(list);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1392 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1393
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1394 static void
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1395 populate_status_dropdown()
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1396 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1397 int i;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1398 GList *iter;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1399 GList *items = NULL;
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1400 StatusBoxItem *item = NULL;
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1401
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1402 /* First the primitives */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1403 GaimStatusPrimitive prims[] = {GAIM_STATUS_AVAILABLE, GAIM_STATUS_AWAY,
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1404 GAIM_STATUS_INVISIBLE, GAIM_STATUS_OFFLINE, GAIM_STATUS_UNSET};
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1405
14493
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14477
diff changeset
1406 gnt_combo_box_remove_all(GNT_COMBO_BOX(ggblist->status));
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14477
diff changeset
1407
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1408 for (i = 0; prims[i] != GAIM_STATUS_UNSET; i++)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1409 {
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1410 item = g_new0(StatusBoxItem, 1);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1411 item->type = STATUS_PRIMITIVE;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1412 item->u.prim = prims[i];
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1413 items = g_list_prepend(items, item);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1414 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item,
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1415 gaim_primitive_get_name_from_type(prims[i]));
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1416 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1417
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1418 /* Now the popular statuses */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1419 for (iter = gaim_savedstatuses_get_popular(6); iter; iter = iter->next)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1420 {
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1421 item = g_new0(StatusBoxItem, 1);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1422 item->type = STATUS_SAVED_POPULAR;
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1423 item->u.saved = iter->data;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1424 items = g_list_prepend(items, item);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1425 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item,
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1426 gaim_savedstatus_get_title(iter->data));
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1427 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1428
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1429 /* New savedstatus */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1430 item = g_new0(StatusBoxItem, 1);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1431 item->type = STATUS_SAVED_NEW;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1432 items = g_list_prepend(items, item);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1433 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item,
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1434 _("New..."));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1435
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1436 /* More savedstatuses */
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1437 item = g_new0(StatusBoxItem, 1);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1438 item->type = STATUS_SAVED_ALL;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1439 items = g_list_prepend(items, item);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1440 gnt_combo_box_add_data(GNT_COMBO_BOX(ggblist->status), item,
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1441 _("Saved..."));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1442
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1443 /* The keys for the combobox are created here, and never used
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1444 * anywhere else. So make sure the keys are freed when the widget
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1445 * is destroyed. */
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1446 g_object_set_data_full(G_OBJECT(ggblist->status), "list of statuses",
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1447 items, (GDestroyNotify)destroy_status_list);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1448 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1449
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1450 static void
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1451 redraw_blist(const char *name, GaimPrefType type, gconstpointer val, gpointer data)
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1452 {
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
1453 GaimBlistNode *node, *sel;
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1454 if (ggblist == NULL)
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1455 return;
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1456
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
1457 sel = gnt_tree_get_selection_data(GNT_TREE(ggblist->tree));
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1458 gnt_tree_remove_all(GNT_TREE(ggblist->tree));
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1459 node = gaim_blist_get_root();
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1460 for (; node; node = gaim_blist_node_next(node, TRUE))
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1461 node->ui_data = NULL;
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1462 populate_buddylist();
14469
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
1463 gnt_tree_set_selected(GNT_TREE(ggblist->tree), sel);
ddfe82afecd8 [gaim-migrate @ 17185]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14427
diff changeset
1464 draw_tooltip(ggblist);
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1465 }
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1466
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1467 void gg_blist_init()
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1468 {
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1469 gaim_prefs_add_none(PREF_ROOT);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1470 gaim_prefs_add_none(PREF_ROOT "/size");
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1471 gaim_prefs_add_int(PREF_ROOT "/size/width", 20);
14218
c509b8b8a646 [gaim-migrate @ 16899]
Ethan Blanton <elb@pidgin.im>
parents: 14214
diff changeset
1472 gaim_prefs_add_int(PREF_ROOT "/size/height", 17);
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1473 gaim_prefs_add_none(PREF_ROOT "/position");
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1474 gaim_prefs_add_int(PREF_ROOT "/position/x", 0);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1475 gaim_prefs_add_int(PREF_ROOT "/position/y", 0);
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1476 gaim_prefs_add_bool(PREF_ROOT "/idletime", TRUE);
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1477 gaim_prefs_add_bool(PREF_ROOT "/showoffline", FALSE);
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1478
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1479 gg_blist_show();
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1480
14399
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1481 gaim_prefs_connect_callback(gg_blist_get_handle(),
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1482 PREF_ROOT "/showoffline", redraw_blist, NULL);
28baa42b5ac2 [gaim-migrate @ 17107]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14396
diff changeset
1483
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1484 return;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1485 }
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1486
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
1487 static gboolean
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1488 remove_typing_cb(gpointer null)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1489 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1490 GaimSavedStatus *current;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1491 const char *message, *newmessage;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1492 GaimStatusPrimitive prim, newprim;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1493 StatusBoxItem *item;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1494
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1495 current = gaim_savedstatus_get_current();
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1496 message = gaim_savedstatus_get_message(current);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1497 prim = gaim_savedstatus_get_type(current);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1498
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1499 newmessage = gnt_entry_get_text(GNT_ENTRY(ggblist->statustext));
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1500 item = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(ggblist->status));
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
1501 g_return_val_if_fail(item->type == STATUS_PRIMITIVE, FALSE);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1502 newprim = item->u.prim;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1503
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1504 if (newprim != prim || ((message && !newmessage) ||
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1505 (!message && newmessage) ||
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1506 (message && newmessage && g_utf8_collate(message, newmessage) != 0)))
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1507 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1508 GaimSavedStatus *status = gaim_savedstatus_find_transient_by_type_and_message(newprim, newmessage);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1509 /* Holy Crap! That's a LAWNG function name */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1510 if (status == NULL)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1511 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1512 status = gaim_savedstatus_new(NULL, newprim);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1513 gaim_savedstatus_set_message(status, newmessage);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1514 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1515
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1516 gaim_savedstatus_activate(status);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1517 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1518
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1519 gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree);
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
1520 if (ggblist->typing)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
1521 g_source_remove(ggblist->typing);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1522 ggblist->typing = 0;
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
1523 return FALSE;
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1524 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1525
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1526 static void
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1527 status_selection_changed(GntComboBox *box, StatusBoxItem *old, StatusBoxItem *now, gpointer null)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1528 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1529 gnt_entry_set_text(GNT_ENTRY(ggblist->statustext), NULL);
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1530 if (now->type == STATUS_SAVED_POPULAR)
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1531 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1532 /* Set the status immediately */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1533 gaim_savedstatus_activate(now->u.saved);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1534 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1535 else if (now->type == STATUS_PRIMITIVE)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1536 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1537 /* Move the focus to the entry box */
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
1538 /* XXX: Make sure the selected status can have a message */
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1539 gnt_box_move_focus(GNT_BOX(ggblist->window), 1);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1540 ggblist->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1541 }
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1542 else if (now->type == STATUS_SAVED_ALL)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1543 {
14131
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
1544 /* Restore the selection to reflect current status. */
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
1545 savedstatus_changed(gaim_savedstatus_get_current(), NULL);
db2311999862 [gaim-migrate @ 16773]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
1546 gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree);
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1547 gg_savedstatus_show_all();
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14105
diff changeset
1548 }
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1549 else if (now->type == STATUS_SAVED_NEW)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1550 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1551 savedstatus_changed(gaim_savedstatus_get_current(), NULL);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1552 gnt_box_give_focus_to_child(GNT_BOX(ggblist->window), ggblist->tree);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1553 gg_savedstatus_edit(NULL);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14131
diff changeset
1554 }
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1555 else
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1556 g_return_if_reached();
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1557 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1558
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1559 static gboolean
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1560 status_text_changed(GntEntry *entry, const char *text, gpointer null)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1561 {
14047
c5bfede33622 [gaim-migrate @ 16660]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14042
diff changeset
1562 if ((text[0] == 27 || (text[0] == '\t' && text[1] == '\0')) && ggblist->typing == 0)
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1563 return FALSE;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1564
14059
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
1565 if (ggblist->typing)
2d1b41e3cf0d [gaim-migrate @ 16674]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14047
diff changeset
1566 g_source_remove(ggblist->typing);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1567 ggblist->typing = 0;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1568
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1569 if (text[0] == '\r' && text[1] == 0)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1570 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1571 /* Set the status only after you press 'Enter' */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1572 remove_typing_cb(NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1573 return TRUE;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1574 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1575
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1576 ggblist->typing = g_timeout_add(TYPING_TIMEOUT, (GSourceFunc)remove_typing_cb, NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1577 return FALSE;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1578 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1579
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1580 static void
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1581 savedstatus_changed(GaimSavedStatus *now, GaimSavedStatus *old)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1582 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1583 GList *list;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1584 GaimStatusPrimitive prim;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1585 const char *message;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1586
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1587 if (!ggblist)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1588 return;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1589
14493
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14477
diff changeset
1590 /* Block the signals we don't want to emit */
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1591 g_signal_handlers_block_matched(ggblist->status, G_SIGNAL_MATCH_FUNC,
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1592 0, 0, NULL, status_selection_changed, NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1593 g_signal_handlers_block_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC,
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1594 0, 0, NULL, status_text_changed, NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1595
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1596 prim = gaim_savedstatus_get_type(now);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1597 message = gaim_savedstatus_get_message(now);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1598
14493
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14477
diff changeset
1599 /* Rebuild the status dropdown */
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14477
diff changeset
1600 populate_status_dropdown();
5ac8f22e7b08 [gaim-migrate @ 17212]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14477
diff changeset
1601
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1602 list = g_object_get_data(G_OBJECT(ggblist->status), "list of statuses");
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1603 for (; list; list = list->next)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1604 {
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1605 StatusBoxItem *item = list->data;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1606 if (item->type == STATUS_PRIMITIVE && item->u.prim == prim)
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1607 {
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14393
diff changeset
1608 char *mess = gaim_unescape_html(message);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1609 gnt_combo_box_set_selected(GNT_COMBO_BOX(ggblist->status), item);
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14393
diff changeset
1610 gnt_entry_set_text(GNT_ENTRY(ggblist->statustext), mess);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1611 gnt_widget_draw(ggblist->status);
14396
9e9699792bb9 [gaim-migrate @ 17104]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14393
diff changeset
1612 g_free(mess);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1613 break;
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1614 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1615 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1616
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1617 g_signal_handlers_unblock_matched(ggblist->status, G_SIGNAL_MATCH_FUNC,
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1618 0, 0, NULL, status_selection_changed, NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1619 g_signal_handlers_unblock_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC,
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1620 0, 0, NULL, status_text_changed, NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1621 }
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1622
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1623 static int
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1624 blist_node_compare(GaimBlistNode *n1, GaimBlistNode *n2)
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1625 {
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1626 const char *s1, *s2;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1627 char *us1, *us2;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1628 int ret;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1629
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1630 g_return_val_if_fail(n1->type == n2->type, -1);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1631
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1632 switch (n1->type)
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1633 {
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1634 case GAIM_BLIST_GROUP_NODE:
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1635 s1 = ((GaimGroup*)n1)->name;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1636 s2 = ((GaimGroup*)n2)->name;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1637 break;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1638 case GAIM_BLIST_CHAT_NODE:
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1639 s1 = gaim_chat_get_name((GaimChat*)n1);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1640 s2 = gaim_chat_get_name((GaimChat*)n2);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1641 break;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1642 case GAIM_BLIST_BUDDY_NODE:
14385
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1643 /* XXX: reordering existing rows don't do well in GntTree */
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1644 return gaim_presence_compare(gaim_buddy_get_presence((GaimBuddy*)n1),
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1645 gaim_buddy_get_presence((GaimBuddy*)n2));
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1646 break;
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1647 case GAIM_BLIST_CONTACT_NODE:
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1648 s1 = gaim_contact_get_alias((GaimContact*)n1);
d1e4e986bbd1 [gaim-migrate @ 17091]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14384
diff changeset
1649 s2 = gaim_contact_get_alias((GaimContact*)n2);
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1650 break;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1651 default:
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1652 return -1;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1653 }
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1654
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1655 us1 = g_utf8_strup(s1, -1);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1656 us2 = g_utf8_strup(s2, -1);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1657 ret = g_utf8_collate(us1, us2);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1658 g_free(us1);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1659 g_free(us2);
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1660
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1661 return ret;
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1662 }
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1663
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1664 static gboolean
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1665 blist_clicked(GntTree *tree, GntMouseEvent event, int x, int y, gpointer ggblist)
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1666 {
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1667 if (event == GNT_RIGHT_MOUSE_DOWN) {
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1668 draw_context_menu(ggblist);
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1669 }
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1670 return FALSE;
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1671 }
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1672
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1673 static void
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1674 plugin_action(GntMenuItem *item, gpointer data)
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1675 {
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1676 GaimPluginAction *action = data;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1677 if (action && action->callback)
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1678 action->callback(action);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1679 }
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1680
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1681 static void
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1682 reconstruct_accounts_menu()
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1683 {
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1684 GntWidget *menu, *sub;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1685 GntMenuItem *item;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1686 GntWindow *window;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1687 GList *iter;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1688
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1689 if (!ggblist)
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1690 return;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1691
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1692 window = GNT_WINDOW(ggblist->window);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1693
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1694 menu = gnt_menu_new(GNT_MENU_TOPLEVEL);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1695 gnt_window_set_menu(window, GNT_MENU(menu));
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1696
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1697 item = gnt_menuitem_new(_("Accounts"));
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1698 gnt_menu_add_item(GNT_MENU(menu), item);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1699
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1700 sub = gnt_menu_new(GNT_MENU_POPUP);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1701 gnt_menuitem_set_submenu(item, GNT_MENU(sub));
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1702
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1703 for (iter = gaim_accounts_get_all_active(); iter;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1704 iter = g_list_delete_link(iter, iter)) {
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1705 GaimAccount *account = iter->data;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1706 GaimConnection *gc = gaim_account_get_connection(account);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1707 GaimPlugin *prpl;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1708
14630
275c84b1b2a4 [gaim-migrate @ 17376]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14616
diff changeset
1709 if (!gc || !GAIM_CONNECTION_IS_CONNECTED(gc))
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1710 continue;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1711 prpl = gc->prpl;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1712
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1713 if (GAIM_PLUGIN_HAS_ACTIONS(prpl)) {
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1714 GList *acts;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1715 GntWidget *s;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1716
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1717 item = gnt_menuitem_new(gaim_account_get_username(account));
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1718 s = gnt_menu_new(GNT_MENU_POPUP);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1719 gnt_menuitem_set_submenu(item, GNT_MENU(s));
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1720 gnt_menu_add_item(GNT_MENU(sub), item);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1721
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1722 for (acts = GAIM_PLUGIN_ACTIONS(prpl, gc); acts;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1723 acts = g_list_delete_link(acts, acts)) {
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1724 GaimPluginAction *action = acts->data;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1725 if (!action)
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1726 continue;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1727
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1728 action->plugin = prpl;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1729 action->context = gc;
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1730
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1731 item = gnt_menuitem_new(action->label);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1732 gnt_menuitem_set_callback(item, plugin_action, action);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1733 /* This is to make sure the action is freed when the menu is destroyed */
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1734 g_object_set_data_full(G_OBJECT(item), "plugin_action", action,
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1735 (GDestroyNotify)gaim_plugin_action_free);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1736 gnt_menu_add_item(GNT_MENU(s), item);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1737 }
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1738 }
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1739 }
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1740 }
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1741
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1742 void gg_blist_show()
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1743 {
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1744 if (ggblist)
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1745 return;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1746
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
1747 ggblist = g_new0(GGBlist, 1);
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
1748
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
1749 gaim_get_blist()->ui_data = ggblist;
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1750
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1751 ggblist->window = gnt_vwindow_new(FALSE);
13869
5642f4658b59 [gaim-migrate @ 16335]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13865
diff changeset
1752 gnt_widget_set_name(ggblist->window, "buddylist");
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1753 gnt_box_set_toplevel(GNT_BOX(ggblist->window), TRUE);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1754 gnt_box_set_title(GNT_BOX(ggblist->window), _("Buddy List"));
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
1755 gnt_box_set_pad(GNT_BOX(ggblist->window), 0);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1756
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1757 ggblist->tree = gnt_tree_new();
14105
eaf7f35635bc [gaim-migrate @ 16739]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14065
diff changeset
1758 gnt_tree_set_compare_func(GNT_TREE(ggblist->tree), (GCompareFunc)blist_node_compare);
13853
bbf0470cb348 [gaim-migrate @ 16312]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13850
diff changeset
1759 GNT_WIDGET_SET_FLAGS(ggblist->tree, GNT_WIDGET_NO_BORDER);
13964
0a0d2a1fd2bc [gaim-migrate @ 16520]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13959
diff changeset
1760 gnt_tree_set_col_width(GNT_TREE(ggblist->tree), 0, 25);
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1761 gnt_widget_set_size(ggblist->tree, gaim_prefs_get_int(PREF_ROOT "/size/width"),
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1762 gaim_prefs_get_int(PREF_ROOT "/size/height"));
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1763 gnt_widget_set_position(ggblist->window, gaim_prefs_get_int(PREF_ROOT "/position/x"),
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1764 gaim_prefs_get_int(PREF_ROOT "/position/y"));
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1765
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1766 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->tree);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1767
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1768 ggblist->status = gnt_combo_box_new();
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1769 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->status);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1770 ggblist->statustext = gnt_entry_new(NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1771 gnt_box_add_widget(GNT_BOX(ggblist->window), ggblist->statustext);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1772
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1773 gnt_widget_show(ggblist->window);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1774
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1775 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", gg_blist_get_handle(),
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1776 GAIM_CALLBACK(reconstruct_accounts_menu), NULL);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1777 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", gg_blist_get_handle(),
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1778 GAIM_CALLBACK(reconstruct_accounts_menu), NULL);
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1779 gaim_signal_connect(gaim_blist_get_handle(), "buddy-status-changed", gg_blist_get_handle(),
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1780 GAIM_CALLBACK(buddy_status_changed), ggblist);
13931
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1781 gaim_signal_connect(gaim_blist_get_handle(), "buddy-idle-changed", gg_blist_get_handle(),
917a71dd02eb [gaim-migrate @ 16458]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13927
diff changeset
1782 GAIM_CALLBACK(buddy_idle_changed), ggblist);
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1783
13864
c7d84d4c5afa [gaim-migrate @ 16328]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13861
diff changeset
1784 #if 0
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1785 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-on", gg_blist_get_handle(),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1786 GAIM_CALLBACK(buddy_signed_on), ggblist);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1787 gaim_signal_connect(gaim_blist_get_handle(), "buddy-signed-off", gg_blist_get_handle(),
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1788 GAIM_CALLBACK(buddy_signed_off), ggblist);
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1789
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1790 /* These I plan to use to indicate unread-messages etc. */
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1791 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", gg_blist_get_handle(),
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1792 GAIM_CALLBACK(received_im_msg), list);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1793 gaim_signal_connect(gaim_conversations_get_handle(), "sent-im-msg", gg_blist_get_handle(),
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1794 GAIM_CALLBACK(sent_im_msg), NULL);
13857
d341b5ac1a78 [gaim-migrate @ 16316]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13853
diff changeset
1795
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1796 gaim_signal_connect(gaim_conversations_get_handle(), "received-chat-msg", gg_blist_get_handle(),
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1797 GAIM_CALLBACK(received_chat_msg), list);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1798 #endif
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1799
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1800 g_signal_connect(G_OBJECT(ggblist->tree), "selection_changed", G_CALLBACK(selection_changed), ggblist);
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1801 g_signal_connect(G_OBJECT(ggblist->tree), "key_pressed", G_CALLBACK(key_pressed), ggblist);
14477
ca36763497d9 [gaim-migrate @ 17195]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14475
diff changeset
1802 g_signal_connect_after(G_OBJECT(ggblist->tree), "clicked", G_CALLBACK(blist_clicked), ggblist);
13860
c1e3f7c75c3f [gaim-migrate @ 16321]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13858
diff changeset
1803 g_signal_connect(G_OBJECT(ggblist->tree), "activate", G_CALLBACK(selection_activate), ggblist);
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1804 g_signal_connect_data(G_OBJECT(ggblist->tree), "gained-focus", G_CALLBACK(draw_tooltip),
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1805 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
13958
6741419af7f7 [gaim-migrate @ 16510]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13952
diff changeset
1806 g_signal_connect_data(G_OBJECT(ggblist->tree), "lost-focus", G_CALLBACK(remove_peripherals),
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1807 ggblist, 0, G_CONNECT_AFTER | G_CONNECT_SWAPPED);
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1808 g_signal_connect(G_OBJECT(ggblist->tree), "size_changed", G_CALLBACK(size_changed_cb), NULL);
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1809 g_signal_connect(G_OBJECT(ggblist->window), "position_set", G_CALLBACK(save_position_cb), NULL);
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1810 g_signal_connect(G_OBJECT(ggblist->window), "destroy", G_CALLBACK(reset_blist_window), NULL);
14010
7573bd40a190 [gaim-migrate @ 16602]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13964
diff changeset
1811
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1812 /* Status signals */
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1813 gaim_signal_connect(gaim_savedstatuses_get_handle(), "savedstatus-changed", gg_blist_get_handle(),
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1814 GAIM_CALLBACK(savedstatus_changed), NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1815 g_signal_connect(G_OBJECT(ggblist->status), "selection_changed",
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1816 G_CALLBACK(status_selection_changed), NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1817 g_signal_connect(G_OBJECT(ggblist->statustext), "key_pressed",
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1818 G_CALLBACK(status_text_changed), NULL);
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1819
14616
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1820 reconstruct_accounts_menu(ggblist);
f1f1dcb26d89 [gaim-migrate @ 17344]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
1821
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1822 populate_buddylist();
14041
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1823
27182f83b79b [gaim-migrate @ 16647]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14024
diff changeset
1824 savedstatus_changed(gaim_savedstatus_get_current(), NULL);
13850
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1825 }
0e1e59770cb0 [gaim-migrate @ 16308]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
1826
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1827 void gg_blist_uninit()
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1828 {
14024
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1829 if (ggblist == NULL)
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1830 return;
7109e6397a31 [gaim-migrate @ 16622]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14020
diff changeset
1831
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1832 gnt_widget_destroy(ggblist->window);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1833 g_free(ggblist);
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1834 ggblist = NULL;
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1835 }
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1836
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1837 gboolean gg_blist_get_position(int *x, int *y)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1838 {
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1839 if (!ggblist || !ggblist->window)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1840 return FALSE;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1841 gnt_widget_get_position(ggblist->window, x, y);
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1842 return TRUE;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1843 }
13907
cc60d0861337 [gaim-migrate @ 16402]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13897
diff changeset
1844
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1845 void gg_blist_set_position(int x, int y)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1846 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1847 gnt_widget_set_position(ggblist->window, x, y);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1848 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1849
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1850 gboolean gg_blist_get_size(int *width, int *height)
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1851 {
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1852 if (!ggblist || !ggblist->window)
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1853 return FALSE;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1854 gnt_widget_get_size(ggblist->window, width, height);
14351
1bd09d355f9e [gaim-migrate @ 17054]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14218
diff changeset
1855 return TRUE;
13916
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1856 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1857
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1858 void gg_blist_set_size(int width, int height)
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1859 {
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1860 gnt_widget_set_size(ggblist->window, width, height);
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1861 }
fdf2dbed6faa [gaim-migrate @ 16418]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 13907
diff changeset
1862