Mercurial > pidgin
annotate plugins/idle.c @ 8986:8cf32769ba1b
[gaim-migrate @ 9761]
" This patch adds a Plugin Actions menu item after the
Account Actions menu. The Plugin Actions menu is
populated from the added 'actions' slot in
GaimPluginInfo. As a demonstration, the Idle Maker
plugin has been converted to no longer require GTK code
and the Preferences interface just to perform its
actions. Instead, it uses a Plugin Action to spawn a
Fields Request.
There's also a minor fix for consistency in the menu
building for buddy actions. The pre-existing method for
instructing a menu list to display a separator was to
insert a NULL rather than a proto_buddy_menu into the
GList of actions. The code for the buddy menus was
instead checking for a proto_buddy_menu with a '-'
label. This has been fixed, and it now correctly uses
NULL to indicate a separator."
"Date: 2004-05-16 02:25
Sender: taliesein
Logged In: YES
user_id=77326
I need to add a callback to this patch to watch for
loading/unloading of plugins (to determine when to rebuild
the menu). Since the appropriate way to handle Plugin
Actions is still mildly up for debate, I'm holding of on
correcting the patch until I know for sure whether I should
fix this patch, or scrap it and write a new one using a
different method."
"Date: 2004-05-18 12:26
Sender: taliesein
Logged In: YES
user_id=77326
I've completed changes to this patch to also add plugin load
and unload signals (it looks like plugin.c actually had
pre-signal callbacks in place, but they were never used or
converted to signals)
This patch now will correctly update the Plugin Action menu
as plugins load and unload."
I'm not entirely sure i like the ui of a plugins actions menu, but i think
that having some way for plugins to add actions on an account is a good
thing, and i'm not sure that every viable action fits under the accounts
actions menu. we may want to merge the two (the existing accounts actions
and this plugins actions), but both times it came up in #gaim no one seemed
to want to comment, and on one commented to the gaim-devel post either.
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Thu, 20 May 2004 05:11:44 +0000 |
parents | d7b8eb1f0a18 |
children | c5825a04fb97 |
rev | line source |
---|---|
4103 | 1 /* a nifty little plugin to set your idle time to whatever you want it to be. |
2 * useful for almost nothing. mostly just a demo plugin. but it's fun to have | |
3 * 40-day idle times. | |
4 */ | |
5 | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
6 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
7 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
8 #include "connection.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
9 #include "debug.h" |
8986 | 10 #include "multi.h" |
11 #include "plugin.h" | |
12 #include "request.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
13 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
14 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
15 #define IDLE_PLUGIN_ID "gtk-idle" |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
16 |
4103 | 17 |
8986 | 18 static void |
19 idle_action_ok(void *ignored, GaimRequestFields *fields) | |
20 { | |
4103 | 21 time_t t; |
8986 | 22 int tm; |
23 GaimAccount *acct; | |
24 GaimConnection *gc; | |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
25 |
8986 | 26 tm = gaim_request_fields_get_integer(fields, "mins"); |
27 acct = gaim_request_fields_get_account(fields, "acct"); | |
28 gc = gaim_account_get_connection(acct); | |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
29 |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
30 gaim_debug(GAIM_DEBUG_INFO, "idle", |
8986 | 31 "setting idle time for %s to %d\n", |
32 gaim_account_get_username(acct), tm); | |
4103 | 33 time(&t); |
34 t -= 60 * tm; | |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
35 gc->last_sent_time = t; |
4103 | 36 serv_set_idle(gc, 60 * tm); |
37 gc->is_idle = 0; | |
38 } | |
39 | |
8986 | 40 |
41 static void | |
42 idle_action(GaimPlugin *plugin) | |
6008
35679a3f2bcc
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
43 { |
8986 | 44 /* Use the super fancy request API */ |
4103 | 45 |
8986 | 46 GaimRequestFields *request; |
47 GaimRequestFieldGroup *group; | |
48 GaimRequestField *field; | |
49 | |
50 group = gaim_request_field_group_new(NULL); | |
4103 | 51 |
8986 | 52 field = gaim_request_field_account_new("acct", "Account", NULL); |
53 gaim_request_field_account_set_show_all(field, FALSE); | |
54 gaim_request_field_group_add_field(group, field); | |
55 | |
56 field = gaim_request_field_int_new("mins", "Minutes", 10); | |
57 gaim_request_field_group_add_field(group, field); | |
4103 | 58 |
8986 | 59 request = gaim_request_fields_new(); |
60 gaim_request_fields_add_group(request, group); | |
61 | |
62 gaim_request_fields(plugin, | |
63 N_("I'dle Mak'er"), | |
64 _("Set Account Idle Time"), | |
65 NULL, | |
66 request, | |
67 _("_Set"), G_CALLBACK(idle_action_ok), | |
68 _("_Cancel"), NULL, | |
69 NULL); | |
4103 | 70 } |
71 | |
8986 | 72 |
73 static GList * | |
74 actions(GaimPlugin *plugin) | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
75 { |
8986 | 76 GList *l = NULL; |
77 struct plugin_actions_menu *pam; | |
4103 | 78 |
8986 | 79 pam = g_new0(struct plugin_actions_menu, 1); |
80 pam->label = _("Set Account Idle Time"); | |
81 pam->callback = idle_action; | |
82 pam->plugin = plugin; | |
83 l = g_list_append(l, pam); | |
4103 | 84 |
8986 | 85 return l; |
4103 | 86 } |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
87 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
88 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
89 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
90 { |
8749
d7b8eb1f0a18
[gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents:
7989
diff
changeset
|
91 GAIM_PLUGIN_API_VERSION, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
92 GAIM_PLUGIN_STANDARD, |
8986 | 93 NULL, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
94 0, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
95 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
96 GAIM_PRIORITY_DEFAULT, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
97 IDLE_PLUGIN_ID, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
98 N_("I'dle Mak'er"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
99 VERSION, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
100 N_("Allows you to hand-configure how long you've been idle for"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
101 N_("Allows you to hand-configure how long you've been idle for"), |
6481 | 102 "Eric Warmenhoven <eric@warmenhoven.org>", |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6064
diff
changeset
|
103 GAIM_WEBSITE, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
104 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
105 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
106 NULL, |
8986 | 107 NULL, |
108 NULL, | |
109 NULL, | |
110 actions | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
111 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
112 |
8986 | 113 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
114 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
115 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
116 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
117 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
118 |
8986 | 119 |
6063 | 120 GAIM_INIT_PLUGIN(idle, init_plugin, info) |
8986 | 121 |