summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2004-01-05 11:48:26 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2004-01-05 11:48:26 +0000
commitaac1ad0ebea33a5157a74e2e3f51e245b8e15d3a (patch)
treee017c096b82f88feb594cc77f8748803ea242fab
parentb52f47a94faf644300fcb4419b8356196245972e (diff)
downloadcontrol-center-aac1ad0ebea33a5157a74e2e3f51e245b8e15d3a.tar
control-center-aac1ad0ebea33a5157a74e2e3f51e245b8e15d3a.tar.gz
control-center-aac1ad0ebea33a5157a74e2e3f51e245b8e15d3a.tar.bz2
control-center-aac1ad0ebea33a5157a74e2e3f51e245b8e15d3a.tar.xz
control-center-aac1ad0ebea33a5157a74e2e3f51e245b8e15d3a.zip
- kill Gtk2::SizeableImage package
- introduce Gtk2::Banner (resizable banner) and Gtk2::WebIcon (web like page) packages - use them for new web look 'n feel
-rwxr-xr-xcontrol-center317
1 files changed, 144 insertions, 173 deletions
diff --git a/control-center b/control-center
index 5f3fe22b..b8d7410d 100755
--- a/control-center
+++ b/control-center
@@ -502,52 +502,47 @@ update_profiles();
gtkadd($window_global,
gtkpack_(Gtk2::VBox->new(0, 0),
0, $menu,
- 0, gtkset_size_request(Gtk2::VBox->new(10, 10), -1, 2),
- 1, gtkpack_(Gtk2::HBox->new(0, 0),
- 0, gtkpack_(Gtk2::VBox->new(0, 0),
- 0, my $fixed_left = gtkset_name(Gtk2::Fixed->new, 'mcc'),
- # default left background
- 1, Gtk2::SizeableImage->new('mcc-left-back-middle'),
- 0, rtl_gtkcreate_img('mcc-left-back-bottom')
- ),
- 1, gtkpack_(Gtk2::VBox->new(0, 0),
- 0, Gtk2::SizeableImage->new('mcc-right-bottom'),
- 1, gtkset_name(
- gtkadd(my $emb_frame = Gtk2::EventBox->new,
- gtkadd(gtkset_border_width(Gtk2::Frame->new, 5),
- gtkpack_(my $emb_box = Gtk2::VBox->new(0, 0),
- 1, gtkpack_(my $emb_wait = Gtk2::VBox->new(0, 0),
- 1, Gtk2::HBox->new(0, 0),
- 0, gtkpack_(Gtk2::HBox->new(0, 0),
- 1, Gtk2::VBox->new(0, 0),
- 0, my $run_darea = gtkset_size_request(Gtk2::DrawingArea->new, 128, 128),
- 1, Gtk2::VBox->new(0, 0),
- ),
- 0, Gtk2::Label->new(N("Please wait...")),
- 1, Gtk2::HBox->new(0, 0),
- 0, gtkadd(gtkset_layout(gtkset_border_width(Gtk2::HButtonBox->new, 10), 'end'),
- gtksignal_connect(Gtk2::Button->new_from_stock(N("Cancel")), clicked => sub { Glib::Source->remove($timeout) if $timeout; &child_just_exited() }),
- ),
+ # 0, gtkset_size_request(Gtk2::VBox->new(10, 10), -1, 2),
+ 1, gtkpack_(Gtk2::VBox->new(0, 0),
+ 1, gtkset_name(
+ # FIXME: move emb_frame as a notebook page instead
+ gtkadd(my $emb_frame = Gtk2::EventBox->new,
+ gtkadd(gtkset_border_width(Gtk2::Frame->new, 5),
+ gtkpack_(my $emb_box = Gtk2::VBox->new(0, 0),
+ 1, gtkpack_(my $emb_wait = Gtk2::VBox->new(0, 0),
+ 1, Gtk2::HBox->new(0, 0),
+ 0, gtkpack_(Gtk2::HBox->new(0, 0),
+ 1, Gtk2::VBox->new(0, 0),
+ 0, my $run_darea = gtkset_size_request(Gtk2::DrawingArea->new, 128, 128),
+ 1, Gtk2::VBox->new(0, 0),
),
+ 0, Gtk2::Label->new(N("Please wait...")),
+ 1, Gtk2::HBox->new(0, 0),
+ 0, gtkadd(gtkset_layout(gtkset_border_width(Gtk2::HButtonBox->new, 10), 'end'),
+ gtksignal_connect(Gtk2::Button->new_from_stock(N("Cancel")), clicked => sub { Glib::Source->remove($timeout) if $timeout; &child_just_exited() }),
+ ),
),
- ),
- ),
- 'mcc'),
- 1, my $notebook_global = gtkset_name(Gtk2::Notebook->new, 'mcc'),
- 0, gtkset_name(my $w_exp = create_scrolled_window(gtkset_shadow_type(gtkset_size_request(gtkset_border_width($exp_frame = Gtk2::Frame->new(N("Logs")), 5), -1, 120), 'etched_in'), [ 'never', 'never' ], 'none'), 'mcc'),
- 0, Gtk2::SizeableImage->new('mcc-right-bottom')
- )
- ),
- 0, gtkset_size_request(Gtk2::VBox->new(10, 10), -1, 2)
- )
- );
+ ),
+ ),
+ ),
+ 'mcc'),
+ 1, my $notebook_global = gtkset_name(Gtk2::Notebook->new, 'mcc'),
+ 0, gtkset_name(my $w_exp = create_scrolled_window(gtkset_shadow_type(gtkset_size_request(gtkset_border_width($exp_frame = Gtk2::Frame->new(N("Logs")), 5), -1, 120), 'etched_in'), [ 'never', 'never' ], 'none'), 'mcc'),
+ ),
+ 0, my $buttons = gtkadd(gtkset_layout(Gtk2::HButtonBox->new, 'end'),
+ gtksignal_connect(my $previous = Gtk2::Button->new(N("Previous")),
+ clicked => sub { set_page(0) }),
+ ),
+ )
+ );
+
$window_global->signal_connect(delete_event => \&quit_global);
$window_global->set_title(N("Mandrake Control Center %s", $version) . " [" . chomp_(`hostname`) . "]");
$window_global->set_position('center');
$notebook_global->set_property('show-border', 0);
-$notebook_global->set_property('show-tabs', 0); #$notebook_global->set_show_tabs(0);
+$notebook_global->set_property('show-tabs', 0);
# banner :
@@ -561,21 +556,13 @@ my $summary = gtktext_insert(Gtk2::TextView->new, [
[ N("Welcome to the Mandrake Control Center")."\n\n",
{'size-points' => 15, justification => 'center', pixels_above_lines => $margin-10,
'weight-set' => 1, weight => 1000 } ],
- [ formatAlaTeX(N("Mandrake Control Center is Mandrake Linux's main configuration
-tool. It enables the system administrator to configure the hardware
-and services used for all users.
-
-
-The tools accessed through the Mandrake Control Center greatly
-simplify the use of the system, notably by avoiding the use of the
-evil command line.")) ],
[ "\n ", { justification => 'GTK_JUSTIFY_RIGHT' } ],
[ gtkcreate_pixbuf('mcc-welcome-logo'), { justification => 'GTK_JUSTIFY_RIGHT' } ]
]);
$summary->set_left_margin($margin);
$summary->set_right_margin($margin);
-add2notebook($notebook_global, "", create_scrolled_window(gtkset_size_request($summary,
+add2notebook($notebook_global, "", create_scrolled_window(gtkset_size_request(my $main_page = Gtk2::HBox->new,
50, 50),
[ 'never', 'automatic' ]
),
@@ -587,33 +574,24 @@ my (undef, $nodename, $release, undef, $machine) = POSIX::uname();
-# left icons :
-
my @darea_left_list;
my ($hand_cursor, $normal_cursor, $wait_cursor) = map { Gtk2::Gdk::Cursor->new($_) } qw(hand2 left-ptr watch);
-my $left_back_pixbuf = rtl_gtkcreate_pixbuf('mcc-left-back');
-my ($back_width, $back_height) = ($left_back_pixbuf->get_width, $left_back_pixbuf->get_height);
-
# 0 => unselected, 1 => highlited, 2 => selected
my ($index, $left_locked) = (0, 0);
-my $index_sav = -1;
-my (@curr_state, @old_state);
my ($d_width, $d_height) = (173, 46);
my $right_text_offset = $d_width - 155;
my @colors = (gtkcolor(0, 0, 0), gtkcolor(0xAA, 0xAA, 0xFF), gtkcolor(0, 0, 0));
my $spacing = 25;
my ($lspacing, $left_txt_offset, $icon_offset);
-my $set_hand_cursor = sub { $_[0]->window->set_cursor($hand_cursor) };
-
-# Create left icons
+my @main_icons;
+
foreach (@tree) {
my ($text, $icon, $subtree) = @$_;
- # Skip empty classes
my @subtree;
foreach my $stuff (@$subtree) {
my $exec = first(split /\s+/, $exec_hash->{$stuff->[0]}[1]);
@@ -624,133 +602,67 @@ foreach (@tree) {
warn qq("$exec" is not executable) if $mdk_rel !~ /Move/;
}
}
+ # Skip empty classes:
next if !@subtree;
my $my_index = $index++;
+ my $box;
+ $box = Gtk2::WebIcon->new($text, $icon,
+ {
+ button_release_event => sub {
+ # FIXME: the following code is currently useless:
+ # should we provide a way to kill buggy embedded programs ?
+ return if $left_locked;
+ if ($pending_app) {
+ return if !splash_warning(N("The modifications done in the current module won't be saved."), 1);
+ kill_children();
+ child_just_exited();
+ }
+
+ set_page($my_index+1);
+ },
+ }
+ );
+
# die "gtkput(fixed_left, VBox of StockButtons there or\n (while waiting for gc to implement IconFactory) VBox of Hbox[icon|text]";
my $darea_left = gtkset_size_request(Gtk2::DrawingArea->new, $d_width, $d_height);
$darea_left->set_events([ 'exposure_mask', 'enter_notify_mask', 'leave_notify_mask', 'button_press_mask', 'button_release_mask' ]);
my $icon_pixbuf = gtkcreate_pixbuf($icon);
- my ($icon_width, $icon_height) = ($icon_pixbuf->get_width, $icon_pixbuf->get_height);
- unless ($lspacing) {
-# $lspacing = round_up(($d_height-$icon_height)/2, 1);
- $lspacing = ($d_height-$icon_height)/2;
- $left_txt_offset = $lspacing * 2 + $icon_width;
- $icon_offset = 15 if lang::text_direction_rtl();
- $left_txt_offset += $icon_offset;
- $lspacing = round_up($lspacing, 1);
- }
-
- my $left_back_pixbuf = $my_index ? $left_back_pixbuf : rtl_gtkcreate_pixbuf('mcc-left-back-top');
my @icon_pixbufs = ($icon_pixbuf, render_shiner($icon_pixbuf, 1.89), $icon_pixbuf);
my @fonts = map { Gtk2::Pango::FontDescription->from_string($_) } '', 'Bold', 'Bold';
my ($lines, $widths, $heights, $offset, @dbl_area_left);
- push @curr_state, 0;
- push @old_state, -1;
-
- $darea_left->signal_connect(expose_event => sub {
- my (undef, $event) = @_;
- my $curr_state = $curr_state[$my_index];
- my $full_redraw = $curr_state != $old_state[$my_index];
- my ($x, $y, $width, $height) = $full_redraw ? (0, 0, $d_width, $d_height) : $event->area->values;
- unless ($lines) {
- $darea_left->modify_font($fonts[1]);
- ($lines, $widths, $heights) = (get_text_coord($text, $darea_left, $d_width-$left_txt_offset-$right_text_offset, $d_height, 0, 0, 0, 0))[2..4];
- $offset = -($d_height - string_height($darea_left, $lines->[0]) * (listlength(@$lines) + 0.2)) / 2; # text lines are offsetted
- }
- # Redraw double buffer on first expose in that particular state (selected <=> not selected): render background, then icon, then text
- unless ($dbl_area_left[$curr_state]) {
- my $window = $darea_left->window;
- $dbl_area_left[$curr_state] = Gtk2::Gdk::Pixmap->new($window, $d_width, $d_height, $window->get_depth);
- my $gc = $darea_left->style->fg_gc('normal');
- $left_back_pixbuf->render_to_drawable($dbl_area_left[$curr_state], $gc, 0, 0, 0, 0, $back_width, $back_height, 'normal', 0, 0);
- $icon_pixbufs[$curr_state]->render_to_drawable($dbl_area_left[$curr_state], $gc, 0, 0, $lspacing+$icon_offset, $lspacing, $icon_width, $icon_height, 'normal', 0, 0);
- $darea_left->style->black_gc->set_rgb_fg_color($colors[$curr_state]);
-
- $darea_left->modify_font($fonts[$curr_state]);
-
- mapn {
- $dbl_area_left[$curr_state]->draw_layout($darea_left->style->black_gc, $_[1]+$left_txt_offset, $_[2]-$offset, $darea_left->create_pango_layout($_[0]));
- } $lines, $widths, $heights;
- }
- $old_state[$my_index] = $curr_state;
- $darea_left->window->draw_drawable($darea_left->style->bg_gc('normal'), $dbl_area_left[$curr_state], $x, $y, $x, $y, $width, $height);
- });
- $darea_left->signal_connect(realize => $set_hand_cursor);
- $darea_left->signal_connect(enter_notify_event => sub {
- return if $old_state[$my_index] == -1 || $curr_state[$my_index] != 0;
- $curr_state[$my_index] = 1;
- $darea_left->queue_draw;
- });
- $darea_left->signal_connect(leave_notify_event => sub {
- return if $curr_state[$my_index] != 1;
- $curr_state[$my_index] = 0;
- $darea_left->queue_draw;
- });
+
+
$darea_left->signal_connect(button_release_event => sub {
- return if $left_locked;
- if ($pending_app) {
- return if !splash_warning(N("The modifications done in the current module won't be saved."), 1);
- kill_children();
- child_just_exited();
- }
-
- # deselect previously selected darea
- if ($index_sav != -1) {
- $curr_state[$index_sav] = 0;
- $set_hand_cursor->($darea_left_list[$index_sav]);
- $darea_left_list[$index_sav]->queue_draw;
- }
- $index_sav = $my_index;
- $curr_state[$my_index] = 2;
- $darea_left->window->set_cursor($normal_cursor);
- $darea_left->queue_draw;
- set_page($my_index+1);
});
# push left icons
- $fixed_left->put($darea_left, 0, $my_index*$d_height);
+ #TV $fixed_left->put($darea_left, 0, $my_index*$d_height);
push @darea_left_list, $darea_left;
# Create right notebook pages :
my $tbl = create_packtable({ col_spacings => $spacing, row_spacings => $spacing, homogeneous => 1, mcc => 1 },
- group_by2(map {
+ group_by3(map {
my ($label, $tag) = @$_;
my $text = $exec_hash->{$label}[3];
die "$label 's icon is missing" if !$exec_hash->{$label} && $::testing;
- my $hbox_spacing = 10;
- my $event_box = gtkadd(Gtk2::EventBox->new,
- gtkpack_(
- Gtk2::VBox->new(0, $hbox_spacing),
- 0, gtkcreate_img($tag),
- 1, Gtk2::WrappedLabel->new($text),
- if_(0,1, gtktext_insert(
- #- disable selecting text and popping the contextual menu
- # (GUI team says it's *horrible* to be able to do select text!)
- gtksignal_connect(my $tv = Gtk2::TextView->new,
- button_press_event => sub { 1 }),
- [ [ $text, {'background_set' => 0,
- 'background_stipple_set' => 0 } ] ])
- ),
- )
- );
- $tv->set_events([]);
+ my $event_box;
+ $event_box = Gtk2::WebIcon->new($text, $tag,
+ {
+ button_release_event => sub { compute_exec_string($label, $event_box, $tag, @{$exec_hash->{$label}}) },
+ }
+ );
$event_box->set_events([ 'enter_notify_mask', 'leave_notify_mask', 'button_press_mask', 'button_release_mask' ]);
- # FIXME: do ->set_pixbuf() on {enter,leave}_events
- $event_box->signal_connect(realize => $set_hand_cursor);
$tool_feedback{$label} = sub { $event_box->window->set_cursor($normal_cursor) };
- $event_box->signal_connect(button_release_event => sub { compute_exec_string($label, $event_box, $tag, @{$exec_hash->{$label}}) });
-
- # FIXME : resize sig: ->foreach; set_size_request
- gtkset_size_request($event_box, 50, -1);
- } @subtree));
+ $event_box;
+ } @subtree));
add2notebook($notebook_global, "",
my $_w_ret = create_scrolled_window(gtkset_border_width($tbl, 5),
@@ -758,13 +670,13 @@ foreach (@tree) {
),
);
# $w_ret->vscrollbar->set_size_request(19, undef);
+ push @main_icons, $box;
}
-
-$notebook_global->set_size_request(-1, $index * 60);
+gtkadd($main_page, create_packtable({ col_spacings => $spacing, row_spacings => $spacing, homogeneous => 1, mcc => 1 }, group_by3(@main_icons)));
-$emb_frame->set_size_request(-1, $index * 50);
+#$emb_frame->set_size_request(-1, $index * 50);
foreach (keys %check_boxes) {
my $widget = $check_boxes{$_};
@@ -793,6 +705,7 @@ $run_darea->signal_connect(expose_event => sub {
gtkflush();
$notebook_global->set_current_page(0);
+show_hide_previous(0);
$notebook_global->signal_connect(switch_page => sub {
my $tab_number = $_[2];
return unless $tab_number > 0;
@@ -814,6 +727,14 @@ undef $window_splash;
Gtk2->main;
+sub group_by3 {
+ my @l;
+ for (my $i = 0; $i < @_; $i += 3) {
+ push @l, [ $_[$i], $_[$i+1], $_[$i+2] ];
+ }
+ @l;
+}
+
#-------------------------------------------------------------
# socket/plug managment
@@ -844,6 +765,7 @@ sub create_hidden_socket() {
$emb_socket->signal_connect('plug-added' => sub {
$left_locked = 0;
$emb_wait->hide;
+ show_hide_previous(0);
return if !$emb_socket;
$emb_socket->show;
$emb_socket->can_focus(1);
@@ -1117,8 +1039,13 @@ sub set_page {
$notebook_global->set_current_page($index);
$still_not_in_a_section = 0;
$help_on_context = $ctx[$index];
+ show_hide_previous($index);
}
+sub show_hide_previous {
+ my ($bool) = @_;
+ if ($bool) { $previous->show } else { $previous->hide }
+}
#-------------------------------------------------------------
@@ -1165,27 +1092,71 @@ sub scale {
}
-package Gtk2::SizeableImage;
+
+package Gtk2::Banner;
use ugtk2 qw(:helpers :wrappers);
+#use common;
-sub set_bg_img {
- my ($w) = @_;
- $w->{pixbuf} ||= gtkcreate_pixbuf($w->{image});
- set_back_pixbuf($w, $w->{pixbuf});
+sub new {
+ my ($_class, $background, $icon, $text) = @_;
+ my $hbox_spacing = 10;
+ my $fixed = gtkput(gtksignal_connect(Gtk2::Fixed->new,
+ "configure-event" => sub {},
+ ),
+ gtkpack_(Gtk2::HBox->new,
+ 0, my $img = gtkcreate_img($icon),
+ 1, Gtk2::WrappedLabel->new($text),
+ if_(0, 1, gtktext_insert(
+ # disable selecting text and popping the contextual menu
+ # (GUI team says it's *horrible* to be able to do select text!)
+ gtksignal_connect(my $tv = Gtk2::TextView->new,
+ button_press_event => sub { 1 }),
+ [ [ $text, {'background_set' => 0,
+ 'background_stipple_set' => 0 } ] ])
+ ),
+ ),
+ );
+
+ $img->{pixbuf} = gtkcreate_pixbuf($icon);
+ $img->signal_connect("configure-event" => sub { set_back_pixbuf($img, $img->{pixbuf}) });
+
+ return $fixed;
}
+package Gtk2::WebIcon;
+
+use ugtk2 qw(:helpers :wrappers);
+use common;
+
sub new {
- my ($_class, $image) = @_;
- my $w = gtksignal_connect(
- gtksignal_connect(
- gtkset_size_request(Gtk2::DrawingArea->new, -1, 1),
- "configure-event" => \&set_bg_img
- ),
- realize => \&set_bg_img
- );
- $w->{image} = $image;
- $w;
+ my ($_class, $text, $icon, $callbacks) = @_;
+ my $hbox_spacing = 10;
+ # FIXME: do ->set_pixbuf() on {enter,leave}_events
+ my $box = gtkadd(gtksignal_connect(Gtk2::EventBox->new, realize => sub { $_[0]->window->set_cursor($hand_cursor) } ),
+ gtkpack_(
+ Gtk2::VBox->new(0, $hbox_spacing),
+ 0, gtkcreate_img($icon),
+ 1, Gtk2::WrappedLabel->new($text),
+ if_(0,1, gtktext_insert(
+ # disable selecting text and popping the contextual menu
+ # (GUI team says it's *horrible* to be able to do select text!)
+ gtksignal_connect(my $tv = Gtk2::TextView->new,
+ button_press_event => sub { 1 }),
+ [ [ $text, {'background_set' => 0,
+ 'background_stipple_set' => 0 } ] ])
+ ),
+ )
+ );
+ $tv->set_events([]);
+ # FIXME : resize sig: ->foreach; set_size_request
+ while (my ($signal, $handler) = each %$callbacks) {
+ $box->signal_connect($signal => $handler);
+ }
+
+ gtkset_size_request($box, 50, -1);
+ $box->set_events([ 'enter_notify_mask', 'leave_notify_mask', 'button_press_mask', 'button_release_mask' ]);
+ return $box;
}
1;