diff options
author | Thierry Vignaud <tv@mandriva.org> | 2008-11-20 15:05:32 +0000 |
---|---|---|
committer | Thierry Vignaud <tv@mandriva.org> | 2008-11-20 15:05:32 +0000 |
commit | eb3134355ed613ce5e87999bcae63a19380f2624 (patch) | |
tree | 8bfaa8e938d7ec3f885122cd602087dea7d2d10a /mdkapplet_gui.pm | |
parent | 4d790d85c13a540539b5c935c7e1ab037d53e8ac (diff) | |
download | mgaonline-eb3134355ed613ce5e87999bcae63a19380f2624.tar mgaonline-eb3134355ed613ce5e87999bcae63a19380f2624.tar.gz mgaonline-eb3134355ed613ce5e87999bcae63a19380f2624.tar.bz2 mgaonline-eb3134355ed613ce5e87999bcae63a19380f2624.tar.xz mgaonline-eb3134355ed613ce5e87999bcae63a19380f2624.zip |
split some code into mdkapplet_gui package
Diffstat (limited to 'mdkapplet_gui.pm')
-rwxr-xr-x | mdkapplet_gui.pm | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/mdkapplet_gui.pm b/mdkapplet_gui.pm new file mode 100755 index 00000000..784c57a6 --- /dev/null +++ b/mdkapplet_gui.pm @@ -0,0 +1,100 @@ +package mdkapplet_gui; + +################################################################################ +# Mandriva Online # +# # +# Copyright (C) 2003-2008 Mandriva # +# # +# Daouda Lo # +# Thierry Vignaud <tvignaud at mandriva dot com> # +# # +# This program is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License Version 2 as # +# published by the Free Software Foundation. # +# # +# 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); +use common; + + +our @ISA = qw(Exporter); +our @EXPORT = qw( + @common + %local_config + $localdir + $localfile + $width + fill_n_run_portable_dialog + new_link_button + new_portable_dialog + setVar + ); + + +use mygtk2 qw(gtknew); #- do not import gtkadd which conflicts with ugtk2 version +use ugtk2 qw(:all); +use lib qw(/usr/lib/libDrakX/drakfirsttime); + +ugtk2::add_icon_path("/usr/share/mdkonline/pixmaps/"); + +our $localdir = "$ENV{HOME}/.MdkOnline"; +our $localfile = "$localdir/mdkonline"; + +#compatibility +mkdir_p($localdir) if !-d $localdir; +-e "$ENV{HOME}/.mdkonline" and system("mv", "$ENV{HOME}/.mdkonline", $localfile); + +our %local_config = getVarsFromSh($localfile); + +our $width = 500; +our @common = ( + # explicitely wrap (for 2008.1): + line_wrap => 1, + # workaround infamous 6 years old gnome bug #101968: + width => $width - 50, +); + +sub new_portable_dialog { + my ($title) = @_; + ugtk2->new($title, width => $width + 20); +} + +sub fill_n_run_portable_dialog { + my ($w, $widgets) = @_; + + # use wizard button order (for both 2008.1 & 2009.0): + local $::isWizard = 1; + local $w->{pop_it} = 0; + local $::isInstall = 1; + gtkadd($w->{window}, gtknew('VBox', children_tight => $widgets)); + + $w->{ok}->grab_focus; + $w->main; +} + +sub new_link_button { + my ($url, $text) = @_; + my $link = Gtk2::LinkButton->new($url, $text); + $link->set_uri_hook(sub { + my (undef, $url) = @_; + run_program::raw({ detach => 1, setuid => get_parent_uid() }, 'www-browser', $url); + }); + $link; +} + +sub setVar { + my ($var, $st) = @_; + my %s = getVarsFromSh($localfile); + $s{$var} = $st; + setVarsInSh($localfile, \%s); +} |