Mercurial > pidgin
changeset 8289:e39ea2b4f6cd
[gaim-migrate @ 9013]
- Moved GaimCheckAccountFunc into account.h, and renamed it to
GaimFilterAccountFunc.
- Added filter functions to the account field in the gaim_request_fields
API.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Thu, 19 Feb 2004 07:25:31 +0000 |
parents | dde73afb3283 |
children | 84ec38c3efcc |
files | src/account.h src/gtkrequest.c src/gtkutils.c src/gtkutils.h src/request.c src/request.h |
diffstat | 6 files changed, 71 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/account.h Thu Feb 19 00:00:37 2004 +0000 +++ b/src/account.h Thu Feb 19 07:25:31 2004 +0000 @@ -27,9 +27,13 @@ #ifndef _GAIM_ACCOUNTS_H_ #define _GAIM_ACCOUNTS_H_ +#include <glib.h> + typedef struct _GaimAccountUiOps GaimAccountUiOps; typedef struct _GaimAccount GaimAccount; +typedef gboolean (*GaimFilterAccountFunc)(GaimAccount *account); + #include "connection.h" #include "proxy.h" #include "prpl.h"
--- a/src/gtkrequest.c Thu Feb 19 00:00:37 2004 +0000 +++ b/src/gtkrequest.c Thu Feb 19 07:25:31 2004 +0000 @@ -659,7 +659,9 @@ widget = gaim_gtk_account_option_menu_new( gaim_request_field_account_get_default_value(field), gaim_request_field_account_get_show_all(field), - G_CALLBACK(field_account_cb), NULL, field); + G_CALLBACK(field_account_cb), + gaim_request_field_account_get_filter(field), + field); return widget; }
--- a/src/gtkutils.c Thu Feb 19 00:00:37 2004 +0000 +++ b/src/gtkutils.c Thu Feb 19 07:25:31 2004 +0000 @@ -761,7 +761,7 @@ static void create_account_menu(GtkWidget *optmenu, GaimAccount *default_account, - GaimCheckAccountFunc check_account_func, gboolean show_all) + GaimFilterAccountFunc filter_func, gboolean show_all) { GaimAccount *account; GtkWidget *menu; @@ -801,7 +801,7 @@ account = gaim_connection_get_account(gc); } - if (check_account_func && !check_account_func(account)) { + if (filter_func && !filter_func(account)) { i--; continue; } @@ -891,7 +891,7 @@ GtkWidget *item; gboolean show_all; GaimAccount *account; - GaimCheckAccountFunc check_account_func; + GaimFilterAccountFunc filter_func; menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(optmenu)); item = gtk_menu_get_active(GTK_MENU(menu)); @@ -900,12 +900,12 @@ show_all = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(optmenu), "show_all")); - check_account_func = g_object_get_data(G_OBJECT(optmenu), - "check_account_func"); + filter_func = g_object_get_data(G_OBJECT(optmenu), + "filter_func"); gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); - create_account_menu(optmenu, account, check_account_func, show_all); + create_account_menu(optmenu, account, filter_func, show_all); } static void @@ -932,7 +932,7 @@ GtkWidget * gaim_gtk_account_option_menu_new(GaimAccount *default_account, gboolean show_all, GCallback cb, - GaimCheckAccountFunc check_account_func, + GaimFilterAccountFunc filter_func, gpointer user_data) { GtkWidget *optmenu; @@ -961,11 +961,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), "check_account_func", - check_account_func); + g_object_set_data(G_OBJECT(optmenu), "filter_func", + filter_func); /* Create and set the actual menu. */ - create_account_menu(optmenu, default_account, check_account_func, show_all); + create_account_menu(optmenu, default_account, filter_func, show_all); /* And now the last callback. */ g_signal_connect(G_OBJECT(optmenu), "changed",
--- a/src/gtkutils.h Thu Feb 19 00:00:37 2004 +0000 +++ b/src/gtkutils.h Thu Feb 19 07:25:31 2004 +0000 @@ -55,8 +55,6 @@ } GaimBrowserPlace; #endif /* _WIN32 */ -typedef gboolean (*GaimCheckAccountFunc)(GaimAccount *account); - extern guint accels_save_timer; /** @@ -256,19 +254,19 @@ /** * 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 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. + * @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 filter_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, - GaimCheckAccountFunc check_account_func, gpointer user_data); + GaimFilterAccountFunc filter_func, gpointer user_data); /** * Check if the given path is a directory or not. If it is, then modify
--- a/src/request.c Thu Feb 19 00:00:37 2004 +0000 +++ b/src/request.c Thu Feb 19 07:25:31 2004 +0000 @@ -1050,6 +1050,16 @@ } } +void +gaim_request_field_account_set_filter(GaimRequestField *field, + GaimFilterAccountFunc filter_func) +{ + g_return_if_fail(field != NULL); + g_return_if_fail(field->type == GAIM_REQUEST_FIELD_ACCOUNT); + + field->u.account.filter_func = filter_func; +} + GaimAccount * gaim_request_field_account_get_default_value(const GaimRequestField *field) { @@ -1077,6 +1087,15 @@ return field->u.account.show_all; } +GaimFilterAccountFunc +gaim_request_field_account_get_filter(const GaimRequestField *field) +{ + g_return_val_if_fail(field != NULL, FALSE); + g_return_val_if_fail(field->type == GAIM_REQUEST_FIELD_ACCOUNT, FALSE); + + return field->u.account.filter_func; +} + /* -- */ void *
--- a/src/request.h Thu Feb 19 00:00:37 2004 +0000 +++ b/src/request.h Thu Feb 19 07:25:31 2004 +0000 @@ -154,6 +154,8 @@ GaimAccount *account; gboolean show_all; + GaimFilterAccountFunc filter_func; + } account; } u; @@ -995,6 +997,18 @@ gboolean show_all); /** + * Sets the account filter function in an account field. + * + * This function will determine which accounts get displayed and which + * don't. + * + * @param field The account field. + * @param filter_func The account filter function. + */ +void gaim_request_field_account_set_filter(GaimRequestField *field, + GaimFilterAccountFunc filter_func); + +/** * Returns the default account in an account field. * * @param field The field. @@ -1026,6 +1040,19 @@ gboolean gaim_request_field_account_get_show_all( const GaimRequestField *field); +/** + * Returns the account filter function in an account field. + * + * This function will determine which accounts get displayed and which + * don't. + * + * @param field The account field. + * + * @return The account filter function. + */ +GaimFilterAccountFunc gaim_request_field_account_get_filter( + const GaimRequestField *field); + /*@}*/ /**************************************************************************/