Wed, 05 Nov 2003 06:39:05 +0000
[gaim-migrate @ 8038]
Because all the log reading and writing is abstracted, it makes it real easy
to tell Gaim, "give me entire contents of the last conversation," which is
useful for, say, a history.c plugin. This code is now much simpler, and it
took no time at all to port it.
Sort-by-log will be a bit harder.
And because two people asked me within a minute of me committing it, there
exists an "old log" GaimLogLogger that doesn't write logs, but can list and
read them. So, you'll be able to seamlessly see your old logs along with
your new logs together in the log viewer.
| 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
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
6 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
7 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
8 | #include "connection.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
9 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
10 | #include "server.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
11 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
12 | #include "gtkplugin.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5614
diff
changeset
|
13 | #include "gtkutils.h" |
|
4202
8b92de3b1c07
[gaim-migrate @ 4438]
Christian Hammond <chipx86@chipx86.com>
parents:
4165
diff
changeset
|
14 | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
15 | #define IDLE_PLUGIN_ID "gtk-idle" |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
16 | |
|
5587
22cb9fe4798a
[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
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
22 | GaimAccount *account; |
|
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
23 | |
|
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
24 | if (!gc) |
| 4103 | 25 | return; |
|
5587
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
26 | |
|
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
27 | account = gaim_connection_get_account(gc); |
|
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
28 | |
|
5227
6b44f7901f94
[gaim-migrate @ 5597]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
29 | gaim_debug(GAIM_DEBUG_INFO, "idle", |
|
5587
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
30 | "setting idle time for %s to %d\n", |
|
22cb9fe4798a
[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
22cb9fe4798a
[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
052096edd56b
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
39 | static void select_account_cb(GtkWidget *opt, GaimAccount *account) |
|
052096edd56b
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
40 | { |
|
052096edd56b
[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
052096edd56b
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
45 | GtkWidget *optmenu; |
| 4103 | 46 | |
|
6008
052096edd56b
[gaim-migrate @ 6456]
Christian Hammond <chipx86@chipx86.com>
parents:
5920
diff
changeset
|
47 | optmenu = gaim_gtk_account_option_menu_new(NULL, FALSE, |
|
6647
fc3661a34b11
[gaim-migrate @ 7172]
Christian Hammond <chipx86@chipx86.com>
parents:
6481
diff
changeset
|
48 | G_CALLBACK(select_account_cb), NULL, NULL); |
|
5587
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
49 | |
|
6008
052096edd56b
[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
22cb9fe4798a
[gaim-migrate @ 5991]
Christian Hammond <chipx86@chipx86.com>
parents:
5530
diff
changeset
|
52 | if (gaim_connections_get_all()) |
|
22cb9fe4798a
[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
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
58 | static GtkWidget * |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
59 | get_config_frame(GaimPlugin *plugin) |
|
242b8aa81328
[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
ba1ad464b56f
[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
28045a1884e8
[gaim-migrate @ 4539]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
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
28045a1884e8
[gaim-migrate @ 4539]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
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
28045a1884e8
[gaim-migrate @ 4539]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
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
56ef6a09fb99
[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
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
104 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
105 | static GaimGtkPluginUiInfo ui_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
106 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
107 | get_config_frame |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
108 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
109 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
110 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
111 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
112 | 2, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
113 | GAIM_PLUGIN_STANDARD, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
114 | GAIM_GTK_PLUGIN_TYPE, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
115 | 0, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
116 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
117 | GAIM_PRIORITY_DEFAULT, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
118 | IDLE_PLUGIN_ID, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
119 | N_("I'dle Mak'er"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
120 | VERSION, |
|
242b8aa81328
[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"), |
|
242b8aa81328
[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
f8d7460aab30
[gaim-migrate @ 6995]
Mark Doliner <markdoliner@pidgin.im>
parents:
6371
diff
changeset
|
123 | "Eric Warmenhoven <eric@warmenhoven.org>", |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6064
diff
changeset
|
124 | GAIM_WEBSITE, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
125 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
126 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
127 | NULL, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
128 | &ui_info, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
129 | NULL |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
130 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
131 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
132 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5873
diff
changeset
|
133 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
134 | { |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
135 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
4635
diff
changeset
|
136 | |
| 6063 | 137 | GAIM_INIT_PLUGIN(idle, init_plugin, info) |