summaryrefslogtreecommitdiffstats
path: root/perl-install/common.pm
blob: a28c3727c47e1ba853d2b3fb02bcda49c24ea8fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
- try not to be larger than screen size minus toolbars size - close_window -> close_all
Diffstat (limited to 'perl-install/standalone/draksplash')
-rwxr-xr-xperl-install/standalone/draksplash61
1 files changed, 38 insertions, 23 deletions
diff --git a/perl-install/standalone/draksplash b/perl-install/standalone/draksplash
index b50153e50..884572cff 100755
--- a/perl-install/standalone/draksplash
+++ b/perl-install/standalone/draksplash
@@ -10,23 +10,25 @@ use bootsplash;
my $in = 'interactive'->vnew('su');
+#- verification of package image magik
+unless ($in->do_pkgs->ensure_is_installed('ImageMagick', '/usr/bin/convert')) {
+ $in->ask_okcancel(N("Error"), N("package 'ImageMagick' is required to be able to complete configuration.\nClick \"Ok\" to install 'ImageMagick' or \"Cancel\" to quit"))
+ && $in->do_pkgs->install('ImageMagick')
+ or close_all();
+}
+
my $window = ugtk2->new('DrakSplash');
-$window->{rwindow}->signal_connect(delete_event => \&close_window);
-my $preview_window = ugtk2->new('DrakSplash');
+$window->{rwindow}->signal_connect(delete_event => \&close_all);
+my @image_pixbuf;
my $current_rect = [];
my $current_point;
-my ($image_area, @image_pixbuf);
-create_image_area();
-switch_to_mode(0);
+my $preview_window = ugtk2->new('DrakSplash');
+my $image_area = create_image_area();
+my $scroll = create_scrolled_window($image_area);
-#- verification of package image magik
-unless ($in->do_pkgs->ensure_is_installed('ImageMagick', '/usr/bin/convert')) {
- $in->ask_okcancel(N("Error"), N("package 'ImageMagick' is required to be able to complete configuration.\nClick \"Ok\" to install 'ImageMagick' or \"Cancel\" to quit"))
- && $in->do_pkgs->install('ImageMagick')
- or close_window();
-}
+switch_to_mode(0);
my %scale_settings = (
tx => [ 1/10, N("x coordinate of text box\nin number of characters") ],
@@ -80,8 +82,8 @@ gtkadd($window->{window},
$notebook,
gtkpack(Gtk2::HBox->new(0, 5),
gtksignal_connect(Gtk2::Button->new(N("Save theme")), clicked => \&save_theme),
- gtksignal_connect(Gtk2::Button->new(N("Quit")), clicked => \&close_window)))),
-gtkshow(gtkadd($preview_window->{window}, $image_area));
+ gtksignal_connect(Gtk2::Button->new(N("Quit")), clicked => \&close_all)))),
+gtkshow(gtkadd($preview_window->{window}, $scroll));
update_scale_values();
@@ -93,7 +95,7 @@ $window->main;
# Should never get here
ugtk2->exit(0);
-sub close_window() {
+sub close_all() {
ugtk2->exit(0);
}
@@ -117,13 +119,26 @@ sub set_theme {
read_theme_config();
}
-sub set_resolution {
- my ($res) = @_;
- $theme{res} = $res;
- ($theme{res_w}, $theme{res_h}) = $theme{res} =~ /([^x]+)x([^x]+)/;
- read_theme_config();
- $image_area->set_size_request($theme{res_w}, $theme{res_h});
- $preview_window->shrink_topwindow();
+{
+ my ($old_scroll_w, $old_scroll_h);
+
+ sub set_resolution {
+ my ($res) = @_;
+ $theme{res} = $res;
+ ($theme{res_w}, $theme{res_h}) = $theme{res} =~ /([^x]+)x([^x]+)/;
+ read_theme_config();
+ $image_area->set_size_request($theme{res_w}, $theme{res_h});
+ #- try not to be larger than screen size minus toolbars size
+ my $w = min(Gtk2::Gdk->screen_width*0.9, $theme{res_w});
+ my $h = min(Gtk2::Gdk->screen_height*0.9, $theme{res_h});
+ #- do not resize and move the window again if size hasn't changed
+ if ($w != $old_scroll_w || $h != $old_scroll_h) {
+ $scroll->set_size_request($w, $h);
+ $preview_window->shrink_topwindow();
+ $preview_window->{window}->move(0, 0);
+ ($old_scroll_w, $old_scroll_h) = ($w, $h);
+ }
+ }
}
sub save_theme() {
@@ -214,7 +229,7 @@ sub update_scale_values {
sub create_image_area() {
- $image_area = Gtk2::DrawingArea->new;
+ my $image_area = Gtk2::DrawingArea->new;
$image_area->can_focus(1);
$image_area->add_events($_) foreach qw(button-press-mask pointer-motion-mask);