changeset 6646:b89d98f0bf79

[gaim-migrate @ 7171] The Privacy dialog now displays only accounts that are online, as does the pounce dialog. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Fri, 29 Aug 2003 22:41:23 +0000
parents 2fa677eb9e57
children ed89cd0c675e
files src/dialogs.c src/gtkpounce.c src/gtkprivacy.c src/gtkutils.c src/gtkutils.h
diffstat 5 files changed, 46 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialogs.c	Fri Aug 29 20:06:46 2003 +0000
+++ b/src/dialogs.c	Fri Aug 29 22:41:23 2003 +0000
@@ -16,7 +16,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
  */
 #include "gtkinternal.h"
 
@@ -39,7 +38,7 @@
 
 #include "ui.h"
 
-/* XXX For the soon-to-be-deprecated MultiEntryDlg stuff */
+/* XXX */
 #include "gaim.h"
 
 static GtkWidget *imdialog = NULL;	/*I only want ONE of these :) */
@@ -675,7 +674,7 @@
 			gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
 
 			info->account = gaim_gtk_account_option_menu_new(NULL, FALSE,
-					G_CALLBACK(show_info_select_account), info);
+					G_CALLBACK(show_info_select_account), NULL, info);
 
 			gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2);
 			gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account));
@@ -753,7 +752,7 @@
 		gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
 
 		info->account = gaim_gtk_account_option_menu_new(NULL, FALSE,
-				G_CALLBACK(show_info_select_account), info);
+				G_CALLBACK(show_info_select_account), NULL, info);
 
 		gtk_table_attach_defaults(GTK_TABLE(table), info->account, 1, 2, 1, 2);
 		gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(info->account));
@@ -964,7 +963,7 @@
 
 	a->account = gaim_gtk_account_option_menu_new(
 			gaim_connection_get_account(gc), FALSE,
-			G_CALLBACK(addbuddy_select_account), a);
+			G_CALLBACK(addbuddy_select_account), NULL, a);
 
 	gtk_table_attach_defaults(GTK_TABLE(table), a->account, 1, 2, 3, 4);
 
--- a/src/gtkpounce.c	Fri Aug 29 20:06:46 2003 +0000
+++ b/src/gtkpounce.c	Fri Aug 29 22:41:23 2003 +0000
@@ -412,8 +412,9 @@
 	gtk_size_group_add_widget(sg, label);
 
 	dialog->account_menu =
-		gaim_gtk_account_option_menu_new(dialog->account, TRUE,
-										 G_CALLBACK(pounce_choose_cb), dialog);
+		gaim_gtk_account_option_menu_new(dialog->account, FALSE,
+										 G_CALLBACK(pounce_choose_cb),
+										 NULL, dialog);
 
 	gtk_box_pack_start(GTK_BOX(hbox), dialog->account_menu, FALSE, FALSE, 0);
 	gtk_widget_show(dialog->account_menu);
--- a/src/gtkprivacy.c	Fri Aug 29 20:06:46 2003 +0000
+++ b/src/gtkprivacy.c	Fri Aug 29 22:41:23 2003 +0000
@@ -330,6 +330,17 @@
 	gaim_gtk_privacy_dialog_hide();
 }
 
+static gboolean
+check_account_func(GaimAccount *account)
+{
+	GaimConnection *gc = gaim_account_get_connection(account);
+	GaimPluginProtocolInfo *prpl_info = NULL;
+
+	prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
+
+	return (prpl_info->set_permit_deny != NULL);
+}
+
 static GaimGtkPrivacyDialog *
 privacy_dialog_new(void)
 {
@@ -388,7 +399,7 @@
 	/* Accounts drop-down */
 	dropdown = gaim_gtk_account_option_menu_new(dialog->account, FALSE,
 												G_CALLBACK(select_account_cb),
-												dialog);
+												check_account_func, dialog);
 	gtk_box_pack_start(GTK_BOX(hbox), dropdown, FALSE, FALSE, 0);
 	gtk_widget_show(dropdown);
 
