Mercurial > pidgin.yaz
changeset 8939:19885cb8a24c
[gaim-migrate @ 9709]
Handle graying out the roomlist menu item in a more sane way.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Sat, 15 May 2004 23:04:08 +0000 |
parents | 88ec59dec95a |
children | b875f5d57b81 |
files | src/gtkblist.c src/gtkroomlist.c src/gtkroomlist.h src/roomlist.c src/roomlist.h |
diffstat | 5 files changed, 43 insertions(+), 88 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gtkblist.c Sat May 15 22:39:09 2004 +0000 +++ b/src/gtkblist.c Sat May 15 23:04:08 2004 +0000 @@ -2891,7 +2891,7 @@ 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()); + gtk_widget_set_sensitive(widget, gaim_gtk_roomlist_is_showable()); widget = gtk_item_factory_get_widget(gtkblist->ift, N_("/Tools/Privacy")); gtk_widget_set_sensitive(widget, gaim_gtk_privacy_is_showable());
--- a/src/gtkroomlist.c Sat May 15 22:39:09 2004 +0000 +++ b/src/gtkroomlist.c Sat May 15 23:04:08 2004 +0000 @@ -1,5 +1,5 @@ /** - * @file gtkroomlist.c Gtk Room List UI + * @file gtkroomlist.c GTK+ Room List UI * @ingroup gtkui * * gaim @@ -283,14 +283,33 @@ } } -static gboolean accounts_filter_func(GaimAccount *account) +static gboolean account_filter_func(GaimAccount *account) { + GaimConnection *gc = gaim_account_get_connection(account); + GaimPluginProtocolInfo *prpl_info = NULL; + +// if (!gc) +// return FALSE; + + prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); + + return (prpl_info->roomlist_get_list != NULL); +} + +gboolean +gaim_gtk_roomlist_is_showable() +{ + GList *c; GaimConnection *gc; - gc = gaim_account_get_connection(account); - if (!gc) - return FALSE; - return gaim_roomlist_is_possible(gc); + for (c = gaim_connections_get_all(); c != NULL; c = c->next) { + gc = c->data; + + if (account_filter_func(gaim_connection_get_account(gc))) + return TRUE; + } + + return FALSE; } GaimGtkRoomlistDialog *gaim_gtk_roomlist_dialog_new_with_account(GaimAccount *account) @@ -303,19 +322,6 @@ GtkWidget *bbox; GtkWidget *label; - if (account == NULL) { - account = gaim_roomlist_get_first_valid_account(); - - if (account == NULL) { - gaim_notify_error(NULL, NULL, - _("You are not currently signed on with any " - "protocols that have the ability to list rooms."), - NULL); - - return NULL; - } - } - dialog = g_new0(GaimGtkRoomlistDialog, 1); dialog->account = account; @@ -351,7 +357,7 @@ gtk_widget_show(label); dialog->account_widget = gaim_gtk_account_option_menu_new(dialog->account, FALSE, - G_CALLBACK(dialog_select_account_cb), accounts_filter_func, dialog); + G_CALLBACK(dialog_select_account_cb), account_filter_func, dialog); gtk_box_pack_start(GTK_BOX(account_hbox), dialog->account_widget, TRUE, TRUE, 0); gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(dialog->account_widget));
--- a/src/gtkroomlist.h Sat May 15 22:39:09 2004 +0000 +++ b/src/gtkroomlist.h Sat May 15 23:04:08 2004 +0000 @@ -1,5 +1,5 @@ /** - * @file gtkroomlist.h Gtk Room List UI + * @file gtkroomlist.h GTK+ Room List UI * @ingroup gtkui * * gaim @@ -36,16 +36,28 @@ */ void gaim_gtk_roomlist_init(void); -void gaim_gtk_roomlist_dialog_show(void); /** - * Create a new room list dialog. + * Determines if showing the room list dialog is a valid action. + * + * @return TRUE if there are accounts online that support listing + * chat rooms. Otherwise return FALSE. + */ +gboolean gaim_gtk_roomlist_is_showable(void); + +/** + * Shows the roomlist dialog. + */ +void gaim_gtk_roomlist_dialog_show(void); + +/** + * Creates a new room list dialog. * * @return The new dialog. */ GaimGtkRoomlistDialog *gaim_gtk_roomlist_dialog_new(void); /** - * Create a new room list dialog and fetch the list on + * Creates a new room list dialog and fetch the list on * the specified account. * * @param account The account to force.
--- a/src/roomlist.c Sat May 15 22:39:09 2004 +0000 +++ b/src/roomlist.c Sat May 15 23:04:08 2004 +0000 @@ -39,31 +39,6 @@ /**************************************************************************/ /*@{*/ -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) @@ -195,20 +170,6 @@ ops->add_room(list, room); } -gboolean gaim_roomlist_is_possible(GaimConnection *gc) -{ - GaimPluginProtocolInfo *prpl_info = NULL; - - g_return_val_if_fail(gc != NULL, FALSE); - - if (gc->prpl != NULL) - prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); - - if (prpl_info && prpl_info->roomlist_get_list) - return TRUE; - return FALSE; -} - GaimRoomlist *gaim_roomlist_get_list(GaimConnection *gc) { GaimPluginProtocolInfo *prpl_info = NULL;
--- a/src/roomlist.h Sat May 15 22:39:09 2004 +0000 +++ b/src/roomlist.h Sat May 15 23:04:08 2004 +0000 @@ -113,22 +113,6 @@ /*@{*/ /** - * 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. @@ -209,14 +193,6 @@ void gaim_roomlist_room_add(GaimRoomlist *list, GaimRoomlistRoom *room); /** - * Do we support room listing? - * - * @param gc The GaimConnection we're asking. - * @return @c TRUE if it's possible to get a room list. - */ -gboolean gaim_roomlist_is_possible(GaimConnection *gc); - -/** * Returns a GaimRoomlist structure from the prpl, and * instructs the prpl to start fetching the list. *