annotate src/gtkroomlist.c @ 12759:019d0e4d8d65

[gaim-migrate @ 15106] Generate the correct full name. This was preventing prefs from ever actually being removed. committer: Tailor Script <tailor@pidgin.im>
author Daniel Atallah <daniel.atallah@gmail.com>
date Sun, 08 Jan 2006 01:11:31 +0000
parents e856f985a0b9
children 82fd52867ffc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
1 /**
8939
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
2 * @file gtkroomlist.c GTK+ Room List UI
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
3 * @ingroup gtkui
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
4 *
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
5 * gaim
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
6 *
8146
596c64a2a2d0 [gaim-migrate @ 8854]
Luke Schierer <lschiere@pidgin.im>
parents: 8143
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
596c64a2a2d0 [gaim-migrate @ 8854]
Luke Schierer <lschiere@pidgin.im>
parents: 8143
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
596c64a2a2d0 [gaim-migrate @ 8854]
Luke Schierer <lschiere@pidgin.im>
parents: 8143
diff changeset
9 * source distribution.
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
10 *
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
14 * (at your option) any later version.
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
15 *
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
19 * GNU General Public License for more details.
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
20 *
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
24 */
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
25
9791
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9606
diff changeset
26 #include "internal.h"
4a15962c344a [gaim-migrate @ 10659]
Mark Doliner <mark@kingant.net>
parents: 9606
diff changeset
27 #include "gtkgaim.h"
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
28 #include "gtkutils.h"
10299
75f052c26f16 [gaim-migrate @ 11483]
Luke Schierer <lschiere@pidgin.im>
parents: 9791
diff changeset
29 #include "gtkstock.h"
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
30 #include "debug.h"
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
31 #include "account.h"
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
32 #include "connection.h"
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
33 #include "notify.h"
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
34
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
35 #include "gtkroomlist.h"
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
36
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
37 typedef struct _GaimGtkRoomlist {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
38 GaimGtkRoomlistDialog *dialog;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
39 GtkTreeStore *model;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
40 GtkWidget *tree;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
41 GHashTable *cats; /**< Meow. */
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
42 gint num_rooms, total_rooms;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
43 } GaimGtkRoomlist;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
44
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
45 struct _GaimGtkRoomlistDialog {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
46 GtkWidget *window;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
47 GtkWidget *account_widget;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
48 GtkWidget *progress;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
49 GtkWidget *sw;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
50
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
51 GtkWidget *stop_button;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
52 GtkWidget *list_button;
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
53 GtkWidget *join_button;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
54 GtkWidget *close_button;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
55
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
56 GaimAccount *account;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
57 GaimRoomlist *roomlist;
8230
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
58
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
59 gboolean pg_needs_pulse;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
60 gboolean pg_to_active;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
61 guint pg_update_to;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
62 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
63
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
64 enum {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
65 NAME_COLUMN = 0,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
66 ROOM_COLUMN,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
67 NUM_OF_COLUMNS,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
68 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
69
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
70 static GList *roomlists = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
71
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
72 static gint delete_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
73 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
74 GaimGtkRoomlistDialog *dialog;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
75
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
76 dialog = (GaimGtkRoomlistDialog *) d;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
77
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
78 if (dialog->roomlist && gaim_roomlist_get_in_progress(dialog->roomlist))
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
79 gaim_roomlist_cancel_get_list(dialog->roomlist);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
80
8230
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
81 if (dialog->roomlist) {
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
82 if (dialog->pg_to_active) {
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8230
diff changeset
83 gaim_timeout_remove(dialog->pg_update_to);
8230
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
84 dialog->pg_to_active = FALSE;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
85 /* yes, that's right, unref it twice. */
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
86 gaim_roomlist_unref(dialog->roomlist);
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
87 }
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
88 }
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
89
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
90 /* free stuff here */
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
91 if (dialog->roomlist)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
92 gaim_roomlist_unref(dialog->roomlist);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
93 g_free(dialog);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
94
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
95 return FALSE;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
96 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
97
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
98 static void dialog_select_account_cb(GObject *w, GaimAccount *account,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
99 GaimGtkRoomlistDialog *dialog)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
100 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
101 dialog->account = account;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
102 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
103
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
104 static void list_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
105 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
106 GaimConnection *gc;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
107 GaimGtkRoomlist *rl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
108
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
109 gc = gaim_account_get_connection(dialog->account);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
110 if (!gc)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
111 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
112
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
113 if (dialog->roomlist != NULL) {
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
114 rl = dialog->roomlist->ui_data;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
115 gtk_widget_destroy(rl->tree);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
116 gaim_roomlist_unref(dialog->roomlist);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
117 }
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
118
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
119 dialog->roomlist = gaim_roomlist_get_list(gc);
9159
31be05742be9 [gaim-migrate @ 9943]
Tim Ringenbach <marv@pidgin.im>
parents: 9067
diff changeset
120 if (!dialog->roomlist)
31be05742be9 [gaim-migrate @ 9943]
Tim Ringenbach <marv@pidgin.im>
parents: 9067
diff changeset
121 return;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
122 gaim_roomlist_ref(dialog->roomlist);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
123 rl = dialog->roomlist->ui_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
124 rl->dialog = dialog;
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
125
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
126 if (dialog->account_widget)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
127 gtk_widget_set_sensitive(dialog->account_widget, FALSE);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
128
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
129 gtk_container_add(GTK_CONTAINER(dialog->sw), rl->tree);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
130
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
131 gtk_widget_set_sensitive(dialog->stop_button, TRUE);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
132 gtk_widget_set_sensitive(dialog->list_button, FALSE);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
133 gtk_widget_set_sensitive(dialog->join_button, FALSE);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
134 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
135
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
136 static void stop_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
137 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
138 gaim_roomlist_cancel_get_list(dialog->roomlist);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
139
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
140 if (dialog->account_widget)
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
141 gtk_widget_set_sensitive(dialog->account_widget, TRUE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
142
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
143 gtk_widget_set_sensitive(dialog->stop_button, FALSE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
144 gtk_widget_set_sensitive(dialog->list_button, TRUE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
145 gtk_widget_set_sensitive(dialog->join_button, FALSE);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
146 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
147
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
148 static void close_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
149 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
150 GtkWidget *window = dialog->window;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
151
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
152 delete_win_cb(NULL, NULL, dialog);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
153 gtk_widget_destroy(window);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
154 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
155
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
156 struct _menu_cb_info {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
157 GaimRoomlist *list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
158 GaimRoomlistRoom *room;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
159 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
160
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
161 static void
8377
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
162 join_button_data_change_cb(gpointer data) {
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
163 g_free(data);
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
164 }
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
165
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
166 static void
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
167 selection_changed_cb(GtkTreeSelection *selection, GaimGtkRoomlist *grl) {
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
168 GtkTreeIter iter;
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12286
diff changeset
169 GValue val;
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
170 GaimRoomlistRoom *room;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
171 static struct _menu_cb_info *info;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
172 GaimGtkRoomlistDialog *dialog;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
173
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
174 dialog = grl->dialog;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
175
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
176 if (gtk_tree_selection_get_selected(selection, NULL, &iter)) {
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12286
diff changeset
177 val.g_type = 0;
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
178 gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
179 room = g_value_get_pointer(&val);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
180 if (!room || !(room->type & GAIM_ROOMLIST_ROOMTYPE_ROOM)) {
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
181 gtk_widget_set_sensitive(dialog->join_button, FALSE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
182 return;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
183 }
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
184
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
185 info = g_new0(struct _menu_cb_info, 1);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
186 info->list = dialog->roomlist;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
187 info->room = room;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
188
8377
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
189 g_object_set_data_full(G_OBJECT(dialog->join_button), "room-info",
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
190 info, join_button_data_change_cb);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
191
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
192 gtk_widget_set_sensitive(dialog->join_button, TRUE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
193 } else {
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
194 gtk_widget_set_sensitive(dialog->join_button, FALSE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
195 }
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
196 }
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
197
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
198 static void do_join_cb(GtkWidget *w, struct _menu_cb_info *info)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
199 {
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
200 gaim_roomlist_room_join(info->list, info->room);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
201 }
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
202
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
203 static void join_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog)
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
204 {
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
205 GaimRoomlist *rl = dialog->roomlist;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
206 GaimGtkRoomlist *grl = rl->ui_data;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
207 struct _menu_cb_info *info;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
208
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
209 info = (struct _menu_cb_info*)g_object_get_data(G_OBJECT(button), "room-info");
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
210
8377
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
211 if(info != NULL)
c1ca19c8f749 [gaim-migrate @ 9104]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
212 do_join_cb(grl->tree, info);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
213 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
214
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
215 static void row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *arg2,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
216 GaimRoomlist *list)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
217 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
218 GaimGtkRoomlist *grl = list->ui_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
219 GtkTreeIter iter;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
220 GaimRoomlistRoom *room;
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12286
diff changeset
221 GValue val;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
222 struct _menu_cb_info info;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
223
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
224 gtk_tree_model_get_iter(GTK_TREE_MODEL(grl->model), &iter, path);
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12286
diff changeset
225 val.g_type = 0;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
226 gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
227 room = g_value_get_pointer(&val);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
228 if (!room || !(room->type & GAIM_ROOMLIST_ROOMTYPE_ROOM))
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
229 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
230
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
231 info.list = list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
232 info.room = room;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
233
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
234 do_join_cb(GTK_WIDGET(tv), &info);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
235 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
236
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
237 static gboolean room_click_cb(GtkWidget *tv, GdkEventButton *event, GaimRoomlist *list)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
238 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
239 GtkTreePath *path;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
240 GaimGtkRoomlist *grl = list->ui_data;
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12286
diff changeset
241 GValue val;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
242 GaimRoomlistRoom *room;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
243 GtkTreeIter iter;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
244 GtkWidget *menu;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
245 static struct _menu_cb_info info; /* XXX? */
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
246
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
247 if (event->button != 3 || event->type != GDK_BUTTON_PRESS)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
248 return FALSE;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
249
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
250 /* Here we figure out which room was clicked */
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
251 if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), event->x, event->y, &path, NULL, NULL, NULL))
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
252 return FALSE;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
253 gtk_tree_model_get_iter(GTK_TREE_MODEL(grl->model), &iter, path);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
254 gtk_tree_path_free(path);
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12286
diff changeset
255 val.g_type = 0;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
256 gtk_tree_model_get_value (GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
257 room = g_value_get_pointer(&val);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
258
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
259 if (!room || !(room->type & GAIM_ROOMLIST_ROOMTYPE_ROOM))
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
260 return FALSE;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
261
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
262 info.list = list;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
263 info.room = room;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
264
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
265
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
266 menu = gtk_menu_new();
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
267 gaim_new_item_from_stock(menu, _("_Join"), GAIM_STOCK_CHAT,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
268 G_CALLBACK(do_join_cb), &info, 0, 0, NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
269
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
270
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
271 gtk_widget_show_all(menu);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
272 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
273
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
274 return FALSE;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
275 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
276
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
277 static void row_expanded_cb(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer user_data)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
278 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
279 GaimRoomlist *list = user_data;
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8425
diff changeset
280 GaimRoomlistRoom *category;
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12286
diff changeset
281 GValue val;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
282
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12286
diff changeset
283 val.g_type = 0;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
284 gtk_tree_model_get_value(gtk_tree_view_get_model(treeview), arg1, ROOM_COLUMN, &val);
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8425
diff changeset
285 category = g_value_get_pointer(&val);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
286
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8425
diff changeset
287 if (!category->expanded_once) {
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8425
diff changeset
288 gaim_roomlist_expand_category(list, category);
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8425
diff changeset
289 category->expanded_once = TRUE;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
290 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
291 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
292
8939
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
293 static gboolean account_filter_func(GaimAccount *account)
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
294 {
8939
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
295 GaimConnection *gc = gaim_account_get_connection(account);
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
296 GaimPluginProtocolInfo *prpl_info = NULL;
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
297
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
298 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
299
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
300 return (prpl_info->roomlist_get_list != NULL);
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
301 }
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
302
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
303 gboolean
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
304 gaim_gtk_roomlist_is_showable()
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
305 {
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
306 GList *c;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
307 GaimConnection *gc;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
308
8939
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
309 for (c = gaim_connections_get_all(); c != NULL; c = c->next) {
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
310 gc = c->data;
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
311
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
312 if (account_filter_func(gaim_connection_get_account(gc)))
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
313 return TRUE;
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
314 }
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
315
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
316 return FALSE;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
317 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
318
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
319 GaimGtkRoomlistDialog *gaim_gtk_roomlist_dialog_new_with_account(GaimAccount *account)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
320 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
321 GaimGtkRoomlistDialog *dialog;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
322 GtkWidget *window;
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
323 GtkWidget *vbox;
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
324 GtkWidget *vbox2;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
325 GtkWidget *account_hbox;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
326 GtkWidget *bbox;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
327 GtkWidget *label;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
328
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
329 dialog = g_new0(GaimGtkRoomlistDialog, 1);
8937
fd1a4ff1f7ed [gaim-migrate @ 9707]
Mark Doliner <mark@kingant.net>
parents: 8584
diff changeset
330 dialog->account = account;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
331
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
332 /* Create the window. */
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
333 dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
334 gtk_window_set_role(GTK_WINDOW(window), "room list");
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
335 gtk_window_set_title(GTK_WINDOW(window), _("Room List"));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
336
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10299
diff changeset
337 gtk_container_set_border_width(GTK_CONTAINER(window), GAIM_HIG_BORDER);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
338
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
339 g_signal_connect(G_OBJECT(window), "delete_event",
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
340 G_CALLBACK(delete_win_cb), dialog);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
341
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
342 /* Create the parent vbox for everything. */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10299
diff changeset
343 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
344 gtk_container_add(GTK_CONTAINER(window), vbox);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
345 gtk_widget_show(vbox);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
346
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10299
diff changeset
347 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
348 gtk_container_add(GTK_CONTAINER(vbox), vbox2);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
349 gtk_widget_show(vbox2);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
350
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
351 /* accounts dropdown list */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10299
diff changeset
352 account_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
353 gtk_box_pack_start(GTK_BOX(vbox2), account_hbox, FALSE, FALSE, 0);
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
354 gtk_widget_show(account_hbox);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
355
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
356 label = gtk_label_new(NULL);
8425
6d8ec773a485 [gaim-migrate @ 9155]
Christian Hammond <chipx86@chipx86.com>
parents: 8377
diff changeset
357 gtk_box_pack_start(GTK_BOX(account_hbox), label, FALSE, FALSE, 0);
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
358 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Account:"));
8425
6d8ec773a485 [gaim-migrate @ 9155]
Christian Hammond <chipx86@chipx86.com>
parents: 8377
diff changeset
359 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
360 gtk_widget_show(label);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
361
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
362 dialog->account_widget = gaim_gtk_account_option_menu_new(dialog->account, FALSE,
8939
19885cb8a24c [gaim-migrate @ 9709]
Mark Doliner <mark@kingant.net>
parents: 8937
diff changeset
363 G_CALLBACK(dialog_select_account_cb), account_filter_func, dialog);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
364
9067
1f2bbb359adb [gaim-migrate @ 9843]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
365 if (!dialog->account) /* this is normally null, and we normally don't care what the first selected item is */
1f2bbb359adb [gaim-migrate @ 9843]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
366 dialog->account = gaim_gtk_account_option_menu_get_selected(dialog->account_widget);
1f2bbb359adb [gaim-migrate @ 9843]
Tim Ringenbach <marv@pidgin.im>
parents: 8940
diff changeset
367
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
368 gtk_box_pack_start(GTK_BOX(account_hbox), dialog->account_widget, TRUE, TRUE, 0);
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
369 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(dialog->account_widget));
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
370 gtk_widget_show(dialog->account_widget);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
371
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
372 /* scrolled window */
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
373 dialog->sw = gtk_scrolled_window_new(NULL, NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
374 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(dialog->sw),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
375 GTK_SHADOW_IN);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
376 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(dialog->sw),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
377 GTK_POLICY_AUTOMATIC,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
378 GTK_POLICY_AUTOMATIC);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
379 gtk_box_pack_start(GTK_BOX(vbox2), dialog->sw, TRUE, TRUE, 0);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
380 gtk_widget_set_size_request(dialog->sw, -1, 250);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
381 gtk_widget_show(dialog->sw);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
382
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
383 /* progress bar */
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
384 dialog->progress = gtk_progress_bar_new();
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
385 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(dialog->progress), 0.1);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
386 gtk_box_pack_start(GTK_BOX(vbox2), dialog->progress, FALSE, FALSE, 0);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
387 gtk_widget_show(dialog->progress);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
388
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
389
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
390 /* button box */
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
391 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10299
diff changeset
392 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
393 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
394 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
395 gtk_widget_show(bbox);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
396
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
397 /* stop button */
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
398 dialog->stop_button = gtk_button_new_from_stock(GTK_STOCK_STOP);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
399 gtk_box_pack_start(GTK_BOX(bbox), dialog->stop_button, FALSE, FALSE, 0);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
400 g_signal_connect(G_OBJECT(dialog->stop_button), "clicked",
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
401 G_CALLBACK(stop_button_cb), dialog);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
402 gtk_widget_set_sensitive(dialog->stop_button, FALSE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
403 gtk_widget_show(dialog->stop_button);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
404
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
405 /* list button */
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
406 dialog->list_button = gtk_button_new_with_mnemonic(_("_Get List"));
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
407 gtk_box_pack_start(GTK_BOX(bbox), dialog->list_button, FALSE, FALSE, 0);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
408 g_signal_connect(G_OBJECT(dialog->list_button), "clicked",
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
409 G_CALLBACK(list_button_cb), dialog);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
410 gtk_widget_show(dialog->list_button);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
411
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
412 /* join button */
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
413 dialog->join_button = gaim_pixbuf_button_from_stock(_("_Join"), GAIM_STOCK_CHAT,
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
414 GAIM_BUTTON_HORIZONTAL);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
415 gtk_box_pack_start(GTK_BOX(bbox), dialog->join_button, FALSE, FALSE, 0);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
416 g_signal_connect(G_OBJECT(dialog->join_button), "clicked",
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
417 G_CALLBACK(join_button_cb), dialog);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
418 gtk_widget_set_sensitive(dialog->join_button, FALSE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
419 gtk_widget_show(dialog->join_button);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
420
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
421 /* close button */
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
422 dialog->close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
423 gtk_box_pack_start(GTK_BOX(bbox), dialog->close_button, FALSE, FALSE, 0);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
424 g_signal_connect(G_OBJECT(dialog->close_button), "clicked",
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
425 G_CALLBACK(close_button_cb), dialog);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
426 gtk_widget_show(dialog->close_button);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
427
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
428 /* show the dialog window and return the dialog */
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
429 gtk_widget_show(dialog->window);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
430
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
431 return dialog;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
432 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
433
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
434 GaimGtkRoomlistDialog *gaim_gtk_roomlist_dialog_new(void)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
435 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
436 return gaim_gtk_roomlist_dialog_new_with_account(NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
437 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
438
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
439 static void gaim_gtk_roomlist_dialog_show_with_account(GaimAccount *account)
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
440 {
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
441 GaimGtkRoomlistDialog *dialog;
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
442
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
443 dialog = gaim_gtk_roomlist_dialog_new_with_account(account);
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
444 if (!dialog)
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
445 return;
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
446
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
447 list_button_cb(GTK_BUTTON(dialog->list_button), dialog);
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
448 }
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
449
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
450 void gaim_gtk_roomlist_dialog_show(void)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
451 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
452 gaim_gtk_roomlist_dialog_new();
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
453 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
454
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
455 static void gaim_gtk_roomlist_new(GaimRoomlist *list)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
456 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
457 GaimGtkRoomlist *rl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
458
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
459 rl = g_new0(GaimGtkRoomlist, 1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
460
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
461 list->ui_data = rl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
462
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
463 rl->cats = g_hash_table_new_full(NULL, NULL, NULL, (GDestroyNotify)gtk_tree_row_reference_free);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
464
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
465 roomlists = g_list_append(roomlists, list);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
466 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
467
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
468 static void int_cell_data_func(GtkTreeViewColumn *col, GtkCellRenderer *renderer,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
469 GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
470 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
471 gchar buf[16];
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
472 int myint;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
473
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
474 gtk_tree_model_get(model, iter, GPOINTER_TO_INT(user_data), &myint, -1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
475
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
476 if (myint)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
477 g_snprintf(buf, sizeof(buf), "%d", myint);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
478 else
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
479 buf[0] = '\0';
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
480
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
481 g_object_set(renderer, "text", buf, NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
482 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
483
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
484 /* this sorts backwards on purpose, so that clicking name sorts a-z, while clicking users sorts
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
485 infinity-0. you can still click again to reverse it on any of them. */
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
486 static gint int_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
487 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
488 int c, d;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
489
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
490 c = d = 0;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
491
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
492 gtk_tree_model_get(model, a, GPOINTER_TO_INT(user_data), &c, -1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
493 gtk_tree_model_get(model, b, GPOINTER_TO_INT(user_data), &d, -1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
494
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
495 if (c == d)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
496 return 0;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
497 else if (c > d)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
498 return -1;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
499 else
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
500 return 1;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
501 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
502
11490
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
503 static gboolean
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
504 _search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data)
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
505 {
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
506 gboolean result;
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
507 gchar *name, *fold, *fkey;
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
508
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
509 gtk_tree_model_get(model, iter, column, &name, -1);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
510 fold = g_utf8_casefold(name, -1);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
511 fkey = g_utf8_casefold(key, -1);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
512
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
513 result = (g_strstr_len(fold, strlen(fold), fkey) == NULL);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
514
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
515 g_free(fold);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
516 g_free(fkey);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
517 g_free(name);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
518
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
519 return result;
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
520 }
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
521
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
522 static void gaim_gtk_roomlist_set_fields(GaimRoomlist *list, GList *fields)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
523 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
524 GaimGtkRoomlist *grl = list->ui_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
525 gint columns = NUM_OF_COLUMNS;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
526 int j;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
527 GtkTreeStore *model;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
528 GtkWidget *tree;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
529 GtkCellRenderer *renderer;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
530 GtkTreeViewColumn *column;
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
531 GtkTreeSelection *selection;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
532 GList *l;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
533 GType *types;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
534
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
535 g_return_if_fail(grl != NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
536
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
537 columns += g_list_length(fields);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
538 types = g_new(GType, columns);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
539
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
540 types[NAME_COLUMN] = G_TYPE_STRING;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
541 types[ROOM_COLUMN] = G_TYPE_POINTER;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
542
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
543 for (j = NUM_OF_COLUMNS, l = fields; l; l = l->next, j++) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
544 GaimRoomlistField *f = l->data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
545
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
546 switch (f->type) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
547 case GAIM_ROOMLIST_FIELD_BOOL:
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
548 types[j] = G_TYPE_BOOLEAN;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
549 break;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
550 case GAIM_ROOMLIST_FIELD_INT:
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
551 types[j] = G_TYPE_INT;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
552 break;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
553 case GAIM_ROOMLIST_FIELD_STRING:
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
554 types[j] = G_TYPE_STRING;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
555 break;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
556 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
557 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
558
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
559 model = gtk_tree_store_newv(columns, types);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
560 g_free(types);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
561
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
562 tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
563 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tree), TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
564
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
565 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
566 g_signal_connect(G_OBJECT(selection), "changed",
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
567 G_CALLBACK(selection_changed_cb), grl);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
568
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
569 g_object_unref(model);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
570
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
571 grl->model = model;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
572 grl->tree = tree;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
573 gtk_widget_show(grl->tree);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
574
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
575 renderer = gtk_cell_renderer_text_new();
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
576 column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
577 "text", NAME_COLUMN, NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
578 gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
579 GTK_TREE_VIEW_COLUMN_GROW_ONLY);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
580 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
581 gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), NAME_COLUMN);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
582 gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
583 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
584
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
585 for (j = NUM_OF_COLUMNS, l = fields; l; l = l->next, j++) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
586 GaimRoomlistField *f = l->data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
587
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
588 if (f->hidden)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
589 continue;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
590
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
591 renderer = gtk_cell_renderer_text_new();
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
592 column = gtk_tree_view_column_new_with_attributes(f->label, renderer,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
593 "text", j, NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
594 gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column),
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
595 GTK_TREE_VIEW_COLUMN_GROW_ONLY);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
596 gtk_tree_view_column_set_resizable(GTK_TREE_VIEW_COLUMN(column), TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
597 gtk_tree_view_column_set_sort_column_id(GTK_TREE_VIEW_COLUMN(column), j);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
598 gtk_tree_view_column_set_reorderable(GTK_TREE_VIEW_COLUMN(column), TRUE);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
599 if (f->type == GAIM_ROOMLIST_FIELD_INT) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
600 gtk_tree_view_column_set_cell_data_func(column, renderer, int_cell_data_func,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
601 GINT_TO_POINTER(j), NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
602 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(model), j, int_sort_func,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
603 GINT_TO_POINTER(j), NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
604 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
605 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), column);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
606 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
607
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
608 g_signal_connect(G_OBJECT(tree), "button-press-event", G_CALLBACK(room_click_cb), list);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
609 g_signal_connect(G_OBJECT(tree), "row-expanded", G_CALLBACK(row_expanded_cb), list);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
610 g_signal_connect(G_OBJECT(tree), "row-activated", G_CALLBACK(row_activated_cb), list);
11490
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
611
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
612 /* Enable CTRL+F searching */
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
613 gtk_tree_view_set_search_column(GTK_TREE_VIEW(tree), NAME_COLUMN);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
614 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(tree), _search_func, NULL, NULL);
1ae1454204cd [gaim-migrate @ 13733]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11243
diff changeset
615
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
616 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
617
8230
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
618 static gboolean gaim_gtk_progress_bar_pulse(gpointer data)
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
619 {
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
620 GaimRoomlist *list = data;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
621 GaimGtkRoomlist *rl = list->ui_data;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
622
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
623 if (!rl || !rl->dialog || !rl->dialog->pg_needs_pulse) {
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
624 rl->dialog->pg_to_active = FALSE;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
625 gaim_roomlist_unref(list);
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
626 return FALSE;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
627 }
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
628
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
629 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress));
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
630 rl->dialog->pg_needs_pulse = FALSE;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
631 return TRUE;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
632 }
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
633
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
634 static void gaim_gtk_roomlist_add_room(GaimRoomlist *list, GaimRoomlistRoom *room)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
635 {
12286
255e6912607b [gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11490
diff changeset
636 GaimGtkRoomlist *rl = list->ui_data;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
637 GtkTreeRowReference *rr, *parentrr = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
638 GtkTreePath *path;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
639 GtkTreeIter iter, parent, child;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
640 GList *l, *k;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
641 int j;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
642 gboolean append = TRUE;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
643
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
644 rl->total_rooms++;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
645 if (room->type == GAIM_ROOMLIST_ROOMTYPE_ROOM)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
646 rl->num_rooms++;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
647
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
648 if (rl->dialog) {
8230
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
649 if (!rl->dialog->pg_to_active) {
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
650 rl->dialog->pg_to_active = TRUE;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
651 gaim_roomlist_ref(list);
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
652 rl->dialog->pg_update_to = g_timeout_add(100, gaim_gtk_progress_bar_pulse, list);
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
653 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(rl->dialog->progress));
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
654 } else {
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
655 rl->dialog->pg_needs_pulse = TRUE;
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
656 }
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
657 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
658 if (room->parent) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
659 parentrr = g_hash_table_lookup(rl->cats, room->parent);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
660 path = gtk_tree_row_reference_get_path(parentrr);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
661 if (path) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
662 GaimRoomlistRoom *tmproom = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
663
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
664 gtk_tree_model_get_iter(GTK_TREE_MODEL(rl->model), &parent, path);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
665 gtk_tree_path_free(path);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
666
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
667 if (gtk_tree_model_iter_children(GTK_TREE_MODEL(rl->model), &child, &parent)) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
668 gtk_tree_model_get(GTK_TREE_MODEL(rl->model), &child, ROOM_COLUMN, &tmproom, -1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
669 if (!tmproom)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
670 append = FALSE;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
671 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
672 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
673 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
674
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
675 if (append)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
676 gtk_tree_store_append(rl->model, &iter, (parentrr ? &parent : NULL));
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
677 else
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
678 iter = child;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
679
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8425
diff changeset
680 if (room->type & GAIM_ROOMLIST_ROOMTYPE_CATEGORY)
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
681 gtk_tree_store_append(rl->model, &child, &iter);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
682
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
683 path = gtk_tree_model_get_path(GTK_TREE_MODEL(rl->model), &iter);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
684
8584
058efd3cb86f [gaim-migrate @ 9334]
Luke Schierer <lschiere@pidgin.im>
parents: 8425
diff changeset
685 if (room->type & GAIM_ROOMLIST_ROOMTYPE_CATEGORY) {
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
686 rr = gtk_tree_row_reference_new(GTK_TREE_MODEL(rl->model), path);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
687 g_hash_table_insert(rl->cats, room, rr);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
688 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
689
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
690 gtk_tree_path_free(path);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
691
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
692 gtk_tree_store_set(rl->model, &iter, NAME_COLUMN, room->name, -1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
693 gtk_tree_store_set(rl->model, &iter, ROOM_COLUMN, room, -1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
694
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
695 for (j = NUM_OF_COLUMNS, l = room->fields, k = list->fields; l && k; j++, l = l->next, k = k->next) {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
696 GaimRoomlistField *f = k->data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
697 if (f->hidden)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
698 continue;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
699 gtk_tree_store_set(rl->model, &iter, j, l->data, -1);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
700 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
701 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
702
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
703 static void gaim_gtk_roomlist_in_progress(GaimRoomlist *list, gboolean flag)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
704 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
705 GaimGtkRoomlist *rl = list->ui_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
706
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
707 if (!rl || !rl->dialog)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
708 return;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
709
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
710 if (flag) {
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
711 if (rl->dialog->account_widget)
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
712 gtk_widget_set_sensitive(rl->dialog->account_widget, FALSE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
713 gtk_widget_set_sensitive(rl->dialog->stop_button, TRUE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
714 gtk_widget_set_sensitive(rl->dialog->list_button, FALSE);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
715 } else {
8230
4e354776ae2a [gaim-migrate @ 8953]
Luke Schierer <lschiere@pidgin.im>
parents: 8199
diff changeset
716 rl->dialog->pg_needs_pulse = FALSE;
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
717 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(rl->dialog->progress), 0.0);
8199
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
718 if (rl->dialog->account_widget)
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
719 gtk_widget_set_sensitive(rl->dialog->account_widget, TRUE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
720 gtk_widget_set_sensitive(rl->dialog->stop_button, FALSE);
12055bae7f59 [gaim-migrate @ 8922]
Nathan Walp <nwalp@pidgin.im>
parents: 8146
diff changeset
721 gtk_widget_set_sensitive(rl->dialog->list_button, TRUE);
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
722 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
723 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
724
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
725 static void gaim_gtk_roomlist_destroy(GaimRoomlist *list)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
726 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
727 GaimGtkRoomlist *rl;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
728
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
729 roomlists = g_list_remove(roomlists, list);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
730
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
731 rl = list->ui_data;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
732
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
733 g_return_if_fail(rl != NULL);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
734
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
735 g_hash_table_destroy(rl->cats);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
736 g_free(rl);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
737 list->ui_data = NULL;
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
738 }
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
739
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
740 static GaimRoomlistUiOps ops = {
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
741 gaim_gtk_roomlist_dialog_show_with_account,
8113
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
742 gaim_gtk_roomlist_new,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
743 gaim_gtk_roomlist_set_fields,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
744 gaim_gtk_roomlist_add_room,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
745 gaim_gtk_roomlist_in_progress,
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
746 gaim_gtk_roomlist_destroy
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
747 };
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
748
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
749
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
750 void gaim_gtk_roomlist_init(void)
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
751 {
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
752 gaim_roomlist_set_ui_ops(&ops);
d60272410bd5 [gaim-migrate @ 8817]
Nathan Walp <nwalp@pidgin.im>
parents:
diff changeset
753 }