--- a/src/gtkutils.c	Fri Aug 29 20:06:46 2003 +0000
+++ b/src/gtkutils.c	Fri Aug 29 22:41:23 2003 +0000
@@ -752,7 +752,7 @@
 
 static void
 create_account_menu(GtkWidget *optmenu, GaimAccount *default_account,
-					gboolean show_all)
+					GaimCheckAccountFunc check_account_func, gboolean show_all)
 {
 	GaimAccount *account;
 	GtkWidget *menu;
@@ -792,6 +792,9 @@
 			account = gaim_connection_get_account(gc);
 		}
 
+		if (check_account_func == NULL || !check_account_func(account))
+			continue;
+
 		plugin = gaim_find_prpl(gaim_account_get_protocol(account));
 
 		if (plugin != NULL)
@@ -871,6 +874,7 @@
 	GtkWidget *item;
 	gboolean show_all;
 	GaimAccount *account;
+	GaimCheckAccountFunc check_account_func;
 
 	menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu));
 	item = gtk_menu_get_active(GTK_MENU(menu));
@@ -879,9 +883,12 @@
 	show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu),
 												 "show_all"));
 
+	check_account_func = g_object_get_data(G_OBJECT(item),
+										   "check_account_func");
+
 	gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu));
 
-	create_account_menu(optmenu, account, show_all);
+	create_account_menu(optmenu, account, check_account_func, show_all);
 }
 
 static gboolean
@@ -896,6 +903,7 @@
 GtkWidget *
 gaim_gtk_account_option_menu_new(GaimAccount *default_account,
 								 gboolean show_all, GCallback cb,
+								 GaimCheckAccountFunc check_account_func,
 								 gpointer user_data)
 {
 	GtkWidget *optmenu;
@@ -918,9 +926,11 @@
 	/* Set some data. */
 	g_object_set_data(G_OBJECT(optmenu), "user_data", user_data);
 	g_object_set_data(G_OBJECT(optmenu), "show_all", GINT_TO_POINTER(show_all));
+	g_object_set_data(G_OBJECT(optmenu), "chck_account_func",
+					  check_account_func);
 
 	/* Create and set the actual menu. */
-	create_account_menu(optmenu, default_account, show_all);
+	create_account_menu(optmenu, default_account, check_account_func, show_all);
 
 	/* And now the last callback. */
 	g_signal_connect(G_OBJECT(optmenu), "changed",
--- a/src/gtkutils.h	Fri Aug 29 20:06:46 2003 +0000
+++ b/src/gtkutils.h	Fri Aug 29 22:41:23 2003 +0000
@@ -5,7 +5,7 @@
  * gaim
  *
  * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
- * 
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -43,6 +43,8 @@
 
 } GaimButtonStyle;
 
+typedef gboolean (*GaimCheckAccountFunc)(GaimAccount *account);
+
 /**
  * Sets up a gtkimhtml widget, loads it with smileys, and sets the
  * default signal handlers.
@@ -230,20 +232,22 @@
 /**
  * Creates a drop-down option menu filled with accounts.
  *
- * @param default_account The account to select by default.
- * @param show_all        Whether or not to show all accounts, or just active
- *                        accounts.
- * @param cb              The callback to call when an account is selected.
- * @param user_data       Data to pass to the callback function.
+ * @param default_account    The account to select by default.
+ * @param show_all           Whether or not to show all accounts, or just
+ *                           active accounts.
+ * @param cb                 The callback to call when an account is selected.
+ * @param check_account_func A function for checking if an account should
+ *                           be shown. This can be NULL.
+ * @param user_data          Data to pass to the callback function.
  *
  * @return The drop-down option menu.
  */
 GtkWidget *gaim_gtk_account_option_menu_new(GaimAccount *default_account,
-											gboolean show_all, GCallback cb,
-											gpointer user_data);
+		gboolean show_all, GCallback cb,
+		GaimCheckAccountFunc check_account_func, gpointer user_data);
 
 /**
- * Check if the given path is a directory or not.  If it is, then modify 
+ * Check if the given path is a directory or not.  If it is, then modify
  * the given GtkFileSelection dialog so that it displays the given path.
  * If the given path is not a directory, then do nothing.
  *
@@ -273,7 +277,7 @@
  *
  * @param mode @c 0 for full options, or @c 1 for a short summary.
  * @param name The name of the binary.
- * 
+ *
  * @todo Move this to the binary, when a library is formed.
  */
 void show_usage(int mode, const char *name);