diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2003-01-28 15:39:51 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2003-01-28 15:39:51 +0000 |
commit | 0f1a363af19d12e8bc38ec02f5a99ecbae1eadc1 (patch) | |
tree | 8ca816bf1fff041b773ac512d3a1e3604e75743e | |
parent | 09676045bd344ea218b7e2abeec8d2f0b5334d76 (diff) | |
download | drakx-0f1a363af19d12e8bc38ec02f5a99ecbae1eadc1.tar drakx-0f1a363af19d12e8bc38ec02f5a99ecbae1eadc1.tar.gz drakx-0f1a363af19d12e8bc38ec02f5a99ecbae1eadc1.tar.bz2 drakx-0f1a363af19d12e8bc38ec02f5a99ecbae1eadc1.tar.xz drakx-0f1a363af19d12e8bc38ec02f5a99ecbae1eadc1.zip |
cleaning the utf8 support stuff:
- consolidate check_for_xserver() to check for x11 access
- introduce prepare_gtk2() to do what gtk+2 needs, so that
tools that're not part of drakxtools (aka: rpmdrake, mcc, ...) can just do :
unshift @::textdomains, 'drakconf'; prepare_gtk2();
-rw-r--r-- | perl-install/common.pm | 12 | ||||
-rw-r--r-- | perl-install/interactive.pm | 4 | ||||
-rw-r--r-- | perl-install/interactive/gtk.pm | 1 | ||||
-rw-r--r-- | perl-install/ugtk.pm | 2 | ||||
-rw-r--r-- | perl-install/ugtk2.pm | 11 |
5 files changed, 22 insertions, 8 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm index 8fa267d46..a3deaac16 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -9,7 +9,7 @@ use vars qw(@ISA @EXPORT $SECTORSIZE); @ISA = qw(Exporter); # no need to export ``_'' -@EXPORT = qw($SECTORSIZE N N_ translate untranslate formatXiB removeXiBSuffix formatTime setVirtual makedev unmakedev salt set_permissions files_exist set_alternative mandrake_release require_root_capability); +@EXPORT = qw($SECTORSIZE N N_ translate untranslate formatXiB removeXiBSuffix formatTime setVirtual makedev unmakedev salt set_permissions files_exist set_alternative mandrake_release require_root_capability check_for_xserver); # perl_checker: RE-EXPORT-ALL push @EXPORT, @MDK::Common::EXPORT; @@ -245,7 +245,7 @@ sub mandrake_release { sub require_root_capability { return unless $>; # we're already root - if ($ENV{DISPLAY} && system('/usr/X11R6/bin/xtest') == 0) { + if (check_for_xserver()) { if (fuzzy_pidofs(qr/\bkwin\b/) > 0) { exec("kdesu", "-c", "$0 @ARGV") or die N("kdesu missing"); } @@ -256,4 +256,12 @@ sub require_root_capability { die "you must be root to run this program" if $>; } +sub check_for_xserver { + if (!defined $::xtest) { + $::xtest = $ENV{DISPLAY} && (system('/usr/X11R6/bin/xtest') == 0); + } + return $::xtest; +} + + 1; diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index b62390180..5285781ab 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -94,13 +94,11 @@ sub vnew { $su = '' if $::testing || $ENV{TESTING}; } require_root_capability() if $su; - if ($ENV{DISPLAY} && system('/usr/X11R6/bin/xtest') == 0) { + if (check_for_xserver()) { eval { require interactive::gtk }; if (!$@) { my $o = interactive::gtk->new; if ($icon && $icon ne 'default' && !$::isWizard) { $o->{icon} = $icon } else { undef $o->{icon} } - c::bind_textdomain_codeset($_, 'UTF8') foreach 'libDrakX', @::textdomains; - $::need_utf8_i18n = 1; return $o; } } diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm index 5706cbeae..16fde93a3 100644 --- a/perl-install/interactive/gtk.pm +++ b/perl-install/interactive/gtk.pm @@ -708,4 +708,5 @@ sub kill { $o->{before_killing} = @interactive::objects; } +prepare_gtk2(); 1; diff --git a/perl-install/ugtk.pm b/perl-install/ugtk.pm index 28c2848ec..d69dcfd1f 100644 --- a/perl-install/ugtk.pm +++ b/perl-install/ugtk.pm @@ -16,7 +16,7 @@ $EXPORT_TAGS{all} = [ map { @$_ } values %EXPORT_TAGS ]; use Gtk; if (!$::no_ugtk_init) { - !$ENV{DISPLAY} || system('/usr/X11R6/bin/xtest') and die "Cannot be run in console mode.\n"; + !check_for_xserver() and die "Cannot be run in console mode.\n"; Gtk->init; eval { require Gtk::Gdk::Pixbuf; Gtk::Gdk::Pixbuf->init }; $use_pixbuf = $@ ? 0 : 1; diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm index 7b25900b3..16a9db1a2 100644 --- a/perl-install/ugtk2.pm +++ b/perl-install/ugtk2.pm @@ -14,7 +14,8 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @icon_paths $force_center $force_focus gtkhide gtkdestroy gtkflush gtkset_mousecursor gtkset_mousecursor_normal gtkset_markup gtkmodify_font gtkset_property gtkset_mousecursor_wait gtkappend_text gtkprepend_text gtkinsert_text gtkroot gtksetstyle gtkappend_page) ], helpers => [ qw(add2notebook add_icon_path n_line_size fill_tiled fill_tiled_coords string_size - get_text_coord gtkcolor gtkset_background gtkfontinfo gtkcreate_img gtkcreate_pixbuf set_back_pixbuf) ], + get_text_coord gtkcolor gtkset_background gtkfontinfo gtkcreate_img gtkcreate_pixbuf set_back_pixbuf + prepare_gtk2) ], create => [ qw(create_box_with_title create_adjustment create_scrolled_window create_hbox create_vbox create_dialog destroy_window create_factory_menu create_menu create_notebook create_packtable create_vpaned create_hpaned create_okcancel) ], @@ -31,10 +32,11 @@ use common; use Gtk2; unless ($::no_ugtk_init) { - !$ENV{DISPLAY} || system('/usr/X11R6/bin/xtest') and die "Cannot be run in console mode.\n"; + !check_for_xserver() and die "Cannot be run in console mode.\n"; Gtk2->init(\@ARGV); } + $border = 5; @@ -1260,4 +1262,9 @@ sub ask_browse_tree_info_given_widgets { } +sub prepare_gtk2 { + c::bind_textdomain_codeset($_, 'UTF8') foreach 'libDrakX', @::textdomains; + $::need_utf8_i18n = 1; +} + 1; |