Mercurial > pidgin
annotate plugins/idle.c @ 6801:b4fe4c1023c6
[gaim-migrate @ 7341]
Remove the "User does not have a MsnUser" error.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Wed, 10 Sep 2003 01:14:00 +0000 |
parents | ed89cd0c675e |
children | e8449d95a493 |
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" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
10 #include "server.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
11 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
12 #include "gtkplugin.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
13 #include "gtkutils.h" |
4202
59751fe608c5
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
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 |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
17 static GaimConnection *gc = NULL; |
4103 | 18 |
19 static void set_idle(GtkWidget *button, GtkWidget *spinner) { | |
20 time_t t; | |
6064 | 21 int tm = CLAMP(gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spinner)), 0, G_MAXSHORT); |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
22 GaimAccount *account; |
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
23 |
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
24 if (!gc) |
4103 | 25 return; |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
26 |
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
27 account = gaim_connection_get_account(gc); |
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
28 |
5227
6d1707dc8c3d
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
29 gaim_debug(GAIM_DEBUG_INFO, "idle", |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
30 "setting idle time for %s to %d\n", |
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
31 gaim_account_get_username(account), tm); |
4103 | 32 time(&t); |
33 t -= 60 * tm; | |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
34 gc->last_sent_time = t; |
4103 | 35 serv_set_idle(gc, 60 * tm); |
36 gc->is_idle = 0; | |
37 } | |
38 | |
6008
35679a3f2bcc
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
39 static void select_account_cb(GtkWidget *opt, GaimAccount *account) |
35679a3f2bcc
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
40 { |
35679a3f2bcc
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
41 gc = gaim_account_get_connection(account); |
4103 | 42 } |
43 | |
44 static void make_connect_menu(GtkWidget *box) { | |
6008
35679a3f2bcc
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
45 GtkWidget *optmenu; |
4103 | 46 |
6008
35679a3f2bcc
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
47 optmenu = gaim_gtk_account_option_menu_new(NULL, FALSE, |
6647
ed89cd0c675e
[gaim-migrate @ 7172]
Christian Hammond <chipx86@chipx86.com>
parents:
6481
diff
changeset
|
48 G_CALLBACK(select_account_cb), NULL, NULL); |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
49 |
6008
35679a3f2bcc
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
50 gtk_box_pack_start(GTK_BOX(box), optmenu, FALSE, FALSE, 5); |
4103 | 51 |
5587
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
52 if (gaim_connections_get_all()) |
1c55b1540e18
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
53 gc = gaim_connections_get_all()->data; |
4103 | 54 else |
55 gc = NULL; | |
56 } | |
57 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
58 static GtkWidget * |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
59 get_config_frame(GaimPlugin *plugin) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
60 { |
4103 | 61 GtkWidget *ret; |
62 GtkWidget *frame, *label; | |
63 GtkWidget *vbox, *hbox; | |
64 GtkAdjustment *adj; | |
65 GtkWidget *spinner, *button; | |
66 | |
67 ret = gtk_vbox_new(FALSE, 18); | |
68 gtk_container_set_border_width(GTK_CONTAINER(ret), 12); | |
69 | |
5530
2c4c975620f0
[gaim-migrate @ 5930]
Christian Hammond <chipx86@chipx86.com>
parents:
5314
diff
changeset
|
70 frame = gaim_gtk_make_frame(ret, _("Idle Time")); |
4103 | 71 |
72 vbox = gtk_vbox_new(FALSE, 5); | |
73 gtk_container_add(GTK_CONTAINER(frame), vbox); | |
74 | |
75 hbox = gtk_hbox_new(FALSE, 5); | |
76 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
77 | |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
78 label = gtk_label_new(_("Set")); |
4103 | 79 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
80 | |
81 make_connect_menu(hbox); | |
82 | |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
83 label = gtk_label_new(_("idle for")); |
4103 | 84 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
85 | |
86 adj = (GtkAdjustment *)gtk_adjustment_new(10, 0, G_MAXINT, 1, 0, 0); | |
87 spinner = gtk_spin_button_new(adj, 0, 0); | |
88 gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0); | |
89 | |
4287
f98e27e2cb10
[gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents:
4260
diff
changeset
|
90 label = gtk_label_new(_("minutes.")); |
4103 | 91 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); |
92 | |
93 hbox = gtk_hbox_new(TRUE, 5); | |
94 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
95 | |
96 button = gtk_button_new_with_mnemonic(_("_Set")); | |
97 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 5); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5227
diff
changeset
|
98 g_signal_connect(G_OBJECT(button), "clicked", G_CALLBACK(set_idle), spinner); |
4103 | 99 |
100 gtk_widget_show_all(ret); | |
101 | |
102 return ret; | |
103 } | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
104 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
105 static GaimGtkPluginUiInfo ui_info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
106 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
107 get_config_frame |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
108 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
109 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
110 static GaimPluginInfo info = |
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 2, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
113 GAIM_PLUGIN_STANDARD, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
114 GAIM_GTK_PLUGIN_TYPE, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
115 0, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
116 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
117 GAIM_PRIORITY_DEFAULT, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
118 IDLE_PLUGIN_ID, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
119 N_("I'dle Mak'er"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
120 VERSION, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
121 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
|
122 N_("Allows you to hand-configure how long you've been idle for"), |
6481 | 123 "Eric Warmenhoven <eric@warmenhoven.org>", |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6064
diff
changeset
|
124 GAIM_WEBSITE, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
125 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
126 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
127 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
128 &ui_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
129 NULL |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
130 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
131 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
132 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
133 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
134 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
135 } |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
136 |
6063 | 137 GAIM_INIT_PLUGIN(idle, init_plugin, info) |