Mercurial > pidgin
changeset 12775:4dc5e71c5a57
[gaim-migrate @ 15122]
sf patch #1399993, from John Bailey and Sadrul Habib Chowdhury, I think
"Add ability to idle all accounts to I'dle Ma'ker"
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Mon, 09 Jan 2006 04:54:16 +0000 |
parents | 3aa8f7c58360 |
children | 54ba44abf356 |
files | ChangeLog plugins/idle.c |
diffstat | 2 files changed, 73 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Mon Jan 09 04:44:49 2006 +0000 +++ b/ChangeLog Mon Jan 09 04:54:16 2006 +0000 @@ -65,6 +65,9 @@ intuitively (Benjamin Kahn with help from Richard Laager) * Entries in the text replacement plugin are now sorted alphabetically (Richard Laager) + * I'dle Ma'ker plugin now has easier an method to unidle accounts, a way + to idle all accounts at once, and a way to unidle all accounts idled by + the plugin (John Bailey, Sadrul Habib Chowdhury) * The Evolution Integration plugin now supports Groupwise contacts * Mono plugin loader (Eoin Coffey) * Perl plugin loader has been rewritten (John Kelm, Google Summer @@ -172,8 +175,6 @@ by the timestamp plugin * Removed all protocol options pages * Removed "Escape closes windows;" default key binding is now Ctrl-W - * Removed "Gaim usage" and "Idle time reporting" preferences; behavior - now always uses mouse/keyboard when available * Removed "Log when buddies sign on/sign off/become idle/become un-idle/go away/come back" and "Log your own actions;" all of these will be logged when the system log is enabled
--- a/plugins/idle.c Mon Jan 09 04:44:49 2006 +0000 +++ b/plugins/idle.c Mon Jan 09 04:54:16 2006 +0000 @@ -39,7 +39,7 @@ static GList *idled_accts = NULL; static gboolean -idle_filter(GaimAccount *acct) +unidle_filter(GaimAccount *acct) { if (g_list_find(idled_accts, acct)) return TRUE; @@ -47,6 +47,17 @@ return FALSE; } +static gboolean +idleable_filter(GaimAccount *acct) +{ + /* LSchiere says we can't control idle time on IRC, so I think we should + * ignore it to avoid some bug reports :) - rekkanoryo */ + if(!strcmp(gaim_account_get_protocol_id(acct), "prpl-irc")) + return FALSE; + + return TRUE; +} + static void set_idle_time(GaimAccount *acct, int mins_idle) { @@ -73,7 +84,7 @@ GaimAccount *acct = gaim_request_fields_get_account(fields, "acct"); /* only add the account to the GList if it's not already been idled */ - if (!idle_filter(acct)) + if (!unidle_filter(acct)) { gaim_debug_misc("idle", "%s hasn't been idled yet; adding to list.\n", @@ -85,6 +96,32 @@ } static void +idle_all_action_ok(void *ignored, GaimRequestFields *fields) +{ + GaimAccount *acct = NULL; + GList *l = gaim_accounts_get_all_active(); + int tm = gaim_request_fields_get_integer(fields, "mins"); + const char *prpl_id = NULL; + + for(; l; l = l->next) { + acct = (GaimAccount *)(l->data); + + if(acct) + prpl_id = gaim_account_get_protocol_id(acct); + + if(acct && idleable_filter(acct)) { + gaim_debug_misc("idle", "Idling %s.\n", + gaim_account_get_username(acct)); + + set_idle_time(acct, tm); + + if(!g_list_find(idled_accts, acct)) + idled_accts = g_list_append(idled_accts, acct); + } + } +} + +static void unidle_action_ok(void *ignored, GaimRequestFields *fields) { GaimAccount *acct = gaim_request_fields_get_account(fields, "acct"); @@ -108,6 +145,7 @@ group = gaim_request_field_group_new(NULL); field = gaim_request_field_account_new("acct", _("Account"), NULL); + gaim_request_field_account_set_filter(field, idleable_filter); gaim_request_field_account_set_show_all(field, FALSE); gaim_request_field_group_add_field(group, field); @@ -143,7 +181,7 @@ group = gaim_request_field_group_new(NULL); field = gaim_request_field_account_new("acct", _("Account"), NULL); - gaim_request_field_account_set_filter(field, idle_filter); + gaim_request_field_account_set_filter(field, unidle_filter); gaim_request_field_account_set_show_all(field, FALSE); gaim_request_field_group_add_field(group, field); @@ -161,6 +199,31 @@ } static void +idle_all_action(GaimPluginAction *action) +{ + GaimRequestFields *request; + GaimRequestFieldGroup *group; + GaimRequestField *field; + + group = gaim_request_field_group_new(NULL); + + field = gaim_request_field_int_new("mins", _("Minutes"), 10); + gaim_request_field_group_add_field(group, field); + + request = gaim_request_fields_new(); + gaim_request_fields_add_group(request, group); + + gaim_request_fields(action->plugin, + N_("I'dle Mak'er"), + _("Set Idle Time for All Accounts"), + NULL, + request, + _("_Set"), G_CALLBACK(idle_all_action_ok), + _("_Cancel"), NULL, + NULL); +} + +static void unidle_all_action(GaimPluginAction *action) { GList *l; @@ -191,6 +254,10 @@ unidle_action); l = g_list_append(l, act); + act = gaim_plugin_action_new(_("Set Idle Time for All Accounts"), + idle_all_action); + l = g_list_append(l, act); + act = gaim_plugin_action_new( _("Unset Idle Time for All Idled Accounts"), unidle_all_action); l = g_list_append(l, act);