App-Chart
view release on metacpan or search on metacpan
lib/App/Chart/Gtk2/VacuumDialog.pm view on Meta::CPAN
# Copyright 2008, 2009, 2010, 2011, 2012 Kevin Ryde
# This file is part of Chart.
#
# Chart is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3, or (at your option) any later version.
#
# Chart is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with Chart. If not, see <http://www.gnu.org/licenses/>.
# FIXME: consistency checks mark as historical things merely not downloaded
# for a while
package App::Chart::Gtk2::VacuumDialog;
use 5.010;
use strict;
use warnings;
use Gtk2;
use Locale::TextDomain ('App-Chart');
use Glib::Ex::ConnectProperties;
use Gtk2::Ex::Units;
use App::Chart::Glib::Ex::MoreUtils;
use App::Chart;
use base 'App::Chart::Gtk2::Ex::ToplevelSingleton';
use Glib::Object::Subclass
'Gtk2::Dialog',
signals => { destroy => \&_do_destroy };
use constant { RESPONSE_START => 0,
RESPONSE_STOP => 1,
RESPONSE_CLEAR => 2 };
# sub popup {
# my ($class) = @_;
# require Gtk2::Ex::WidgetCursor;
# Gtk2::Ex::WidgetCursor->busy;
# my $dialog = $class->instance;
# $dialog->present;
# return $dialog;
# }
sub INIT_INSTANCE {
my ($self) = @_;
$self->set_title (__('Chart: Vacuum'));
$self->add_buttons (__('_Start') => $self->RESPONSE_START,
__('_Stop') => $self->RESPONSE_STOP,
'gtk-clear' => $self->RESPONSE_CLEAR,
'gtk-close' => 'close',
'gtk-help' => 'help');
$self->signal_connect (response => \&_do_response);
my $vbox = $self->vbox;
my $heading = Gtk2::Label->new (__"Compact and clean out the database.\n(May take a while if the database is big.)");
$heading->set (justify => 'center');
$vbox->pack_start ($heading, 0,0,0);
{
my $button = $self->{'consistency'}
= Gtk2::CheckButton->new_with_label (__('Consistency Checks'));
$button->set_active (1);
$vbox->pack_start ($button, 0, 0, 0);
}
{
my $button = $self->{'compact'}
= Gtk2::CheckButton->new_with_label (__('Compact Files'));
$button->set_active (1);
$vbox->pack_start ($button, 0, 0, 0);
}
{
my $button = $self->{'verbose'}
= Gtk2::CheckButton->new_with_label (__('Verbose'));
$vbox->pack_start ($button, 0, 0, 0);
}
my $textbuf = $self->{'textbuf'} = Gtk2::TextBuffer->new;
# clear button sensitive when there is in fact something to clear
Glib::Ex::ConnectProperties->new
([$textbuf, 'textbuffer#not-empty'],
[$self, 'response-sensitive#'.$self->RESPONSE_CLEAR]);
require Gtk2::Ex::TextView::FollowAppend;
my $textview = $self->{'textview'}
= Gtk2::Ex::TextView::FollowAppend->new_with_buffer ($textbuf);
$textview->set (wrap_mode => 'char',
editable => 0);
my $scrolled = Gtk2::ScrolledWindow->new();
$scrolled->add($textview);
$scrolled->set_policy('never', 'always');
$vbox->pack_start ($scrolled, 1, 1, 0);
my $status = $self->{'status'}
= Gtk2::Label->new ("Press Start to begin vacuuming ...\n");
$vbox->pack_start ($status, 0,0,0);
( run in 0.482 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )