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