From 9e2f460998c85976f00f6f5d75a0098155ba196c Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Thu, 7 Jun 2007 21:11:56 +0000 Subject: reimport from latest checkout --- bin/drak3d | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100755 bin/drak3d (limited to 'bin') diff --git a/bin/drak3d b/bin/drak3d new file mode 100755 index 0000000..591bd48 --- /dev/null +++ b/bin/drak3d @@ -0,0 +1,149 @@ +#!/usr/bin/perl + +# Copyright (C) 2006 Mandriva +# Olivier Blin +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +use strict; + +use lib qw(/usr/lib/libDrakX); + +# i18n: IMPORTANT: to get correct namespace (drak3d instead of libDrakX) +BEGIN { unshift @::textdomains, 'drak3d' } + +use standalone; +use common; +use interactive; +use Xconfig::glx; +use any; + +my $in = interactive->vnew('su'); +my $glx = Xconfig::glx::detect_may_install($in) or $in->exit; +my $running_wm = any::running_window_manager(); + +my @advanced_settings = ( + [ N_("A graphical server supporting OpenGL compositing should be selected."), 'methods', 'method', \@Xconfig::glx::gl_compositing_servers, 1 ], + [ N_("An OpenGL compositing window manager should be selected. It provides 3D desktop and compositing effects in window management, such as translucent windows and moving effects."), 'wms', 'wm', \@Xconfig::glx::gl_compositing_wms, 0 ], +); + +sub choose_gtk { + my ($glx) = @_; + require mygtk2; + import mygtk2 qw(gtknew); + require ugtk2; + import ugtk2 qw(:create :helpers :wrappers :dialogs); + + $ugtk2::wm_icon = 'drak3d-16'; + my $title = N("3D Desktop effects"); + my $w = ugtk2->new($title, no_Window_Manager => !$running_wm); + + $::main_window = $w->{real_window}; #- so that transient_for is defined for wait messages and dialogs + + my $types_group; + my %state; + (my $available_types, $state{type}) = Xconfig::glx::detect_types($glx); + $state{type} and $state{$state{type}{type}}{$_} = $glx->{$_} foreach map { $_->[2] } @advanced_settings; + foreach my $type (@Xconfig::glx::gl_compositing_types) { + foreach (@advanced_settings) { + my (undef, $available, $field, $list, $check_capabilities) = @$_; + my @available = @{$type->{$available} || []}; + my $default = find { + member($_->{$field}, @available) && (!$check_capabilities || $glx->{capabilities}{$_->{$field}}); + } @$list; + $state{$type->{type}}{$field} ||= $default && $default->{$field}; + } + } + + gtkadd($w->{window}, + gtknew('VBox', spacing => 5, children => [ + $::isEmbedded ? () : (0, Gtk2::Banner->new('drak3d', $title)), + 0, gtknew('Title2', label => N("This tool allows you to configure 3D desktop effects.")), + if_(!$glx->{supported}, 0, N("Your system does not support 3D desktop effects.")), + 1, gtknew('VBox', spacing => 5, children_tight => [ + (map { + my $type = $_; + my @advanced = map { + my ($text, $available, $field, $list, $check_capabilities) = @$_; + my $radio_group; + @{$type->{$available} || []} > 1 ? ( + gtknew('WrappedLabel', text => translate($text), + alignment => [ 0, 0 ], padding => [ 10, 0 ]), + gtknew('HBox', children => [ + 0, gtknew('Label', text => ' ' x 10), + 1, gtknew('VBox', children_tight => [ + map { + my $val = $_; + my $match = find { $_->{$field} eq $val } @$list; + $radio_group = gtknew('RadioButton', text => translate($match->{name}), + $radio_group ? (group => $radio_group->get_group) : (), + if_($check_capabilities, sensitive => $glx->{capabilities}{$val}), + active => $state{$type->{type}}{$field} eq $match->{$field}, + toggled => sub { $state{$type->{type}}{$field} = $match->{$field} if $_[0]->get_active }, + ); + } @{$type->{$available}} + ]), + ]), + ) : (); + } @advanced_settings; + gtknew('HBox', children_tight => [ + gtknew('VBox', children => [ + 0, gtknew('Image', file => "IC-3D-" . $type->{type} . "-64.png"), + 1, gtknew('Label'), + ]), + gtknew('VBox', children_tight => [ + gtknew('Label'), + $types_group = gtknew('RadioButton', text => translate($type->{name}), + $types_group ? (group => $types_group->get_group) : (), + sensitive => member($type, @$available_types), + active => $state{type} eq $type, + toggled => sub { + $state{type} = $type if $_[0]->get_active; + $state{advanced}{$_}->set_sensitive($state{type}{type} eq $_) foreach keys %{$state{advanced}}; + }, + ), + @advanced ? + gtknew('HBox', children_tight => [ + gtknew('Label', text => ' ' x 5), + $state{advanced}{$type->{type}} = gtknew('Expander', text => N("Advanced settings"), + sensitive => $state{type} eq $type, + child => gtknew('VBox', children_tight => \@advanced)), + ]) : (), + ]), + ]); + } @Xconfig::glx::gl_compositing_types), + ]), + 0, $w->create_okcancel(undef, undef, undef, [ N("Help"), sub { run_program::raw({ detach => 1 }, 'drakhelp', '--id', 'drak3d') } ]), + ]), + ); + + $w->main; + $glx->{method} = $state{$state{type}{type}}{method} || find { $glx->{capabilities}{$_} } @{$state{type}{methods}}; + $glx->{wm} = $state{$state{type}{type}}{wm} || first(@{$state{type}{wms}}); + $w->{retval}; +} + +my $res; +if ($in->isa('interactive::gtk')) { + $res = choose_gtk($glx); +} else { + $res = Xconfig::glx::choose_interactive($in, $glx); +} +if ($res && Xconfig::glx::install($in, $glx)) { + Xconfig::glx::write($glx); + any::ask_for_X_restart($in); +} + +$in->exit; -- cgit v1.2.1