Thierry Vignaud <[EMAIL PROTECTED]> writes:
> > > as i'm currently playing with perl-Gtk2, could you resend me all
> > > what you see once i upload a perl-Gtk2 aware drakxtools ?
> >
> > sure, no pb.
>
> if some people want to test:
--- control-center 2003-07-07 22:27:12.000000000 +0200
+++ control-center.xs 2003-07-07 22:27:59.000000000 +0200
@@ -1,5 +1,5 @@
#!/usr/bin/perl
-# $Id: control-center,v 1.336 2003/07/07 20:27:12 tvignaud Exp $
+# $Id: control-center,v 1.334 2003/07/01 08:41:06 tvignaud Exp $
# Copyright (C) 1999-2003 MandrakeSoft
# Daouda Lo <[EMAIL PROTECTED]>
@@ -27,6 +27,7 @@
use standalone;
use common;
use detect_devices;
+use lang;
# i18n: IMPORTANT: to get correct namespace (drakconf instead of libDrakX)
BEGIN { unshift @::textdomains, 'drakconf' }
@@ -69,8 +70,6 @@
my $window_splash = Gtk2::Window->new('popup');
$window_splash->signal_connect(delete_event => \&quit_global);
$window_splash->set_title(N("Mandrake Control Center") . $version);
-$window_splash->allow_shrink(0);
-$window_splash->allow_grow(0);
$window_splash->set_position('center_always');
$window_splash->add(gtkadd(gtkset_shadow_type(Gtk2::Frame->new, 'etched_out'),
gtkpack(Gtk2::VBox->new(0, 0),
@@ -284,51 +283,57 @@
'wiz_expert' => [ N("/_Options"), N("/Expert mode in _wizards") ],
);
-my ($menu, $factory) = create_factory_menu($window_global,
- ({ path => N("/_File"), type => '<Branch>' },
- { path => N("/_File") . N("/_Quit"), accelerator => N("<control>Q"), callback => \&quit_global },
- { path => N("/_Options"), type => '<Branch>' },
- { path => join('', @{$options{show_log}}), type => '<CheckItem>',
- callback => sub {
- $option_values{show_log} = $check_boxes{show_log}->active;
- update_exp();
- }
- },
- { path => join('', @{$options{embedded_mode}}), type => '<ToggleItem>',
- callback => sub { $option_values{embedded} = $check_boxes{embedded_mode}->active }
- },
- if_($::isWiz,
- { path => join('', @{$options{wiz_expert}}), type => '<ToggleItem>',
- callback => sub { $option_values{expert_wizard} = $check_boxes{wiz_expert}->active }
- },
- ),
- if_(all($themes_dir) > 1,
- { path => N("/_Themes"), type => '<Branch>' },
- (map {
- my $name = $_;
- { path => N("/_Themes") . "/" . ($name eq $theme ? " O " : " ") . "_$_",
- callback => sub {
- return if $theme eq $name;
- !$pending_app || splash_warning(N("This action will restart the control center.\nAny change not applied will be lost."), 1) and do {
- # embedded app must be killed
- kill_children();
- kill_logdrake();
- child_just_exited();
- exec "$0 --theme $name";
- };
- }
- }
- } grep { -d "$themes_dir/$_" } all($themes_dir)),
- { path => N("/_Themes").N("/_More themes"), callback => \&more_themes }
- ),
- { path => N("/_Help"), type => '<Branch>' },
- { path => N("/_Help").N("/_Help"), callback => sub { fork_("drakhelp Drakxtools-Guide.html/drakconf-intro.html") } },
- { path => N("/_Help").N("/_Report Bug"), callback => sub { fork_("drakbug --report drakconf &") } },
- { path => N("/_Help").N("/_About..."), callback => \&about_mdk_cc }
- ));
+my @menu_items = (
+ [ N("/_File"), undef, undef, undef, '<Branch>' ],
+ [ N("/_File") . N("/_Quit"), N("<control>Q"), \&quit_global, undef, '<StockItem>', 'gtk-quit' ],
+ [ N("/_Options"), undef, undef, undef, '<Branch>' ],
+ [ join('', @{$options{show_log}}), undef,
+ sub {
+ $option_values{show_log} = $check_boxes{show_log}->get_active;
+ update_exp();
+ },
+ undef, '<CheckItem>'
+ ],
+ [ join('', @{$options{embedded_mode}}), undef,
+ sub { $option_values{embedded} = $check_boxes{embedded_mode}->get_active },
+ undef, '<CheckItem>',
+ ],
+ if_($::isWiz,
+ [ join('', @{$options{wiz_expert}}), undef,
+ sub { $option_values{expert_wizard} = $check_boxes{wiz_expert}->get_active },
+ undef, '<CheckItem>',
+ ],
+ ),
+ if_(all($themes_dir) > 1,
+ [ N("/_Themes"), undef, undef, undef, '<Branch>' ],
+ (map {
+ my $name = $_;
+ [ N("/_Themes") . "/" . ($name eq $theme ? " O " : " ") . "_$_", undef,
+ sub {
+ return if $theme eq $name;
+ !$pending_app || splash_warning(N("This action will restart the control center.\nAny change not applied will be lost."), 1) and do {
+ # embedded app must be killed
+ kill_children();
+ kill_logdrake();
+ child_just_exited();
+ exec "$0 --theme $name";
+ };
+ }, '<CheckItem>'
+ ]
+ } grep { -d "$themes_dir/$_" } all($themes_dir)),
+ [ N("/_Themes").N("/_More themes"), undef, \&more_themes, undef, '<Item>' ]
+ ),
+ [ N("/_Help"), undef, undef, undef, '<Branch>' ],
+ [ N("/_Help").N("/_Help"), undef, sub { fork_("drakhelp Drakxtools-Guide.html/drakconf-intro.html") }, undef, '<StockItem>', 'gtk-help' ],
+ [ N("/_Help").N("/_Report Bug"), undef, sub { fork_("drakbug --report drakconf &") }, undef, '<Item>' ],
+ [ N("/_Help").N("/_About..."), undef, \&about_mdk_cc, undef, '<Item>' ]
+ );
+
+my ($menu, $factory) = create_factory_menu($window_global, @menu_items);
+
%check_boxes = map {
- $_ => $factory->get_widget("<main>" . join '', map { s/_//; $_ } @{$options{$_}})
+ $_ => $factory->get_widget("<main>" . join('', map { s/_//; $_ } @{$options{$_}}))
} ("embedded_mode", "show_log", if_($::isWiz, "wiz_expert"));
@@ -341,8 +346,8 @@
0, my $fixed_left = gtkset_name(Gtk2::Fixed->new, 'mcc'),
# default left background
1, gtksignal_connect(gtkset_size_request(Gtk2::DrawingArea->new(), -1, -1),
- realize => sub { set_back_pixbuf($_[0], gtkcreate_pixbuf('mcc-left-back-middle')) }),
- 0, gtkcreate_img('mcc-left-back-bottom')
+ realize => sub { set_back_pixbuf($_[0], rtl_gtkcreate_pixbuf('mcc-left-back-middle')) }),
+ 0, rtl_gtkcreate_img('mcc-left-back-bottom')
),
1, gtkpack_(Gtk2::VBox->new(0, 0),
0, gtksignal_connect(gtkset_size_request(Gtk2::DrawingArea->new(), -1, 1),
@@ -363,7 +368,7 @@
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('gtk-cancel'), clicked => sub { Gtk2->timeout_remove($timeout) if $timeout; &child_just_exited() }),
+ gtksignal_connect(Gtk2::Button->new_from_stock('gtk-cancel'), clicked => sub { Glib::Source->remove($timeout) if $timeout; &child_just_exited() }),
),
),
),
@@ -395,33 +400,25 @@
# main page (summary) :
-my $summary = create_scrolled_window(
- gtkpack_(Gtk2::VBox->new(0, 0),
- 1, gtkset_size_request(
- gtkset_border_width(
- gtktext_insert(Gtk2::TextView->new, [
- [ N("Welcome to the Mandrake Control Center")."\n\n",
- {'size-points' => 15, justification => 'center', 'weight-set' => 1, weight => 1000 } ],
- [ formatAlaTeX(N("Mandrake Control Center is Mandrake Linux's main configuration
+my $summary = gtktext_insert(Gtk2::TextView->new, [
+ [ N("Welcome to the Mandrake Control Center")."\n\n",
+ {'size-points' => 15, justification => 'center', '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.")) ]
- ]),
- 40),
- 50, 50),
- 0, gtkpack2__(Gtk2::HBox->new(0, 0),
- { 'pack_end' => 1, expand => 0, fill => 0 }, gtkcreate_img('mcc-welcome-logo'),
- )
- ),
- undef, 'none');
-
-
-
-$notebook_global->append_page($summary, "");
+evil command line.")) ],
+ [ "\n ", { justification => 'GTK_JUSTIFY_RIGHT' } ],
+ [ gtkcreate_pixbuf('mcc-welcome-logo'), { justification => 'GTK_JUSTIFY_RIGHT' } ]
+ ]);
+
+add2notebook($notebook_global, "", create_scrolled_window(gtkset_size_request(gtkset_border_width($summary, 40),
+ 50, 50),
+ ),
+ "");
use POSIX qw(:sys_utsname_h :math_h :sys_wait_h :unistd_h);
@@ -434,7 +431,7 @@
my @darea_left_list;
my ($cursor_hand, $cursor_normal) = (Gtk2::Gdk::Cursor->new('hand2'), Gtk2::Gdk::Cursor->new('left-ptr'));
-my $left_back_pixbuf = gtkcreate_pixbuf('mcc-left-back');
+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
@@ -447,7 +444,7 @@
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);
+my ($lspacing, $left_txt_offset, $icon_offset);
# Create left icons
foreach (@tree) {
@@ -464,10 +461,12 @@
# $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 : gtkcreate_pixbuf('mcc-left-back-top');
+ 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);
@@ -488,7 +487,7 @@
$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, $lspacing, $icon_width, $icon_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]);
@@ -561,12 +560,12 @@
);
} @$subtree));
- $notebook_global->append_page(
- my $_w_ret = create_scrolled_window(gtkset_border_width($tbl, 5),
- [ 'never', 'automatic' ], 'none'
- ),
- ""
- );
+ add2notebook($notebook_global, "",
+ my $_w_ret = create_scrolled_window(gtkset_border_width($tbl, 5),
+ [ 'never', 'automatic' ], 'none'
+ ),
+ ""
+ );
# $w_ret->vscrollbar->set_size_request(19, undef);
}
@@ -596,7 +595,6 @@
my $pixbuf = render_alpha($run_pixbuf, $run_counter);
my ($window, $gc, $width, $height) = ($run_darea->window, $run_darea->style->fg_gc('normal'), $pixbuf->get_width, $pixbuf->get_height);
$pixbuf->render_to_drawable($window, $gc, 0, 0, 0, 0, $width, $height, 'normal', 0, 0);
- $pixbuf->unref;
$run_counter += $run_counter_add;
$run_counter_add = -$run_counter_add if $run_counter < 100 || 245 < $run_counter;
});
@@ -636,7 +634,7 @@
clean_socket();
gtkset_mousecursor_normal();
$notebook_global->show;
- Gtk2->timeout_remove($timeout) if $timeout;
+ Glib::Source->remove($timeout) if $timeout;
}
sub hide_socket_and_clean() {
@@ -731,13 +729,12 @@
$emb_socket->realize;
$pending_app = 1;
if ($gtkplug > 0) {
- $exec .= " --embedded " . $emb_socket->window->XWINDOW;
+ $exec .= " --embedded " . $emb_socket->get_id;
$emb_wait->show;
- $run_pixbuf->unref if $run_pixbuf;
$run_pixbuf = gtkcreate_pixbuf($icon . "_128");
$run_counter = 255;
$run_counter_add = -10;
- $timeout = Gtk2->timeout_add(70, sub { $run_darea->queue_draw; 1 });
+ $timeout = Glib::Timeout->add(70, sub { $run_darea->queue_draw; 1 });
$left_locked = 1;
fork_($exec);
} else { # gtkplug == 0
@@ -746,7 +743,7 @@
$emb_socket->show;
$exec_->[0] = $exec;
$SIG{CHLD} = undef;
- $emb_socket->steal(launch_xapp(@$exec_));
+ $emb_socket->add_id(launch_xapp(@$exec_));
$emb_socket->grab_focus;
$SIG{CHLD} = \&sig_child;
}
@@ -821,7 +818,7 @@
THEME => $theme,
});
gtkset_mousecursor_normal();
- Gtk2->exit(0);
+ Gtk2::exit(0);
}
@@ -881,7 +878,7 @@
sub about_mdk_cc() {
my $window_about = new_dialog(N("About - Mandrake Control Center"));
- my $tree_model = Gtk2::TreeStore->new(Gtk2::GType->STRING, Gtk2::GType->STRING, Gtk2::GType->STRING);
+ my $tree_model = Gtk2::TreeStore->new("Glib::String", "Glib::String", "Glib::String");
my $list = Gtk2::TreeView->new_with_model($tree_model);
$list->can_focus(0);
each_index { $list->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => $::i)) } 0..2;
@@ -900,7 +897,7 @@
#-PO If your language allows it, use eacute for first "e" and egrave for 2nd one.
[ '', N("Helene Durosini"), '<[EMAIL PROTECTED]>' ],
) {
- $tree_model->append_set(undef, [ map_index { $::i => $_ } @$row ])->free;
+ $tree_model->append_set(undef, [ map_index { $::i => $_ } @$row ]);
}
# Give our translators the ability to show their family and
@@ -911,7 +908,7 @@
#-PO Add your E-Mail address here if you want to show it in the about doialog.
my $translator_email = N("~ @ ~");
if ($translator_name ne "~ * ~ " && 0) {
- $list->append_set(undef, [ 0 => $_->[0], 1 => $_->[1] ])->free foreach [ '', '' ], [ N("Translator: "), $translator_name, $translator_email ];
+ $list->append_set(undef, [ 0 => $_->[0], 1 => $_->[1] ]) foreach [ '', '' ], [ N("Translator: "), $translator_name, $translator_email ];
}
$list->get_selection()->set_mode('none');
@@ -939,6 +936,18 @@
#-------------------------------------------------------------
# mcc specific graphic functions:
+sub rtl_gtkcreate_pixbuf {
+ my ($icon) = @_;
+ my $pixbuf;
+ eval { $pixbuf = ugtk2::gtkcreate_pixbuf($icon . "_rtl") } if lang::text_direction_rtl();
+ $pixbuf ||= ugtk2::gtkcreate_pixbuf($icon);
+}
+
+sub rtl_gtkcreate_img {
+ my ($icon) = @_;
+ ugtk2::gtkcreate_img($icon . "_rtl");
+}
+
sub new_pixbuf {
my ($pixbuf) = @_;
my ($height, $width) = ($pixbuf->get_height, $pixbuf->get_width);
known issues with mcc:
- logdrake does not embbed (needed fixed perl-Gtk2 is building)
- drakconnect won't embbed
- some space is lost after process embedding