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