Fri, 18 Jul 2008 00:46:22 +0000
disapproval of revision 'a39a33c79a3f235c5e1acf5602d7896f829623ba'
| 8113 | 1 | /** |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
2 | * @file gtkroomlist.c GTK+ Room List UI |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
15931
diff
changeset
|
3 | * @ingroup pidgin |
|
20147
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
66f05a854eee
applied changes from 8a731bbd0197fbcc91a705c2d8f528154216defa
Richard Laager <rlaager@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* pidgin |
| 8113 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
8146
4961c9c5fd61
[gaim-migrate @ 8854]
John Silvestri <john.silvestri@gmail.com>
parents:
8143
diff
changeset
|
9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
4961c9c5fd61
[gaim-migrate @ 8854]
John Silvestri <john.silvestri@gmail.com>
parents:
8143
diff
changeset
|
10 | * source distribution. |
| 8113 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * it under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
18122
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 8113 | 25 | */ |
| 26 | ||
| 9791 | 27 | #include "internal.h" |
| 15577 | 28 | #include "pidgin.h" |
| 8113 | 29 | #include "gtkutils.h" |
|
15883
969b74a3e27a
According to etags, pidgin/ should be completely clean of references to 'gaim' as a client
Sean Egan <seanegan@pidgin.im>
parents:
15882
diff
changeset
|
30 | #include "pidginstock.h" |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
31 | #include "pidgintooltip.h" |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
32 | |
| 8113 | 33 | #include "debug.h" |
| 34 | #include "account.h" | |
| 35 | #include "connection.h" | |
| 36 | #include "notify.h" | |
| 37 | ||
| 38 | #include "gtkroomlist.h" | |
| 39 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
40 | typedef struct _PidginRoomlistDialog { |
| 8113 | 41 | GtkWidget *window; |
| 42 | GtkWidget *account_widget; | |
| 43 | GtkWidget *progress; | |
| 44 | GtkWidget *sw; | |
| 45 | ||
| 8199 | 46 | GtkWidget *stop_button; |
| 8113 | 47 | GtkWidget *list_button; |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
48 | GtkWidget *add_button; |
| 8199 | 49 | GtkWidget *join_button; |
| 8113 | 50 | GtkWidget *close_button; |
| 51 | ||
| 15884 | 52 | PurpleAccount *account; |
| 53 | PurpleRoomlist *roomlist; | |
| 8230 | 54 | |
| 55 | gboolean pg_needs_pulse; | |
| 56 | gboolean pg_to_active; | |
| 57 | guint pg_update_to; | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
58 | } PidginRoomlistDialog; |
| 14649 | 59 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
60 | typedef struct _PidginRoomlist { |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
61 | PidginRoomlistDialog *dialog; |
| 14649 | 62 | GtkTreeStore *model; |
| 63 | GtkWidget *tree; | |
| 64 | GHashTable *cats; /**< Meow. */ | |
| 65 | gint num_rooms, total_rooms; | |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
66 | GtkWidget *tipwindow; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
67 | GdkRectangle tip_rect; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
68 | guint timeout; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
69 | PangoLayout *tip_layout; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
70 | PangoLayout *tip_name_layout; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
71 | int tip_height; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
72 | int tip_width; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
73 | int tip_name_height; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
74 | int tip_name_width; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
75 | } PidginRoomlist; |
| 8113 | 76 | |
| 77 | enum { | |
| 78 | NAME_COLUMN = 0, | |
| 79 | ROOM_COLUMN, | |
| 80 | NUM_OF_COLUMNS, | |
| 81 | }; | |
| 82 | ||
| 83 | static GList *roomlists = NULL; | |
| 84 | ||
| 85 | static gint delete_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
| 86 | { | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
87 | PidginRoomlistDialog *dialog; |
| 8113 | 88 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
89 | dialog = (PidginRoomlistDialog *) d; |
| 8113 | 90 | |
| 15884 | 91 | if (dialog->roomlist && purple_roomlist_get_in_progress(dialog->roomlist)) |
| 92 | purple_roomlist_cancel_get_list(dialog->roomlist); | |
| 8199 | 93 | |
| 8230 | 94 | if (dialog->roomlist) { |
| 95 | if (dialog->pg_to_active) { | |
| 15884 | 96 | purple_timeout_remove(dialog->pg_update_to); |
| 8230 | 97 | dialog->pg_to_active = FALSE; |
| 98 | /* yes, that's right, unref it twice. */ | |
| 15884 | 99 | purple_roomlist_unref(dialog->roomlist); |
| 8230 | 100 | } |
| 101 | } | |
| 102 | ||
| 8113 | 103 | /* free stuff here */ |
| 104 | if (dialog->roomlist) | |
| 15884 | 105 | purple_roomlist_unref(dialog->roomlist); |
| 8113 | 106 | g_free(dialog); |
| 107 | ||
| 108 | return FALSE; | |
| 109 | } | |
| 110 | ||
| 15884 | 111 | static void dialog_select_account_cb(GObject *w, PurpleAccount *account, |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
112 | PidginRoomlistDialog *dialog) |
| 8113 | 113 | { |
| 114 | dialog->account = account; | |
| 115 | } | |
| 116 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
117 | static void list_button_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
| 8113 | 118 | { |
| 15884 | 119 | PurpleConnection *gc; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
120 | PidginRoomlist *rl; |
| 8113 | 121 | |
| 15884 | 122 | gc = purple_account_get_connection(dialog->account); |
| 8113 | 123 | if (!gc) |
| 124 | return; | |
| 125 | ||
| 8199 | 126 | if (dialog->roomlist != NULL) { |
| 127 | rl = dialog->roomlist->ui_data; | |
| 128 | gtk_widget_destroy(rl->tree); | |
| 15884 | 129 | purple_roomlist_unref(dialog->roomlist); |
| 8199 | 130 | } |
| 131 | ||
| 15884 | 132 | dialog->roomlist = purple_roomlist_get_list(gc); |
| 9159 | 133 | if (!dialog->roomlist) |
| 134 | return; | |
| 15884 | 135 | purple_roomlist_ref(dialog->roomlist); |
| 8113 | 136 | rl = dialog->roomlist->ui_data; |
| 137 | rl->dialog = dialog; | |
| 8199 | 138 | |
| 8113 | 139 | if (dialog->account_widget) |
| 140 | gtk_widget_set_sensitive(dialog->account_widget, FALSE); | |
| 8199 | 141 | |
| 142 | gtk_container_add(GTK_CONTAINER(dialog->sw), rl->tree); | |
| 143 | ||
| 15884 | 144 | /* some protocols (not bundled with libpurple) finish getting their |
| 15350 | 145 | * room list immediately */ |
| 15884 | 146 | if(purple_roomlist_get_in_progress(dialog->roomlist)) { |
| 15350 | 147 | gtk_widget_set_sensitive(dialog->stop_button, TRUE); |
| 148 | gtk_widget_set_sensitive(dialog->list_button, FALSE); | |
| 149 | } else { | |
| 150 | gtk_widget_set_sensitive(dialog->stop_button, FALSE); | |
| 151 | gtk_widget_set_sensitive(dialog->list_button, TRUE); | |
| 152 | } | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
153 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
| 8199 | 154 | gtk_widget_set_sensitive(dialog->join_button, FALSE); |
| 8113 | 155 | } |
| 156 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
157 | static void stop_button_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
| 8113 | 158 | { |
| 15884 | 159 | purple_roomlist_cancel_get_list(dialog->roomlist); |
| 8199 | 160 | |
| 161 | if (dialog->account_widget) | |
| 162 | gtk_widget_set_sensitive(dialog->account_widget, TRUE); | |
| 163 | ||
| 164 | gtk_widget_set_sensitive(dialog->stop_button, FALSE); | |
| 165 | gtk_widget_set_sensitive(dialog->list_button, TRUE); | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
166 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
| 8199 | 167 | gtk_widget_set_sensitive(dialog->join_button, FALSE); |
| 8113 | 168 | } |
| 169 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
170 | static void close_button_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
| 8113 | 171 | { |
| 172 | GtkWidget *window = dialog->window; | |
| 173 | ||
| 174 | delete_win_cb(NULL, NULL, dialog); | |
| 175 | gtk_widget_destroy(window); | |
| 176 | } | |
| 177 | ||
| 178 | struct _menu_cb_info { | |
| 15884 | 179 | PurpleRoomlist *list; |
| 180 | PurpleRoomlistRoom *room; | |
| 8113 | 181 | }; |
| 182 | ||
| 8199 | 183 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
184 | selection_changed_cb(GtkTreeSelection *selection, PidginRoomlist *grl) { |
| 8199 | 185 | GtkTreeIter iter; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
186 | GValue val; |
| 15884 | 187 | PurpleRoomlistRoom *room; |
| 8199 | 188 | static struct _menu_cb_info *info; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
189 | PidginRoomlistDialog *dialog; |
| 8199 | 190 | |
| 191 | dialog = grl->dialog; | |
| 192 | ||
| 193 | if (gtk_tree_selection_get_selected(selection, NULL, &iter)) { | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
194 | val.g_type = 0; |
| 8199 | 195 | gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); |
| 196 | room = g_value_get_pointer(&val); | |
| 15884 | 197 | if (!room || !(room->type & PURPLE_ROOMLIST_ROOMTYPE_ROOM)) { |
| 8199 | 198 | gtk_widget_set_sensitive(dialog->join_button, FALSE); |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
199 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
| 8199 | 200 | return; |
| 201 | } | |
| 202 | ||
| 203 | info = g_new0(struct _menu_cb_info, 1); | |
| 204 | info->list = dialog->roomlist; | |
| 205 | info->room = room; | |
| 206 | ||
| 8377 | 207 | g_object_set_data_full(G_OBJECT(dialog->join_button), "room-info", |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
208 | info, g_free); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
209 | g_object_set_data(G_OBJECT(dialog->add_button), "room-info", info); |
| 8199 | 210 | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
211 | gtk_widget_set_sensitive(dialog->add_button, TRUE); |
| 8199 | 212 | gtk_widget_set_sensitive(dialog->join_button, TRUE); |
| 213 | } else { | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
214 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
| 8199 | 215 | gtk_widget_set_sensitive(dialog->join_button, FALSE); |
| 216 | } | |
| 217 | } | |
| 218 | ||
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
219 | static void do_add_room_cb(GtkWidget *w, struct _menu_cb_info *info) |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
220 | { |
| 15185 | 221 | char *name; |
| 15884 | 222 | PurpleConnection *gc = purple_account_get_connection(info->list->account); |
| 223 | PurplePluginProtocolInfo *prpl_info = NULL; | |
| 15185 | 224 | |
| 225 | if(gc != NULL) | |
| 15884 | 226 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
| 15185 | 227 | |
| 228 | if(prpl_info != NULL && prpl_info->roomlist_room_serialize) | |
| 229 | name = prpl_info->roomlist_room_serialize(info->room); | |
| 230 | else | |
| 231 | name = g_strdup(info->room->name); | |
| 232 | ||
| 15884 | 233 | purple_blist_request_add_chat(info->list->account, NULL, NULL, name); |
| 15185 | 234 | |
| 235 | g_free(name); | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
236 | } |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
237 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
238 | static void add_room_to_blist_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
239 | { |
| 15884 | 240 | PurpleRoomlist *rl = dialog->roomlist; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
241 | PidginRoomlist *grl = rl->ui_data; |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
242 | struct _menu_cb_info *info; |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
243 | |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
244 | info = (struct _menu_cb_info*)g_object_get_data(G_OBJECT(button), "room-info"); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
245 | |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
246 | if(info != NULL) |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
247 | do_add_room_cb(grl->tree, info); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
248 | } |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
249 | |
| 8113 | 250 | static void do_join_cb(GtkWidget *w, struct _menu_cb_info *info) |
| 251 | { | |
| 15884 | 252 | purple_roomlist_room_join(info->list, info->room); |
| 8199 | 253 | } |
| 8113 | 254 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
255 | static void join_button_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
| 8199 | 256 | { |
| 15884 | 257 | PurpleRoomlist *rl = dialog->roomlist; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
258 | PidginRoomlist *grl = rl->ui_data; |
| 8199 | 259 | struct _menu_cb_info *info; |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
260 | |
| 8199 | 261 | info = (struct _menu_cb_info*)g_object_get_data(G_OBJECT(button), "room-info"); |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
262 | |
| 8377 | 263 | if(info != NULL) |
| 264 | do_join_cb(grl->tree, info); | |
| 8113 | 265 | } |
| 266 | ||
| 267 | static void row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *arg2, | |
| 15884 | 268 | PurpleRoomlist *list) |
| 8113 | 269 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
270 | PidginRoomlist *grl = list->ui_data; |
| 8113 | 271 | GtkTreeIter iter; |
| 15884 | 272 | PurpleRoomlistRoom *room; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
273 | GValue val; |
| 8113 | 274 | struct _menu_cb_info info; |
| 275 | ||
| 276 | gtk_tree_model_get_iter(GTK_TREE_MODEL(grl->model), &iter, path); | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
277 | val.g_type = 0; |
| 8113 | 278 | gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); |
| 279 | room = g_value_get_pointer(&val); | |
| 15884 | 280 | if (!room || !(room->type & PURPLE_ROOMLIST_ROOMTYPE_ROOM)) |
| 8113 | 281 | return; |
| 282 | ||
| 283 | info.list = list; | |
| 284 | info.room = room; | |
| 285 | ||
| 286 | do_join_cb(GTK_WIDGET(tv), &info); | |
| 287 | } | |
| 288 | ||
| 15884 | 289 | static gboolean room_click_cb(GtkWidget *tv, GdkEventButton *event, PurpleRoomlist *list) |
| 8113 | 290 | { |
| 291 | GtkTreePath *path; | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
292 | PidginRoomlist *grl = list->ui_data; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
293 | GValue val; |
| 15884 | 294 | PurpleRoomlistRoom *room; |
| 8113 | 295 | GtkTreeIter iter; |
| 296 | GtkWidget *menu; | |
| 297 | static struct _menu_cb_info info; /* XXX? */ | |
| 298 | ||
| 299 | if (event->button != 3 || event->type != GDK_BUTTON_PRESS) | |
| 300 | return FALSE; | |
| 301 | ||
| 302 | /* Here we figure out which room was clicked */ | |
| 303 | if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL)) | |
| 304 | return FALSE; | |
| 305 | gtk_tree_model_get_iter(GTK_TREE_MODEL(grl->model), &iter, path); | |
| 306 | gtk_tree_path_free(path); | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
307 | val.g_type = 0; |
| 8113 | 308 | gtk_tree_model_get_value (GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); |
| 309 | room = g_value_get_pointer(&val); | |
| 310 | ||
| 15884 | 311 | if (!room || !(room->type & PURPLE_ROOMLIST_ROOMTYPE_ROOM)) |
| 8113 | 312 | return FALSE; |
| 313 | ||
| 314 | info.list = list; | |
| 315 | info.room = room; | |
| 316 | ||
| 317 | menu = gtk_menu_new(); | |
| 15570 | 318 | pidgin_new_item_from_stock(menu, _("_Join"), PIDGIN_STOCK_CHAT, |
| 8113 | 319 | G_CALLBACK(do_join_cb), &info, 0, 0, NULL); |
| 15568 | 320 | pidgin_new_item_from_stock(menu, _("_Add"), GTK_STOCK_ADD, |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
321 | G_CALLBACK(do_add_room_cb), &info, 0, 0, NULL); |
| 8113 | 322 | |
| 323 | gtk_widget_show_all(menu); | |
| 324 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); | |
| 325 | ||
| 326 | return FALSE; | |
| 327 | } | |
| 328 | ||
| 329 | static void row_expanded_cb(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer user_data) | |
| 330 | { | |
| 15884 | 331 | PurpleRoomlist *list = user_data; |
| 332 | PurpleRoomlistRoom *category; | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
333 | GValue val; |
| 8113 | 334 | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
335 | val.g_type = 0; |
| 8113 | 336 | gtk_tree_model_get_value(gtk_tree_view_get_model(treeview), arg1, ROOM_COLUMN, &val); |
| 8584 | 337 | category = g_value_get_pointer(&val); |
| 8113 | 338 | |
| 8584 | 339 | if (!category->expanded_once) { |
| 15884 | 340 | purple_roomlist_expand_category(list, category); |
| 8584 | 341 | category->expanded_once = TRUE; |
| 8113 | 342 | } |
| 343 | } | |
| 344 | ||
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
345 | #define SMALL_SPACE 6 |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
346 | #define TOOLTIP_BORDER 12 |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
347 | |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
348 | static gboolean |
|
21998
3dbae318c88d
Refactor some of the tooltip drawing functions. And add some pretend docs.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21903
diff
changeset
|
349 | pidgin_roomlist_paint_tooltip(GtkWidget *widget, gpointer user_data) |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
350 | { |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
351 | PurpleRoomlist *list = user_data; |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
352 | PidginRoomlist *grl = list->ui_data; |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
353 | GtkStyle *style; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
354 | int current_height, max_width; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
355 | int max_text_width; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
356 | GtkTextDirection dir = gtk_widget_get_direction(GTK_WIDGET(grl->tree)); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
357 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
358 | style = grl->tipwindow->style; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
359 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
360 | max_text_width = 0; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
361 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
362 | max_text_width = MAX(grl->tip_width, grl->tip_name_width); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
363 | max_width = TOOLTIP_BORDER + SMALL_SPACE + max_text_width + TOOLTIP_BORDER; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
364 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
365 | current_height = 12; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
366 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
367 | if (dir == GTK_TEXT_DIR_RTL) { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
368 | gtk_paint_layout(style, grl->tipwindow->window, GTK_STATE_NORMAL, FALSE, |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
369 | NULL, grl->tipwindow, "tooltip", |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
370 | max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000), |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
371 | current_height, grl->tip_name_layout); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
372 | } else { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
373 | gtk_paint_layout (style, grl->tipwindow->window, GTK_STATE_NORMAL, FALSE, |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
374 | NULL, grl->tipwindow, "tooltip", |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
375 | TOOLTIP_BORDER + SMALL_SPACE, current_height, grl->tip_name_layout); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
376 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
377 | if (dir != GTK_TEXT_DIR_RTL) { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
378 | gtk_paint_layout (style, grl->tipwindow->window, GTK_STATE_NORMAL, FALSE, |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
379 | NULL, grl->tipwindow, "tooltip", |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
380 | TOOLTIP_BORDER + SMALL_SPACE, current_height + grl->tip_name_height, grl->tip_layout); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
381 | } else { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
382 | gtk_paint_layout(style, grl->tipwindow->window, GTK_STATE_NORMAL, FALSE, |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
383 | NULL, grl->tipwindow, "tooltip", |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
384 | max_width - (TOOLTIP_BORDER + SMALL_SPACE) - PANGO_PIXELS(600000), |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
385 | current_height + grl->tip_name_height, |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
386 | grl->tip_layout); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
387 | } |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
388 | return FALSE; |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
389 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
390 | |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
391 | static gboolean pidgin_roomlist_create_tip(PurpleRoomlist *list, GtkTreePath *path) |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
392 | { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
393 | PidginRoomlist *grl = list->ui_data; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
394 | PurpleRoomlistRoom *room; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
395 | GtkTreeIter iter; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
396 | GValue val; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
397 | gchar *name, *tmp, *node_name; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
398 | GString *tooltip_text = NULL; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
399 | GList *l, *k; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
400 | gint j; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
401 | gboolean first = TRUE; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
402 | |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
403 | #if 0 |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
404 | if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), grl->tip_rect.x, grl->tip_rect.y + (grl->tip_rect.height/2), |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
405 | &path, NULL, NULL, NULL)) |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
406 | return FALSE; |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
407 | #endif |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
408 | gtk_tree_model_get_iter(GTK_TREE_MODEL(grl->model), &iter, path); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
409 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
410 | val.g_type = 0; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
411 | gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
412 | room = g_value_get_pointer(&val); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
413 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
414 | if (!room || !(room->type & PURPLE_ROOMLIST_ROOMTYPE_ROOM)) |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
415 | return FALSE; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
416 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
417 | tooltip_text = g_string_new(""); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
418 | gtk_tree_model_get(GTK_TREE_MODEL(grl->model), &iter, NAME_COLUMN, &name, -1); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
419 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
420 | for (j = NUM_OF_COLUMNS, l = room->fields, k = list->fields; l && k; j++, l = l->next, k = k->next) { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
421 | PurpleRoomlistField *f = k->data; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
422 | gchar *label; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
423 | if (f->hidden) |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
424 | continue; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
425 | label = g_markup_escape_text(f->label, -1); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
426 | switch (f->type) { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
427 | case PURPLE_ROOMLIST_FIELD_BOOL: |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
428 | g_string_append_printf(tooltip_text, "%s<b>%s:</b> %s", first ? "" : "\n", label, l->data ? "True" : "False"); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
429 | break; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
430 | case PURPLE_ROOMLIST_FIELD_INT: |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
431 | g_string_append_printf(tooltip_text, "%s<b>%s:</b> %d", first ? "" : "\n", label, GPOINTER_TO_INT(l->data)); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
432 | break; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
433 | case PURPLE_ROOMLIST_FIELD_STRING: |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
434 | tmp = g_markup_escape_text((char *)l->data, -1); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
435 | g_string_append_printf(tooltip_text, "%s<b>%s:</b> %s", first ? "" : "\n", label, tmp); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
436 | g_free(tmp); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
437 | break; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
438 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
439 | first = FALSE; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
440 | g_free(label); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
441 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
442 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
443 | grl->tip_layout = gtk_widget_create_pango_layout(grl->tipwindow, NULL); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
444 | grl->tip_name_layout = gtk_widget_create_pango_layout(grl->tipwindow, NULL); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
445 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
446 | tmp = g_markup_escape_text(name, -1); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
447 | g_free(name); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
448 | node_name = g_strdup_printf("<span size='x-large' weight='bold'>%s</span>", tmp); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
449 | g_free(tmp); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
450 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
451 | pango_layout_set_markup(grl->tip_layout, tooltip_text->str, -1); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
452 | pango_layout_set_wrap(grl->tip_layout, PANGO_WRAP_WORD); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
453 | pango_layout_set_width(grl->tip_layout, 600000); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
454 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
455 | pango_layout_get_size (grl->tip_layout, &grl->tip_width, &grl->tip_height); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
456 | grl->tip_width = PANGO_PIXELS(grl->tip_width); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
457 | grl->tip_height = PANGO_PIXELS(grl->tip_height); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
458 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
459 | pango_layout_set_markup(grl->tip_name_layout, node_name, -1); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
460 | pango_layout_set_wrap(grl->tip_name_layout, PANGO_WRAP_WORD); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
461 | pango_layout_set_width(grl->tip_name_layout, 600000); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
462 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
463 | pango_layout_get_size (grl->tip_name_layout, &grl->tip_name_width, &grl->tip_name_height); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
464 | grl->tip_name_width = PANGO_PIXELS(grl->tip_name_width) + SMALL_SPACE; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
465 | grl->tip_name_height = MAX(PANGO_PIXELS(grl->tip_name_height), SMALL_SPACE); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
466 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
467 | g_free(node_name); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
468 | g_string_free(tooltip_text, TRUE); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
469 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
470 | return TRUE; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
471 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
472 | |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
473 | static gboolean |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
474 | pidgin_roomlist_create_tooltip(GtkWidget *widget, GtkTreePath *path, |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
475 | gpointer data, int *w, int *h) |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
476 | { |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
477 | PurpleRoomlist *list = data; |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
478 | PidginRoomlist *grl = list->ui_data; |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
479 | grl->tipwindow = widget; |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
480 | if (!pidgin_roomlist_create_tip(data, path)) |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
481 | return FALSE; |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
482 | if (w) |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
483 | *w = TOOLTIP_BORDER + SMALL_SPACE + |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
484 | MAX(grl->tip_width, grl->tip_name_width) + TOOLTIP_BORDER; |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
485 | if (h) |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
486 | *h = TOOLTIP_BORDER + grl->tip_height + grl->tip_name_height |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
487 | + TOOLTIP_BORDER; |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
488 | return TRUE; |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
489 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
490 | |
| 15884 | 491 | static gboolean account_filter_func(PurpleAccount *account) |
| 8113 | 492 | { |
| 15884 | 493 | PurpleConnection *gc = purple_account_get_connection(account); |
| 494 | PurplePluginProtocolInfo *prpl_info = NULL; | |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
495 | |
| 15884 | 496 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
497 | |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
498 | return (prpl_info->roomlist_get_list != NULL); |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
499 | } |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
500 | |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
501 | gboolean |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
502 | pidgin_roomlist_is_showable() |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
503 | { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
504 | GList *c; |
| 15884 | 505 | PurpleConnection *gc; |
| 8113 | 506 | |
| 15884 | 507 | for (c = purple_connections_get_all(); c != NULL; c = c->next) { |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
508 | gc = c->data; |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
509 | |
| 15884 | 510 | if (account_filter_func(purple_connection_get_account(gc))) |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
511 | return TRUE; |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
512 | } |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
513 | |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
514 | return FALSE; |
| 8113 | 515 | } |
| 516 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
517 | static PidginRoomlistDialog * |
| 15884 | 518 | pidgin_roomlist_dialog_new_with_account(PurpleAccount *account) |
| 8113 | 519 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
520 | PidginRoomlistDialog *dialog; |
| 8113 | 521 | GtkWidget *window; |
| 8199 | 522 | GtkWidget *vbox; |
| 523 | GtkWidget *vbox2; | |
| 8113 | 524 | GtkWidget *bbox; |
| 525 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
526 | dialog = g_new0(PidginRoomlistDialog, 1); |
|
8937
b436e9cbd701
[gaim-migrate @ 9707]
Mark Doliner <markdoliner@pidgin.im>
parents:
8584
diff
changeset
|
527 | dialog->account = account; |
| 8113 | 528 | |
| 529 | /* Create the window. */ | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21494
diff
changeset
|
530 | dialog->window = window = pidgin_create_dialog(_("Room List"), PIDGIN_HIG_BORDER, "room list", TRUE); |
| 8113 | 531 | |
| 532 | g_signal_connect(G_OBJECT(window), "delete_event", | |
| 533 | G_CALLBACK(delete_win_cb), dialog); | |
| 534 | ||
| 535 | /* Create the parent vbox for everything. */ | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21494
diff
changeset
|
536 | vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(window), FALSE, PIDGIN_HIG_BORDER); |
| 8113 | 537 | |
| 15882 | 538 | vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); |
| 8199 | 539 | gtk_container_add(GTK_CONTAINER(vbox), vbox2); |
| 8113 | 540 | gtk_widget_show(vbox2); |
| 541 | ||
| 8352 | 542 | /* accounts dropdown list */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
543 | dialog->account_widget = pidgin_account_option_menu_new(dialog->account, FALSE, |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
544 | G_CALLBACK(dialog_select_account_cb), account_filter_func, dialog); |
| 9067 | 545 | if (!dialog->account) /* this is normally null, and we normally don't care what the first selected item is */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
546 | dialog->account = pidgin_account_option_menu_get_selected(dialog->account_widget); |
|
22131
12b395dc8c59
Remove a lot of duplication from a lot of places. Closes #4558.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22064
diff
changeset
|
547 | pidgin_add_widget_to_vbox(GTK_BOX(vbox2), _("_Account:"), NULL, dialog->account_widget, TRUE, NULL); |
| 8113 | 548 | |
| 8199 | 549 | /* scrolled window */ |
| 8113 | 550 | dialog->sw = gtk_scrolled_window_new(NULL, NULL); |
| 551 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(dialog->sw), | |
| 552 | GTK_SHADOW_IN); | |
| 553 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dialog->sw), | |
| 554 | GTK_POLICY_AUTOMATIC, | |
| 555 | GTK_POLICY_AUTOMATIC); | |
| 8199 | 556 | gtk_box_pack_start(GTK_BOX(vbox2), dialog->sw, TRUE, TRUE, 0); |
| 557 | gtk_widget_set_size_request(dialog->sw, -1, 250); | |
| 8113 | 558 | gtk_widget_show(dialog->sw); |
| 559 | ||
| 8199 | 560 | /* progress bar */ |
| 561 | dialog->progress = gtk_progress_bar_new(); | |
| 562 | gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(dialog->progress), 0.1); | |
| 563 | gtk_box_pack_start(GTK_BOX(vbox2), dialog->progress, FALSE, FALSE, 0); | |
| 564 | gtk_widget_show(dialog->progress); | |
| 565 | ||
| 566 | /* button box */ | |
|
22000
5e7708f58d3d
Patch from fmoo. This makes a lot of the windows closeable with Escape. There
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21494
diff
changeset
|
567 | bbox = pidgin_dialog_get_action_area(GTK_DIALOG(window)); |
| 15882 | 568 | gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); |
| 8199 | 569 | gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); |
| 570 | ||
| 571 | /* stop button */ | |
|
22005
0183020ba2cc
Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22000
diff
changeset
|
572 | dialog->stop_button = pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_STOP, |
| 8199 | 573 | G_CALLBACK(stop_button_cb), dialog); |
| 574 | gtk_widget_set_sensitive(dialog->stop_button, FALSE); | |
| 575 | ||
| 576 | /* list button */ | |
| 15568 | 577 | dialog->list_button = pidgin_pixbuf_button_from_stock(_("_Get List"), GTK_STOCK_REFRESH, |
| 578 | PIDGIN_BUTTON_HORIZONTAL); | |
| 8199 | 579 | gtk_box_pack_start(GTK_BOX(bbox), dialog->list_button, FALSE, FALSE, 0); |
| 580 | g_signal_connect(G_OBJECT(dialog->list_button), "clicked", | |
| 581 | G_CALLBACK(list_button_cb), dialog); | |
| 582 | gtk_widget_show(dialog->list_button); | |
| 583 | ||
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
584 | /* add button */ |
| 15568 | 585 | dialog->add_button = pidgin_pixbuf_button_from_stock(_("_Add Chat"), GTK_STOCK_ADD, |
| 586 | PIDGIN_BUTTON_HORIZONTAL); | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
587 | gtk_box_pack_start(GTK_BOX(bbox), dialog->add_button, FALSE, FALSE, 0); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
588 | g_signal_connect(G_OBJECT(dialog->add_button), "clicked", |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
589 | G_CALLBACK(add_room_to_blist_cb), dialog); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
590 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
591 | gtk_widget_show(dialog->add_button); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
592 | |
| 8199 | 593 | /* join button */ |
| 15570 | 594 | dialog->join_button = pidgin_pixbuf_button_from_stock(_("_Join"), PIDGIN_STOCK_CHAT, |
| 15568 | 595 | PIDGIN_BUTTON_HORIZONTAL); |
| 8199 | 596 | gtk_box_pack_start(GTK_BOX(bbox), dialog->join_button, FALSE, FALSE, 0); |
| 597 | g_signal_connect(G_OBJECT(dialog->join_button), "clicked", | |
| 598 | G_CALLBACK(join_button_cb), dialog); | |
| 599 | gtk_widget_set_sensitive(dialog->join_button, FALSE); | |
| 600 | gtk_widget_show(dialog->join_button); | |
| 601 | ||
| 602 | /* close button */ | |
|
22005
0183020ba2cc
Add a utility function pidgin_dialog_add_button to add buttons to a dialog
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22000
diff
changeset
|
603 | dialog->close_button = pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, |
| 8199 | 604 | G_CALLBACK(close_button_cb), dialog); |
| 605 | ||
| 606 | /* show the dialog window and return the dialog */ | |
| 607 | gtk_widget_show(dialog->window); | |
| 608 | ||
| 8113 | 609 | return dialog; |
| 610 | } | |
| 611 | ||
| 15884 | 612 | void pidgin_roomlist_dialog_show_with_account(PurpleAccount *account) |
| 8352 | 613 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
614 | PidginRoomlistDialog *dialog; |
| 8352 | 615 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
616 | dialog = pidgin_roomlist_dialog_new_with_account(account); |
| 8352 | 617 | if (!dialog) |
| 618 | return; | |
| 619 | ||
| 620 | list_button_cb(GTK_BUTTON(dialog->list_button), dialog); | |
| 621 | } | |
| 622 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
623 | void pidgin_roomlist_dialog_show(void) |
| 8113 | 624 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
625 | pidgin_roomlist_dialog_new_with_account(NULL); |
| 8113 | 626 | } |
| 627 | ||
| 15884 | 628 | static void pidgin_roomlist_new(PurpleRoomlist *list) |
| 8113 | 629 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
630 | PidginRoomlist *rl; |
| 8113 | 631 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
632 | rl = g_new0(PidginRoomlist, 1); |
| 8113 | 633 | |
| 634 | list->ui_data = rl; | |
| 635 | ||
| 636 | rl->cats = g_hash_table_new_full(NULL, NULL, NULL, (GDestroyNotify)gtk_tree_row_reference_free); | |
| 637 | ||
| 638 | roomlists = g_list_append(roomlists, list); | |
| 639 | } | |
| 640 | ||
| 641 | static void int_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer, | |
| 642 | GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) | |
| 643 | { | |
| 644 | gchar buf[16]; | |
| 645 | int myint; | |
| 646 | ||
| 647 | gtk_tree_model_get(model, iter, GPOINTER_TO_INT(user_data), &myint, -1); | |
| 648 | ||
| 649 | if (myint) | |
| 650 | g_snprintf(buf, sizeof(buf), "%d", myint); | |
| 651 | else | |
| 652 | buf[0] = '\0'; | |
| 653 | ||
| 654 | g_object_set(renderer, "text", buf, NULL); | |
| 655 | } | |
| 656 | ||
| 657 | /* this sorts backwards on purpose, so that clicking name sorts a-z, while clicking users sorts | |
| 658 | infinity-0. you can still click again to reverse it on any of them. */ | |
| 659 | static gint int_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) | |
| 660 | { | |
| 661 | int c, d; | |
| 662 | ||
| 663 | c = d = 0; | |
| 664 | ||
| 665 | gtk_tree_model_get(model, a, GPOINTER_TO_INT(user_data), &c, -1); | |
| 666 | gtk_tree_model_get(model, b, GPOINTER_TO_INT(user_data), &d, -1); | |
| 667 | ||
| 668 | if (c == d) | |
| 669 | return 0; | |
| 670 | else if (c > d) | |
| 671 | return -1; | |
| 672 | else | |
| 673 | return 1; | |
| 674 | } | |
| 675 | ||
|
11490
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
676 | static gboolean |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
677 | _search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data) |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
678 | { |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
679 | gboolean result; |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
680 | gchar *name, *fold, *fkey; |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
681 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
682 | gtk_tree_model_get(model, iter, column, &name, -1); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
683 | fold = g_utf8_casefold(name, -1); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
684 | fkey = g_utf8_casefold(key, -1); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
685 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
686 | result = (g_strstr_len(fold, strlen(fold), fkey) == NULL); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
687 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
688 | g_free(fold); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
689 | g_free(fkey); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
690 | g_free(name); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
691 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
692 | return result; |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
693 | } |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
694 | |
| 15884 | 695 | static void pidgin_roomlist_set_fields(PurpleRoomlist *list, GList *fields) |
| 8113 | 696 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
697 | PidginRoomlist *grl = list->ui_data; |
| 8113 | 698 | gint columns = NUM_OF_COLUMNS; |
| 699 | int j; | |
| 700 | GtkTreeStore *model; | |
| 701 | GtkWidget *tree; | |
| 702 | GtkCellRenderer *renderer; | |
| 703 | GtkTreeViewColumn *column; | |
| 8199 | 704 | GtkTreeSelection *selection; |
| 8113 | 705 | GList *l; |
| 706 | GType *types; | |
| 707 | ||
| 708 | g_return_if_fail(grl != NULL); | |
| 709 | ||
| 710 | columns += g_list_length(fields); | |
| 711 | types = g_new(GType, columns); | |
| 712 | ||
| 713 | types[NAME_COLUMN] = G_TYPE_STRING; | |
| 714 | types[ROOM_COLUMN] = G_TYPE_POINTER; | |
| 715 | ||
| 716 | for (j = NUM_OF_COLUMNS, l = fields; l; l = l->next, j++) { | |
| 15884 | 717 | PurpleRoomlistField *f = l->data; |
| 8113 | 718 | |
| 719 | switch (f->type) { | |
| 15884 | 720 | case PURPLE_ROOMLIST_FIELD_BOOL: |
| 8113 | 721 | types[j] = G_TYPE_BOOLEAN; |
| 722 | break; | |
| 15884 | 723 | case PURPLE_ROOMLIST_FIELD_INT: |
| 8113 | 724 | types[j] = G_TYPE_INT; |
| 725 | break; | |
| 15884 | 726 | case PURPLE_ROOMLIST_FIELD_STRING: |
| 8113 | 727 | types[j] = G_TYPE_STRING; |
| 728 | break; | |
| 729 | } | |
| 730 | } | |
| 731 | ||
| 732 | model = gtk_tree_store_newv(columns, types); | |
| 733 | g_free(types); | |
| 734 | ||
| 735 | tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
| 736 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); | |
| 737 | ||
| 8199 | 738 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); |
| 739 | g_signal_connect(G_OBJECT(selection), "changed", | |
| 740 | G_CALLBACK(selection_changed_cb), grl); | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13448
diff
changeset
|
741 | |
| 8113 | 742 | g_object_unref(model); |
| 743 | ||
| 744 | grl->model = model; | |
| 745 | grl->tree = tree; | |
| 746 | gtk_widget_show(grl->tree); | |
| 747 | ||
| 748 | renderer = gtk_cell_renderer_text_new(); | |
| 749 | column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, | |
| 750 | "text", NAME_COLUMN, NULL); | |
| 751 | gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), | |
| 752 | GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
| 753 | gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 754 | gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), NAME_COLUMN); | |
| 755 | gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 756 | gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
| 757 | ||
| 758 | for (j = NUM_OF_COLUMNS, l = fields; l; l = l->next, j++) { | |
| 15884 | 759 | PurpleRoomlistField *f = l->data; |
| 8113 | 760 | |
| 761 | if (f->hidden) | |
| 762 | continue; | |
| 763 | ||
| 764 | renderer = gtk_cell_renderer_text_new(); | |
| 765 | column = gtk_tree_view_column_new_with_attributes(f->label, renderer, | |
| 766 | "text", j, NULL); | |
| 767 | gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), | |
| 768 | GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
| 769 | gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 770 | gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), j); | |
| 771 | gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 15884 | 772 | if (f->type == PURPLE_ROOMLIST_FIELD_INT) { |
| 8113 | 773 | gtk_tree_view_column_set_cell_data_func(column, renderer, int_cell_data_func, |
| 774 | GINT_TO_POINTER(j), NULL); | |
| 775 | gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), j, int_sort_func, | |
| 776 | GINT_TO_POINTER(j), NULL); | |
| 777 | } | |
| 778 | gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
| 779 | } | |
| 780 | ||
| 781 | g_signal_connect(G_OBJECT(tree), "button-press-event", G_CALLBACK(room_click_cb), list); | |
| 782 | g_signal_connect(G_OBJECT(tree), "row-expanded", G_CALLBACK(row_expanded_cb), list); | |
| 783 | g_signal_connect(G_OBJECT(tree), "row-activated", G_CALLBACK(row_activated_cb), list); | |
|
21741
0855e8f1a6af
applied changes from b52ee4ed509de4ed4f568b335e1e4499f0829f64
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21494
diff
changeset
|
784 | #if 0 /* uncomment this when the tooltips are slightly less annoying and more well behaved */ |
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
785 | g_signal_connect(G_OBJECT(tree), "motion-notify-event", G_CALLBACK(row_motion_cb), list); |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
786 | g_signal_connect(G_OBJECT(tree), "leave-notify-event", G_CALLBACK(row_leave_cb), list); |
|
21741
0855e8f1a6af
applied changes from b52ee4ed509de4ed4f568b335e1e4499f0829f64
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21494
diff
changeset
|
787 | #endif |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
788 | pidgin_tooltip_setup_for_treeview(tree, list, |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
789 | pidgin_roomlist_create_tooltip, |
|
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
790 | pidgin_roomlist_paint_tooltip); |
|
11490
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
791 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
792 | /* Enable CTRL+F searching */ |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
793 | gtk_tree_view_set_search_column(GTK_TREE_VIEW(tree), NAME_COLUMN); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
794 | gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(tree), _search_func, NULL, NULL); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
795 | |
| 8113 | 796 | } |
| 797 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
798 | static gboolean pidgin_progress_bar_pulse(gpointer data) |
| 8230 | 799 | { |
| 15884 | 800 | PurpleRoomlist *list = data; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
801 | PidginRoomlist *rl = list->ui_data; |
| 8230 | 802 | |
| 803 | if (!rl || !rl->dialog || !rl->dialog->pg_needs_pulse) { | |
|
13448
27832a91b988
[gaim-migrate @ 15822]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12896
diff
changeset
|
804 | if (rl && rl->dialog) |
|
27832a91b988
[gaim-migrate @ 15822]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12896
diff
changeset
|
805 | rl->dialog->pg_to_active = FALSE; |
| 15884 | 806 | purple_roomlist_unref(list); |
| 8230 | 807 | return FALSE; |
| 808 | } | |
| 809 | ||
| 810 | gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress)); | |
| 811 | rl->dialog->pg_needs_pulse = FALSE; | |
| 812 | return TRUE; | |
| 813 | } | |
| 814 | ||
| 15884 | 815 | static void pidgin_roomlist_add_room(PurpleRoomlist *list, PurpleRoomlistRoom *room) |
| 8113 | 816 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
817 | PidginRoomlist *rl = list->ui_data; |
| 8113 | 818 | GtkTreeRowReference *rr, *parentrr = NULL; |
| 819 | GtkTreePath *path; | |
| 820 | GtkTreeIter iter, parent, child; | |
| 821 | GList *l, *k; | |
| 822 | int j; | |
| 823 | gboolean append = TRUE; | |
| 824 | ||
| 825 | rl->total_rooms++; | |
| 15884 | 826 | if (room->type == PURPLE_ROOMLIST_ROOMTYPE_ROOM) |
| 8113 | 827 | rl->num_rooms++; |
| 828 | ||
| 829 | if (rl->dialog) { | |
| 8230 | 830 | if (!rl->dialog->pg_to_active) { |
| 831 | rl->dialog->pg_to_active = TRUE; | |
| 15884 | 832 | purple_roomlist_ref(list); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
833 | rl->dialog->pg_update_to = g_timeout_add(100, pidgin_progress_bar_pulse, list); |
| 8230 | 834 | gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress)); |
| 835 | } else { | |
| 836 | rl->dialog->pg_needs_pulse = TRUE; | |
| 837 | } | |
| 8113 | 838 | } |
| 839 | if (room->parent) { | |
| 840 | parentrr = g_hash_table_lookup(rl->cats, room->parent); | |
| 841 | path = gtk_tree_row_reference_get_path(parentrr); | |
| 842 | if (path) { | |
| 15884 | 843 | PurpleRoomlistRoom *tmproom = NULL; |
| 8113 | 844 | |
| 845 | gtk_tree_model_get_iter(GTK_TREE_MODEL(rl->model), &parent, path); | |
| 846 | gtk_tree_path_free(path); | |
| 847 | ||
| 848 | if (gtk_tree_model_iter_children(GTK_TREE_MODEL(rl->model), &child, &parent)) { | |
| 849 | gtk_tree_model_get(GTK_TREE_MODEL(rl->model), &child, ROOM_COLUMN, &tmproom, -1); | |
| 850 | if (!tmproom) | |
| 851 | append = FALSE; | |
| 852 | } | |
| 853 | } | |
| 854 | } | |
| 855 | ||
| 856 | if (append) | |
| 857 | gtk_tree_store_append(rl->model, &iter, (parentrr ? &parent : NULL)); | |
| 858 | else | |
| 859 | iter = child; | |
| 860 | ||
| 15884 | 861 | if (room->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) |
| 8113 | 862 | gtk_tree_store_append(rl->model, &child, &iter); |
| 863 | ||
| 864 | path = gtk_tree_model_get_path(GTK_TREE_MODEL(rl->model), &iter); | |
| 865 | ||
| 15884 | 866 | if (room->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) { |
| 8113 | 867 | rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(rl->model), path); |
| 868 | g_hash_table_insert(rl->cats, room, rr); | |
| 869 | } | |
| 870 | ||
| 871 | gtk_tree_path_free(path); | |
| 872 | ||
| 873 | gtk_tree_store_set(rl->model, &iter, NAME_COLUMN, room->name, -1); | |
| 874 | gtk_tree_store_set(rl->model, &iter, ROOM_COLUMN, room, -1); | |
| 875 | ||
| 876 | for (j = NUM_OF_COLUMNS, l = room->fields, k = list->fields; l && k; j++, l = l->next, k = k->next) { | |
| 15884 | 877 | PurpleRoomlistField *f = k->data; |
| 8113 | 878 | if (f->hidden) |
| 879 | continue; | |
| 880 | gtk_tree_store_set(rl->model, &iter, j, l->data, -1); | |
| 881 | } | |
| 882 | } | |
| 883 | ||
| 15884 | 884 | static void pidgin_roomlist_in_progress(PurpleRoomlist *list, gboolean flag) |
| 8113 | 885 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
886 | PidginRoomlist *rl = list->ui_data; |
| 8113 | 887 | |
| 888 | if (!rl || !rl->dialog) | |
| 889 | return; | |
| 890 | ||
| 891 | if (flag) { | |
| 8199 | 892 | if (rl->dialog->account_widget) |
| 893 | gtk_widget_set_sensitive(rl->dialog->account_widget, FALSE); | |
| 894 | gtk_widget_set_sensitive(rl->dialog->stop_button, TRUE); | |
| 895 | gtk_widget_set_sensitive(rl->dialog->list_button, FALSE); | |
| 8113 | 896 | } else { |
| 8230 | 897 | rl->dialog->pg_needs_pulse = FALSE; |
| 8113 | 898 | gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(rl->dialog->progress), 0.0); |
| 8199 | 899 | if (rl->dialog->account_widget) |
| 900 | gtk_widget_set_sensitive(rl->dialog->account_widget, TRUE); | |
| 901 | gtk_widget_set_sensitive(rl->dialog->stop_button, FALSE); | |
| 902 | gtk_widget_set_sensitive(rl->dialog->list_button, TRUE); | |
| 8113 | 903 | } |
| 904 | } | |
| 905 | ||
| 15884 | 906 | static void pidgin_roomlist_destroy(PurpleRoomlist *list) |
| 8113 | 907 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
908 | PidginRoomlist *rl; |
| 8113 | 909 | |
| 910 | roomlists = g_list_remove(roomlists, list); | |
| 911 | ||
| 912 | rl = list->ui_data; | |
| 913 | ||
| 914 | g_return_if_fail(rl != NULL); | |
| 915 | ||
| 916 | g_hash_table_destroy(rl->cats); | |
| 917 | g_free(rl); | |
| 918 | list->ui_data = NULL; | |
| 919 | } | |
| 920 | ||
| 15884 | 921 | static PurpleRoomlistUiOps ops = { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
922 | pidgin_roomlist_dialog_show_with_account, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
923 | pidgin_roomlist_new, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
924 | pidgin_roomlist_set_fields, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
925 | pidgin_roomlist_add_room, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
926 | pidgin_roomlist_in_progress, |
|
16752
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
927 | pidgin_roomlist_destroy, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
928 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
929 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
930 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
931 | NULL |
| 8113 | 932 | }; |
| 933 | ||
| 934 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
935 | void pidgin_roomlist_init(void) |
| 8113 | 936 | { |
| 15884 | 937 | purple_roomlist_set_ui_ops(&ops); |
| 8113 | 938 | } |