Mercurial > pidgin.yaz
comparison src/gtkroomlist.c @ 12896:82fd52867ffc
[gaim-migrate @ 15249]
A patch from Bleeter that "adds a GTK_STOCK_REFRESH for the 'get list' button, remove a redundant cb to a g_free, and adds a 'add room' button to the roomlist dialog". He renamed the button to "Add Chat" after he wrote that description. :)
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Tue, 17 Jan 2006 00:04:11 +0000 |
parents | e856f985a0b9 |
children | 7b8f12aacfa1 |
comparison
equal
deleted
inserted
replaced
12895:a355472257f4 | 12896:82fd52867ffc |
---|---|
48 GtkWidget *progress; | 48 GtkWidget *progress; |
49 GtkWidget *sw; | 49 GtkWidget *sw; |
50 | 50 |
51 GtkWidget *stop_button; | 51 GtkWidget *stop_button; |
52 GtkWidget *list_button; | 52 GtkWidget *list_button; |
53 GtkWidget *add_button; | |
53 GtkWidget *join_button; | 54 GtkWidget *join_button; |
54 GtkWidget *close_button; | 55 GtkWidget *close_button; |
55 | 56 |
56 GaimAccount *account; | 57 GaimAccount *account; |
57 GaimRoomlist *roomlist; | 58 GaimRoomlist *roomlist; |
128 | 129 |
129 gtk_container_add(GTK_CONTAINER(dialog->sw), rl->tree); | 130 gtk_container_add(GTK_CONTAINER(dialog->sw), rl->tree); |
130 | 131 |
131 gtk_widget_set_sensitive(dialog->stop_button, TRUE); | 132 gtk_widget_set_sensitive(dialog->stop_button, TRUE); |
132 gtk_widget_set_sensitive(dialog->list_button, FALSE); | 133 gtk_widget_set_sensitive(dialog->list_button, FALSE); |
134 gtk_widget_set_sensitive(dialog->add_button, FALSE); | |
133 gtk_widget_set_sensitive(dialog->join_button, FALSE); | 135 gtk_widget_set_sensitive(dialog->join_button, FALSE); |
134 } | 136 } |
135 | 137 |
136 static void stop_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog) | 138 static void stop_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog) |
137 { | 139 { |
140 if (dialog->account_widget) | 142 if (dialog->account_widget) |
141 gtk_widget_set_sensitive(dialog->account_widget, TRUE); | 143 gtk_widget_set_sensitive(dialog->account_widget, TRUE); |
142 | 144 |
143 gtk_widget_set_sensitive(dialog->stop_button, FALSE); | 145 gtk_widget_set_sensitive(dialog->stop_button, FALSE); |
144 gtk_widget_set_sensitive(dialog->list_button, TRUE); | 146 gtk_widget_set_sensitive(dialog->list_button, TRUE); |
147 gtk_widget_set_sensitive(dialog->add_button, FALSE); | |
145 gtk_widget_set_sensitive(dialog->join_button, FALSE); | 148 gtk_widget_set_sensitive(dialog->join_button, FALSE); |
146 } | 149 } |
147 | 150 |
148 static void close_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog) | 151 static void close_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog) |
149 { | 152 { |
155 | 158 |
156 struct _menu_cb_info { | 159 struct _menu_cb_info { |
157 GaimRoomlist *list; | 160 GaimRoomlist *list; |
158 GaimRoomlistRoom *room; | 161 GaimRoomlistRoom *room; |
159 }; | 162 }; |
160 | |
161 static void | |
162 join_button_data_change_cb(gpointer data) { | |
163 g_free(data); | |
164 } | |
165 | 163 |
166 static void | 164 static void |
167 selection_changed_cb(GtkTreeSelection *selection, GaimGtkRoomlist *grl) { | 165 selection_changed_cb(GtkTreeSelection *selection, GaimGtkRoomlist *grl) { |
168 GtkTreeIter iter; | 166 GtkTreeIter iter; |
169 GValue val; | 167 GValue val; |
177 val.g_type = 0; | 175 val.g_type = 0; |
178 gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); | 176 gtk_tree_model_get_value(GTK_TREE_MODEL(grl->model), &iter, ROOM_COLUMN, &val); |
179 room = g_value_get_pointer(&val); | 177 room = g_value_get_pointer(&val); |
180 if (!room || !(room->type & GAIM_ROOMLIST_ROOMTYPE_ROOM)) { | 178 if (!room || !(room->type & GAIM_ROOMLIST_ROOMTYPE_ROOM)) { |
181 gtk_widget_set_sensitive(dialog->join_button, FALSE); | 179 gtk_widget_set_sensitive(dialog->join_button, FALSE); |
180 gtk_widget_set_sensitive(dialog->add_button, FALSE); | |
182 return; | 181 return; |
183 } | 182 } |
184 | 183 |
185 info = g_new0(struct _menu_cb_info, 1); | 184 info = g_new0(struct _menu_cb_info, 1); |
186 info->list = dialog->roomlist; | 185 info->list = dialog->roomlist; |
187 info->room = room; | 186 info->room = room; |
188 | 187 |
189 g_object_set_data_full(G_OBJECT(dialog->join_button), "room-info", | 188 g_object_set_data_full(G_OBJECT(dialog->join_button), "room-info", |
190 info, join_button_data_change_cb); | 189 info, g_free); |
191 | 190 g_object_set_data(G_OBJECT(dialog->add_button), "room-info", info); |
191 | |
192 gtk_widget_set_sensitive(dialog->add_button, TRUE); | |
192 gtk_widget_set_sensitive(dialog->join_button, TRUE); | 193 gtk_widget_set_sensitive(dialog->join_button, TRUE); |
193 } else { | 194 } else { |
195 gtk_widget_set_sensitive(dialog->add_button, FALSE); | |
194 gtk_widget_set_sensitive(dialog->join_button, FALSE); | 196 gtk_widget_set_sensitive(dialog->join_button, FALSE); |
195 } | 197 } |
196 } | 198 } |
197 | 199 |
198 static void do_join_cb(GtkWidget *w, struct _menu_cb_info *info) | 200 static void do_add_room_cb(GtkWidget *w, struct _menu_cb_info *info) |
199 { | 201 { |
200 gaim_roomlist_room_join(info->list, info->room); | 202 gaim_blist_request_add_chat(info->list->account, NULL, NULL, info->room->name); |
201 } | 203 } |
202 | 204 |
203 static void join_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog) | 205 static void add_room_to_blist_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog) |
204 { | 206 { |
205 GaimRoomlist *rl = dialog->roomlist; | 207 GaimRoomlist *rl = dialog->roomlist; |
206 GaimGtkRoomlist *grl = rl->ui_data; | 208 GaimGtkRoomlist *grl = rl->ui_data; |
207 struct _menu_cb_info *info; | 209 struct _menu_cb_info *info; |
208 | 210 |
209 info = (struct _menu_cb_info*)g_object_get_data(G_OBJECT(button), "room-info"); | 211 info = (struct _menu_cb_info*)g_object_get_data(G_OBJECT(button), "room-info"); |
210 | 212 |
213 if(info != NULL) | |
214 do_add_room_cb(grl->tree, info); | |
215 } | |
216 | |
217 static void do_join_cb(GtkWidget *w, struct _menu_cb_info *info) | |
218 { | |
219 gaim_roomlist_room_join(info->list, info->room); | |
220 } | |
221 | |
222 static void join_button_cb(GtkButton *button, GaimGtkRoomlistDialog *dialog) | |
223 { | |
224 GaimRoomlist *rl = dialog->roomlist; | |
225 GaimGtkRoomlist *grl = rl->ui_data; | |
226 struct _menu_cb_info *info; | |
227 | |
228 info = (struct _menu_cb_info*)g_object_get_data(G_OBJECT(button), "room-info"); | |
229 | |
211 if(info != NULL) | 230 if(info != NULL) |
212 do_join_cb(grl->tree, info); | 231 do_join_cb(grl->tree, info); |
213 } | 232 } |
214 | 233 |
215 static void row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *arg2, | 234 static void row_activated_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *arg2, |
260 return FALSE; | 279 return FALSE; |
261 | 280 |
262 info.list = list; | 281 info.list = list; |
263 info.room = room; | 282 info.room = room; |
264 | 283 |
265 | |
266 menu = gtk_menu_new(); | 284 menu = gtk_menu_new(); |
267 gaim_new_item_from_stock(menu, _("_Join"), GAIM_STOCK_CHAT, | 285 gaim_new_item_from_stock(menu, _("_Join"), GAIM_STOCK_CHAT, |
268 G_CALLBACK(do_join_cb), &info, 0, 0, NULL); | 286 G_CALLBACK(do_join_cb), &info, 0, 0, NULL); |
269 | 287 gaim_new_item_from_stock(menu, _("_Add"), GTK_STOCK_ADD, |
288 G_CALLBACK(do_add_room_cb), &info, 0, 0, NULL); | |
270 | 289 |
271 gtk_widget_show_all(menu); | 290 gtk_widget_show_all(menu); |
272 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); | 291 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 3, event->time); |
273 | 292 |
274 return FALSE; | 293 return FALSE; |
384 dialog->progress = gtk_progress_bar_new(); | 403 dialog->progress = gtk_progress_bar_new(); |
385 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(dialog->progress), 0.1); | 404 gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(dialog->progress), 0.1); |
386 gtk_box_pack_start(GTK_BOX(vbox2), dialog->progress, FALSE, FALSE, 0); | 405 gtk_box_pack_start(GTK_BOX(vbox2), dialog->progress, FALSE, FALSE, 0); |
387 gtk_widget_show(dialog->progress); | 406 gtk_widget_show(dialog->progress); |
388 | 407 |
389 | |
390 /* button box */ | 408 /* button box */ |
391 bbox = gtk_hbutton_box_new(); | 409 bbox = gtk_hbutton_box_new(); |
392 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); | 410 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE); |
393 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | 411 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); |
394 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); | 412 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, TRUE, 0); |
401 G_CALLBACK(stop_button_cb), dialog); | 419 G_CALLBACK(stop_button_cb), dialog); |
402 gtk_widget_set_sensitive(dialog->stop_button, FALSE); | 420 gtk_widget_set_sensitive(dialog->stop_button, FALSE); |
403 gtk_widget_show(dialog->stop_button); | 421 gtk_widget_show(dialog->stop_button); |
404 | 422 |
405 /* list button */ | 423 /* list button */ |
406 dialog->list_button = gtk_button_new_with_mnemonic(_("_Get List")); | 424 dialog->list_button = gaim_pixbuf_button_from_stock(_("_Get List"), GTK_STOCK_REFRESH, |
425 GAIM_BUTTON_HORIZONTAL); | |
407 gtk_box_pack_start(GTK_BOX(bbox), dialog->list_button, FALSE, FALSE, 0); | 426 gtk_box_pack_start(GTK_BOX(bbox), dialog->list_button, FALSE, FALSE, 0); |
408 g_signal_connect(G_OBJECT(dialog->list_button), "clicked", | 427 g_signal_connect(G_OBJECT(dialog->list_button), "clicked", |
409 G_CALLBACK(list_button_cb), dialog); | 428 G_CALLBACK(list_button_cb), dialog); |
410 gtk_widget_show(dialog->list_button); | 429 gtk_widget_show(dialog->list_button); |
430 | |
431 /* add button */ | |
432 dialog->add_button = gaim_pixbuf_button_from_stock(_("_Add Chat"), GTK_STOCK_ADD, | |
433 GAIM_BUTTON_HORIZONTAL); | |
434 gtk_box_pack_start(GTK_BOX(bbox), dialog->add_button, FALSE, FALSE, 0); | |
435 g_signal_connect(G_OBJECT(dialog->add_button), "clicked", | |
436 G_CALLBACK(add_room_to_blist_cb), dialog); | |
437 gtk_widget_set_sensitive(dialog->add_button, FALSE); | |
438 gtk_widget_show(dialog->add_button); | |
411 | 439 |
412 /* join button */ | 440 /* join button */ |
413 dialog->join_button = gaim_pixbuf_button_from_stock(_("_Join"), GAIM_STOCK_CHAT, | 441 dialog->join_button = gaim_pixbuf_button_from_stock(_("_Join"), GAIM_STOCK_CHAT, |
414 GAIM_BUTTON_HORIZONTAL); | 442 GAIM_BUTTON_HORIZONTAL); |
415 gtk_box_pack_start(GTK_BOX(bbox), dialog->join_button, FALSE, FALSE, 0); | 443 gtk_box_pack_start(GTK_BOX(bbox), dialog->join_button, FALSE, FALSE, 0); |