annotate plugins/idle.c @ 6800:8f228a7d5076

[gaim-migrate @ 7340] Added what I have of MSNSLP in my tree. It's broken, and therefore disabled, but I need to get this out so I can do other stuff too, and have something to revert back to if I break something :) committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Wed, 10 Sep 2003 00:24:48 +0000
parents ed89cd0c675e
children e8449d95a493
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /* a nifty little plugin to set your idle time to whatever you want it to be.
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * useful for almost nothing. mostly just a demo plugin. but it's fun to have
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 * 40-day idle times.
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 */
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 static void set_idle(GtkWidget *button, GtkWidget *spinner) {
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 time_t t;
6064
ed3c3c38e182 [gaim-migrate @ 6514]
Sean Egan <seanegan@gmail.com>
parents: 6063
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 time(&t);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
35 serv_set_idle(gc, 60 * tm);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
36 gc->is_idle = 0;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
37 }
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 }
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 else
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 gc = NULL;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 }
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 GtkWidget *ret;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 GtkWidget *frame, *label;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 GtkWidget *vbox, *hbox;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 GtkAdjustment *adj;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 GtkWidget *spinner, *button;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 ret = gtk_vbox_new(FALSE, 18);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68 gtk_container_set_border_width(GTK_CONTAINER(ret), 12);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 vbox = gtk_vbox_new(FALSE, 5);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 gtk_container_add(GTK_CONTAINER(frame), vbox);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 hbox = gtk_hbox_new(FALSE, 5);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
4287
f98e27e2cb10 [gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents: 4260
diff changeset
78 label = gtk_label_new(_("Set"));
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 make_connect_menu(hbox);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
4287
f98e27e2cb10 [gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents: 4260
diff changeset
83 label = gtk_label_new(_("idle for"));
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 adj = (GtkAdjustment *)gtk_adjustment_new(10, 0, G_MAXINT, 1, 0, 0);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 spinner = gtk_spin_button_new(adj, 0, 0);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 gtk_box_pack_start(GTK_BOX(hbox), spinner, TRUE, TRUE, 0);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89
4287
f98e27e2cb10 [gaim-migrate @ 4539]
Christian Hammond <chipx86@chipx86.com>
parents: 4260
diff changeset
90 label = gtk_label_new(_("minutes."));
4103
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 hbox = gtk_hbox_new(TRUE, 5);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 button = gtk_button_new_with_mnemonic(_("_Set"));
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 gtk_widget_show_all(ret);
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 return ret;
caa7701b67d1 [gaim-migrate @ 4318]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
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
4dfae12a97bc [gaim-migrate @ 6995]
Mark Doliner <mark@kingant.net>
parents: 6371
diff changeset
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
5239a3b4ab33 [gaim-migrate @ 6513]
Nathan Walp <nwalp@pidgin.im>
parents: 6008
diff changeset
137 GAIM_INIT_PLUGIN(idle, init_plugin, info)