summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorGuillaume Cottenceau <gc@mandriva.com>2002-12-03 13:12:23 +0000
committerGuillaume Cottenceau <gc@mandriva.com>2002-12-03 13:12:23 +0000
commit6c11366dd6fea8ce8ff8039873aa30ecd4a60be5 (patch)
tree5996b94fb57a3866decf68e449a00a95db7a3dfe /perl-install
parent23c259c90cbed0280c9e23b3c9763363c148c472 (diff)
downloaddrakx-backup-do-not-use-6c11366dd6fea8ce8ff8039873aa30ecd4a60be5.tar
drakx-backup-do-not-use-6c11366dd6fea8ce8ff8039873aa30ecd4a60be5.tar.gz
drakx-backup-do-not-use-6c11366dd6fea8ce8ff8039873aa30ecd4a60be5.tar.bz2
drakx-backup-do-not-use-6c11366dd6fea8ce8ff8039873aa30ecd4a60be5.tar.xz
drakx-backup-do-not-use-6c11366dd6fea8ce8ff8039873aa30ecd4a60be5.zip
gtk2
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/diskdrake/hd_gtk.pm60
-rw-r--r--perl-install/diskdrake/smbnfs_gtk.pm34
-rw-r--r--perl-install/install_gtk.pm76
-rw-r--r--perl-install/install_steps_gtk.pm125
-rw-r--r--perl-install/interactive/gtk.pm318
-rw-r--r--perl-install/mouse.pm144
-rw-r--r--perl-install/services.pm36
7 files changed, 402 insertions, 391 deletions
diff --git a/perl-install/diskdrake/hd_gtk.pm b/perl-install/diskdrake/hd_gtk.pm
index 36336b8c1..9ccfb3da4 100644
--- a/perl-install/diskdrake/hd_gtk.pm
+++ b/perl-install/diskdrake/hd_gtk.pm
@@ -5,7 +5,7 @@ use strict;
use common;
use resize_fat::main;
-use my_gtk qw(:helpers :wrappers :ask);
+use ugtk2 qw(:helpers :wrappers :create);
use partition_table qw(:types);
use partition_table::raw;
use detect_devices;
@@ -54,22 +54,22 @@ sub main {
local $in->{grab} = 1;
- $w = my_gtk->new('DiskDrake');
+ $w = ugtk2->new('DiskDrake');
my $rc = "/usr/share/libDrakX/diskdrake.rc";
-r $rc or $rc = dirname(__FILE__) . "/../diskdrake.rc";
-r $rc or $rc = dirname(__FILE__) . "/../share/diskdrake.rc";
- Gtk::Rc->parse($rc);
+ Gtk2::Rc->parse($rc);
# TODO
# is_empty_array_ref($all_hds->{raids}) or raid::stopAll;
# updateLoopback();
gtkadd($w->{window},
- gtkpack_(new Gtk::VBox(0,7),
+ gtkpack_(Gtk2::VBox->new(0,7),
0, (my $filesystems_button_box = filesystems_button_box()),
- 1, (my $notebook_widget = new Gtk::Notebook),
- 0, (my $per_kind_action_box = new Gtk::HBox(0,0)),
- 0, (my $general_action_box = new Gtk::HBox(0,0)),
+ 1, (my $notebook_widget = Gtk2::Notebook->new),
+ 0, (my $per_kind_action_box = Gtk2::HBox->new(0,0)),
+ 0, (my $general_action_box = Gtk2::HBox->new(0,0)),
),
);
my $lock;
@@ -86,14 +86,14 @@ sub main {
};
create_automatic_notebooks($notebook_widget);
- $notebook_widget->signal_connect('switch_page' => sub {
+ $notebook_widget->signal_connect(switch_page => sub {
$current_kind = $notebook[$_[2]];
$current_entry = '';
$update_all->();
});
$w->sync;
$done_button->grab_focus;
- $my_gtk::pop_it = 1;
+ $ugtk2::pop_it = 1;
$in->ask_okcancel(N("Read carefully!"), N("Please make a backup of your data first"), 1) or return
if $::isStandalone;
$in->ask_warn('',
@@ -123,7 +123,7 @@ sub try_ {
$update_all->();
if ($v && member($name, 'Done', 'Wizard')) {
- $::isEmbedded ? kill('USR1', $::CCPID) : Gtk->main_quit;
+ $::isEmbedded ? kill('USR1', $::CCPID) : Gtk2->main_quit;
}
}
@@ -134,16 +134,16 @@ sub add_kind2notebook {
my ($notebook_widget, $kind) = @_;
die if $kind->{main_box};
- $kind->{display_box} = gtkset_usize(new Gtk::HBox(0,0), $width, $height);
- $kind->{action_box} = gtkset_usize(new Gtk::VBox(0,0), 150, 180);
- $kind->{info_box} = new Gtk::VBox(0,0);
+ $kind->{display_box} = gtkset_size_request(Gtk2::HBox->new(0,0), $width, $height);
+ $kind->{action_box} = gtkset_size_request(Gtk2::VBox->new(0,0), 150, 180);
+ $kind->{info_box} = Gtk2::VBox->new(0,0);
$kind->{main_box} =
- gtkpack_(new Gtk::VBox(0,7),
+ gtkpack_(Gtk2::VBox->new(0,7),
0, $kind->{display_box},
- 1, gtkpack_(new Gtk::HBox(0,7),
+ 1, gtkpack_(Gtk2::HBox->new(0,7),
0, $kind->{action_box},
1, $kind->{info_box}));
- my_gtk::add2notebook($notebook_widget, $kind->{name}, $kind->{main_box});
+ ugtk2::add2notebook($notebook_widget, $kind->{name}, $kind->{main_box});
push @notebook, $kind;
$kind;
}
@@ -155,7 +155,7 @@ sub general_action_box {
diskdrake::interactive::general_possible_actions($in, $all_hds),
N_("Done"));
foreach my $s (@actions) {
- my $button = new Gtk::Button(translate($s));
+ my $button = Gtk2::Button->new(translate($s));
$done_button = $button if $s eq 'Done';
gtkadd($box, gtksignal_connect($button, clicked => sub { try($s) }));
}
@@ -168,7 +168,7 @@ sub per_kind_action_box {
foreach my $s (diskdrake::interactive::hd_possible_actions($in, kind2hd($kind), $all_hds)) {
gtkadd($box,
- gtksignal_connect(new Gtk::Button(translate($s)),
+ gtksignal_connect(Gtk2::Button->new(translate($s)),
clicked => sub { try($s, kind2hd($kind)) }));
}
}
@@ -179,20 +179,20 @@ sub per_entry_action_box {
if ($entry) {
my @buttons = map {
my $s = $_;
- my $w = new Gtk::Button(translate($s));
+ my $w = Gtk2::Button->new(translate($s));
$w->signal_connect(clicked => sub { try($s, kind2hd($kind), $entry) });
$w;
} diskdrake::interactive::part_possible_actions($in, kind2hd($kind), $entry, $all_hds);
- gtkadd($box, gtkadd(new Gtk::Frame(N("Choose action")),
- createScrolledWindow(gtkpack__(new Gtk::VBox(0,0), @buttons)))) if @buttons;
+ gtkadd($box, gtkadd(Gtk2::Frame->new(N("Choose action")),
+ create_scrolled_window(gtkpack__(Gtk2::VBox->new(0,0), @buttons)))) if @buttons;
} else {
my $txt = !$::isStandalone && fsedit::is_one_big_fat($all_hds->{hds}) ?
N("You have one big FAT partition
(generally used by MicroSoft Dos/Windows).
I suggest you first resize that partition
(click on it, then click on \"Resize\")") : N("Please click on a partition");
- gtkpack($box, gtktext_insert(new Gtk::Text, $txt));
+ gtkpack($box, gtktext_insert(Gtk2::TextView->new, $txt));
}
}
@@ -205,7 +205,7 @@ sub per_entry_info_box {
} elsif ($kind->{type} =~ /hd|lvm/) {
$info = diskdrake::interactive::format_hd_info($kind->{val});
}
- gtkpack($box, gtkadd(new Gtk::Frame(N("Details")), gtkset_justify(new Gtk::Label($info), 'left')));
+ gtkpack($box, gtkadd(Gtk2::Frame->new(N("Details")), gtkset_justify(Gtk2::Label->new($info), 'left')));
}
sub current_kind_changed {
@@ -271,13 +271,13 @@ sub create_buttons4partitions {
}
foreach my $entry (@parts) {
- my $w = new Gtk::Button($entry->{mntpoint} || '') or die '';
+ my $w = Gtk2::Button->new($entry->{mntpoint} || '') or die '';
$w->signal_connect(focus_in_event => sub { current_entry_changed($kind, $entry) });
$w->signal_connect(button_press_event => sub { current_entry_changed($kind, $entry) });
$w->signal_connect(key_press_event => sub {
- my ($w, $e) = @_;
- $e->{state} & 4 or return;
- my $c = chr $e->{keyval};
+ my (undef, $event) = @_;
+ member('control-mask', @{$event->state}) or return;
+ my $c = chr $event->keyval;
foreach my $s (diskdrake::interactive::part_possible_actions($in, kind2hd($kind), $entry, $all_hds)) {
${{
@@ -293,7 +293,7 @@ sub create_buttons4partitions {
}
});
$w->set_name("PART_" . type2name($entry->{type}));
- $w->set_usize($entry->{size} * $ratio + $minwidth, 0);
+ $w->set_size_request($entry->{size} * $ratio + $minwidth, 0);
gtkpack__($kind->{display_box}, $w);
$w->grab_focus if $current_entry && fsedit::is_same_part($current_entry, $entry);
}
@@ -327,9 +327,9 @@ sub filesystems_button_box() {
N_("Other"), N_("Empty"));
my %name2type = (Ext2 => 0x83, 'Journalised FS' => 0x483, Swap => 0x82, Other => 1, FAT => 0xb, HFS => 0x402);
- gtkpack(new Gtk::HBox(0,0),
+ gtkpack(Gtk2::HBox->new(0,0),
N("Filesystem types:"),
- map { my $w = new Gtk::Button(translate($_));
+ map { my $w = Gtk2::Button->new(translate($_));
my $t = $name2type{$_};
$w->signal_connect(clicked => sub { try_('', \&createOrChangeType, $t, current_hd(), current_part()) });
$w->can_focus(0);
diff --git a/perl-install/diskdrake/smbnfs_gtk.pm b/perl-install/diskdrake/smbnfs_gtk.pm
index 5e901fd9e..4b1eee633 100644
--- a/perl-install/diskdrake/smbnfs_gtk.pm
+++ b/perl-install/diskdrake/smbnfs_gtk.pm
@@ -10,7 +10,7 @@ use common;
use interactive;
use network::smb;
use network::nfs;
-use my_gtk qw(:helpers :wrappers :ask);
+use ugtk2 qw(:helpers :wrappers :create);
my ($all_hds, $in, $tree, $current_entry, $current_leaf, %icons);
@@ -18,11 +18,11 @@ sub main {
($in, $all_hds, my $type) = @_;
my ($kind) = $type eq 'smb' ? smb2kind() : nfs2kind();
{
- local $my_gtk::pop_it = 1;
+ local $ugtk2::pop_it = 1;
$kind->check($in) or return;
}
- my $w = my_gtk->new('DiskDrake');
+ my $w = ugtk2->new('DiskDrake');
add_smbnfs($w->{window}, $kind);
$w->{rwindow}->set_default_size(400, 300) if $w->{rwindow}->can('set_default_size');
@@ -45,7 +45,7 @@ sub try_ {
$in->ask_warn(N("Error"), formatError($err));
}
update($kind);
- Gtk->main_quit if member($name, 'Cancel', 'Done');
+ Gtk2->main_quit if member($name, 'Cancel', 'Done');
}
sub raw_hd_options {
@@ -61,12 +61,12 @@ sub raw_hd_mount_point {
sub per_entry_info_box {
my ($box, $kind, $entry) = @_;
- $_->isa('Gtk::Button') or $_->destroy foreach map { $_->widget } $box->children;
+ $_->isa('Gtk2::Button') or $_->destroy foreach map { $_->widget } $box->children;
my $info;
if ($entry) {
$info = diskdrake::interactive::format_raw_hd_info($entry);
}
- gtkpack($box, gtkadd(new Gtk::Frame(N("Details")), gtkset_justify(new Gtk::Label($info), 'left')));
+ gtkpack($box, gtkadd(Gtk2::Frame->new(N("Details")), gtkset_justify(Gtk2::Label->new($info), 'left')));
}
sub per_entry_action_box {
@@ -77,7 +77,7 @@ sub per_entry_action_box {
push @buttons, map {
my $s = $_;
- gtksignal_connect(new Gtk::Button(translate($s)), clicked => sub { try($kind, $s, {}, $entry) });
+ gtksignal_connect(Gtk2::Button->new(translate($s)), clicked => sub { try($kind, $s, {}, $entry) });
} (if_($entry->{isMounted}, N_("Unmount")),
if_($entry->{mntpoint} && !$entry->{isMounted}, N_("Mount"))) if $entry;
@@ -89,10 +89,10 @@ sub per_entry_action_box {
);
push @buttons, map {
my ($txt, $f) = @$_;
- gtksignal_connect(new Gtk::Button(translate($txt)), clicked => sub { try_($kind, $txt, $f, $entry) });
+ gtksignal_connect(Gtk2::Button->new(translate($txt)), clicked => sub { try_($kind, $txt, $f, $entry) });
} group_by2(@l);
- gtkadd($box, gtkpack(new Gtk::HBox(0,0), @buttons));
+ gtkadd($box, gtkpack(Gtk2::HBox->new(0,0), @buttons));
}
sub done {
@@ -133,7 +133,7 @@ sub import_ctree {
my ($kind, $info_box) = @_;
my (%servers_displayed, %wservers, %wexports, $inside);
- $tree = Gtk::CTree->new(1, 0);
+ $tree = Gtk2::CTree->new(1, 0);
$tree->set_column_auto_resize(0, 1);
$tree->set_selection_mode('browse');
$tree->set_row_height($tree->style->font->ascent + $tree->style->font->descent + 1);
@@ -197,7 +197,7 @@ sub import_ctree {
};
{
- my $search = new Gtk::Button(N("Search servers"));
+ my $search = Gtk2::Button->new(N("Search servers"));
gtkpack__($info_box,
gtksignal_connect($search,
clicked => sub {
@@ -221,7 +221,7 @@ sub import_ctree {
} else {
if (!$curr->row->children) {
gtkset_mousecursor_wait($tree->window);
- my_gtk::flush();
+ ugtk2::flush();
$add_exports->($curr);
gtkset_mousecursor_normal($tree->window);
}
@@ -237,13 +237,13 @@ sub add_smbnfs {
my ($widget, $kind) = @_;
die if $kind->{main_box};
- $kind->{info_box} = new Gtk::VBox(0,0);
+ $kind->{info_box} = Gtk2::VBox->new(0,0);
$kind->{display_box} = createScrolledWindow(import_ctree($kind, $kind->{info_box}));
- $kind->{action_box} = new Gtk::HBox(0,0);
+ $kind->{action_box} = Gtk2::HBox->new(0,0);
$kind->{main_box} =
- gtkpack_(new Gtk::VBox(0,7),
- 1, gtkpack(new Gtk::HBox(0,7),
- gtkset_usize($kind->{display_box}, 200, 0),
+ gtkpack_(Gtk2::VBox->new(0,7),
+ 1, gtkpack(Gtk2::HBox->new(0,7),
+ gtkset_size_request($kind->{display_box}, 200, 0),
$kind->{info_box}),
0, $kind->{action_box},
);
diff --git a/perl-install/install_gtk.pm b/perl-install/install_gtk.pm
index a12146948..62fe43fb4 100644
--- a/perl-install/install_gtk.pm
+++ b/perl-install/install_gtk.pm
@@ -3,7 +3,7 @@ package install_gtk; # $Id$
use diagnostics;
use strict;
-use my_gtk qw(:helpers :wrappers);
+use ugtk2 qw(:wrappers :helpers :create);
use common;
use lang;
use devices;
@@ -20,7 +20,7 @@ sub load_rc {
my ($name) = @_;
if (my ($f) = grep { -r $_ } map { "$_/$name.rc" } ("share", $ENV{SHARE_PATH}, dirname(__FILE__))) {
- Gtk::Rc->parse($f);
+ Gtk2::Rc->parse($f);
foreach (cat_($f)) {
if (/style\s+"background"/ .. /^\s*$/) {
@background1 = map { $_ * 256 * 257 } split ',', $1 if /NORMAL.*\{(.*)\}/;
@@ -47,7 +47,7 @@ sub install_theme {
if (my ($font, $font2) = lang::get_x_fontset($o->{lang}, $::rootwidth < 800 ? 10 : 12)) {
$font2 ||= $font;
- Gtk::Rc->parse_string(qq(
+ Gtk2::Rc->parse_string(qq(
style "default-font"
{
fontset = "$font,*"
@@ -61,7 +61,6 @@ widget "*Steps*" style "small-font"
));
}
-
gtkset_background(@background1) unless $::live; #- || testing;
create_logo_window($o);
@@ -71,12 +70,12 @@ widget "*Steps*" style "small-font"
#------------------------------------------------------------------------------
sub create_big_help {
my ($o) = @_;
- my $w = my_gtk->new('', grab => 1, force_position => [ $::stepswidth, $::logoheight ]);
- $w->{rwindow}->set_usize($::logowidth, $::rootheight - $::logoheight);
+ my $w = ugtk2->new('', grab => 1, force_position => [ $::stepswidth, $::logoheight ]);
+ $w->{rwindow}->set_size_request($::logowidth, $::rootheight - $::logoheight);
gtkadd($w->{window},
- gtkpack_(new Gtk::VBox(0,0),
- 1, createScrolledWindow(gtktext_insert(new Gtk::Text, $o->{current_help})),
- 0, gtksignal_connect(my $ok = new Gtk::Button(N("Ok")), "clicked" => sub { Gtk->main_quit }),
+ gtkpack_(Gtk2::VBox->new(0,0),
+ 1, create_scrolled_window(gtktext_insert(Gtk2::TextView->new, $o->{current_help})),
+ 0, gtksignal_connect(my $ok = Gtk2::Button->new(N("Ok")), "clicked" => sub { Gtk2->main_quit }),
));
$ok->grab_focus;
$w->main;
@@ -89,15 +88,15 @@ sub create_help_window {
my $w;
if ($w = $o->{help_window}) {
- $_->destroy foreach $w->{window}->children;
+ $w->{window}->foreach(sub { $_[0]->destroy }, undef);
} else {
- $w = $o->{help_window} = bless {}, 'my_gtk';
- $w->{rwindow} = $w->{window} = new Gtk::Window;
+ $w = $o->{help_window} = bless {}, 'ugtk2';
+ $w->{rwindow} = $w->{window} = Gtk2::Window->new('toplevel');
$w->{rwindow}->set_uposition($::rootwidth - $::helpwidth, $::rootheight - $::helpheight);
- $w->{rwindow}->set_usize($::helpwidth, $::helpheight);
+ $w->{rwindow}->set_size_request($::helpwidth, $::helpheight);
$w->{rwindow}->set_title('skip');
};
- gtkadd($w->{window}, createScrolledWindow($o->{help_window_text} = new Gtk::Text));
+ gtkadd($w->{window}, create_scrolled_window($o->{help_window_text} = Gtk2::TextView->new));
$w->show;
}
@@ -109,29 +108,32 @@ sub create_steps_window {
$o->{steps_window}->destroy if $o->{steps_window};
- my $w = bless {}, 'my_gtk';
- $w->{rwindow} = $w->{window} = new Gtk::Window;
+ my $w = bless {}, 'ugtk2';
+ $w->{rwindow} = $w->{window} = Gtk2::Window->new('toplevel');
$w->{rwindow}->set_uposition(0, 0);
- $w->{rwindow}->set_usize($::stepswidth, $::stepsheight);
+ $w->{rwindow}->set_size_request($::stepswidth, $::stepsheight);
$w->{rwindow}->set_name('Steps');
$w->{rwindow}->set_events('button_press_mask');
$w->{rwindow}->set_title('skip');
#$w->show;
+ my %cache_pixbuf;
gtkadd($w->{window},
- gtkpack_(new Gtk::VBox(0,0),
+ gtkpack_(Gtk2::VBox->new(0,0),
(map { (1, $_) } map {
my $step_name = $_;
my $step = $o->{steps}{$_};
- my $darea = new Gtk::DrawingArea;
+ my $darea = Gtk2::DrawingArea->new;
my $in_button;
my $draw_pix = sub {
- my ($map, $mask) = gtkcreate_xpm($_[0]);
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $map, 0, 0,
- ($darea->allocation->[2]-$PIX_W)/2 + 3,
- ($darea->allocation->[3]-$PIX_H)/2,
- $PIX_W, $PIX_H);
+ $cache_pixbuf{$_[0]} ||= gtkcreate_pixbuf($_[0]);
+ $cache_pixbuf{$_[0]}->render_to_drawable($darea->window(),
+ $darea->style()->bg_gc('normal'),
+ 0, 0,
+ ($darea->allocation->width-$PIX_W)/2 + 3,
+ ($darea->allocation->height-$PIX_H)/2,
+ $PIX_W, $PIX_H,
+ 'none', 0, 0);
};
my $f = sub {
@@ -139,8 +141,9 @@ sub create_steps_window {
my $color = $step->{done} ? 'green' : $step->{entered} ? 'orange' : 'red';
"$ENV{SHARE_PATH}/step-$color$type.xpm";
};
- $darea->set_usize($PIX_W+3,$PIX_H);
- $darea->set_events(['exposure_mask', 'enter_notify_mask', 'leave_notify_mask', 'button_press_mask', 'button_release_mask']);
+ $darea->set_size_request($PIX_W+3,$PIX_H);
+ $darea->add_events(['exposure_mask', 'enter_notify_mask', 'leave_notify_mask',
+ 'button_press_mask', 'button_release_mask']);
$darea->signal_connect(expose_event => sub { $draw_pix->($f->('')) });
if ($step->{reachable}) {
$darea->signal_connect(enter_notify_event => sub { $in_button = 1; $draw_pix->($f->('-on')) });
@@ -148,7 +151,7 @@ sub create_steps_window {
$darea->signal_connect(button_press_event => sub { $draw_pix->($f->('-click')) });
$darea->signal_connect(button_release_event => sub { $in_button && die "setstep $step_name\n" });
}
- gtkpack_(new Gtk::HBox(0,5), 0, $darea, 0, new Gtk::Label(translate($step->{text})));
+ gtkpack_(Gtk2::HBox->new(0,5), 0, $darea, 0, Gtk2::Label->new(translate($step->{text})));
} grep {
!eval $o->{steps}{$_}{hidden};
} @{$o->{orderedSteps}})));
@@ -161,23 +164,30 @@ sub create_logo_window {
my ($o) = @_;
gtkdestroy($o->{logo_window});
- my $w = bless {}, 'my_gtk';
- $w->{rwindow} = $w->{window} = new Gtk::Window;
+
+ my $w = bless {}, 'ugtk2';
+ $w->{rwindow} = $w->{window} = Gtk2::Window->new('toplevel');
$w->{rwindow}->set_uposition($::stepswidth, 0);
- $w->{rwindow}->set_usize($::logowidth, $::logoheight);
+ $w->{rwindow}->set_size_request($::logowidth, $::logoheight);
$w->{rwindow}->set_name("logo");
$w->{rwindow}->set_title('skip');
$w->show;
my $file = $o->{meta_class} eq 'desktop' ? "logo-mandrake-Desktop.png" : "logo-mandrake.png";
$o->{meta_class} eq 'firewall' and $file = "logo-mandrake-Firewall.png";
-r $file or $file = "$ENV{SHARE_PATH}/$file";
- -r $file and gtkadd($w->{window}, gtkpng($file));
+ -r $file and gtkadd($w->{window}, gtkcreate_img($file));
$o->{logo_window} = $w;
}
#------------------------------------------------------------------------------
+sub init_gtk() {
+ Gtk2->init(\@ARGV);
+ Gtk2->set_locale;
+}
+
+#------------------------------------------------------------------------------
sub init_sizes() {
- ($::rootheight, $::rootwidth) = gtkroot()->get_size;
+ ($::rootwidth, $::rootheight) = (Gtk2::Gdk->screen_width, Gtk2::Gdk->screen_height);
$::live and $::rootheight -= 80;
#- ($::rootheight, $::rootwidth) = (min(768, $::rootheight), min(1024, $::rootwidth));
($::stepswidth, $::stepsheight) = (145, $::rootheight);
diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm
index 0837ab0a6..c054ff704 100644
--- a/perl-install/install_steps_gtk.pm
+++ b/perl-install/install_steps_gtk.pm
@@ -13,8 +13,7 @@ use pkgs;
use install_steps_interactive;
use interactive::gtk;
use common;
-use my_gtk qw(:helpers :wrappers);
-use Gtk;
+use ugtk2 qw(:helpers :wrappers :create);
use devices;
use modules;
use install_gtk;
@@ -30,7 +29,7 @@ sub new($$) {
my ($type, $o) = @_;
my $old = $SIG{__DIE__};
- $SIG{__DIE__} = sub { $_[0] !~ /my_gtk\.pm/ and goto $old };
+ $SIG{__DIE__} = sub { $_[0] !~ /ugtk2\.pm/ and goto $old };
$ENV{DISPLAY} ||= $o->{display} || ":0";
unless ($::testing) {
@@ -105,11 +104,12 @@ sub new($$) {
}
}
OK:
+ install_gtk::init_gtk();
install_gtk::init_sizes();
install_gtk::install_theme($o, install_gtk::default_theme($o));
install_gtk::create_logo_window($o);
- $my_gtk::force_center = [ $::rootwidth - $::windowwidth, $::logoheight, $::windowwidth, $::windowheight ];
+ $ugtk2::force_center = [ $::rootwidth - $::windowwidth, $::logoheight, $::windowwidth, $::windowheight ];
$o = (bless {}, ref $type || $type)->SUPER::new($o);
$o->interactive::gtk::new;
@@ -133,7 +133,7 @@ sub leavingStep {
sub charsetChanged {
my ($o) = @_;
- Gtk->set_locale;
+ Gtk2->set_locale;
install_gtk::install_theme($o);
install_gtk::create_steps_window($o);
}
@@ -157,22 +157,25 @@ sub selectInstallClass1 {
my ($o, $verif, $l, $def, $l2, $def2) = @_;
$::live || @$l == 1 || !@$l2 and return $o->SUPER::selectInstallClass1($verif, $l, $def, $l2, $def2);
- my $w = my_gtk->new(N("Install Class"));
- my $focused;
+ my $w = ugtk2->new(N("Install Class"));
+ my ($focused, @radios);
gtkadd($w->{window},
gtkpack($w->create_box_with_title(N("Please choose one of the following classes of installation:")),
- (my @radios = gtkradio($def, @$l)),
+ (@radios = gtkradio($def, @$l)),
gtkadd(create_vbox(),
map { my $v = $_;
- my $b = new Gtk::Button(translate($_));
+ my $b = Gtk2::Button->new(translate($_));
$focused = $b if $_ eq $def2;
- gtksignal_connect($b, "clicked" => sub { $w->{retval} = $v; Gtk->main_quit });
+ gtksignal_connect($b, "clicked" => sub {
+ $w->{retval} = $v;
+ mapn { $verif->($_[1]) if $_[0]->get_active } \@radios, $l;
+ Gtk2->main_quit
+ });
} @$l2)
));
$focused->grab_focus if $focused;
$w->main;
- mapn { $verif->($_[1]) if $_[0]->active } \@radios, $l;
install_gtk::create_steps_window($o);
$w->{retval};
@@ -189,7 +192,7 @@ sub selectMouse {
$old{name} eq $mouse->{name} &&
$old{device} eq $mouse->{device} && !$force and return;
- local $my_gtk::grab = 1; #- unsure a crazy mouse don't go wild clicking everywhere
+ local $ugtk2::grab = 1; #- unsure a crazy mouse don't go wild clicking everywhere
while (1) {
log::l("telling X server to use another mouse");
@@ -209,23 +212,23 @@ sub selectMouse {
sub reallyChooseGroups {
my ($o, $size_to_display, $individual, $val) = @_;
- my $w = my_gtk->new('');
- my $tips = new Gtk::Tooltips;
- my $w_size = new Gtk::Label(&$size_to_display);
+ my $w = ugtk2->new('');
+ my $tips = Gtk2::Tooltips->new;
+ my $w_size = Gtk2::Label->new(&$size_to_display);
my $entry = sub {
my ($e) = @_;
my $text = translate($o->{compssUsers}{$e}{label});
my $help = translate($o->{compssUsers}{$e}{descr});
- my $check = Gtk::CheckButton->new($text);
+ my $check = Gtk2::CheckButton->new($text);
$check->set_active($val->{$e});
$check->signal_connect(clicked => sub {
$val->{$e} = $check->get_active;
$w_size->set(&$size_to_display);
});
gtkset_tip($tips, $check, $help);
- #gtkpack_(new Gtk::HBox(0,0), 0, gtkpng($file), 1, $check);
+ #gtkpack_(Gtk2::HBox->new(0, 0), 0, gtkpng($file), 1, $check);
$check;
};
my $entries_in_path = sub {
@@ -234,13 +237,13 @@ sub reallyChooseGroups {
};
gtkadd($w->{window},
gtkpack($w->create_box_with_title(N("Package Group Selection")),
- gtkpack_(new Gtk::VBox(0,0),
- 1, gtkpack_(new Gtk::HBox(0,0),
+ gtkpack_(Gtk2::VBox->new(0, 0),
+ 1, gtkpack_(Gtk2::HBox->new(0, 0),
$o->{meta_class} eq 'server' ? (
- 1, gtkpack(new Gtk::VBox(0,0),
+ 1, gtkpack(Gtk2::VBox->new(0, 0),
$entries_in_path->('Server'),
),
- 1, gtkpack(new Gtk::VBox(0,0),
+ 1, gtkpack(Gtk2::VBox->new(0, 0),
$entries_in_path->('Graphical Environment'),
'',
$entries_in_path->('Development'),
@@ -248,14 +251,14 @@ sub reallyChooseGroups {
$entries_in_path->('Utilities'),
),
) : (
- 1, gtkpack(new Gtk::VBox(0,0),
+ 1, gtkpack(Gtk2::VBox->new(0, 0),
$entries_in_path->('Workstation'),
'',
$entry->('Development|Development'),
$entry->('Development|Documentation'),
$entry->('Development|LSB'),
),
- 0, gtkpack(new Gtk::VBox(0,0),
+ 0, gtkpack(Gtk2::VBox->new(0, 0),
$entries_in_path->('Server'),
'',
$entries_in_path->('Graphical Environment'),
@@ -263,15 +266,15 @@ sub reallyChooseGroups {
),
)),
'',
- gtkadd(new Gtk::HBox(0,0),
+ gtkadd(Gtk2::HBox->new(0, 0),
$w_size,
if_($individual, do {
- my $check = Gtk::CheckButton->new(N("Individual package selection"));
+ my $check = Gtk2::CheckButton->new(N("Individual package selection"));
$check->set_active($$individual);
$check->signal_connect(clicked => sub { $$individual = $check->get_active });
$check;
}),
- gtksignal_connect(new Gtk::Button(N("Ok")), clicked => sub { Gtk->main_quit }),
+ gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub { Gtk2->main_quit }),
),
),
);
@@ -441,17 +444,17 @@ sub installPackages {
my ($current_total_size, $last_size, $nb, $total_size, $start_time, $last_dtime, $trans_progress_total);
- my $w = my_gtk->new(N("Installing"));
+ my $w = ugtk2->new(N("Installing"));
$w->sync;
- my $text = new Gtk::Label;
+ my $text = Gtk2::Label->new;
my ($advertising, $change_time, $i);
my $show_advertising if 0;
$show_advertising = to_bool(@install_any::advertising_images) if !defined $show_advertising;
- my ($msg, $msg_time_remaining, $msg_time_total) = map { new Gtk::Label($_) } '', (N("Estimating")) x 2;
- my ($progress, $progress_total) = map { new Gtk::ProgressBar } (1..2);
- $w->{rwindow}->set_policy(1, 1, 1);
- gtkadd($w->{window}, my $box = new Gtk::VBox(0,10));
- $box->pack_end(gtkshow(gtkpack(gtkset_usize(new Gtk::VBox(0,5), $::windowwidth * 0.6, 0),
+ my ($msg, $msg_time_remaining, $msg_time_total) = map { Gtk2::Label->new($_) } '', (N("Estimating")) x 2;
+ my ($progress, $progress_total) = map { Gtk2::ProgressBar->new } (1..2);
+ $w->{rwindow}->set_resizable(0); #- so that it will auto shrink when passing from adverts to details
+ gtkadd($w->{window}, my $box = Gtk2::VBox->new(0,10));
+ $box->pack_end(gtkshow(gtkpack(gtkset_size_request(Gtk2::VBox->new(0,5), $::windowwidth * 0.6, -1),
$msg, $progress,
create_packtable({},
[N("Time remaining "), $msg_time_remaining],
@@ -460,8 +463,8 @@ sub installPackages {
$text,
$progress_total,
gtkadd(create_hbox(),
- my $cancel = new Gtk::Button(N("Cancel")),
- my $details = new Gtk::Button(N("Details")),
+ my $cancel = Gtk2::Button->new(N("Cancel")),
+ my $details = Gtk2::Button->new(N("Details")),
),
)), 0, 1, 0);
$details->hide if !@install_any::advertising_images;
@@ -482,23 +485,18 @@ sub installPackages {
my ($draw_text, $width, $height, @data, $icon, $icon_dx, $icon_dy, $icon_px);
-e $pl and $draw_text = 1;
eval(cat_($pl)) if $draw_text;
- my ($pix, undef) = gtkcreate_png($f);
- if ($icon) {
- ($icon_px, undef) = gtkcreate_png($icon_name);
- }
+ my $pix = gtkcreate_pixbuf($f);
+ $icon_px = gtkcreate_pixbuf($icon_name) if $icon;
my $dbl_area;
- my $darea = new Gtk::DrawingArea;
+ my $darea = Gtk2::DrawingArea->new;
gtkpack($box, $advertising = !$draw_text ?
- gtkpng($f) :
- gtksignal_connect(gtkset_usize($darea, $width, $height), expose_event => sub {
- my ($dx, $dy) = ($darea->allocation->[2], $darea->allocation->[3]);
+ gtkcreate_img($f) :
+ gtksignal_connect(gtkset_size_request($darea, $width, $height), expose_event => sub {
+ my (undef, undef, $dx, $dy) = $darea->allocation->values;
if (!defined($dbl_area)) {
- $dbl_area = new Gtk::Gdk::Pixmap($darea->window, $dx, $dy);
- $dbl_area->draw_rectangle($darea->style->bg_gc('active'), 1, 0, 0, $dx, $dy);
- $dbl_area->draw_pixmap($darea->style->bg_gc('normal'),
- $pix, 0, 0, ($dx-$width)/2, 0, $width, $height);
- my $gc_text = new Gtk::Gdk::GC($darea->window);
- $gc_text->set_foreground(gtkcolor(65535, 65535, 65535));
+ $darea->window->draw_rectangle($darea->style->bg_gc('active'), 1, 0, 0, $dx, $dy);
+ $pix->render_to_drawable($darea->window, $darea->style->bg_gc('normal'), 0, 0,
+ ($dx-$width)/2, 0, $width, $height, 'none', 0, 0);
my $yicon = 0;
my $decy = 0;
my $first = 1;
@@ -510,25 +508,28 @@ sub installPackages {
my $iconx = ($dx-$width)/2 + $x + ${$widths}[0] - $icon_dx;
my $icony = $y + ${$heights}[0] - $icon_dy/2;
$icony > 0 or $icony = 0;
- $dbl_area->draw_pixmap($darea->style->bg_gc('normal'), $icon_px, 0, 0,
- $iconx, $icony, $icon_dx, $icon_dy
- );
+ $icon_px->render_to_drawable($darea->window, $darea->style->bg_gc('normal'), 0, 0,
+ $iconx, $icony, $icon_dx, $icon_dy, 'none', 0, 0);
$yicon = $icony + $icon_dy;
}
my $i = 0;
$yicon > $y + ${$heights}[0] and $decy = $yicon - ($y + ${$heights}[$i]);
foreach (@{$lines}) {
- $dbl_area->draw_string($darea->style->font, $gc_text,
- ($dx-$width)/2 + $x + ${$widths}[$i], ($first ? 0 : $decy) + $y + ${$heights}[$i], $_);
- $bold and $dbl_area->draw_string($darea->style->font, $gc_text,
- ($dx-$width)/2 + $x + ${$widths}[$i] + 1, ($first ? 0 : $decy) + $y + ${$heights}[$i], $_);
+ my $layout = $darea->create_pango_layout($_);
+ $darea->window->draw_layout($darea->style->white_gc,
+ ($dx-$width)/2 + $x + ${$widths}[$i],
+ ($first ? 0 : $decy) + $y + ${$heights}[$i],
+ $layout);
+ $darea->window->draw_layout($darea->style->white_gc,
+ ($dx-$width)/2 + $x + ${$widths}[$i] + 1,
+ ($first ? 0 : $decy) + $y + ${$heights}[$i],
+ $layout);
+ $layout->unref;
$i++;
}
$first = 0;
}
}
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $dbl_area, 0, 0, 0, 0, $dx, $dy);
}));
} else {
$advertising = undef;
@@ -553,7 +554,7 @@ sub installPackages {
$msg->set(N("%d packages", $nb));
$w->flush;
} elsif ($type eq 'inst' && $subtype eq 'start') {
- $progress->update(0);
+ $progress->set_fraction(0);
my $p = $data->{depslist}[$id];
$msg->set(N("Installing package %s", $p->name));
$current_total_size += $last_size;
@@ -562,7 +563,7 @@ sub installPackages {
$advertize->(1) if $show_advertising && $total_size > 20_000_000 && time() - $change_time > 20;
$w->flush;
} elsif ($type eq 'inst' && $subtype eq 'progress') {
- $progress->update($total ? $amount / $total : 0);
+ $progress->set_fraction($total ? $amount / $total : 0);
my $dtime = time() - $start_time;
my $ratio =
@@ -571,7 +572,7 @@ sub installPackages {
$ratio >= 1 and $ratio = 1;
my $total_time = $ratio ? $dtime / $ratio : time();
- $progress_total->update($ratio);
+ $progress_total->set_fraction($ratio);
if ($dtime != $last_dtime && $current_total_size > 80_000_000) {
$msg_time_total->set(formatTime(10 * round($total_time / 10) + 10));
#- $msg_time_total->set(formatTimeRaw($total_time) . " " . formatTimeRaw($dtime / $ratio2));
@@ -588,7 +589,7 @@ sub installPackages {
#- if not using a cdrom medium, always abort.
if ($method eq 'cdrom' && !$::oem) {
- local $my_gtk::grab = 1;
+ local $ugtk2::grab = 1;
my $name = pkgs::mediumDescr($o->{packages}, $medium);
local $| = 1; print "\a";
my $time = time();
diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm
index b4c09afe6..3d392fa3e 100644
--- a/perl-install/interactive/gtk.pm
+++ b/perl-install/interactive/gtk.pm
@@ -8,29 +8,29 @@ use vars qw(@ISA);
use interactive;
use common;
-use my_gtk qw(:helpers :wrappers);
+use ugtk2 qw(:helpers :wrappers :create);
my $forgetTime = 1000; #- in milli-seconds
sub new {
- ($::windowheight, $::windowwidth) = my_gtk::gtkroot()->get_size if !$::isInstall;
+ ($::windowwidth, $::windowheight) = gtkroot()->get_size if !$::isInstall;
goto &interactive::new;
}
sub enter_console { my ($o) = @_; $o->{suspended} = common::setVirtual(1) }
sub leave_console { my ($o) = @_; common::setVirtual(delete $o->{suspended}) }
-sub exit { my_gtk::exit(@_) }
+sub exit { ugtk2::exit(@_) }
sub ask_warn {
- local $my_gtk::pop_it = 1;
+ local $ugtk2::pop_it = 1;
&interactive::ask_warn;
}
sub ask_fileW {
my ($o, $title, $dir) = @_;
- my $w = my_gtk->new($title);
+ my $w = ugtk2->new($title);
$dir .= '/' if $dir !~ m|/$|;
- my_gtk::_ask_file($w, $title, $dir);
+ ugtk2::_ask_file($w, $title, $dir);
$w->main;
}
@@ -38,10 +38,10 @@ sub create_boxradio {
my ($e, $may_go_to_next, $changed, $double_click) = @_;
my @l = map { may_apply($e->{format}, $_) } @{$e->{list}};
- my $boxradio = gtkpack2__(new Gtk::VBox(0, 0),
+ my $boxradio = gtkpack2__(Gtk2::VBox->new(0, 0),
my @radios = gtkradio('', @l));
$boxradio->show;
- my $tips = new Gtk::Tooltips;
+ my $tips = Gtk2::Tooltips->new;
mapn {
my ($txt, $w) = @_;
$w->signal_connect(button_press_event => $double_click) if $double_click;
@@ -68,40 +68,34 @@ sub create_boxradio {
}, $radios[0];
}
-sub create_clist {
+sub create_treeview_list {
my ($e, $may_go_to_next, $changed, $double_click) = @_;
my $curr;
my @l = map { may_apply($e->{format}, $_) } @{$e->{list}};
- my $list = new Gtk::CList(1);
- $list->set_selection_mode('browse');
- $list->set_column_auto_resize(0, 1);
-
- my $select = sub {
- $list->set_focus_row($_[0]);
- $list->select_row($_[0], 0);
- $list->moveto($_[0], 0, 0.5, 0) if $list->row_is_visible($_[0]) ne 'full';
- };
-
-# ref $title && !@okcancel ?
-# $list->signal_connect(button_release_event => $leave) :
-# $list->signal_connect(button_press_event => sub { &$leave if $_[1]{type} =~ /^2/ });
+ my $list = Gtk2::ListStore->new(Gtk2::GType->STRING);
+ my $list_tv = Gtk2::TreeView->new_with_model($list);
+ $list_tv->set_headers_visible(0);
+ $list_tv->get_selection()->set_mode('browse');
+ my $textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new(), 'text' => 0);
+ $list_tv->append_column($textcolumn);
+
+ my $select = sub { $list_tv->set_cursor($_[0], $textcolumn, 0) };
- my ($first_time, $starting_word, $start_reg) = (1, '', "^");
+ my ($first_time, $starting_word, $start_reg) = (1, '', '^');
my $timeout;
- $list->signal_connect(key_press_event => sub {
+ $list_tv->signal_connect(key_press_event => sub {
my ($w, $event) = @_;
- my $c = chr($event->{keyval} & 0xff);
+ my $c = chr($event->keyval & 0xff);
- Gtk->timeout_remove($timeout) if $timeout; $timeout = '';
+ Gtk2->timeout_remove($timeout) if $timeout; $timeout = '';
- if ($event->{keyval} >= 0x100) {
- &$may_go_to_next if $c eq "\r" || $c eq "\x8d";
- $starting_word = '' if $event->{keyval} != 0xffe4; # control
+ if ($event->keyval >= 0x100) {
+ &$may_go_to_next if member($event->keyval, (Gtk2::Gdk::Event::Key->Sym_Return, Gtk2::Gdk::Event::Key->Sym_KP_Enter));
+ $starting_word = '' if !member($event->keyval, (Gtk2::Gdk::Event::Key->Sym_Control_L, Gtk2::Gdk::Event::Key->Sym_Control_R));
} else {
- if ($event->{state} & 4) {
- #- control pressed
- $c eq "s" or return 1;
+ if (member('control-mask', @{$event->state})) {
+ $c eq 's' or return 1;
$start_reg and $start_reg = '', return 1;
$curr++;
} else {
@@ -114,42 +108,57 @@ sub create_clist {
my $j; for ($j = 0; $j < @l; $j++) {
$l[($j + $curr) % @l] =~ /$start_reg$word/i and last;
}
- $j == @l ?
- ($starting_word = '') :
- $select->(($j + $curr) % @l);
+ if ($j == @l) {
+ $starting_word = '';
+ } else {
+ my $path = Gtk2::TreePath->new_from_string(($j + $curr) % @l);
+ $select->($path);
+ $path->free;
+ }
- $timeout = Gtk->timeout_add($forgetTime, sub { $timeout = $starting_word = ''; 0 });
+ $timeout = Gtk2->timeout_add($forgetTime, sub { $timeout = $starting_word = ''; 0 });
}
1;
});
- $list->show;
+ $list_tv->show;
- $list->append($_) foreach @l;
+ $list->append_set([ 0 => $_ ])->free foreach @l;
- $list->signal_connect(select_row => sub {
- my ($w, $row) = @_;
+ $list_tv->get_selection->signal_connect(changed => sub {
+ my ($model, $iter) = $_[0]->get_selected;
+ $model && $iter or return;
+ my $row = $model->get_path_str($iter);
+ $iter->free;
${$e->{val}} = $e->{list}[$curr = $row];
&$changed;
});
- $list->signal_connect(button_press_event => $double_click) if $double_click;
+ $list_tv->signal_connect(button_press_event => $double_click) if $double_click;
- $list, sub {
+ $list_tv, sub {
my ($v) = @_;
eval {
my $nb = find_index { $_ eq $v } @{$e->{list}};
- $select->($nb) if $nb != $list->focus_row;
+ my ($path) = $list_tv->get_cursor;
+ if ($path) {
+ $select->($path) if $nb != $path->to_string;
+ $path->free;
+ }
};
};
}
-sub create_ctree {
+sub create_treeview_tree {
my ($e, $may_go_to_next, $changed, $double_click, $tree_expanded) = @_;
my @l = map { may_apply($e->{format}, $_) } @{$e->{list}};
$tree_expanded = to_bool($tree_expanded); #- to reduce "Use of uninitialized value", especially when debugging
my $sep = quotemeta $e->{separator};
- my $tree = Gtk::CTree->new(1, 0);
+ my $tree_model = Gtk2::TreeStore->new(Gtk2::GType->STRING);
+ my $tree = Gtk2::TreeView->new_with_model($tree_model);
+ $tree->get_selection->set_mode('browse');
+ $tree->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
+ $tree->set_headers_visible(0);
my (%wtree, %wleaves, $size, $selected_via_click);
my $parent; $parent = sub {
@@ -157,7 +166,7 @@ sub create_ctree {
my $s = '';
foreach (split $sep, $_[0]) {
$wtree{"$s$_$e->{separator}"} ||=
- $tree->insert_node($s ? $parent->($s) : undef, undef, [$_], 5, (undef) x 4, 0, $tree_expanded);
+ $tree_model->append_set($s ? $parent->($s) : undef, [ 0 => $_ ]);
$size++ if !$s;
$s .= "$_$e->{separator}";
}
@@ -165,130 +174,149 @@ sub create_ctree {
};
foreach (@l) {
my ($root, $leaf) = /(.*)$sep(.+)/ ? ($1, $2) : ('', $_);
- $wleaves{$_} = $tree->insert_node($parent->($root), undef, [$leaf], 5, (undef) x 4, 1, 0);
+ my $iter = $tree_model->append_set($parent->($root), [ 0 => $leaf ]);
+ $wleaves{$_} = $tree_model->get_path_str($iter);
+ $iter->free;
}
+ $_->free foreach values %wtree;
undef %wtree;
+ #- do some precomputing to not slowdown selection change and key press
+ my (%precomp, @ordered_keys);
+ $tree_model->foreach(sub {
+ my (undef, $path_, $iter) = @_;
+ my ($path, $pathstr, @ll, $val, $listval);
+ $path = $path_->copy;
+ $pathstr = $path->to_string;
+ while ($path->get_depth) { unshift @ll, $tree_model->get($path, 0); $path->up }
+ $val = join($e->{separator}, @ll);
+ mapn { $listval = $_[1] if $val eq $_[0] } \@l, $e->{list};
+ $precomp{$pathstr} = { value => $tree_model->get($iter, 0), fullvalue => $val, listvalue => $listval };
+ push @ordered_keys, $pathstr;
+ 0
+ }, undef);
+
my $select = sub {
- my ($node) = @_;
- for (my $c = $node; $c; $c = $c->row->parent) {
- $tree->expand($c);
- }
- for (my $i = 0; $tree->node_nth($i); $i++) {
- if ($tree->node_nth($i) == $node) {
- $tree->set_focus_row($i);
- last;
- }
- }
- $tree->select($node);
- $tree->node_moveto($node, 0, 0.5, 0) if $tree->node_is_visible($node) ne 'full';
+ my ($path_str) = @_;
+ my $path = Gtk2::TreePath->new_from_string($path_str);
+ print STDERR "TODO: Gtk2::TreeView::expand_to_path segfaults as of 2.1.2, disabling it until a fix\n";
+ return;
+ $tree->expand_to_path($path);
+ $path->free;
+ $path = Gtk2::TreePath->new_from_string($path_str);
+ $tree->set_cursor($path, undef, 0);
+ $tree->scroll_to_cell($path, undef, 1, 0.5, 0);
+ $path->free;
};
- my $curr = $tree->node_nth(0); #- default value
- $tree->set_column_auto_resize(0, 1);
- $tree->set_selection_mode('browse');
- $tree->set_row_height($tree->style->font->ascent + $tree->style->font->descent + 1);
- $tree->signal_connect(tree_select_row => sub {
- $curr = $_[1];
- if ($curr->row->is_leaf) {
- my @ll; for (my $c = $curr; $c; $c = $c->row->parent) {
- unshift @ll, first $tree->node_get_pixtext($c, 0);
- }
- my $val = join $e->{separator}, @ll;
- mapn {
- ${$e->{val}} = $_[1] if $val eq $_[0]
- } \@l, $e->{list};
+ my $curr = $tree_model->get_iter_first; #- default value
+ $tree->expand_all if $tree_expanded;
+
+ $tree->get_selection->signal_connect(changed => sub {
+ my ($model, $iter) = $_[0]->get_selected;
+ $model && $iter or return;
+ $curr->free if ref $curr;
+ my $path = $tree_model->get_path($curr = $iter);
+ if (!$tree_model->iter_has_child($iter)) {
+ ${$e->{val}} = $precomp{$path->to_string}{listvalue};
&$changed;
} else {
- $tree->expand($curr) if $selected_via_click;
+ print STDERR "TODO: Gtk2::TreeView::expand_row scrolls the tree and make the expanded row invisible, disable it for now\n";
+# $tree->expand_row($path, 0) if $selected_via_click;
}
+ $path->free;
});
my ($first_time, $starting_word, $start_reg) = (1, '', "^");
my $timeout;
- my $toggle = sub {
- $curr->row->is_leaf ?
- &$may_go_to_next :
- $tree->toggle_expansion($curr);
+ my $toggle = sub {
+ if ($tree_model->iter_has_child($curr)) {
+ my $path = $tree_model->get_path($curr);
+ $tree->toggle_expansion($path, 0);
+ $path->free;
+ } else {
+ &$may_go_to_next;
+ }
};
+
$tree->signal_connect(key_press_event => sub {
my ($w, $event) = @_;
$selected_via_click = 0;
- my $c = chr($event->{keyval} & 0xff);
+ my $c = chr($event->keyval & 0xff);
$curr or return;
- Gtk->timeout_remove($timeout) if $timeout; $timeout = '';
+ Gtk2->timeout_remove($timeout) if $timeout; $timeout = '';
- if ($event->{keyval} >= 0x100) {
- &$toggle if $c eq "\r" || $c eq "\x8d";
- $starting_word = '' if $event->{keyval} != 0xffe4; # control
+ if ($event->keyval >= 0x100) {
+ &$toggle if member($event->keyval, (Gtk2::Gdk::Event::Key->Sym_Return, Gtk2::Gdk::Event::Key->Sym_KP_Enter));
+ $starting_word = '' if !member($event->keyval, (Gtk2::Gdk::Event::Key->Sym_Control_L, Gtk2::Gdk::Event::Key->Sym_Control_R));
} else {
my $next;
- if ($event->{state} & 4) {
- #- control pressed
+ if (member('control-mask', @{$event->state})) {
$c eq "s" or return 1;
$start_reg and $start_reg = '', return 1;
$next = 1;
} else {
&$toggle if $c eq ' ';
-
$next = 1 if $starting_word eq '' || $starting_word eq $c;
$starting_word .= $c unless $starting_word eq $c;
}
my $word = quotemeta $starting_word;
my ($after, $best);
- $tree->pre_recursive(undef, sub {
- my ($tree, $node) = @_;
+ my $currpath = $tree_model->get_path_str($curr);
+ foreach my $v (@ordered_keys) {
$next &&= !$after;
- $after ||= $node == $curr;
- my ($t) = $tree->node_get_pixtext($node, 0);
-
- if ($t =~ /$start_reg$word/i) {
+ $after ||= $v eq $currpath;
+ if ($precomp{$v}{value} =~ /$start_reg$word/i) {
if ($after && !$next) {
- ($best, $after) = ($node, 0);
+ ($best, $after) = ($v, 0);
} else {
- $best ||= $node;
+ $best ||= $v;
}
}
- });
+ }
+
if (defined $best) {
$select->($best);
} else {
$starting_word = '';
}
- $timeout = Gtk->timeout_add($forgetTime, sub { $timeout = $starting_word = ''; 0 });
+
+ $timeout = Gtk2->timeout_add($forgetTime, sub { $timeout = $starting_word = ''; 0 });
}
1;
});
$tree->signal_connect(button_press_event => sub {
$selected_via_click = 1;
- &$double_click if $curr->row->is_leaf && $double_click;
+ &$double_click if !$tree_model->iter_has_child($curr) && $double_click;
});
$tree, sub {
my $v = may_apply($e->{format}, $_[0]);
- $select->($wleaves{$v} || return) if $wleaves{$v} != $tree->selection;
+ my ($model, $iter) = $tree->get_selection->get_selected;
+ $select->($wleaves{$v} || return) if !$model || $wleaves{$v} ne $model->get_path_str($iter);
+ $iter->free if ref $iter;
}, $size;
}
sub create_list {
my ($e, $may_go_to_next, $changed, $double_click) = @_;
my $l = $e->{list};
- my $list = new Gtk::List();
+ my $list = Gtk2::List->new;
$list->set_selection_mode('browse');
my $select = sub {
$list->select_item($_[0]);
};
- my $tips = new Gtk::Tooltips;
+ my $tips = Gtk2::Tooltips->new;
my $toselect;
each_index {
- my $item = new Gtk::ListItem(may_apply($e->{format}, $_));
+ my $item = Gtk2::ListItem->new(may_apply($e->{format}, $_));
$item->signal_connect(key_press_event => sub {
my ($w, $event) = @_;
- my $c = chr($event->{keyval} & 0xff);
- $may_go_to_next->($event) if $event->{keyval} < 0x100 ? $c eq ' ' : $c eq "\r" || $c eq "\x8d";
+ my $c = chr($event->keyval & 0xff);
+ $may_go_to_next->($event) if $event->keyval < 0x100 ? $c eq ' ' : $c eq "\r" || $c eq "\x8d";
1;
});
$list->append_items($item);
@@ -321,12 +349,11 @@ sub ask_fromW {
my ($o, $common, $l, $l2) = @_;
my $ignore = 0; #-to handle recursivity
- my $mainw = my_gtk->new($common->{title}, %$o);
- $mainw->sync; # for XPM's creation
-
+ my $mainw = ugtk2->new($common->{title}, %$o);
+
#-the widgets
my (@widgets, @widgets_always, @widgets_advanced, $advanced, $advanced_pack, $has_horiz_scroll, $has_scroll, $total_size, $max_width);
- my $tooltips = new Gtk::Tooltips;
+ my $tooltips = Gtk2::Tooltips->new;
my $set_all = sub {
$ignore = 1;
@@ -343,15 +370,15 @@ sub ask_fromW {
$get_all->();
$f->();
$set_all->();
- };
+ };
my $create_widget = sub {
my ($e, $ind) = @_;
my $may_go_to_next = sub {
my ($w, $event, $kind) = @_;
if ($kind eq 'tab') {
- if (($event->{keyval} & 0x7f) == 0x9) {
- $w->signal_emit_stop("key_press_event");
+ if (($event->keyval & 0x7f) == 0x9) {
+ $w->signal_stop_emission_by_name('key_press_event');
if ($ind == $#widgets) {
$mainw->{ok}->grab_focus;
} else {
@@ -359,8 +386,8 @@ sub ask_fromW {
}
}
} else {
- if (!$event || ($event->{keyval} & 0x7f) == 0xd) {
- $w->signal_emit_stop("key_press_event") if $event;
+ if (!$event || ($event->keyval & 0x7f) == 0xd) {
+ $w->signal_stop_emission_by_name('key_press_event') if $event;
if ($ind == $#widgets) {
@widgets == 1 ? $mainw->{ok}->clicked : $mainw->{ok}->grab_focus;
} else {
@@ -373,13 +400,13 @@ sub ask_fromW {
my ($w, $real_w, $focus_w, $set, $get, $expand, $size, $width);
if ($e->{type} eq 'iconlist') {
- $w = new Gtk::Button;
+ $w = Gtk2::Button->new;
$set = sub {
gtkdestroy($e->{icon});
my $f = $e->{icon2f}->($_[0]);
$e->{icon} = -e $f ?
- gtkpng($f) :
- new Gtk::Label(may_apply($e->{format}, $_[0]));
+ gtkcreate_img($f) :
+ Gtk2::Label->new(may_apply($e->{format}, $_[0]));
$w->add($e->{icon});
$e->{icon}->show;
};
@@ -387,19 +414,19 @@ sub ask_fromW {
$set->(${$e->{val}} = next_val_in_array(${$e->{val}}, $e->{list}));
$changed->();
});
- $real_w = gtkpack_(new Gtk::HBox(0,10), 1, new Gtk::HBox(0,0), 0, $w, 1, new Gtk::HBox(0,0));
+ $real_w = gtkpack_(Gtk2::HBox->new(0,10), 1, Gtk2::HBox->new(0,0), 0, $w, 1, Gtk2::HBox->new(0,0));
} elsif ($e->{type} eq 'bool') {
- $w = Gtk::CheckButton->new($e->{text});
+ $w = Gtk2::CheckButton->new($e->{text});
$w->signal_connect(clicked => $changed);
$set = sub { $w->set_active($_[0]) };
$get = sub { $w->get_active };
$width = length $e->{text};
} elsif ($e->{type} eq 'label') {
- $w = Gtk::Label->new(${$e->{val}});
+ $w = Gtk2::Label->new(${$e->{val}});
$set = sub { $w->set($_[0]) };
$width = length ${$e->{val}};
} elsif ($e->{type} eq 'button') {
- $w = Gtk::Button->new('');
+ $w = Gtk2::Button->new('');
$w->signal_connect(clicked => sub {
$get_all->();
if ($::isWizard) {
@@ -409,7 +436,7 @@ sub ask_fromW {
}
if (my $v = $e->{clicked_may_quit}()) {
$mainw->{retval} = $v;
- Gtk->main_quit;
+ Gtk2->main_quit;
}
if ($::isWizard) {
$mainw->{rwindow}->set_sensitive(1);
@@ -423,7 +450,7 @@ sub ask_fromW {
} elsif ($e->{type} eq 'range') {
my $adj = create_adjustment(${$e->{val}}, $e->{min}, $e->{max});
$adj->signal_connect(value_changed => $changed);
- $w = new Gtk::HScale($adj);
+ $w = Gtk2::HScale->new($adj);
$w->set_digits(0);
$w->signal_connect(key_press_event => $may_go_to_next);
$set = sub { $adj->set_value($_[0]) };
@@ -434,23 +461,24 @@ sub ask_fromW {
my $quit_if_double_click =
#- i'm the only one, double click means accepting
@$l == 1 || $e->{quit_if_double_click} ?
- sub { if ($_[1]{type} =~ /^2/) { $mainw->{retval} = 1; Gtk->main_quit } } : '';
+ sub { if ($_[1]->type =~ /^2/) { $mainw->{retval} = 1; Gtk2->main_quit } } : '';
my @para = ($e, $may_go_to_next, $changed, $quit_if_double_click);
my $use_boxradio = exists $e->{gtk}{use_boxradio} ? $e->{gtk}{use_boxradio} : @{$e->{list}} <= 8;
if ($e->{help}) {
- #- used only when needed, as key bindings are dropped by List (CList does not seems to accepts Tooltips).
+ #- used only when needed, as key bindings are dropped by List (ListStore does not seems to accepts Tooltips).
($w, $set, $focus_w) = $use_boxradio ? create_boxradio(@para) : create_list(@para);
} elsif ($e->{type} eq 'treelist') {
- ($w, $set, $size) = create_ctree(@para, $e->{tree_expanded});
+ ($w, $set, $size) = create_treeview_tree(@para, $e->{tree_expanded});
+ $e->{saved_default_val} = ${$e->{val}}; #- during realization, signals will mess up the default val :(
} else {
- ($w, $set, $focus_w) = $use_boxradio ? create_boxradio(@para) : create_clist(@para);
+ ($w, $set, $focus_w) = $use_boxradio ? create_boxradio(@para) : create_treeview_list(@para);
}
if (@{$e->{list}} > (@$l == 1 ? 10 : 4)) {
$has_scroll = 1;
$expand = 1;
- $real_w = createScrolledWindow($w);
+ $real_w = create_scrolled_window($w);
$size = (@$l == 1 ? 10 : 4);
} else {
$size ||= @{$e->{list}};
@@ -458,7 +486,7 @@ sub ask_fromW {
$width = max(map { length } @{$e->{list}});
} else {
if ($e->{type} eq "combo") {
- $w = new Gtk::Combo;
+ $w = Gtk2::Combo->new;
$w->set_use_arrows_always(1);
$w->entry->set_editable(!$e->{not_edit});
$w->disable_activate;
@@ -481,9 +509,9 @@ sub ask_fromW {
$has_horiz_scroll = 1;
$width = $l[@l / 16]; # take the third octile (think quartile)
} else {
- $w = new Gtk::Entry;
- $w->signal_connect(focus_in_event => sub { $w->select_region });
- $w->signal_connect(focus_out_event => sub { $w->select_region(0,0) });
+ $w = Gtk2::Entry->new;
+ $w->signal_connect(focus_in_event => sub { $w->select_region(0, -1) });
+ $w->signal_connect(focus_out_event => sub { $w->select_region(0, 0) });
$set = sub { $w->set_text($_[0]) if $_[0] ne $w->get_text };
$get = sub { $w->get_text };
}
@@ -501,7 +529,7 @@ sub ask_fromW {
{ e => $e, w => $w, real_w => $real_w || $w, focus_w => $focus_w || $w, expand => $expand,
get => $get || sub { ${$e->{val}} }, set => $set || sub {},
- icon_w => $e->{icon} && eval { gtkpng($e->{icon}) } };
+ icon_w => $e->{icon} && eval { gtkcreate_img($e->{icon}) } };
};
@widgets_always = map_index { $create_widget->($_, $::i) } @$l;
my $always_total_size = $total_size;
@@ -510,11 +538,11 @@ sub ask_fromW {
my $pack = create_box_with_title($mainw, @{$common->{messages}});
- my ($totalheight, $totalwidth) = ($mainw->{box_size}, 0);
+ my ($totalwidth, $totalheight) = (0, $mainw->{box_size});
my $set_default_size = sub {
if (($has_scroll || $has_horiz_scroll) && !$mainw->{isEmbedded} && !$mainw->{isWizard}) {
- $mainw->{rwindow}->set_default_size($totalwidth+6+$my_gtk::shape_width, $has_scroll ? $totalheight+6+3+$my_gtk::shape_width : 0);
+ $mainw->{rwindow}->set_default_size($totalwidth+6+$ugtk2::shape_width, $has_scroll ? $totalheight+6+3+$ugtk2::shape_width : -1);
}
};
@@ -547,7 +575,7 @@ sub ask_fromW {
my $wantedwidth = max(250, $max_width * 5);
my $width = min($possiblewidth, $wantedwidth);
- my $wantedheight = my_gtk::n_line_size($size, 'various', $mainw->{rwindow});
+ my $wantedheight = ugtk2::n_line_size($size, 'various', $mainw->{rwindow});
my $height = min($possibleheight * $ratio, max(200, $wantedheight));
$totalheight += $height;
@@ -555,7 +583,7 @@ sub ask_fromW {
my $has = $wantedwidth > $width || $wantedheight > $height;
$has_scroll ||= $has;
- $has ? createScrolledWindow($w) : $w;
+ $has ? create_scrolled_window($w) : $w;
};
gtkpack_($pack,
@@ -565,10 +593,10 @@ sub ask_fromW {
my $has_scroll_always = $has_scroll;
my @adv = map { warp_text($_) } @{$common->{advanced_messages}};
$advanced_pack =
- gtkpack_(new Gtk::VBox(0,0),
+ gtkpack_(Gtk2::VBox->new(0,0),
0, '',
- (map { (0, new Gtk::Label($_)) } @adv),
- 0, new Gtk::HSeparator,
+ (map { (0, Gtk2::Label->new($_)) } @adv),
+ 0, Gtk2::HSeparator->new,
1, $create_widgets->($advanced_total_size, @widgets_advanced));
$pack->pack_start($advanced_pack, 1, 1, 0);
@@ -590,6 +618,8 @@ sub ask_fromW {
!$error;
}
};
+
+ $_->{set}->($_->{e}{saved_default_val} || next) foreach @widgets_always, @widgets_advanced;
$mainw->main(map { $check->($common->{callbacks}{$_}) } 'complete', 'canceled');
}
@@ -597,17 +627,17 @@ sub ask_fromW {
sub ask_browse_tree_info_refW {
my ($o, $common) = @_;
add2hash($common, { wait_message => sub { $o->wait_message(@_) } });
- my_gtk::ask_browse_tree_info($common);
+ ugtk2::ask_browse_tree_info($common);
}
sub wait_messageW($$$) {
my ($o, $title, $messages) = @_;
- local $my_gtk::pop_it = 1;
- my $w = my_gtk->new($title, %$o, grab => 1);
- gtkadd($w->{window}, my $hbox = new Gtk::HBox(0,0));
- $hbox->pack_start(my $box = new Gtk::VBox(0,0), 1, 1, 10);
- $box->pack_start($_, 1, 1, 4) foreach my @l = map { new Gtk::Label(scalar warp_text($_)) } @$messages;
+ local $ugtk2::pop_it = 1;
+ my $w = ugtk2->new($title, %$o, grab => 1);
+ gtkadd($w->{window}, my $hbox = Gtk2::HBox->new(0,0));
+ $hbox->pack_start(my $box = Gtk2::VBox->new(0,0), 1, 1, 10);
+ $box->pack_start($_, 1, 1, 4) foreach my @l = map { Gtk2::Label->new(scalar warp_text($_)) } @$messages;
($w->{wait_messageW} = $l[$#l])->signal_connect(expose_event => sub { $w->{displayed} = 1 });
$w->{rwindow}->set_position('center') if $::isStandalone && !$w->{isEmbedded} && !$w->{isWizard};
diff --git a/perl-install/mouse.pm b/perl-install/mouse.pm
index cc164e38e..f3073fd3a 100644
--- a/perl-install/mouse.pm
+++ b/perl-install/mouse.pm
@@ -422,139 +422,109 @@ sub write_conf {
sub test_mouse_install {
my ($mouse) = @_;
- require my_gtk;
- my_gtk->import(qw(:wrappers :helpers));
- my $w = my_gtk->new('', disallow_big_help => 1);
+ require ugtk2;
+ ugtk2->import(qw(:wrappers :create));
+ my $w = ugtk2->new('', disallow_big_help => 1);
my ($width, $height, $offset) = (210, round_up(min(350, $::windowheight - 150), 6), 25);
- my $darea = new Gtk::DrawingArea;
+ my $darea = Gtk2::DrawingArea->new;
$darea->set_events([ 'button_press_mask', 'button_release_mask' ]); #$darea must be unrealized.
gtkadd($w->{window},
- gtkpack(my $vbox_grab = new Gtk::VBox(0,0),
- gtksize(gtkset_usize($darea, $width+1, $height+1), $width+1, $height+1),
- my $okcancel = gtkset_sensitive(create_okcancel($w, undef, undef, "edge"), 1)
+ gtkpack(my $vbox_grab = Gtk2::VBox->new(0, 0),
+ gtkset_size_request($darea, $width+1, $height+1),
+ my $okcancel = gtkset_sensitive(create_okcancel($w, undef, undef, 'edge'), 1)
),
);
- $okcancel->set_uposition(7, $height-43);
- Gtk->timeout_add(2000, sub { gtkset_sensitive($okcancel, 1); $okcancel->draw(undef) });
test_mouse($mouse, $w, $darea, $width, $height);
- $w->{window}->set_usize(undef, $height+10);
$w->sync; # HACK
- Gtk::Gdk->pointer_grab($darea->window, 1,
- [ 'pointer_motion_mask' ],
- $darea->window, undef, 0);
+ Gtk2::Gdk->pointer_grab($vbox_grab->window, 1, 'pointer_motion_mask', $vbox_grab->window, undef, 0);
$w->main;
}
sub test_mouse_standalone {
my ($mouse, $hbox) = @_;
- require my_gtk;
- my_gtk->import(qw(:wrappers));
+ require ugtk2;
+ ugtk2->import(qw(:wrappers));
my ($width, $height, $offset) = (210, round_up(min(350, $::windowheight - 150), 6), 25);
- my $darea = new Gtk::DrawingArea;
+ my $darea = Gtk2::DrawingArea->new;
$darea->set_events([ 'button_press_mask', 'button_release_mask' ]); #$darea must be unrealized.
gtkpack($hbox,
- gtkpack(gtkset_border_width(new Gtk::VBox(0,10), 10),
- gtksize(gtkset_usize($darea, $width+1, $height+1), $width, $height)
- )
- );
+ gtkpack(gtkset_border_width(Gtk2::VBox->new(0,10), 10),
+ gtksize(gtkset_size_request($darea, $width+1, $height+1), $width, $height)));
test_mouse($mouse, $hbox, $darea, $width, $height);
}
sub test_mouse {
my ($mouse, $w, $darea, $width, $height) = @_;
- require my_gtk;
- my_gtk->import(qw(:wrappers));
- $darea->realize();
+# $darea->realize; IS IT REALLY NEEDED? generates a Gtk-CRITICAL when run..
+ require ugtk2;
+ ugtk2->import(qw(:wrappers));
my $wait = 0;
- my ($m3_image, $m3_mask) = gtkcreate_xpm('mouse_3b.xpm');
- my ($m3_imagep, $m3_maskp) = gtkcreate_xpm('mouse_3b+.xpm');
- my ($m3_left, $m3_left_mask) = gtkcreate_xpm('mouse_left.xpm');
- my ($m3_right, $m3_right_mask) = gtkcreate_xpm('mouse_right.xpm');
- my ($m3_middle, $m3_middle_mask) = gtkcreate_xpm('mouse_middle.xpm');
- my ($aru, $aru_mask) = gtkcreate_xpm('arrow_up.xpm');
- my ($ard, $ard_mask) = gtkcreate_xpm('arrow_down.xpm');
- my $image = $m3_image;
- $mouse->{nbuttons} > 3 and $image = $m3_imagep;
+ my %xpms;
+ $xpms{$_} = ugtk2::gtkcreate_pixbuf("mouse_$_.xpm") foreach qw(3b 3bp left right middle);
+ $xpms{au} = ugtk2::gtkcreate_pixbuf('arrow_up.xpm');
+ $xpms{ad} = ugtk2::gtkcreate_pixbuf('arrow_down.xpm');
+ my $image = $xpms{'3b'};
+ $mouse->{nbuttons} > 3 and $image = $xpms{'3bp'};
my $draw_text = sub {
my ($t, $y) = @_;
- my $font = $darea->style->font;
- my $w = $font->string_width($t);
- $darea->window->draw_string($font, $darea->style->black_gc, ($darea->allocation->[2]-$width)/2 + ($width - $w) / 2, ($darea->allocation->[3]-$height)/2 + $y, $t);
+ my $layout = $darea->create_pango_layout($t);
+ my ($w) = $layout->get_pixel_size;
+ $darea->window->draw_layout($darea->style->black_gc,
+ ($darea->allocation->width-$w)/2,
+ ($darea->allocation->height-$height)/2 + $y,
+ $layout);
+ $layout->unref;
+ };
+ my $draw_pixbuf = sub {
+ my ($p, $x, $y, $w, $h) = @_;
+ $p->render_to_drawable($darea->window, $darea->style->bg_gc('normal'), 0, 0,
+ ($darea->allocation->width-$width)/2 + $x, ($darea->allocation->height-$height)/2 + $y,
+ $w, $h, 'none', 0, 0);
};
my $drawarea;
- $drawarea = sub { $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $image, 0, 0,
- ($darea->allocation->[2]-$width)/2, ($darea->allocation->[3]-$height)/2,
- 210, 350);
- if ($::isInstall) {
- my $bad_mouse = member($mouse->{XMOUSETYPE}, 'IMPS/2', 'ExplorerPS/2');
- $draw_text->(N("Please test the mouse"), $height - 120);
- $draw_text->(N("To activate the mouse,"), $height - 105) if $bad_mouse;
- $draw_text->(N("MOVE YOUR WHEEL!"), $height - 90) if $bad_mouse;
- $darea->window->draw_rectangle($darea->style->bg_gc('normal'), 1, 0, $height-65, $width, $height);
- }
- };
+ $drawarea = sub {
+ $draw_pixbuf->($image, 0, 0, 210, 350);
+ if ($::isInstall) {
+ my $bad_mouse = member($mouse->{XMOUSETYPE}, 'IMPS/2', 'ExplorerPS/2');
+ $draw_text->(N("Please test the mouse"), $height - 120);
+ $draw_text->(N("To activate the mouse,"), $height - 105) if $bad_mouse;
+ $draw_text->(N("MOVE YOUR WHEEL!"), $height - 90) if $bad_mouse;
+ }
+ };
my $paintButton = sub {
my ($nb, $pressed) = @_;
my $x = 60 + $nb*33;
$drawarea->();
if ($nb == 0) {
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $m3_left, 0, 0,
- ($darea->allocation->[2]-$width)/2+31, ($darea->allocation->[3]-$height)/2 + 52,
- 59, 91);
+ $draw_pixbuf->($xpms{left}, 31, 52, 59, 91);
} elsif ($nb == 2) {
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $m3_right, 0, 0,
- ($darea->allocation->[2]-$width)/2+117, ($darea->allocation->[3]-$height)/2 + 52,
- 61, 91);
+ $draw_pixbuf->($xpms{right}, 117, 52, 61, 91);
} elsif ($nb == 1) {
if ($mouse->{nbuttons} > 3) {
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $m3_middle, 0, 0,
- ($darea->allocation->[2]-$width)/2+98, ($darea->allocation->[3]-$height)/2 + 67,
- 13, 62);
+ $draw_pixbuf->($xpms{middle}, 98, 67, 13, 62);
} else {
$darea->window->draw_arc($darea->style->black_gc,
- 1, ($darea->allocation->[2]-$width)/2 + $x, ($darea->allocation->[3]-$height)/2 + 90, 20, 25,
+ 1, ($darea->allocation->width-$width)/2 + $x, ($darea->allocation->height-$height)/2 + 90, 20, 25,
0, 360*64);
}
} elsif ($nb == 3) {
- $wait = 1;
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $aru, 0, 0,
- ($darea->allocation->[2]-$width)/2+102, ($darea->allocation->[3]-$height)/2 + 57,
- 6, 8);
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $m3_middle, 0, 0,
- ($darea->allocation->[2]-$width)/2+98, ($darea->allocation->[3]-$height)/2 + 67,
- 13, 62);
- Gtk->timeout_add(200, sub { $wait = 0 });
+ $draw_pixbuf->($xpms{au}, 102, 57, 6, 8);
} elsif ($nb == 4) {
+ $draw_pixbuf->($xpms{ad}, 102, 131, 6, 8);
+ }
+ if (member($nb, 3..4)) {
$wait = 1;
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $ard, 0, 0,
- ($darea->allocation->[2]-$width)/2+102, ($darea->allocation->[3]-$height)/2 + 131,
- 6, 8);
- $darea->window->draw_pixmap($darea->style->bg_gc('normal'),
- $m3_middle, 0, 0,
- ($darea->allocation->[2]-$width)/2+98, ($darea->allocation->[3]-$height)/2 + 67,
- 13, 62);
+ $draw_pixbuf->($xpms{middle}, 98, 67, 13, 62);
Gtk->timeout_add(200, sub { $wait = 0 });
}
};
- $darea->signal_connect(button_press_event => sub {
- my $b = $_[1]{button};
- $paintButton->($b - 1);
- });
- $darea->signal_connect(button_release_event => sub {
- while ($wait) { my_gtk::flush() }
- $drawarea->()
- });
+
+ $darea->signal_connect(button_press_event => sub { $paintButton->($_[1]->button - 1) });
+ $darea->signal_connect(button_release_event => sub { ugtk2::flush() while $wait; $drawarea->() });
$darea->signal_connect(expose_event => sub { $drawarea->() });
- $darea->size($width, $height);
+ $darea->set_size_request($width, $height);
}
diff --git a/perl-install/services.pm b/perl-install/services.pm
index 456317555..5d5140161 100644
--- a/perl-install/services.pm
+++ b/perl-install/services.pm
@@ -185,16 +185,16 @@ sub ask_standalone_gtk {
my ($in, $prefix) = @_;
my ($l, $on_services) = services($prefix);
- require my_gtk;
- my_gtk->import(qw(:helpers :wrappers));
+ require ugtk2;
+ ugtk2->import(qw(:wrappers :create));
- my $W = my_gtk->new(N("Services"));
+ my $W = ugtk2->new(N("Services"));
my ($x, $y, $w_popup);
my $nopop = sub { $w_popup and $w_popup->destroy };
- my $display = sub { $nopop->(); $_[0] and gtkmove(gtkshow(gtkadd($w_popup = new Gtk::Window('-popup'),
- gtksignal_connect(gtkadd(new Gtk::EventBox(),
- gtkadd(gtkset_shadow_type(new Gtk::Frame, 'etched_out'),
- gtkset_justify(new Gtk::Label($_[0]), 0))),
+ my $display = sub { $nopop->(); $_[0] and gtkmove(gtkshow(gtkadd($w_popup = Gtk2::Window->new('popup'),
+ gtksignal_connect(gtkadd(Gtk2::EventBox->new,
+ gtkadd(gtkset_shadow_type(Gtk2::Frame->new, 'etched_out'),
+ gtkset_justify(Gtk2::Label->new($_[0]), 0))),
button_press_event => sub { $nopop->() }
))), $x, $y) };
my $update_service = sub {
@@ -212,28 +212,28 @@ sub ask_standalone_gtk {
}
$infos .= $infos_old;
};
- my $b = new Gtk::EventBox();
- $b->set_events(["pointer_motion_mask"]);
+ my $b = Gtk2::EventBox->new;
+ $b->set_events('pointer_motion_mask');
gtkadd($W->{window}, gtkadd($b, gtkpack_($W->create_box_with_title(N("Services and deamons")),
- 1, gtkset_usize(createScrolledWindow(create_packtable({ col_spacings => 10, row_spacings => 3 },
+ 1, gtkset_size_request(createScrolledWindow(create_packtable({ col_spacings => 10, row_spacings => 3 },
map {
my $service = $_;
my $infos = $strip->(description($_, $prefix));
$infos ||= N("No additional information\nabout this service, sorry.");
- my $l = new Gtk::Label();
+ my $l = Gtk2::Label->new;
my ($started, $action) = $update_service->($service, gtkset_justify($l, 0));
- [ gtkpack__(new Gtk::HBox(0,0), $_),
- gtkpack__(new Gtk::HBox(0,0), $l),
- gtkpack__(new Gtk::HBox(0,0), gtksignal_connect(new Gtk::Button(N("Info")), clicked => sub { $display->($infos) })),
- gtkpack__(new Gtk::HBox(0,0), gtkset_active(gtksignal_connect(
- new Gtk::CheckButton(N("On boot")),
+ [ gtkpack__(Gtk2::HBox->new(0,0), $_),
+ gtkpack__(Gtk2::HBox->new(0,0), $l),
+ gtkpack__(Gtk2::HBox->new(0,0), gtksignal_connect(Gtk2::Button->new(N("Info")), clicked => sub { $display->($infos) })),
+ gtkpack__(Gtk2::HBox->new(0,0), gtkset_active(gtksignal_connect(
+ Gtk2::CheckButton->new(N("On boot")),
clicked => sub { if ($_[0]->active) {
push @$on_services, $service if !member($service, @$on_services);
} else {
@$on_services = grep { $_ ne $service } @$on_services;
} }), member($service, @$on_services))),
map { my $a = $_;
- gtkpack__(new Gtk::HBox(0,0), gtksignal_connect(new Gtk::Button(translate($a)),
+ gtkpack__(Gtk2::HBox->new(0,0), gtksignal_connect(Gtk2::Button->new(translate($a)),
clicked => sub { my $c = "service $service " . (lc($a) eq "start" ? "restart" : lc($a)) . " 2>&1"; local $_ = `$c`; s/\033\[[^mG]*[mG]//g;
($started, $action) = $update_service->($service, $l);
$display->($_);
@@ -242,7 +242,7 @@ sub ask_standalone_gtk {
]
}
@$l)), 500, 400),
- 0, gtkpack(gtkset_border_width(new Gtk::HBox(0,0),5), $W->create_okcancel)
+ 0, gtkpack(gtkset_border_width(Gtk2::HBox->new(0,0),5), $W->create_okcancel)
))
);
$b->signal_connect(motion_notify_event => sub { my ($w, $e) = @_;