summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2010-04-09 03:59:02 +0000
committerNorbert Preining <preining@logic.at>2010-04-09 03:59:02 +0000
commita474739a83ef23f37c3b32b3ce9d73f983373c0a (patch)
tree9bf10f69d7eb43f4b1d9af3f55f5eab3d449ba88 /Master
parent6e9742015d7b2ac4a8a4c9e42b5f8f35c4b87152 (diff)
tlmgr gui: provide simple and expert modes, configuration is done
in TEXMFCONFIG/tlmgr/config git-svn-id: svn://tug.org/texlive/trunk@17768 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf/scripts/texlive/NEWS1
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr.pl73
-rw-r--r--Master/texmf/scripts/texlive/tlmgrgui.pl286
3 files changed, 243 insertions, 117 deletions
diff --git a/Master/texmf/scripts/texlive/NEWS b/Master/texmf/scripts/texlive/NEWS
index ff81729927d..38a1b69509c 100644
--- a/Master/texmf/scripts/texlive/NEWS
+++ b/Master/texmf/scripts/texlive/NEWS
@@ -10,6 +10,7 @@ tlmgr rev next
--no-auto-remove (under Menu->Options), and --reinstall-forcibly-removed
(just below the "Update all installed" button)
* GUI: provide access to the manual (tlmgr help) in the Help menu
+ * GUI: provide simple and expert modes
tlmgr rev 17611 (2010-03-30)
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl
index 291a421646d..830ad9e2b03 100755
--- a/Master/texmf/scripts/texlive/tlmgr.pl
+++ b/Master/texmf/scripts/texlive/tlmgr.pl
@@ -89,6 +89,7 @@ use TeXLive::TLPaper;
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
+our %config; # hash of config settings from config file
our $tlmediasrc; # media from which we install/update
our $tlmediatlpdb;
our $location; # location from which the new packages come
@@ -330,6 +331,11 @@ sub main {
TeXLive::TLUtils::setup_persistent_downloads()
if $opts{'persistent-downloads'};
+ #
+ # load the config file and set the config options
+ #
+ load_config_file();
+
execute_action($action, @ARGV);
# end of main program.
@@ -4259,6 +4265,73 @@ sub finish
}
}
+#
+# config file handling
+# config files are located in TEXMFCONFIG/tlmgr/config thus specific
+# for each user
+#
+# format:
+# key=value
+#
+# allowed keys at the moment
+# gui_expertmode = 0|1
+#
+sub load_config_file
+{
+ #
+ # first set default values
+ # the default for gui_expertmode is 1 since that is what we
+ # have shipped till now
+ $config{"gui_expertmode"} = 1;
+
+ chomp (my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`);
+ my $fn = "$TEXMFCONFIG/tlmgr/config";
+ if (-r $fn) {
+ if (!open(TLC, "<$fn")) {
+ tlwarn("Cannot open $fn: $!");
+ return;
+ }
+ while (<TLC>) {
+ if (m/^\s*$/) { next; }
+ if (m/^\s*(\w+)\s*=\s*(.*)\s*$/) {
+ my $key = $1;
+ my $val = $2;
+ if ($key eq "gui_expertmode") {
+ if ($val eq "0") {
+ $config{"gui_expertmode"} = 0;
+ } elsif ($val eq "1") {
+ $config{"gui_expertmode"} = 1;
+ } else {
+ tlwarn("Unknown value $val for gui_expertmode in $fn\n");
+ }
+ } else {
+ tlwarn("Unknown key $key in $fn\n");
+ }
+ next;
+ }
+ tlwarn("I cannot understand the following line in $fn:\n$_\n");
+ next;
+ }
+ close(TLC);
+ }
+}
+
+sub write_config_file
+{
+ chomp (my $TEXMFCONFIG = `kpsewhich -var-value=TEXMFCONFIG`);
+ my $fn = "$TEXMFCONFIG/tlmgr/config";
+ if (-r $fn) {
+ if (!open(TLC, ">$fn")) {
+ tlwarn("Cannot open $fn for writing: $!");
+ return;
+ }
+ for my $k (keys %config) {
+ print TLC "$k = $config{$k}\n";
+ }
+ close(TLC);
+ }
+}
+
# if the packagelog variable is set then write to PACKAGELOG filehandle
#
sub logpackage
diff --git a/Master/texmf/scripts/texlive/tlmgrgui.pl b/Master/texmf/scripts/texlive/tlmgrgui.pl
index 6db08bf444e..23da51e8f24 100644
--- a/Master/texmf/scripts/texlive/tlmgrgui.pl
+++ b/Master/texmf/scripts/texlive/tlmgrgui.pl
@@ -46,6 +46,12 @@ use TeXLive::TLUtils qw(setup_programs platform_desc win32 debug);
use TeXLive::TLConfig;
#
+# GUI mode
+#
+our %config;
+my $mode_expert = $config{"gui_expertmode"};
+
+#
# stuff defined in tlmgr.pl that needs to be our-ed
our $Master;
our $tlmediatlpdb;
@@ -275,7 +281,7 @@ sub do_rest_of_gui {
-variable => \$status_value, -value => $status_only_updated)->pack(@a_w);
my $filter_category = $filter_frame->Labelframe(-text => __("Category"));
- $filter_category->pack(@left, @x_y, @p_ii);
+ if ($mode_expert) { $filter_category->pack(@left, @x_y, @p_ii); }
$filter_category->Checkbutton(-text => __("packages"), -command => \&update_grid,
-variable => \$show_packages)->pack(@a_w);
$filter_category->Checkbutton(-text => __("collections"), -command => \&update_grid,
@@ -302,7 +308,7 @@ sub do_rest_of_gui {
update_grid(); return 1; });
my $filter_selection = $filter_frame->Labelframe(-text => __("Selection"));
- $filter_selection->pack(@left, @x_y, @p_ii);
+ if ($mode_expert) { $filter_selection->pack(@left, @x_y, @p_ii); }
$filter_selection->Radiobutton(-text => __("all"), -command => \&update_grid,
-variable => \$selection_value, -value => 0)->pack(@a_w);
$filter_selection->Radiobutton(-text => __("selected"),
@@ -315,10 +321,12 @@ sub do_rest_of_gui {
my $filter_button = $filter_frame->Frame;
$filter_button->pack(@left, @x_y, @p_ii);
- $filter_button->Button(-text => __("Select all"),
- -command => [ \&update_grid, 1 ])->pack(@x_x, @a_c);
- $filter_button->Button(-text => __("Select none"),
- -command => [ \&update_grid, 0 ])->pack(@x_x, @a_c);
+ if ($mode_expert) {
+ $filter_button->Button(-text => __("Select all"),
+ -command => [ \&update_grid, 1 ])->pack(@x_x, @a_c);
+ $filter_button->Button(-text => __("Select none"),
+ -command => [ \&update_grid, 0 ])->pack(@x_x, @a_c);
+ }
$filter_button->Button(-text => __("Reset filters"),
-command => sub { $status_value = $status_all;
@@ -373,10 +381,12 @@ $g->headerCreate(4, @htype, -itemtype => 'text', -text => __("Short description"
# disable the with filter applied or not applied, it is too complicated, or?
#
- $with_sel_frame->Button(-text => __('Update'),
- -state => $::action_button_state,
- -command => sub { update_selected_packages(); }
- )->pack(@left, @p_ii);
+ if ($mode_expert) {
+ $with_sel_frame->Button(-text => __('Update'),
+ -state => $::action_button_state,
+ -command => sub { update_selected_packages(); }
+ )->pack(@left, @p_ii);
+ }
$with_sel_frame->Button(-text => __('Install'),
-state => $::action_button_state,
-command => sub { install_selected_packages(); }
@@ -385,10 +395,12 @@ $g->headerCreate(4, @htype, -itemtype => 'text', -text => __("Short description"
-state => $::action_button_state,
-command => sub { remove_selected_packages(); }
)->pack(@left, @p_ii);
- $with_sel_frame->Button(-text => __('Backup'),
- -state => $::action_button_state,
- -command => sub { backup_selected_packages(); }
- )->pack(@left, @p_ii);
+ if ($mode_expert) {
+ $with_sel_frame->Button(-text => __('Backup'),
+ -state => $::action_button_state,
+ -command => sub { backup_selected_packages(); }
+ )->pack(@left, @p_ii);
+ }
$top_frame->pack(-fill => 'x', -padx => '2m');
$bot_frame->pack(-fill => 'x', @p_ii, -side => 'bottom');
@@ -432,7 +444,9 @@ sub setup_menu_system {
$menu_help = $menu->Menu();
$menu->add('cascade', -label => "tlmgr", -menu => $menu_file);
$menu->add('cascade', -label => __("Options"), -menu => $menu_options);
- $menu->add('cascade', -label => __("Actions"), -menu => $menu_actions);
+ if ($mode_expert) {
+ $menu->add('cascade', -label => __("Actions"), -menu => $menu_actions);
+ }
# on win32 people expect to have the Help button on the right side
if (win32()) { $menu->add('separator'); }
$menu->add('cascade', -label => __("Help"), -menu => $menu_help);
@@ -449,8 +463,10 @@ sub setup_menu_system {
}
$menu_file->add('command', -label => __("Load default net repository:") . " $TeXLiveURL",
-command => sub { setup_location($TeXLiveURL); });
- $menu_file->add('command', -label => __("Load other repository ..."),
- -command => \&cb_edit_location);
+ if ($mode_expert) {
+ $menu_file->add('command', -label => __("Load other repository ..."),
+ -command => \&cb_edit_location);
+ }
$menu_file->add('separator');
$menu_file->add('command', -label => __("Quit"),
-command => sub { $mw->destroy; exit(0); });
@@ -462,20 +478,24 @@ sub setup_menu_system {
-command => sub { do_general_settings(); });
$menu_options->add('command', -label => __("Paper ..."),
-command => sub { do_paper_settings(); });
- if (!win32()) {
+ if (!win32() && $mode_expert) {
$menu_options->add('command', -label => __("Architectures ..."),
-command => sub { do_arch_settings(); });
}
$menu_options->add('separator');
- $menu_options->add('checkbutton', -label => __("Enable debugging output"),
- -onvalue => ($::opt_verbosity == 0 ? 1 : $::opt_verbosity),
- -variable => \$::opt_verbosity);
- $menu_options->add('checkbutton',
- -label => __("Disable auto-install of new packages"),
- -variable => \$opts{"no-auto-install"});
- $menu_options->add('checkbutton',
- -label => __("Disable auto-removal of server-deleted packages"),
- -variable => \$opts{"no-auto-remove"});
+ $menu_options->add('command', -label => __("GUI mode ..."),
+ -command => sub { do_gui_mode_settings(); });
+ if ($mode_expert) {
+ $menu_options->add('checkbutton', -label => __("Enable debugging output"),
+ -onvalue => ($::opt_verbosity == 0 ? 1 : $::opt_verbosity),
+ -variable => \$::opt_verbosity);
+ $menu_options->add('checkbutton',
+ -label => __("Disable auto-install of new packages"),
+ -variable => \$opts{"no-auto-install"});
+ $menu_options->add('checkbutton',
+ -label => __("Disable auto-removal of server-deleted packages"),
+ -variable => \$opts{"no-auto-remove"});
+ }
#
# Actions menu
@@ -557,7 +577,7 @@ sub setup_menu_system {
tlmgrgui revision $tlmgrguirevision
$tlmgrrev
-Copyright 2009 Norbert Preining
+Copyright 2009, 2010 Norbert Preining
Licensed under the GNU General Public License version 2 or higher
In case of problems, please contact: texlive\@tug.org"
@@ -970,108 +990,110 @@ sub do_general_settings {
-command => sub { menu_default_location($sw); });
- push @config_set_l,
- $back_config_set->Label(-text => __("Create formats on installation"), -anchor => "w");
- push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"create_formats"}{'display'});
- push @config_set_r,
- $back_config_set->Button(-text => __("Toggle"),
- -command => sub { toggle_setting("create_formats"); });
-
- push @config_set_l,
- $back_config_set->Label(-text => __("Install macro/font sources"), -anchor => "w");
- push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"install_srcfiles"}{'display'});
- push @config_set_r,
- $back_config_set->Button(-text => __("Toggle"),
- -command => sub { toggle_setting("install_srcfiles"); });
-
- push @config_set_l,
- $back_config_set->Label(-text => __("Install macro/font docs"), -anchor => "w");
- push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"install_docfiles"}{'display'});
- push @config_set_r,
- $back_config_set->Button(-text => __("Toggle"),
- -command => sub { toggle_setting("install_docfiles"); });
-
- push @config_set_l,
- $back_config_set->Label(-text => __("Default backup directory"), -anchor => "w");
- push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"backupdir"}{'display'});
- push @config_set_r,
- $back_config_set->Button(-text => __("Change"),
- -command => sub {
- my $dir = $sw->chooseDirectory();
- if (defined($dir) && ($defaults{"backupdir"} ne $dir)) {
- # see warning concerning UTF8 or other encoded dir names!!
- $changeddefaults{"backupdir"}{'value'} = $dir;
- $changeddefaults{"backupdir"}{'display'} = $dir;
- }
- });
-
- push @config_set_l,
- $back_config_set->Label(-text => __("Auto backup setting"), -anchor => "w");
- push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"autobackup"}{'display'});
- push @config_set_r,
- $back_config_set->Button(-text => __("Change"),
- -command => sub { select_autobackup($sw); }, -anchor => "w");
-
- if (!win32()) {
+ if ($mode_expert) {
push @config_set_l,
- $back_config_set->Label(-text => __("Link destination for programs"), -anchor => "w");
+ $back_config_set->Label(-text => __("Create formats on installation"), -anchor => "w");
push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"sys_bin"}{'display'});
+ $back_config_set->Label(-textvariable => \$changeddefaults{"create_formats"}{'display'});
push @config_set_r,
- $back_config_set->Button(-text => __("Change"),
- -command => sub { edit_link_dir($sw, "sys_bin"); });
+ $back_config_set->Button(-text => __("Toggle"),
+ -command => sub { toggle_setting("create_formats"); });
+
+ push @config_set_l,
+ $back_config_set->Label(-text => __("Install macro/font sources"), -anchor => "w");
+ push @config_set_m,
+ $back_config_set->Label(-textvariable => \$changeddefaults{"install_srcfiles"}{'display'});
+ push @config_set_r,
+ $back_config_set->Button(-text => __("Toggle"),
+ -command => sub { toggle_setting("install_srcfiles"); });
push @config_set_l,
- $back_config_set->Label(-text => __("Link destination for info docs"), -anchor => "w");
+ $back_config_set->Label(-text => __("Install macro/font docs"), -anchor => "w");
push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"sys_info"}{'display'});
+ $back_config_set->Label(-textvariable => \$changeddefaults{"install_docfiles"}{'display'});
push @config_set_r,
- $back_config_set->Button(-text => __("Change"),
- -command => sub { edit_link_dir($sw, "sys_info"); });
+ $back_config_set->Button(-text => __("Toggle"),
+ -command => sub { toggle_setting("install_docfiles"); });
push @config_set_l,
- $back_config_set->Label(-text => __("Link destination for man pages"), -anchor => "w");
+ $back_config_set->Label(-text => __("Default backup directory"), -anchor => "w");
push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"sys_man"}{'display'});
+ $back_config_set->Label(-textvariable => \$changeddefaults{"backupdir"}{'display'});
push @config_set_r,
$back_config_set->Button(-text => __("Change"),
- -command => sub { edit_link_dir($sw, "sys_man"); });
- }
+ -command => sub {
+ my $dir = $sw->chooseDirectory();
+ if (defined($dir) && ($defaults{"backupdir"} ne $dir)) {
+ # see warning concerning UTF8 or other encoded dir names!!
+ $changeddefaults{"backupdir"}{'value'} = $dir;
+ $changeddefaults{"backupdir"}{'display'} = $dir;
+ }
+ });
- if (win32()) {
push @config_set_l,
- $back_config_set->Label(-text => __("Create shortcuts in menu and on desktop"), -anchor => "w");
+ $back_config_set->Label(-text => __("Auto backup setting"), -anchor => "w");
push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"desktop_integration"}{'display'});
+ $back_config_set->Label(-textvariable => \$changeddefaults{"autobackup"}{'display'});
push @config_set_r,
- $back_config_set->Button(-text => __("Toggle"),
- -command => sub { toggle_setting("desktop_integration"); });
-
- if (admin()) {
+ $back_config_set->Button(-text => __("Change"),
+ -command => sub { select_autobackup($sw); }, -anchor => "w");
+
+ if (!win32()) {
push @config_set_l,
- $back_config_set->Label(-text => __("Install for all users"), -anchor => "w");
+ $back_config_set->Label(-text => __("Link destination for programs"), -anchor => "w");
push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{"w32_multi_user"}{'display'});
+ $back_config_set->Label(-textvariable => \$changeddefaults{"sys_bin"}{'display'});
push @config_set_r,
- $back_config_set->Button(-text => __("Toggle"),
- -command => sub { toggle_setting("w32_multi_user"); });
+ $back_config_set->Button(-text => __("Change"),
+ -command => sub { edit_link_dir($sw, "sys_bin"); });
+
+ push @config_set_l,
+ $back_config_set->Label(-text => __("Link destination for info docs"), -anchor => "w");
+ push @config_set_m,
+ $back_config_set->Label(-textvariable => \$changeddefaults{"sys_info"}{'display'});
+ push @config_set_r,
+ $back_config_set->Button(-text => __("Change"),
+ -command => sub { edit_link_dir($sw, "sys_info"); });
+
+ push @config_set_l,
+ $back_config_set->Label(-text => __("Link destination for man pages"), -anchor => "w");
+ push @config_set_m,
+ $back_config_set->Label(-textvariable => \$changeddefaults{"sys_man"}{'display'});
+ push @config_set_r,
+ $back_config_set->Button(-text => __("Change"),
+ -command => sub { edit_link_dir($sw, "sys_man"); });
}
+
+ if (win32()) {
+ push @config_set_l,
+ $back_config_set->Label(-text => __("Create shortcuts in menu and on desktop"), -anchor => "w");
+ push @config_set_m,
+ $back_config_set->Label(-textvariable => \$changeddefaults{"desktop_integration"}{'display'});
+ push @config_set_r,
+ $back_config_set->Button(-text => __("Toggle"),
+ -command => sub { toggle_setting("desktop_integration"); });
- push @config_set_l,
- $back_config_set->Label(-text => __("Change file associations"), -anchor => "w");
- push @config_set_m,
- $back_config_set->Label(-textvariable => \$changeddefaults{'file_assocs'}{'display'});
- push @config_set_r,
- $back_config_set->Button(-text => __("Change"),
- -command => sub { select_file_assocs($sw); }, -anchor => "w");
+ if (admin()) {
+ push @config_set_l,
+ $back_config_set->Label(-text => __("Install for all users"), -anchor => "w");
+ push @config_set_m,
+ $back_config_set->Label(-textvariable => \$changeddefaults{"w32_multi_user"}{'display'});
+ push @config_set_r,
+ $back_config_set->Button(-text => __("Toggle"),
+ -command => sub { toggle_setting("w32_multi_user"); });
+ }
- }
+ push @config_set_l,
+ $back_config_set->Label(-text => __("Change file associations"), -anchor => "w");
+ push @config_set_m,
+ $back_config_set->Label(-textvariable => \$changeddefaults{'file_assocs'}{'display'});
+ push @config_set_r,
+ $back_config_set->Button(-text => __("Change"),
+ -command => sub { select_file_assocs($sw); }, -anchor => "w");
+ }
+ } # of $mode_export
+
for my $i (0..$#config_set_l) {
$config_set_l[$i]->grid( $config_set_m[$i], $config_set_r[$i],
-padx => "1m", -pady => "1m", -sticky => "nwe");
@@ -1167,17 +1189,19 @@ sub do_paper_settings {
-padx => "2m", -pady => "2m", -sticky => "nswe");
my (%l,%m,%r);
- foreach my $p (sort keys %papers) {
- if (($p eq "context") && !defined($localtlpdb->get_package("bin-context"))) {
- next;
+ if ($mode_expert) {
+ foreach my $p (sort keys %papers) {
+ if (($p eq "context") && !defined($localtlpdb->get_package("bin-context"))) {
+ next;
+ }
+ $l{$p} = $back_config_pap->Label(-text => __("Default paper for") . " $p", -anchor => "w");
+ $m{$p} = $back_config_pap->Label(-textvariable => \$changedpaper{$p}, -anchor => "w");
+ $r{$p} = $back_config_pap->Button(-text => __("Change"),
+ -command => sub { select_paper($sw,$p); }, -anchor => "w");
+ $l{$p}->grid( $m{$p}, $r{$p},
+ -padx => "2m", -pady => "2m", -sticky => "nsw");
}
- $l{$p} = $back_config_pap->Label(-text => __("Default paper for") . " $p", -anchor => "w");
- $m{$p} = $back_config_pap->Label(-textvariable => \$changedpaper{$p}, -anchor => "w");
- $r{$p} = $back_config_pap->Button(-text => __("Change"),
- -command => sub { select_paper($sw,$p); }, -anchor => "w");
- $l{$p}->grid( $m{$p}, $r{$p},
- -padx => "2m", -pady => "2m", -sticky => "nsw");
-}
+ }
$back_config_pap->pack(-side => 'left', -fill => "both", -padx => "2m", -pady => "2m");
@@ -1190,6 +1214,34 @@ sub do_paper_settings {
}
+sub do_gui_mode_settings {
+ my $sw = $mw->Toplevel(-title => __("GUI mode"));
+ $sw->transient($mw);
+ $sw->grab();
+
+ my $txt;
+ my $newmode;
+ if ($mode_expert) {
+ $txt = "Do you want to switch to normal GUI mode?";
+ $newmode = 0;
+ } else {
+ $txt = "Do you want to switch to expert GUI mode?";
+ $newmode = 1;
+ }
+ $txt .= "\n\n" . "(Changes will take effect after restart)";
+ $sw->Label(-text => $txt)->pack(@p_iii);
+ my $lower = $sw->Frame;
+ $lower->pack(-fill => "y", @p_iii);
+
+ $lower->Button(-text => __("Yes"),
+ -command => sub {
+ $config{"gui_expertmode"} = $newmode;
+ write_config_file();
+ $sw->destroy; })->pack(@left, -padx => "3m");
+ $lower->Button(-text => __("Cancel"),
+ -command => sub { $sw->destroy; })->pack(@left, -padx => "3m");
+}
+
#
# this function is used to edit/change the default tlpdb repository
# we also want to change the menu entry if we change that