Mercurial > pidgin
annotate plugins/idle.c @ 4649:f04e2a5b637a
[gaim-migrate @ 4960]
This adds a "You signed on at another location, jerk," message for AIM
and ICQ. I don't think it should cause any problems. The wood
nymphs say "hi."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 04 Mar 2003 21:38:05 +0000 |
parents | 42d53c416bb9 |
children | fefad67de2c7 |
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 | |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
6 #include "config.h" |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
7 |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
8 #ifndef GAIM_PLUGINS |
4103 | 9 #define GAIM_PLUGINS |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
10 #endif |
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
11 |
4608 | 12 #include "gaim.h" |
4103 | 13 #include "multi.h" |
14 #include <sys/time.h> | |
15 | |
16 static struct gaim_connection *gc = NULL; | |
17 | |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
18 const char *name() { |
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
19 return _("I'dle Mak'er"); |
4103 | 20 } |
21 | |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
22 const char *description() { |
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
23 return _("Allows you to hand-configure how long you've been idle for"); |
4103 | 24 } |
25 | |
26 char *gaim_plugin_init(GModule *module) { | |
27 return NULL; | |
28 } | |
29 | |
30 static void set_idle(GtkWidget *button, GtkWidget *spinner) { | |
31 time_t t; | |
32 int tm = CLAMP(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner)), 0, G_MAXINT); | |
33 if (!gc) { | |
34 return; | |
35 } | |
36 debug_printf("setting idle time for %s to %d\n", gc->username, tm); | |
37 time(&t); | |
38 t -= 60 * tm; | |
39 gc->lastsent = t; | |
40 serv_set_idle(gc, 60 * tm); | |
41 gc->is_idle = 0; | |
42 } | |
43 | |
44 static void sel_gc(GtkWidget *opt, struct gaim_connection *g) { | |
45 gc = g; | |
46 } | |
47 | |
48 static void make_connect_menu(GtkWidget *box) { | |
49 GtkWidget *optmenu, *menu, *opt; | |
50 GSList *c = connections; | |
51 struct gaim_connection *g; | |
52 | |
53 optmenu = gtk_option_menu_new(); | |
54 gtk_box_pack_start(GTK_BOX(box), optmenu, FALSE, FALSE, 5); | |
55 | |
56 menu = gtk_menu_new(); | |
57 | |
58 while (c) { | |
59 g = (struct gaim_connection *)c->data; | |
60 opt = gtk_menu_item_new_with_label(g->username); | |
4165
07a3d1fae88f
[gaim-migrate @ 4394]
Christian Hammond <chipx86@chipx86.com>
parents:
4103
diff
changeset
|
61 g_signal_connect(GTK_OBJECT(opt), "activate", |
07a3d1fae88f
[gaim-migrate @ 4394]
Christian Hammond <chipx86@chipx86.com>
parents:
4103
diff
changeset
|
62 G_CALLBACK(sel_gc), g); |
4635 | 63 gtk_menu_shell_append(GTK_MENU_SHELL(menu), opt); |
4103 | 64 gtk_widget_show(opt); |
65 c = g_slist_next(c); | |
66 } | |
67 | |
68 gtk_option_menu_remove_menu(GTK_OPTION_MENU(optmenu)); | |
69 gtk_option_menu_set_menu(GTK_OPTION_MENU(optmenu), menu); | |
70 gtk_option_menu_set_history(GTK_OPTION_MENU(optmenu), 0); | |
71 | |
72 if (connections) | |
73 gc = connections->data; | |
74 else | |
75 gc = NULL; | |
76 } | |
77 | |
78 struct gaim_plugin_description desc; | |
79 struct gaim_plugin_description *gaim_plugin_desc() { | |
80 desc.api_version = PLUGIN_API_VERSION; | |
4585 | 81 desc.name = g_strdup(_("I'dle Mak'er")); |
4103 | 82 desc.version = g_strdup(VERSION); |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
83 desc.description = g_strdup(_("Allows you to hand-configure how long you've been idle for")); |
4103 | 84 desc.authors = g_strdup("Eric Warmenhoven <eric@warmenhoven.org>"); |
85 desc.url = g_strdup(WEBSITE); | |
86 return &desc; | |
87 } | |
88 | |
89 GtkWidget *gaim_plugin_config_gtk() { | |
90 GtkWidget *ret; | |
91 GtkWidget *frame, *label; | |
92 GtkWidget *vbox, *hbox; | |
93 GtkAdjustment *adj; | |
94 GtkWidget *spinner, *button; | |
95 | |
96 ret = gtk_vbox_new(FALSE, 18); | |
97 gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
98 | |
99 frame = make_frame(ret, _("Idle Time")); | |
100 | |
101 vbox = gtk_vbox_new(FALSE, 5); | |
102 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
103 | |
104 hbox = gtk_hbox_new(FALSE, 5); | |
105 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
106 | |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
107 label = gtk_label_new(_("Set")); |
4103 | 108 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
109 | |
110 make_connect_menu(hbox); | |
111 | |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
112 label = gtk_label_new(_("idle for")); |
4103 | 113 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
114 | |
115 adj = (GtkAdjustment *)gtk_adjustment_new(10, 0, G_MAXINT, 1, 0, 0); | |
116 spinner = gtk_spin_button_new(adj, 0, 0); | |
117 gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0); | |
118 | |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
119 label = gtk_label_new(_("minutes.")); |
4103 | 120 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
121 | |
122 hbox = gtk_hbox_new(TRUE, 5); | |
123 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
124 | |
125 button = gtk_button_new_with_mnemonic(_("_Set")); | |
126 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5); | |
4165
07a3d1fae88f
[gaim-migrate @ 4394]
Christian Hammond <chipx86@chipx86.com>
parents:
4103
diff
changeset
|
127 g_signal_connect(GTK_OBJECT(button), "clicked", G_CALLBACK(set_idle), spinner); |
4103 | 128 |
129 gtk_widget_show_all(ret); | |
130 | |
131 return ret; | |
132 } |