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