Sun, 03 May 2009 23:18:28 +0000
I forgot about g_strlcpy in 3d3f63414473d19a9f2eb0cdeab673cde67dbda9.
| 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 | guint pg_update_to; | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
57 | } PidginRoomlistDialog; |
| 14649 | 58 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
59 | typedef struct _PidginRoomlist { |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
60 | PidginRoomlistDialog *dialog; |
| 14649 | 61 | GtkTreeStore *model; |
| 62 | GtkWidget *tree; | |
| 63 | GHashTable *cats; /**< Meow. */ | |
| 64 | 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
|
65 | 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
|
66 | 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
|
67 | 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
|
68 | 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
|
69 | 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
|
70 | 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
|
71 | 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
|
72 | 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
|
73 | int tip_name_width; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
74 | } PidginRoomlist; |
| 8113 | 75 | |
| 76 | enum { | |
| 77 | NAME_COLUMN = 0, | |
| 78 | ROOM_COLUMN, | |
| 79 | NUM_OF_COLUMNS, | |
| 80 | }; | |
| 81 | ||
| 82 | static GList *roomlists = NULL; | |
| 83 | ||
| 84 | static gint delete_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
| 85 | { | |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
86 | PidginRoomlistDialog *dialog = d; |
| 8113 | 87 | |
| 15884 | 88 | if (dialog->roomlist && purple_roomlist_get_in_progress(dialog->roomlist)) |
| 89 | purple_roomlist_cancel_get_list(dialog->roomlist); | |
| 8199 | 90 | |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
91 | if (dialog->pg_update_to > 0) |
|
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
92 | purple_timeout_remove(dialog->pg_update_to); |
|
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
93 | |
| 8230 | 94 | if (dialog->roomlist) { |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
95 | PidginRoomlist *rl = dialog->roomlist->ui_data; |
|
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
96 | |
|
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
97 | if (dialog->pg_update_to > 0) |
| 8230 | 98 | /* yes, that's right, unref it twice. */ |
| 15884 | 99 | purple_roomlist_unref(dialog->roomlist); |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
100 | |
|
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
101 | if (rl) |
|
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
102 | rl->dialog = NULL; |
|
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
103 | purple_roomlist_unref(dialog->roomlist); |
| 8230 | 104 | } |
| 105 | ||
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
106 | dialog->progress = NULL; |
| 8113 | 107 | g_free(dialog); |
| 108 | ||
| 109 | return FALSE; | |
| 110 | } | |
| 111 | ||
| 15884 | 112 | static void dialog_select_account_cb(GObject *w, PurpleAccount *account, |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
113 | PidginRoomlistDialog *dialog) |
| 8113 | 114 | { |
| 115 | dialog->account = account; | |
| 116 | } | |
| 117 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
118 | static void list_button_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
| 8113 | 119 | { |
| 15884 | 120 | PurpleConnection *gc; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
121 | PidginRoomlist *rl; |
| 8113 | 122 | |
| 15884 | 123 | gc = purple_account_get_connection(dialog->account); |
| 8113 | 124 | if (!gc) |
| 125 | return; | |
| 126 | ||
| 8199 | 127 | if (dialog->roomlist != NULL) { |
| 128 | rl = dialog->roomlist->ui_data; | |
| 129 | gtk_widget_destroy(rl->tree); | |
| 15884 | 130 | purple_roomlist_unref(dialog->roomlist); |
| 8199 | 131 | } |
| 132 | ||
| 15884 | 133 | dialog->roomlist = purple_roomlist_get_list(gc); |
| 9159 | 134 | if (!dialog->roomlist) |
| 135 | return; | |
| 15884 | 136 | purple_roomlist_ref(dialog->roomlist); |
| 8113 | 137 | rl = dialog->roomlist->ui_data; |
| 138 | rl->dialog = dialog; | |
| 8199 | 139 | |
| 8113 | 140 | if (dialog->account_widget) |
| 141 | gtk_widget_set_sensitive(dialog->account_widget, FALSE); | |
| 8199 | 142 | |
| 143 | gtk_container_add(GTK_CONTAINER(dialog->sw), rl->tree); | |
| 144 | ||
| 15884 | 145 | /* some protocols (not bundled with libpurple) finish getting their |
| 15350 | 146 | * room list immediately */ |
| 15884 | 147 | if(purple_roomlist_get_in_progress(dialog->roomlist)) { |
| 15350 | 148 | gtk_widget_set_sensitive(dialog->stop_button, TRUE); |
| 149 | gtk_widget_set_sensitive(dialog->list_button, FALSE); | |
| 150 | } else { | |
| 151 | gtk_widget_set_sensitive(dialog->stop_button, FALSE); | |
| 152 | gtk_widget_set_sensitive(dialog->list_button, TRUE); | |
| 153 | } | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
154 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
| 8199 | 155 | gtk_widget_set_sensitive(dialog->join_button, FALSE); |
| 8113 | 156 | } |
| 157 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
158 | static void stop_button_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
| 8113 | 159 | { |
| 15884 | 160 | purple_roomlist_cancel_get_list(dialog->roomlist); |
| 8199 | 161 | |
| 162 | if (dialog->account_widget) | |
| 163 | gtk_widget_set_sensitive(dialog->account_widget, TRUE); | |
| 164 | ||
| 165 | gtk_widget_set_sensitive(dialog->stop_button, FALSE); | |
| 166 | gtk_widget_set_sensitive(dialog->list_button, TRUE); | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
167 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
| 8199 | 168 | gtk_widget_set_sensitive(dialog->join_button, FALSE); |
| 8113 | 169 | } |
| 170 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
171 | static void close_button_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
| 8113 | 172 | { |
| 173 | GtkWidget *window = dialog->window; | |
| 174 | ||
| 175 | delete_win_cb(NULL, NULL, dialog); | |
| 176 | gtk_widget_destroy(window); | |
| 177 | } | |
| 178 | ||
| 179 | struct _menu_cb_info { | |
| 15884 | 180 | PurpleRoomlist *list; |
| 181 | PurpleRoomlistRoom *room; | |
| 8113 | 182 | }; |
| 183 | ||
| 8199 | 184 | static void |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
185 | selection_changed_cb(GtkTreeSelection *selection, PidginRoomlist *grl) { |
| 8199 | 186 | GtkTreeIter iter; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
187 | GValue val; |
| 15884 | 188 | PurpleRoomlistRoom *room; |
| 8199 | 189 | static struct _menu_cb_info *info; |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
190 | PidginRoomlistDialog *dialog = grl->dialog; |
| 8199 | 191 | |
| 192 | if (gtk_tree_selection_get_selected(selection, NULL, &iter)) { | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
193 | val.g_type = 0; |
| 8199 | 194 | gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); |
| 195 | room = g_value_get_pointer(&val); | |
| 15884 | 196 | if (!room || !(room->type & PURPLE_ROOMLIST_ROOMTYPE_ROOM)) { |
| 8199 | 197 | gtk_widget_set_sensitive(dialog->join_button, FALSE); |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
198 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
| 8199 | 199 | return; |
| 200 | } | |
| 201 | ||
| 202 | info = g_new0(struct _menu_cb_info, 1); | |
| 203 | info->list = dialog->roomlist; | |
| 204 | info->room = room; | |
| 205 | ||
| 8377 | 206 | 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
|
207 | info, g_free); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
208 | g_object_set_data(G_OBJECT(dialog->add_button), "room-info", info); |
| 8199 | 209 | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
210 | gtk_widget_set_sensitive(dialog->add_button, TRUE); |
| 8199 | 211 | gtk_widget_set_sensitive(dialog->join_button, TRUE); |
| 212 | } else { | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
213 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
| 8199 | 214 | gtk_widget_set_sensitive(dialog->join_button, FALSE); |
| 215 | } | |
| 216 | } | |
| 217 | ||
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
218 | 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
|
219 | { |
| 15185 | 220 | char *name; |
| 15884 | 221 | PurpleConnection *gc = purple_account_get_connection(info->list->account); |
| 222 | PurplePluginProtocolInfo *prpl_info = NULL; | |
| 15185 | 223 | |
| 224 | if(gc != NULL) | |
| 15884 | 225 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
| 15185 | 226 | |
| 227 | if(prpl_info != NULL && prpl_info->roomlist_room_serialize) | |
| 228 | name = prpl_info->roomlist_room_serialize(info->room); | |
| 229 | else | |
| 230 | name = g_strdup(info->room->name); | |
| 231 | ||
| 15884 | 232 | purple_blist_request_add_chat(info->list->account, NULL, NULL, name); |
| 15185 | 233 | |
| 234 | g_free(name); | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
235 | } |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
236 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
237 | 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
|
238 | { |
| 15884 | 239 | PurpleRoomlist *rl = dialog->roomlist; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
240 | PidginRoomlist *grl = rl->ui_data; |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
241 | struct _menu_cb_info *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
|
242 | |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
243 | if(info != NULL) |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
244 | do_add_room_cb(grl->tree, 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 | |
| 8113 | 247 | static void do_join_cb(GtkWidget *w, struct _menu_cb_info *info) |
| 248 | { | |
| 15884 | 249 | purple_roomlist_room_join(info->list, info->room); |
| 8199 | 250 | } |
| 8113 | 251 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
252 | static void join_button_cb(GtkButton *button, PidginRoomlistDialog *dialog) |
| 8199 | 253 | { |
| 15884 | 254 | PurpleRoomlist *rl = dialog->roomlist; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
255 | PidginRoomlist *grl = rl->ui_data; |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
256 | struct _menu_cb_info *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
|
257 | |
| 8377 | 258 | if(info != NULL) |
| 259 | do_join_cb(grl->tree, info); | |
| 8113 | 260 | } |
| 261 | ||
| 262 | static void row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *arg2, | |
| 15884 | 263 | PurpleRoomlist *list) |
| 8113 | 264 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
265 | PidginRoomlist *grl = list->ui_data; |
| 8113 | 266 | GtkTreeIter iter; |
| 15884 | 267 | PurpleRoomlistRoom *room; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
268 | GValue val; |
| 8113 | 269 | struct _menu_cb_info info; |
| 270 | ||
| 271 | 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
|
272 | val.g_type = 0; |
| 8113 | 273 | gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); |
| 274 | room = g_value_get_pointer(&val); | |
| 15884 | 275 | if (!room || !(room->type & PURPLE_ROOMLIST_ROOMTYPE_ROOM)) |
| 8113 | 276 | return; |
| 277 | ||
| 278 | info.list = list; | |
| 279 | info.room = room; | |
| 280 | ||
| 281 | do_join_cb(GTK_WIDGET(tv), &info); | |
| 282 | } | |
| 283 | ||
| 15884 | 284 | static gboolean room_click_cb(GtkWidget *tv, GdkEventButton *event, PurpleRoomlist *list) |
| 8113 | 285 | { |
| 286 | GtkTreePath *path; | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
287 | PidginRoomlist *grl = list->ui_data; |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
288 | GValue val; |
| 15884 | 289 | PurpleRoomlistRoom *room; |
| 8113 | 290 | GtkTreeIter iter; |
| 291 | GtkWidget *menu; | |
| 292 | static struct _menu_cb_info info; /* XXX? */ | |
| 293 | ||
| 294 | if (event->button != 3 || event->type != GDK_BUTTON_PRESS) | |
| 295 | return FALSE; | |
| 296 | ||
| 297 | /* Here we figure out which room was clicked */ | |
| 298 | if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL)) | |
| 299 | return FALSE; | |
| 300 | gtk_tree_model_get_iter(GTK_TREE_MODEL(grl->model), &iter, path); | |
| 301 | gtk_tree_path_free(path); | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
302 | val.g_type = 0; |
| 8113 | 303 | gtk_tree_model_get_value (GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); |
| 304 | room = g_value_get_pointer(&val); | |
| 305 | ||
| 15884 | 306 | if (!room || !(room->type & PURPLE_ROOMLIST_ROOMTYPE_ROOM)) |
| 8113 | 307 | return FALSE; |
| 308 | ||
| 309 | info.list = list; | |
| 310 | info.room = room; | |
| 311 | ||
| 312 | menu = gtk_menu_new(); | |
| 15570 | 313 | pidgin_new_item_from_stock(menu, _("_Join"), PIDGIN_STOCK_CHAT, |
| 8113 | 314 | G_CALLBACK(do_join_cb), &info, 0, 0, NULL); |
| 15568 | 315 | 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
|
316 | G_CALLBACK(do_add_room_cb), &info, 0, 0, NULL); |
| 8113 | 317 | |
| 318 | gtk_widget_show_all(menu); | |
| 319 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); | |
| 320 | ||
| 321 | return FALSE; | |
| 322 | } | |
| 323 | ||
| 324 | static void row_expanded_cb(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer user_data) | |
| 325 | { | |
| 15884 | 326 | PurpleRoomlist *list = user_data; |
| 327 | PurpleRoomlistRoom *category; | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
328 | GValue val; |
| 8113 | 329 | |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12286
diff
changeset
|
330 | val.g_type = 0; |
| 8113 | 331 | gtk_tree_model_get_value(gtk_tree_view_get_model(treeview), arg1, ROOM_COLUMN, &val); |
| 8584 | 332 | category = g_value_get_pointer(&val); |
| 8113 | 333 | |
| 8584 | 334 | if (!category->expanded_once) { |
| 15884 | 335 | purple_roomlist_expand_category(list, category); |
| 8584 | 336 | category->expanded_once = TRUE; |
| 8113 | 337 | } |
| 338 | } | |
| 339 | ||
|
21494
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
340 | #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
|
341 | #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
|
342 | |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
343 | 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
|
344 | 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
|
345 | { |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
346 | 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
|
347 | 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
|
348 | 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
|
349 | 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
|
350 | 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
|
351 | 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
|
352 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
353 | 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
|
354 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
355 | 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
|
356 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
357 | 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
|
358 | 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
|
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 | 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
|
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 | 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
|
363 | 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
|
364 | 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
|
365 | 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
|
366 | 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
|
367 | } else { |
|
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 | 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
|
371 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
372 | 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
|
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_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
|
376 | } else { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
377 | 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
|
378 | 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
|
379 | 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
|
380 | 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
|
381 | 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
|
382 | } |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
383 | 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
|
384 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
385 | |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
386 | 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
|
387 | { |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
388 | 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
|
389 | 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
|
390 | 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
|
391 | 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
|
392 | 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
|
393 | 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
|
394 | 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
|
395 | 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
|
396 | 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
|
397 | |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
398 | #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
|
399 | 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
|
400 | &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
|
401 | 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
|
402 | #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
|
403 | 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
|
404 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
405 | 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
|
406 | 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
|
407 | 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
|
408 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
409 | 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
|
410 | 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
|
411 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
412 | 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
|
413 | 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
|
414 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
415 | 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
|
416 | 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
|
417 | 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
|
418 | 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
|
419 | continue; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
420 | 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
|
421 | 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
|
422 | 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
|
423 | 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
|
424 | break; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
425 | 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
|
426 | 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
|
427 | break; |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
428 | 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
|
429 | 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
|
430 | 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
|
431 | 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
|
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 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
434 | 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
|
435 | 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
|
436 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
437 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
438 | 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
|
439 | 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
|
440 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
441 | 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
|
442 | 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
|
443 | 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
|
444 | 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
|
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 | 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
|
447 | 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
|
448 | 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
|
449 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
450 | 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
|
451 | 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
|
452 | 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
|
453 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
454 | 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
|
455 | 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
|
456 | 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
|
457 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
458 | 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
|
459 | 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
|
460 | 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
|
461 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
462 | 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
|
463 | 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
|
464 | |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
465 | 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
|
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 | |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
468 | 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
|
469 | 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
|
470 | 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
|
471 | { |
|
21903
5b5ad54ae1da
Some utility functions for showing tooltips. This is used by the buddylist,
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21741
diff
changeset
|
472 | 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
|
473 | 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
|
474 | 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
|
475 | 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
|
476 | 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
|
477 | 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
|
478 | *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
|
479 | 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
|
480 | 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
|
481 | *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
|
482 | + 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
|
483 | 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
|
484 | } |
|
c7368d0f5d5a
Add tooltips when hovering over rooms in the roomlist so the full channel
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
20147
diff
changeset
|
485 | |
| 15884 | 486 | static gboolean account_filter_func(PurpleAccount *account) |
| 8113 | 487 | { |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
488 | PurpleConnection *conn = purple_account_get_connection(account); |
| 15884 | 489 | PurplePluginProtocolInfo *prpl_info = NULL; |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
490 | |
|
24863
68c109ca0089
Fix a crash that happens when accessing the roomlist for an account that's
Paul Aurich <darkrain42@pidgin.im>
parents:
23918
diff
changeset
|
491 | if (conn && PURPLE_CONNECTION_IS_CONNECTED(conn)) |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
492 | prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(conn->prpl); |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
493 | |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
494 | return (prpl_info && prpl_info->roomlist_get_list != NULL); |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
495 | } |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
496 | |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
497 | gboolean |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
498 | pidgin_roomlist_is_showable() |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
499 | { |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
500 | GList *c; |
| 15884 | 501 | PurpleConnection *gc; |
| 8113 | 502 | |
| 15884 | 503 | 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
|
504 | gc = c->data; |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
505 | |
| 15884 | 506 | if (account_filter_func(purple_connection_get_account(gc))) |
|
8939
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
507 | return TRUE; |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
508 | } |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
509 | |
|
ec2ecc652447
[gaim-migrate @ 9709]
Mark Doliner <markdoliner@pidgin.im>
parents:
8937
diff
changeset
|
510 | return FALSE; |
| 8113 | 511 | } |
| 512 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
513 | static PidginRoomlistDialog * |
| 15884 | 514 | pidgin_roomlist_dialog_new_with_account(PurpleAccount *account) |
| 8113 | 515 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
516 | PidginRoomlistDialog *dialog; |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
517 | GtkWidget *window, *vbox, *vbox2, *bbox; |
| 8113 | 518 | |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
519 | dialog = g_new0(PidginRoomlistDialog, 1); |
|
8937
b436e9cbd701
[gaim-migrate @ 9707]
Mark Doliner <markdoliner@pidgin.im>
parents:
8584
diff
changeset
|
520 | dialog->account = account; |
| 8113 | 521 | |
| 522 | /* 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
|
523 | dialog->window = window = pidgin_create_dialog(_("Room List"), PIDGIN_HIG_BORDER, "room list", TRUE); |
| 8113 | 524 | |
| 525 | g_signal_connect(G_OBJECT(window), "delete_event", | |
| 526 | G_CALLBACK(delete_win_cb), dialog); | |
| 527 | ||
| 528 | /* 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
|
529 | vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(window), FALSE, PIDGIN_HIG_BORDER); |
| 8113 | 530 | |
| 15882 | 531 | vbox2 = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); |
| 8199 | 532 | gtk_container_add(GTK_CONTAINER(vbox), vbox2); |
| 8113 | 533 | gtk_widget_show(vbox2); |
| 534 | ||
| 8352 | 535 | /* accounts dropdown list */ |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
536 | 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
|
537 | G_CALLBACK(dialog_select_account_cb), account_filter_func, dialog); |
| 9067 | 538 | 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
|
539 | 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
|
540 | pidgin_add_widget_to_vbox(GTK_BOX(vbox2), _("_Account:"), NULL, dialog->account_widget, TRUE, NULL); |
| 8113 | 541 | |
| 8199 | 542 | /* scrolled window */ |
| 8113 | 543 | dialog->sw = gtk_scrolled_window_new(NULL, NULL); |
| 544 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(dialog->sw), | |
| 545 | GTK_SHADOW_IN); | |
| 546 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dialog->sw), | |
| 547 | GTK_POLICY_AUTOMATIC, | |
| 548 | GTK_POLICY_AUTOMATIC); | |
| 8199 | 549 | gtk_box_pack_start(GTK_BOX(vbox2), dialog->sw, TRUE, TRUE, 0); |
| 550 | gtk_widget_set_size_request(dialog->sw, -1, 250); | |
| 8113 | 551 | gtk_widget_show(dialog->sw); |
| 552 | ||
| 8199 | 553 | /* progress bar */ |
| 554 | dialog->progress = gtk_progress_bar_new(); | |
| 555 | gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(dialog->progress), 0.1); | |
| 556 | gtk_box_pack_start(GTK_BOX(vbox2), dialog->progress, FALSE, FALSE, 0); | |
| 557 | gtk_widget_show(dialog->progress); | |
| 558 | ||
| 559 | /* 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
|
560 | bbox = pidgin_dialog_get_action_area(GTK_DIALOG(window)); |
| 15882 | 561 | gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE); |
| 8199 | 562 | gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); |
| 563 | ||
| 564 | /* 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
|
565 | dialog->stop_button = pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_STOP, |
| 8199 | 566 | G_CALLBACK(stop_button_cb), dialog); |
| 567 | gtk_widget_set_sensitive(dialog->stop_button, FALSE); | |
| 568 | ||
| 569 | /* list button */ | |
| 15568 | 570 | dialog->list_button = pidgin_pixbuf_button_from_stock(_("_Get List"), GTK_STOCK_REFRESH, |
| 571 | PIDGIN_BUTTON_HORIZONTAL); | |
| 8199 | 572 | gtk_box_pack_start(GTK_BOX(bbox), dialog->list_button, FALSE, FALSE, 0); |
| 573 | g_signal_connect(G_OBJECT(dialog->list_button), "clicked", | |
| 574 | G_CALLBACK(list_button_cb), dialog); | |
| 575 | gtk_widget_show(dialog->list_button); | |
| 576 | ||
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
577 | /* add button */ |
| 15568 | 578 | dialog->add_button = pidgin_pixbuf_button_from_stock(_("_Add Chat"), GTK_STOCK_ADD, |
| 579 | PIDGIN_BUTTON_HORIZONTAL); | |
|
12896
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
580 | 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
|
581 | g_signal_connect(G_OBJECT(dialog->add_button), "clicked", |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
582 | G_CALLBACK(add_room_to_blist_cb), dialog); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
583 | gtk_widget_set_sensitive(dialog->add_button, FALSE); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
584 | gtk_widget_show(dialog->add_button); |
|
d368037a2bb7
[gaim-migrate @ 15249]
Peter Lawler <pidgin@bleeter.id.au>
parents:
12600
diff
changeset
|
585 | |
| 8199 | 586 | /* join button */ |
| 15570 | 587 | dialog->join_button = pidgin_pixbuf_button_from_stock(_("_Join"), PIDGIN_STOCK_CHAT, |
| 15568 | 588 | PIDGIN_BUTTON_HORIZONTAL); |
| 8199 | 589 | gtk_box_pack_start(GTK_BOX(bbox), dialog->join_button, FALSE, FALSE, 0); |
| 590 | g_signal_connect(G_OBJECT(dialog->join_button), "clicked", | |
| 591 | G_CALLBACK(join_button_cb), dialog); | |
| 592 | gtk_widget_set_sensitive(dialog->join_button, FALSE); | |
| 593 | gtk_widget_show(dialog->join_button); | |
| 594 | ||
| 595 | /* 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
|
596 | dialog->close_button = pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, |
| 8199 | 597 | G_CALLBACK(close_button_cb), dialog); |
| 598 | ||
| 599 | /* show the dialog window and return the dialog */ | |
| 600 | gtk_widget_show(dialog->window); | |
| 601 | ||
| 8113 | 602 | return dialog; |
| 603 | } | |
| 604 | ||
| 15884 | 605 | void pidgin_roomlist_dialog_show_with_account(PurpleAccount *account) |
| 8352 | 606 | { |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
607 | PidginRoomlistDialog *dialog = pidgin_roomlist_dialog_new_with_account(account); |
| 8352 | 608 | |
| 609 | if (!dialog) | |
| 610 | return; | |
| 611 | ||
| 612 | list_button_cb(GTK_BUTTON(dialog->list_button), dialog); | |
| 613 | } | |
| 614 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
615 | void pidgin_roomlist_dialog_show(void) |
| 8113 | 616 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
617 | pidgin_roomlist_dialog_new_with_account(NULL); |
| 8113 | 618 | } |
| 619 | ||
| 15884 | 620 | static void pidgin_roomlist_new(PurpleRoomlist *list) |
| 8113 | 621 | { |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
622 | PidginRoomlist *rl = g_new0(PidginRoomlist, 1); |
| 8113 | 623 | |
| 624 | list->ui_data = rl; | |
| 625 | ||
| 626 | rl->cats = g_hash_table_new_full(NULL, NULL, NULL, (GDestroyNotify)gtk_tree_row_reference_free); | |
| 627 | ||
| 628 | roomlists = g_list_append(roomlists, list); | |
| 629 | } | |
| 630 | ||
| 631 | static void int_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer, | |
| 632 | GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data) | |
| 633 | { | |
| 634 | gchar buf[16]; | |
| 635 | int myint; | |
| 636 | ||
| 637 | gtk_tree_model_get(model, iter, GPOINTER_TO_INT(user_data), &myint, -1); | |
| 638 | ||
| 639 | if (myint) | |
| 640 | g_snprintf(buf, sizeof(buf), "%d", myint); | |
| 641 | else | |
| 642 | buf[0] = '\0'; | |
| 643 | ||
| 644 | g_object_set(renderer, "text", buf, NULL); | |
| 645 | } | |
| 646 | ||
| 647 | /* this sorts backwards on purpose, so that clicking name sorts a-z, while clicking users sorts | |
| 648 | infinity-0. you can still click again to reverse it on any of them. */ | |
| 649 | static gint int_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) | |
| 650 | { | |
| 651 | int c, d; | |
| 652 | ||
| 653 | c = d = 0; | |
| 654 | ||
| 655 | gtk_tree_model_get(model, a, GPOINTER_TO_INT(user_data), &c, -1); | |
| 656 | gtk_tree_model_get(model, b, GPOINTER_TO_INT(user_data), &d, -1); | |
| 657 | ||
| 658 | if (c == d) | |
| 659 | return 0; | |
| 660 | else if (c > d) | |
| 661 | return -1; | |
| 662 | else | |
| 663 | return 1; | |
| 664 | } | |
| 665 | ||
|
11490
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
666 | static gboolean |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
667 | _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
|
668 | { |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
669 | gboolean result; |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
670 | gchar *name, *fold, *fkey; |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
671 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
672 | gtk_tree_model_get(model, iter, column, &name, -1); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
673 | fold = g_utf8_casefold(name, -1); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
674 | fkey = g_utf8_casefold(key, -1); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
675 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
676 | result = (g_strstr_len(fold, strlen(fold), fkey) == NULL); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
677 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
678 | g_free(fold); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
679 | g_free(fkey); |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
680 | g_free(name); |
|
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 | return result; |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
683 | } |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
684 | |
| 15884 | 685 | static void pidgin_roomlist_set_fields(PurpleRoomlist *list, GList *fields) |
| 8113 | 686 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
687 | PidginRoomlist *grl = list->ui_data; |
| 8113 | 688 | gint columns = NUM_OF_COLUMNS; |
| 689 | int j; | |
| 690 | GtkTreeStore *model; | |
| 691 | GtkWidget *tree; | |
| 692 | GtkCellRenderer *renderer; | |
| 693 | GtkTreeViewColumn *column; | |
| 8199 | 694 | GtkTreeSelection *selection; |
| 8113 | 695 | GList *l; |
| 696 | GType *types; | |
| 697 | ||
| 698 | g_return_if_fail(grl != NULL); | |
| 699 | ||
| 700 | columns += g_list_length(fields); | |
| 701 | types = g_new(GType, columns); | |
| 702 | ||
| 703 | types[NAME_COLUMN] = G_TYPE_STRING; | |
| 704 | types[ROOM_COLUMN] = G_TYPE_POINTER; | |
| 705 | ||
| 706 | for (j = NUM_OF_COLUMNS, l = fields; l; l = l->next, j++) { | |
| 15884 | 707 | PurpleRoomlistField *f = l->data; |
| 8113 | 708 | |
| 709 | switch (f->type) { | |
| 15884 | 710 | case PURPLE_ROOMLIST_FIELD_BOOL: |
| 8113 | 711 | types[j] = G_TYPE_BOOLEAN; |
| 712 | break; | |
| 15884 | 713 | case PURPLE_ROOMLIST_FIELD_INT: |
| 8113 | 714 | types[j] = G_TYPE_INT; |
| 715 | break; | |
| 15884 | 716 | case PURPLE_ROOMLIST_FIELD_STRING: |
| 8113 | 717 | types[j] = G_TYPE_STRING; |
| 718 | break; | |
| 719 | } | |
| 720 | } | |
| 721 | ||
| 722 | model = gtk_tree_store_newv(columns, types); | |
| 723 | g_free(types); | |
| 724 | ||
| 725 | tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
| 726 | gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE); | |
| 727 | ||
| 8199 | 728 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); |
| 729 | g_signal_connect(G_OBJECT(selection), "changed", | |
| 730 | G_CALLBACK(selection_changed_cb), grl); | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
13448
diff
changeset
|
731 | |
| 8113 | 732 | g_object_unref(model); |
| 733 | ||
| 734 | grl->model = model; | |
| 735 | grl->tree = tree; | |
| 736 | gtk_widget_show(grl->tree); | |
| 737 | ||
| 738 | renderer = gtk_cell_renderer_text_new(); | |
| 739 | column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer, | |
| 740 | "text", NAME_COLUMN, NULL); | |
| 741 | gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), | |
| 742 | GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
| 743 | gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 744 | gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), NAME_COLUMN); | |
| 745 | gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 746 | gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
| 747 | ||
| 748 | for (j = NUM_OF_COLUMNS, l = fields; l; l = l->next, j++) { | |
| 15884 | 749 | PurpleRoomlistField *f = l->data; |
| 8113 | 750 | |
| 751 | if (f->hidden) | |
| 752 | continue; | |
| 753 | ||
| 754 | renderer = gtk_cell_renderer_text_new(); | |
| 755 | column = gtk_tree_view_column_new_with_attributes(f->label, renderer, | |
| 756 | "text", j, NULL); | |
| 757 | gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column), | |
| 758 | GTK_TREE_VIEW_COLUMN_GROW_ONLY); | |
| 759 | gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 760 | gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), j); | |
| 761 | gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE); | |
| 15884 | 762 | if (f->type == PURPLE_ROOMLIST_FIELD_INT) { |
| 8113 | 763 | gtk_tree_view_column_set_cell_data_func(column, renderer, int_cell_data_func, |
| 764 | GINT_TO_POINTER(j), NULL); | |
| 765 | gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), j, int_sort_func, | |
| 766 | GINT_TO_POINTER(j), NULL); | |
| 767 | } | |
| 768 | gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column); | |
| 769 | } | |
| 770 | ||
| 771 | g_signal_connect(G_OBJECT(tree), "button-press-event", G_CALLBACK(room_click_cb), list); | |
| 772 | g_signal_connect(G_OBJECT(tree), "row-expanded", G_CALLBACK(row_expanded_cb), list); | |
| 773 | 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
|
774 | #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
|
775 | 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
|
776 | 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
|
777 | #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
|
778 | 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
|
779 | 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
|
780 | pidgin_roomlist_paint_tooltip); |
|
11490
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
781 | |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
782 | /* Enable CTRL+F searching */ |
|
7a4f16625f66
[gaim-migrate @ 13733]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11243
diff
changeset
|
783 | 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
|
784 | 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
|
785 | |
| 8113 | 786 | } |
| 787 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
788 | static gboolean pidgin_progress_bar_pulse(gpointer data) |
| 8230 | 789 | { |
| 15884 | 790 | PurpleRoomlist *list = data; |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
791 | PidginRoomlist *rl = list->ui_data; |
| 8230 | 792 | |
| 793 | if (!rl || !rl->dialog || !rl->dialog->pg_needs_pulse) { | |
|
13448
27832a91b988
[gaim-migrate @ 15822]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12896
diff
changeset
|
794 | if (rl && rl->dialog) |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
795 | rl->dialog->pg_update_to = 0; |
| 15884 | 796 | purple_roomlist_unref(list); |
| 8230 | 797 | return FALSE; |
| 798 | } | |
| 799 | ||
| 800 | gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress)); | |
| 801 | rl->dialog->pg_needs_pulse = FALSE; | |
| 802 | return TRUE; | |
| 803 | } | |
| 804 | ||
| 15884 | 805 | static void pidgin_roomlist_add_room(PurpleRoomlist *list, PurpleRoomlistRoom *room) |
| 8113 | 806 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
807 | PidginRoomlist *rl = list->ui_data; |
| 8113 | 808 | GtkTreeRowReference *rr, *parentrr = NULL; |
| 809 | GtkTreePath *path; | |
| 810 | GtkTreeIter iter, parent, child; | |
| 811 | GList *l, *k; | |
| 812 | int j; | |
| 813 | gboolean append = TRUE; | |
| 814 | ||
| 815 | rl->total_rooms++; | |
| 15884 | 816 | if (room->type == PURPLE_ROOMLIST_ROOMTYPE_ROOM) |
| 8113 | 817 | rl->num_rooms++; |
| 818 | ||
| 819 | if (rl->dialog) { | |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
820 | if (rl->dialog->pg_update_to == 0) { |
| 15884 | 821 | purple_roomlist_ref(list); |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
822 | rl->dialog->pg_update_to = g_timeout_add(100, pidgin_progress_bar_pulse, list); |
| 8230 | 823 | gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress)); |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
824 | } else |
| 8230 | 825 | rl->dialog->pg_needs_pulse = TRUE; |
| 8113 | 826 | } |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
827 | |
| 8113 | 828 | if (room->parent) { |
| 829 | parentrr = g_hash_table_lookup(rl->cats, room->parent); | |
| 830 | path = gtk_tree_row_reference_get_path(parentrr); | |
| 831 | if (path) { | |
| 15884 | 832 | PurpleRoomlistRoom *tmproom = NULL; |
| 8113 | 833 | |
| 834 | gtk_tree_model_get_iter(GTK_TREE_MODEL(rl->model), &parent, path); | |
| 835 | gtk_tree_path_free(path); | |
| 836 | ||
| 837 | if (gtk_tree_model_iter_children(GTK_TREE_MODEL(rl->model), &child, &parent)) { | |
| 838 | gtk_tree_model_get(GTK_TREE_MODEL(rl->model), &child, ROOM_COLUMN, &tmproom, -1); | |
| 839 | if (!tmproom) | |
| 840 | append = FALSE; | |
| 841 | } | |
| 842 | } | |
| 843 | } | |
| 844 | ||
| 845 | if (append) | |
| 846 | gtk_tree_store_append(rl->model, &iter, (parentrr ? &parent : NULL)); | |
| 847 | else | |
| 848 | iter = child; | |
| 849 | ||
| 15884 | 850 | if (room->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) |
| 8113 | 851 | gtk_tree_store_append(rl->model, &child, &iter); |
| 852 | ||
| 853 | path = gtk_tree_model_get_path(GTK_TREE_MODEL(rl->model), &iter); | |
| 854 | ||
| 15884 | 855 | if (room->type & PURPLE_ROOMLIST_ROOMTYPE_CATEGORY) { |
| 8113 | 856 | rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(rl->model), path); |
| 857 | g_hash_table_insert(rl->cats, room, rr); | |
| 858 | } | |
| 859 | ||
| 860 | gtk_tree_path_free(path); | |
| 861 | ||
| 862 | gtk_tree_store_set(rl->model, &iter, NAME_COLUMN, room->name, -1); | |
| 863 | gtk_tree_store_set(rl->model, &iter, ROOM_COLUMN, room, -1); | |
| 864 | ||
| 865 | for (j = NUM_OF_COLUMNS, l = room->fields, k = list->fields; l && k; j++, l = l->next, k = k->next) { | |
| 15884 | 866 | PurpleRoomlistField *f = k->data; |
| 8113 | 867 | if (f->hidden) |
| 868 | continue; | |
| 869 | gtk_tree_store_set(rl->model, &iter, j, l->data, -1); | |
| 870 | } | |
| 871 | } | |
| 872 | ||
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
873 | static void pidgin_roomlist_in_progress(PurpleRoomlist *list, gboolean in_progress) |
| 8113 | 874 | { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
875 | PidginRoomlist *rl = list->ui_data; |
| 8113 | 876 | |
| 877 | if (!rl || !rl->dialog) | |
| 878 | return; | |
| 879 | ||
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
880 | if (in_progress) { |
| 8199 | 881 | if (rl->dialog->account_widget) |
| 882 | gtk_widget_set_sensitive(rl->dialog->account_widget, FALSE); | |
| 883 | gtk_widget_set_sensitive(rl->dialog->stop_button, TRUE); | |
| 884 | gtk_widget_set_sensitive(rl->dialog->list_button, FALSE); | |
| 8113 | 885 | } else { |
| 8230 | 886 | rl->dialog->pg_needs_pulse = FALSE; |
| 8113 | 887 | gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(rl->dialog->progress), 0.0); |
| 8199 | 888 | if (rl->dialog->account_widget) |
| 889 | gtk_widget_set_sensitive(rl->dialog->account_widget, TRUE); | |
| 890 | gtk_widget_set_sensitive(rl->dialog->stop_button, FALSE); | |
| 891 | gtk_widget_set_sensitive(rl->dialog->list_button, TRUE); | |
| 8113 | 892 | } |
| 893 | } | |
| 894 | ||
| 15884 | 895 | static void pidgin_roomlist_destroy(PurpleRoomlist *list) |
| 8113 | 896 | { |
|
23918
ae3c8eb64659
Fix a race related to closing the roomlist window and do some minor cleanup.
Daniel Atallah <datallah@pidgin.im>
parents:
22131
diff
changeset
|
897 | PidginRoomlist *rl = list->ui_data; |
| 8113 | 898 | |
| 899 | roomlists = g_list_remove(roomlists, list); | |
| 900 | ||
| 901 | g_return_if_fail(rl != NULL); | |
| 902 | ||
| 903 | g_hash_table_destroy(rl->cats); | |
| 904 | g_free(rl); | |
| 905 | list->ui_data = NULL; | |
| 906 | } | |
| 907 | ||
| 15884 | 908 | static PurpleRoomlistUiOps ops = { |
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
909 | pidgin_roomlist_dialog_show_with_account, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
910 | pidgin_roomlist_new, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
911 | pidgin_roomlist_set_fields, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
912 | pidgin_roomlist_add_room, |
|
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
913 | 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
|
914 | 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
|
915 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
916 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
917 | NULL, |
|
e6bcb1628c57
Patch from John 'rekkanoryo' Bailey to add the padding struct members in pidgin
Gary Kramlich <grim@reaperworld.com>
parents:
16254
diff
changeset
|
918 | NULL |
| 8113 | 919 | }; |
| 920 | ||
| 921 | ||
|
15562
8c8249fe5e3c
gaim_gtk to pidgin. I hope
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
922 | void pidgin_roomlist_init(void) |
| 8113 | 923 | { |
| 15884 | 924 | purple_roomlist_set_ui_ops(&ops); |
| 8113 | 925 | } |