2 ############################################################################
3 # soepkiptng (c) copyright 2000 Eric Lammerts <eric@lammerts.org>.
4 ############################################################################
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License, version 2, as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # A copy of the GNU General Public License is available on the World Wide Web
15 # at `http://www.gnu.org/copyleft/gpl.html'. You can also obtain it by
16 # writing to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
18 ############################################################################
25 # find program directory
28 my $l = readlink or die "readlink $_: $!\n";
29 if($l =~ m
|^/|) { $_ = $l; } else { s|[^/]*$|/$l|; }
32 my $progdir = abs_path
($1);
34 require "$progdir/soepkiptng.lib";
38 read_configfile
(\
%conf, $opt_c);
40 init Gnome
"soepkiptng.pl";
42 #init Gnome::Panel::AppletWidget 'soepkiptng.pl';
72 #my $window = new Gtk::Window;
73 my $window = new Gtk
::Widget
"GtkWindow",
75 title
=> "SoepkipTNG status",
80 #$window = new Gnome::Panel::AppletWidget 'soepkiptng.pl';
83 #my $Label = Gtk::Widget->new("Gnome::CanvasText",
84 # text => "A string\nToinen rivi",
85 # font_gdk => load Gtk::Gdk::Font('-*-helvetica-*'),
86 # fill_color => 'steelblue',
90 my $label = new Gtk
::Label
("Artist\nTitle\nAlbum");
91 $label->set_justify('left');
92 #$label->set_usize(300,40);
94 my $label2 = new Gtk
::Label
("");
96 $button_pause = Gtk
::Widget
->new("GtkButton",
99 -clicked
=> sub { player_cmd
("pausetoggle"); },
103 $button_kill = Gtk
::Widget
->new("GtkButton",
106 -clicked
=> \
&kill_song
,
111 $hbox = new Gtk
::HBox
0, 1;
115 $vbox = new Gtk
::VBox
0, 1;
117 $hbox->pack_start($label, 0, 1, 3);
118 $hbox->pack_start($label2, 1, 1, 3);
119 $hbox->pack_start($vbox, 0, 0, 0);
121 $vbox->pack_start($button_pause, 0, 0, 1);
122 #$vbox->pack_start($button_resume, 0, 0, 1);
123 $vbox->pack_start($button_kill, 0, 0, 1);
126 #$splashimage = new Gtk::Pixmap($p,$pause_xpm)
131 my $id = Gtk
->timeout_add(250, \
&update_song
);
133 $window->signal_connect('destroy', sub { Gtk
->exit(0); });
138 # Gnome::Panel::AppletWidget;
142 my $newmtime = (stat $conf{statusfile
})[9];
144 if($newmtime != $mtime) {
146 if(open F
, $conf{statusfile
}) {
147 my ($nowplaying, $filename);
148 chop($nowplaying = <F
>);
149 chop($filename = <F
>);
151 $playerpid = 0 + <F
>;
152 chop ((undef, undef, undef, undef,
153 $now_playing->{artist
},
154 $now_playing->{title
},
155 $now_playing->{album
},
156 $now_playing->{track
}) = <F
>);
159 if($nowplaying > 0) {
160 my $query = "SELECT song.title as title,artist.name as artist,album.name as album,song.id,song.track" .
161 " FROM song,artist,album" .
163 " AND song.artist_id=artist.id AND song.album_id=album.id";
165 if($dbh = DBI
->connect("DBI:$conf{db_type}:$conf{db_name}:$conf{db_host}", $conf{db_user
}, $conf{db_pass
})) {
166 my $sth = $dbh->prepare($query);
167 my $rv = $sth->execute($nowplaying);
168 if(my $n = $sth->fetchrow_hashref) {
174 $label->set_text(sprintf("%s\n%s\n[%02d] %s",
175 $now_playing->{artist
},
176 $now_playing->{title
},
177 $now_playing->{track
},
178 $now_playing->{album
}));
180 $filename =~ /^(.*)\/(.*?
)$/;
181 $label->set_text("$1\n$2\n");
184 $label->set_text("** soepkiptngd not running!\n\n");
189 # my $p = is_paused($playerpid);
190 # if($p != $paused) {
192 # $button_pause->set_title("Resume");
194 # $button_pause->set_title("Pause");