Mercurial > pidgin.yaz
annotate finch/gntroomlist.c @ 22006:1278280fa0b6
Implementation of the roomlist API.
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Sun, 06 Jan 2008 19:01:24 +0000 |
parents | |
children | d65fd48a3ad9 |
rev | line source |
---|---|
22006
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 /** |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 * @file gntroomlist.c GNT Room List API |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 * @ingroup finch |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
4 */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 /* finch |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 * |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 * Finch is the legal property of its developers, whose names are too numerous |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 * |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 * it under the terms of the GNU General Public License as published by |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 * |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
21 * |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
25 */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
26 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
27 #include"internal.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
28 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
29 #include "gntrequest.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
30 #include "gntroomlist.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
31 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
32 #include "gntbox.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 #include "gntbutton.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 #include "gntcombobox.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 #include "gnttextview.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 #include "gnttree.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 #include "gntwindow.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
39 #include "debug.h" |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
40 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 /* Yes, just one roomlist at a time. Let's not get greedy. Aight? */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 struct _FinchRoomlist |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 GntWidget *window; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 GntWidget *accounts; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 GntWidget *tree; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 GntWidget *details; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 GntWidget *getlist; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 GntWidget *add; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 GntWidget *join; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 GntWidget *stop; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 GntWidget *close; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
55 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 PurpleAccount *account; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 PurpleRoomlist *roomlist; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 } froomlist; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 typedef struct _FinchRoomlist FinchRoomlist; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 unset_roomlist(gpointer null) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
65 froomlist.window = NULL; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
66 if (froomlist.roomlist) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
67 purple_roomlist_unref(froomlist.roomlist); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
68 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
69 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
70 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
71 update_roomlist(PurpleRoomlist *list) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
72 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
73 if (froomlist.roomlist == list) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
74 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
75 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
76 if (froomlist.roomlist) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 purple_roomlist_unref(froomlist.roomlist); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
79 if ((froomlist.roomlist = list) != NULL) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 purple_roomlist_ref(list); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
81 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
82 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
83 static void fl_stop(GntWidget *button, gpointer null) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
84 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
85 if (froomlist.roomlist && |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
86 purple_roomlist_get_in_progress(froomlist.roomlist)) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 purple_roomlist_cancel_get_list(froomlist.roomlist); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
88 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 static void fl_get_list(GntWidget *button, gpointer null) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 PurpleAccount *account = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(froomlist.accounts)); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
93 PurpleConnection *gc = purple_account_get_connection(account); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 if (!gc) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 froomlist.roomlist = purple_roomlist_get_list(gc); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
99 gnt_box_give_focus_to_child(GNT_BOX(froomlist.window), froomlist.tree); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
100 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
102 static void fl_add_chat(GntWidget *button, gpointer null) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
103 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
104 char *name; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
105 PurpleRoomlistRoom *room = gnt_tree_get_selection_data(GNT_TREE(froomlist.tree)); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
106 PurpleConnection *gc = purple_account_get_connection(froomlist.account); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
107 PurplePluginProtocolInfo *prpl_info = NULL; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
108 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
109 if (gc == NULL || room == NULL) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
110 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
111 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
112 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
113 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
114 if(prpl_info != NULL && prpl_info->roomlist_room_serialize) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
115 name = prpl_info->roomlist_room_serialize(room); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 else |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 name = g_strdup(purple_roomlist_room_get_name(room)); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 purple_blist_request_add_chat(froomlist.account, NULL, NULL, name); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 g_free(name); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 static void fl_close(GntWidget *button, gpointer null) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 gnt_widget_destroy(froomlist.window); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
128 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
129 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 roomlist_activated(GntWidget *widget) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 PurpleRoomlistRoom *room = gnt_tree_get_selection_data(GNT_TREE(widget)); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 if (!room) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 switch (purple_roomlist_room_get_type(room)) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
137 case PURPLE_ROOMLIST_ROOMTYPE_ROOM: |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
138 purple_roomlist_room_join(froomlist.roomlist, room); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 break; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 case PURPLE_ROOMLIST_ROOMTYPE_CATEGORY: |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 purple_roomlist_expand_category(froomlist.roomlist, room); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
142 break; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
143 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
147 roomlist_selection_changed(GntWidget *widget, gpointer old, gpointer current, gpointer null) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
148 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 GList *iter, *field; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
150 PurpleRoomlistRoom *room = current; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
151 GntTextView *tv = GNT_TEXT_VIEW(froomlist.details); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 gboolean first = TRUE; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 gnt_text_view_clear(tv); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
155 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
156 if (!room) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 for (iter = purple_roomlist_room_get_fields(room), |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 field = purple_roomlist_get_fields(froomlist.roomlist); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 iter && field; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 iter = iter->next, field = field->next) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
163 PurpleRoomlistField *f = field->data; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
164 char *label = NULL; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
165 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
166 if (purple_roomlist_field_get_hidden(f)) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
167 continue; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
168 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
170 if (!first) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
171 gnt_text_view_append_text_with_flags(tv, "\n", GNT_TEXT_FLAG_NORMAL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
172 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
173 gnt_text_view_append_text_with_flags(tv, |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
174 purple_roomlist_field_get_label(f), GNT_TEXT_FLAG_BOLD); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
175 gnt_text_view_append_text_with_flags(tv, ": ", GNT_TEXT_FLAG_BOLD); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
176 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
177 switch (purple_roomlist_field_get_type(f)) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
178 case PURPLE_ROOMLIST_FIELD_BOOL: |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
179 label = g_strdup(iter->data ? "True" : "False"); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
180 break; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
181 case PURPLE_ROOMLIST_FIELD_INT: |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
182 label = g_strdup_printf("%d", (int)iter->data); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
183 break; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
184 case PURPLE_ROOMLIST_FIELD_STRING: |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
185 label = g_strdup(iter->data); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
186 break; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
187 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
188 gnt_text_view_append_text_with_flags(tv, label, GNT_TEXT_FLAG_NORMAL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
189 g_free(label); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
190 first = FALSE; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
191 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
192 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
193 if (purple_roomlist_room_get_type(room) == PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
194 gnt_text_view_append_text_with_flags(tv, |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
195 _("\nHit 'Enter' to find more rooms of this category."), |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
196 GNT_TEXT_FLAG_NORMAL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
197 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
198 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
199 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
200 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
201 roomlist_account_changed(GntWidget *widget, gpointer old, gpointer current, gpointer null) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
202 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
203 if (froomlist.account == current) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
204 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
205 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
206 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
207 froomlist.account = current; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
208 if (froomlist.roomlist) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
209 if (purple_roomlist_get_in_progress(froomlist.roomlist)) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
210 purple_roomlist_cancel_get_list(froomlist.roomlist); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
211 update_roomlist(NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
212 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
213 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
214 gnt_tree_remove_all(GNT_TREE(froomlist.tree)); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
215 gnt_widget_draw(froomlist.tree); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
216 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
217 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
218 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
219 reset_account_list(PurpleAccount *account) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
220 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
221 GList *list; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
222 GntComboBox *accounts = GNT_COMBO_BOX(froomlist.accounts); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
223 gnt_combo_box_remove_all(accounts); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
224 for (list = purple_connections_get_all(); list; list = list->next) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
225 PurplePluginProtocolInfo *prpl_info = NULL; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
226 PurpleConnection *gc = list->data; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
227 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
228 prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
229 if (prpl_info->roomlist_get_list != NULL) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
230 PurpleAccount *account = purple_connection_get_account(gc); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
231 char *text = g_strdup_printf("%s (%s)", |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
232 purple_account_get_username(account), |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
233 purple_account_get_protocol_name(account)); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
234 gnt_combo_box_add_data(accounts, account, text); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
235 g_free(text); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
236 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
237 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
238 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
240 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
241 setup_roomlist(PurpleAccount *account) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
242 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
243 GntWidget *window, *tree, *hbox, *accounts; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
244 int iter; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
245 struct { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
246 const char *label; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
247 GCallback callback; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
248 GntWidget **widget; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
249 } buttons[] = { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
250 {_("Stop"), G_CALLBACK(fl_stop), &froomlist.stop}, |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
251 {_("Get"), G_CALLBACK(fl_get_list), &froomlist.getlist}, |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
252 {_("Add"), G_CALLBACK(fl_add_chat), &froomlist.add}, |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
253 {_("Close"), G_CALLBACK(fl_close), &froomlist.close}, |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
254 {NULL, NULL, NULL} |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
255 }; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
256 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
257 if (froomlist.window) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
258 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
259 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
260 froomlist.window = window = gnt_window_new(); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
261 g_object_set(G_OBJECT(window), "vertical", TRUE, NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
262 gnt_box_set_pad(GNT_BOX(window), 0); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
263 gnt_box_set_title(GNT_BOX(window), _("Room List")); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
264 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
265 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
266 froomlist.accounts = accounts = gnt_combo_box_new(); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
267 reset_account_list(account); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
268 gnt_box_add_widget(GNT_BOX(window), froomlist.accounts); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
269 g_signal_connect(G_OBJECT(froomlist.accounts), "selection-changed", |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
270 G_CALLBACK(roomlist_account_changed), NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
271 froomlist.account = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(froomlist.accounts)); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
272 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
273 froomlist.tree = tree = gnt_tree_new_with_columns(2); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
274 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
275 g_signal_connect(G_OBJECT(tree), "activate", G_CALLBACK(roomlist_activated), NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
276 gnt_tree_set_column_titles(GNT_TREE(tree), _("Name"), ""); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
277 gnt_tree_set_show_separator(GNT_TREE(tree), FALSE); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
278 gnt_tree_set_col_width(GNT_TREE(tree), 1, 1); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
279 gnt_tree_set_column_resizable(GNT_TREE(tree), 1, FALSE); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
280 gnt_tree_set_search_column(GNT_TREE(tree), 0); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
281 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
282 gnt_box_add_widget(GNT_BOX(window), tree); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
283 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
284 froomlist.details = gnt_text_view_new(); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
285 gnt_text_view_set_flag(GNT_TEXT_VIEW(froomlist.details), GNT_TEXT_VIEW_TOP_ALIGN); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
286 gnt_box_add_widget(GNT_BOX(window), froomlist.details); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
287 gnt_widget_set_size(froomlist.details, -1, 10); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
288 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
289 hbox = gnt_hbox_new(FALSE); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
290 gnt_box_add_widget(GNT_BOX(window), hbox); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
291 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
292 for (iter = 0; buttons[iter].label; iter++) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
293 GntWidget *button = gnt_button_new(buttons[iter].label); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
294 gnt_box_add_widget(GNT_BOX(hbox), button); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
295 g_signal_connect(G_OBJECT(button), "activate", buttons[iter].callback, NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
296 *buttons[iter].widget = button; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
297 gnt_text_view_attach_scroll_widget(GNT_TEXT_VIEW(froomlist.details), button); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
298 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
299 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
300 g_signal_connect(G_OBJECT(tree), "selection-changed", G_CALLBACK(roomlist_selection_changed), NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
301 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
302 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(unset_roomlist), NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
303 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
304 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
305 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
306 fl_show_with_account(PurpleAccount *account) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
307 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
308 setup_roomlist(account); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
309 gnt_window_present(froomlist.window); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
310 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
311 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
312 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
313 fl_create(PurpleRoomlist *list) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
314 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
315 list->ui_data = &froomlist; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
316 setup_roomlist(NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
317 update_roomlist(list); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
318 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
319 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
320 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
321 fl_set_fields(PurpleRoomlist *list, GList *fields) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
322 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
323 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
324 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
325 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
326 fl_add_room(PurpleRoomlist *roomlist, PurpleRoomlistRoom *room) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
327 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
328 if (froomlist.roomlist != roomlist) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
329 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
330 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
331 gnt_tree_remove(GNT_TREE(froomlist.tree), room); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
332 gnt_tree_add_row_after(GNT_TREE(froomlist.tree), room, |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
333 gnt_tree_create_row(GNT_TREE(froomlist.tree), |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
334 purple_roomlist_room_get_name(room), |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
335 purple_roomlist_room_get_type(room) == PURPLE_ROOMLIST_ROOMTYPE_CATEGORY ? "<" : ""), |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
336 purple_roomlist_room_get_parent(room), NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
337 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
338 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
339 static void |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
340 fl_destroy(PurpleRoomlist *list) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
341 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
342 if (!froomlist.window) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
343 return; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
344 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
345 if (froomlist.roomlist == list) { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
346 froomlist.roomlist = NULL; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
347 gnt_tree_remove_all(GNT_TREE(froomlist.tree)); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
348 gnt_widget_destroy(froomlist.tree); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
349 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
350 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
351 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
352 static PurpleRoomlistUiOps ui_ops = |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
353 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
354 fl_show_with_account, /* void (*show_with_account)(PurpleAccount *account); **< Force the ui to pop up a dialog and get the list */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
355 fl_create, /* void (*create)(PurpleRoomlist *list); **< A new list was created. */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
356 fl_set_fields, /* void (*set_fields)(PurpleRoomlist *list, GList *fields); **< Sets the columns. */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
357 fl_add_room, /* void (*add_room)(PurpleRoomlist *list, PurpleRoomlistRoom *room); **< Add a room to the list. */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
358 NULL, /* void (*in_progress)(PurpleRoomlist *list, gboolean flag); **< Are we fetching stuff still? */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
359 fl_destroy, /* void (*destroy)(PurpleRoomlist *list); **< We're destroying list. */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
360 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
361 NULL, /* void (*_purple_reserved1)(void); */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
362 NULL, /* void (*_purple_reserved2)(void); */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
363 NULL, /* void (*_purple_reserved3)(void); */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
364 NULL /* void (*_purple_reserved4)(void); */ |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
365 }; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
366 PurpleRoomlistUiOps *finch_roomlist_get_ui_ops(void) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
367 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
368 return &ui_ops; |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
369 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
370 |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
371 void finch_roomlist_show_all(void) |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
372 { |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
373 purple_roomlist_show_with_account(NULL); |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
374 } |
1278280fa0b6
Implementation of the roomlist API.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
375 |