Mercurial > pidgin
changeset 8937:fd1a4ff1f7ed
[gaim-migrate @ 9707]
Tools->Room List will now be grayed out when you're not signed on
with an account that supports listing rooms.
This involved 2 big changes:
-Change when the sign_on_off_cb function in gtkblist gets called...
it used to get called when the signing-on and signing-off signal
was emitted, but I changed it to signed-on and signed-off. This
makes more sense to me, and it makes my code work :-) Let me know
if you notice any side-effects
-Add functions to the roomlist API for determining if any online
accounts support chatting or not. This involved extracting a
function from gtkroomlist.c and putting it in roomlist.c, and
adding a little helper TRUE/FALSE function
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 15 May 2004 21:56:17 +0000 |
parents | 7cbdbed9d329 |
children | 88ec59dec95a |
files | src/gtkblist.c src/gtkroomlist.c src/roomlist.c src/roomlist.h |
diffstat | 4 files changed, 58 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkblist.c Sat May 15 21:24:43 2004 +0000 +++ b/src/gtkblist.c Sat May 15 21:56:17 2004 +0000 @@ -2882,12 +2882,16 @@ } static void -signed_on_off_cb(GaimConnection *gc, GaimBuddyList *blist) +sign_on_off_cb(GaimConnection *gc, GaimBuddyList *blist) { GaimGtkBuddyList *gtkblist = GAIM_GTK_BLIST(blist); + GtkWidget *widget; gaim_gtk_blist_update_protocol_actions(); gaim_gtkpounce_menu_build(gtkblist->bpmenu); + + widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Room List")); + gtk_widget_set_sensitive(widget, gaim_roomlist_is_showable()); } /* this is called on all sorts of signals, and we have no reason to pass @@ -3244,10 +3248,10 @@ gaim_gtk_blist_update_columns, NULL))); /* Setup some gaim signal handlers. */ - gaim_signal_connect(gaim_connections_get_handle(), "signing-on", - gtkblist, GAIM_CALLBACK(signed_on_off_cb), list); - gaim_signal_connect(gaim_connections_get_handle(), "signing-off", - gtkblist, GAIM_CALLBACK(signed_on_off_cb), list); + gaim_signal_connect(gaim_connections_get_handle(), "signed-on", + gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); + gaim_signal_connect(gaim_connections_get_handle(), "signed-off", + gtkblist, GAIM_CALLBACK(sign_on_off_cb), list); /* emit our created signal */ gaim_signal_emit(gaim_gtk_blist_get_handle(), "gtkblist-created", list); @@ -3737,10 +3741,10 @@ if (!gtkblist) return; - gaim_signal_disconnect(gaim_connections_get_handle(), "signing-on", - gtkblist, GAIM_CALLBACK(signed_on_off_cb)); - gaim_signal_disconnect(gaim_connections_get_handle(), "signing-off", - gtkblist, GAIM_CALLBACK(signed_on_off_cb)); + gaim_signal_disconnect(gaim_connections_get_handle(), "signed-on", + gtkblist, GAIM_CALLBACK(sign_on_off_cb)); + gaim_signal_disconnect(gaim_connections_get_handle(), "signed-off", + gtkblist, GAIM_CALLBACK(sign_on_off_cb)); gtk_widget_destroy(gtkblist->window);
--- a/src/gtkroomlist.c Sat May 15 21:24:43 2004 +0000 +++ b/src/gtkroomlist.c Sat May 15 21:56:17 2004 +0000 @@ -302,22 +302,11 @@ GtkWidget *account_hbox; GtkWidget *bbox; GtkWidget *label; - GaimAccount *first_account = NULL; - - if (!account) { - GList *c; - GaimConnection *gc; - for (c = gaim_connections_get_all(); c != NULL; c = c->next) { - gc = c->data; + if (account == NULL) { + account = gaim_roomlist_get_first_valid_account(); - if (gaim_roomlist_is_possible(gc)) { - first_account = gaim_connection_get_account(gc); - break; - } - } - - if (first_account == NULL) { + if (account == NULL) { gaim_notify_error(NULL, NULL, _("You are not currently signed on with any " "protocols that have the ability to list rooms."), @@ -328,6 +317,7 @@ } dialog = g_new0(GaimGtkRoomlistDialog, 1); + dialog->account = account; /* Create the window. */ dialog->window = window = gtk_window_new(GTK_WINDOW_TOPLEVEL); @@ -349,12 +339,6 @@ gtk_container_add(GTK_CONTAINER(vbox), vbox2); gtk_widget_show(vbox2); - - if (!account) - dialog->account = first_account; - else - dialog->account = account; - /* accounts dropdown list */ account_hbox = gtk_hbox_new(FALSE, 6); gtk_box_pack_start(GTK_BOX(vbox2), account_hbox, FALSE, FALSE, 0);
--- a/src/roomlist.c Sat May 15 21:24:43 2004 +0000 +++ b/src/roomlist.c Sat May 15 21:56:17 2004 +0000 @@ -39,6 +39,31 @@ /**************************************************************************/ /*@{*/ +gboolean gaim_roomlist_is_showable() +{ + if (gaim_roomlist_get_first_valid_account() != NULL) + return TRUE; + return FALSE; +} + +GaimAccount *gaim_roomlist_get_first_valid_account() +{ + GList *c; + GaimConnection *gc; + GaimAccount *first_account = NULL; + + for (c = gaim_connections_get_all(); c != NULL; c = c->next) { + gc = c->data; + + if (gaim_roomlist_is_possible(gc)) { + first_account = gaim_connection_get_account(gc); + break; + } + } + + return first_account; +} + void gaim_roomlist_show_with_account(GaimAccount *account) { if (ops && ops->show_with_account)
--- a/src/roomlist.h Sat May 15 21:24:43 2004 +0000 +++ b/src/roomlist.h Sat May 15 21:56:17 2004 +0000 @@ -113,6 +113,22 @@ /*@{*/ /** + * Return true if there are accounts signed on that support showing + * a roomlist. + * + * @return True if showing the roomlist is a valid action. + */ +gboolean gaim_roomlist_is_showable(); + +/** + * Get the first online acocunt that supports showing a roomlist. + * + * @return The first selected account of all the accounts that + * support showing a roomlist. + */ +GaimAccount *gaim_roomlist_get_first_valid_account(); + +/** * This is used to get the room list on an account, asking the UI * to pop up a dialog with the specified account already selected, * and pretend the user clicked the get list button.