annotate plugins/perl/scripts/count_down.pl @ 12116:e75ef7aa913e

[gaim-migrate @ 14416] " This patch implements a replacement for the queuing system from 1.x. It also obsoletes a previous patch [#1338873] I submitted to prioritize the unseen states in gtk conversations. The attached envelope.png is ripped from the msgunread.png already included in gaim. It should be dropped in the pixmaps directory (Makefile.am is updated accordingly in this patch). The two separate queuing preferences from 1.x, queuing messages while away and queuing all new messages (from docklet), are replaced with a single 3-way preference for conversations. The new preference is "Hide new IM conversations". This preference can be set to never, away and always. When a gtk conversation is created, it may be placed in a hidden conversation window instead of being placed normally. This decision is based upon the preference and possibly the away state of the account the conversation is being created for. This *will* effect conversations the user explicitly requests to be created, so in these cases the caller must be sure to present the conversation to the user, using gaim_gtkconv_present_conversation(). This is done already in gtkdialogs.c which handles creating conversations requested by the user from gaim proper (menus, double-clicking on budy in blist, etc.). The main advantage to not queuing messages is that the conversations exist, the message is written to the conversation (and logged if appropriate) and the unseen state is set on the conversation. This means no additional features are needed to track whether there are queued messages or not, just use the unseen state on conversations. Since conversations may not be visible (messages "queued"), gaim proper needs some notification that there are messages waiting. I opted for a menutray icon that shows up when an im conversation has an unseen message. Clicking this icon will focus (and show if hidden) the first conversation with an unseen message. This is essentially the same behavior of the docklet in cvs right now, except that the icon is only visible when there is a conversation with an unread message. The api that is added is flexible enough to allow either the docklet or the new blist menutray icon to be visible for conversations of any/all types and for unseen messages >= any state. Currently they are set to only IM conversations and only unseen states >= TEXT (system messages and no log messages will not trigger blinking the docklet or showing the blist tray icon), but these could be made preferences relatively easily in the future. Other plugins could probably benefit as well: gaim_gtk_conversations_get_first_unseen(). There is probably some limit to comment size, so I'll stop rambling now. If anyone has more questions/comments, catch me in #gaim, here or on gaim-devel." committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 16 Nov 2005 18:17:01 +0000
parents 0e9e2b923d09
children 6fd82071a7b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
11170
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
1 use Gaim;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
2
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
3 %PLUGIN_INFO = (
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
4 perl_api_version => 2,
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
5 name => "Countdown Info Timer",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
6 version => "0.1",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
7 summary => "Makes a countdown in days from today.",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
8 description => "Long description coming....",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
9 author => "John H. Kelm <johnhkelm\@gmail.com>",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
10 url => "http://gaim.sourceforge.net/",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
11
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
12 load => "plugin_load",
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
13 unload => "plugin_unload"
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
14 );
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
15
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
16 $GLOBAL_TEST_VAR = "STUFF!";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
17
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
18 sub plugin_unload {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
19 my $plugin = shift;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
20 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
21
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
22 sub plugin_init {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
23 return %PLUGIN_INFO;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
24 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
25
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
26
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
27 sub plugin_load {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
28 my $plugin = shift;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
29
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
30 # Retrieve all the accounts
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
31 @accounts = Gaim::Accounts::get_all();
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
32
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
33 print "NUM OF ACCS: " . $accounts . "\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
34 # Search each account's user info for our tag
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
35 foreach $acc (@accounts) {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
36 print "IN ACCOUNTS\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
37 $user_info = Gaim::Account::get_user_info($acc);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
38 print "USER INFO 1: " . $user_info . "\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
39 # Find <countdown> and replace
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
40 $user_info =~ /countdown([0-9]+).([0-9]+).([0-9]+)/;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
41 print "Found: " .$1 . " " . $2 . " " . $3 . "\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
42 $days = count_days($1, $2, $3);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
43 $user_info =~ s/countdown(\d\d\d\d).(\d\d).(\d\d)/$days/;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
44 print "USER INFO 2: " . $user_info . "\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
45 # Gaim::Account::set_user_info($acc, $user_info);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
46
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
47 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
48
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
49 eval '
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
50 use Gtk2 \'-init\';
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
51 use Glib;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
52 $window = Gtk2::Window->new(\'toplevel\');
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
53 $window->set_border_width(10);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
54 $button = Gtk2::Button->new("Hello World");
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
55 $button->signal_connect(clicked => \&hello, $window);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
56
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
57 $window->add($button);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
58 $button->show;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
59 $window->show;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
60 # Gtk2->main;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
61
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
62 0;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
63
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
64 '; warn $@ if $@;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
65 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
66
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
67 sub hello {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
68 my ($widget, $window) = @_;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
69 print "Called from sub hello!\n ";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
70 print "Test var: " . $GLOBAL_TEST_VAR . " \n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
71 @accounts = Gaim::Accounts::get_all();
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
72 $acc = $accounts[0];
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
73 $user_info = Gaim::Account::get_user_info($acc);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
74 print "USER INFO from sub hello: " . $user_info . "\n";
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
75 $window->destroy;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
76 }
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
77
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
78 sub count_days {
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
79 ($year, $month, $day) = @_;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
80
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
81
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
82 eval '
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
83 use Time::Local;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
84 $future = timelocal(0,0,0,$day,$month-1,$year);
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
85 '; warn $@ if $@;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
86 $today = time();
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
87 $days = int(($future - $today)/(60*60*24));
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
88 return $days;
0e9e2b923d09 [gaim-migrate @ 13271]
John H. Kelm <johnkelm@gmail.com>
parents:
diff changeset
89 }