summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorOlivier Blin <oblin@mandriva.com>2008-03-11 18:58:01 +0000
committerOlivier Blin <oblin@mandriva.com>2008-03-11 18:58:01 +0000
commit59e824737470e36305de16acc5f0b9518c1cc287 (patch)
treef7a18ce42a11a0df0ca583ef04702e36b39a1cc1 /bin
parent3c748f9670a42548d7a2463e852c798b0547830b (diff)
downloaddrakguard-59e824737470e36305de16acc5f0b9518c1cc287.tar
drakguard-59e824737470e36305de16acc5f0b9518c1cc287.tar.gz
drakguard-59e824737470e36305de16acc5f0b9518c1cc287.tar.bz2
drakguard-59e824737470e36305de16acc5f0b9518c1cc287.tar.xz
drakguard-59e824737470e36305de16acc5f0b9518c1cc287.zip
initial drakguard mockup
Diffstat (limited to 'bin')
-rwxr-xr-xbin/drakguard160
1 files changed, 160 insertions, 0 deletions
diff --git a/bin/drakguard b/bin/drakguard
new file mode 100755
index 0000000..769889d
--- /dev/null
+++ b/bin/drakguard
@@ -0,0 +1,160 @@
+#!/usr/bin/perl
+
+use lib qw(/usr/lib/libDrakX);
+# i18n: IMPORTANT: to get correct namespace (drakguard instead of libDrakX)
+BEGIN { unshift @::textdomains, 'drakguard' }
+use strict;
+use diagnostics;
+use common;
+use standalone;
+use mygtk2;
+use ugtk2 qw(:create :helpers :wrappers);
+use Gtk2::SimpleList;
+use interactive;
+
+my $toolname = 'drakguard';
+my $title = N("Parental Control");
+my $icon = "IC-control-52";
+
+$ugtk2::wm_icon = $icon;
+my $w = ugtk2->new(N($title));
+#- so that transient_for is defined, for wait messages and popups to be centered
+$::main_window = $w->{real_window};
+my $in = interactive->vnew('su');
+
+my $allusers_list = Gtk2::SimpleList->new(N("All users") => 'text');
+$allusers_list->get_selection->set_mode('multiple');
+@{$allusers_list->{data}} = sort(list_users());
+
+my $users_list = Gtk2::SimpleList->new(N("Allowed users") => 'text');
+$users_list->get_selection->set_mode('multiple');
+
+my $whitelist = Gtk2::SimpleList->new(N("Allowed addresses") => 'text');
+$whitelist->get_selection->set_mode('multiple');
+my $blacklist = Gtk2::SimpleList->new(N("Forbidden addresses") => 'text');
+$blacklist->get_selection->set_mode('multiple');
+
+my $whitelist = Gtk2::SimpleList->new(N("Allowed addresses") => 'text');
+$whitelist->get_selection->set_mode('multiple');
+
+my ($enable, $level, $time_control, $allow_time_change);
+$level ||= "Normal";
+
+sub update_time_change {
+ gtkval_modify(\$allow_time_change, $enable && $time_control);
+}
+
+gtkadd($w->{window},
+ gtknew('VBox', spacing => 5, children => [
+ $::isEmbedded ? () : (0, Gtk2::Banner->new($icon, $title)),
+ 1, gtknew('Notebook', children => [
+ gtknew('Label', text => N("Configuration")),
+ gtknew('VBox', spacing => 5, border_width => 5, children => [
+ 1, gtknew('WrappedLabel', text => N("This tool allows to configure parental control. It can block access to web sites and restrict connection during a specified timeframe.")),
+ 1, gtknew('Label'),
+ 0, gtknew('Title2', label => N("Main options")),
+ 0, gtknew('CheckButton', text => N("Enable parental control"),
+ active_ref => \$enable, toggled => \&update_time_change),
+ 0, gtknew('HBox', children_tight => [
+ gtknew('Label_Left', text_markup => N("Control level"),
+ alignment => [ 0, 0.5 ]),
+ gtknew('ComboBox',
+ list => [ N_("Low"), N_("Normal"), N_("High") ],
+ text_ref => \$level,
+ sensitive_ref => \$enable,
+ format => \&translate),
+ ]),
+ 1, gtknew('Label'),
+ 0, gtknew('Title2', label => N("User access")),
+ 0, gtknew('HBox', spacing => 5, children_tight => [
+ $allusers_list,
+ gtknew('VBox', spacing => 5, children_tight => [
+ gtknew('Button', text => N("Add")),
+ gtknew('Button', text => N("Remove")),
+ ]),
+ $users_list,
+ ]),
+ 1, gtknew('Label'),
+ 0, gtknew('Title2', label => N("Time control")),
+ 0, gtknew('CheckButton', text => N("Allow connections only between these times:"),
+ active_ref => \$time_control, sensitive_ref => \$enable,
+ toggled => \&update_time_change),
+ 0, gtknew('HBox', spacing => 20, children_tight => [
+ gtknew('Label', text => N("Start:")),
+ gtknew('HBox', spacing => 2, children_tight => [
+ gtknew('SpinButton', lower => 0, upper => 24, step_increment => 1, value => 18,
+ sensitive_ref => \$allow_time_change),
+ gtknew('Label', text => ':'),
+ gtknew('SpinButton', lower => 0, upper => 60, step_increment => 1,
+ sensitive_ref => \$allow_time_change),
+ ]),
+ gtknew('Label'),
+ gtknew('Label', text => N("End:")),
+ gtknew('HBox', spacing => 2, children_tight => [
+ gtknew('SpinButton', lower => 0, upper => 24, step_increment => 1, value => 21,
+ sensitive_ref => \$allow_time_change),
+ gtknew('Label', text => ':'),
+ gtknew('SpinButton', lower => 0, upper => 60, step_increment => 1,
+ sensitive_ref => \$allow_time_change),
+ ]),
+ ]),
+ ]),
+ gtknew('Label', text => N("Blacklist")),
+ gtknew('VBox', spacing => 5, children => [
+ 1, gtknew('ScrolledWindow', width => 500, height => 300, child => $blacklist),
+ 0, gtknew('HButtonBox', border_width => 5, layout => 'edge', children_loose => [
+ gtknew('Button', text => N("Remove from blacklist"), clicked => sub { unblacklist(get_selected_blacklist()) }),
+ gtknew('Button', text => N("Close"), clicked => sub { Gtk2->main_quit })
+ ]),
+ ]),
+ gtknew('Label', text => N("Whitelist")),
+ gtknew('VBox', spacing => 5, children => [
+ 1, gtknew('ScrolledWindow', width => 500, height => 300, child => $whitelist),
+ 0, gtknew('HButtonBox', border_width => 5, layout => 'edge', children_loose => [
+ gtknew('Button', text => N("Remove from whitelist"), clicked => sub { unwhitelist(get_selected_whitelist()) }),
+ gtknew('Button', text => N("Close"), clicked => sub { Gtk2->main_quit })
+ ]),
+ ]),
+ ]),
+ 0, $w->create_okcancel(
+ undef, undef, undef,
+ [ N("Help"), sub { run_program::raw({ detach => 1 }, 'drakhelp', '--id', $toolname) } ]),
+ ]),
+);
+
+$w->show;
+Gtk2->main;
+
+ugtk2::exit(0);
+
+sub list_remove_addr {
+ my ($list, @addr) = @_;
+ #- workaround buggy Gtk2::SimpleList array abstraction, it destroys references
+ @$list = map { member($_->[0], @addr) ? () : [ @$_ ] } @$list;
+}
+
+sub get_selected_blacklist() {
+ uniq(map { $blacklist->{data}[$_][0] } $blacklist->get_selected_indices);
+}
+
+sub blacklist {
+ my @addr = @_;
+}
+
+sub unblacklist {
+ my @addr = @_;
+ list_remove_addr($blacklist->{data}, @addr);
+}
+
+sub get_selected_whitelist() {
+ uniq(map { $whitelist->{data}[$_][0] } $whitelist->get_selected_indices);
+}
+
+sub whitelist {
+ my @addr = @_;
+}
+
+sub unwhitelist {
+ my @addr = @_;
+ list_remove_addr($whitelist->{data}, @addr);
+}