Add in list of clusters to 'Add Host' window

- thanks for Stanislas Rouvelin for the idea
This commit is contained in:
duncan_ferguson 2009-06-04 17:26:16 +00:00
parent 70d96b54b6
commit 6eaa511fd8
3 changed files with 94 additions and 46 deletions

View file

@ -1,3 +1,8 @@
??? Duncan Ferguson <duncan_ferguson@user.sf.net> - v3.27-1
* Add in list of clusters to 'Add Host' window
- thanks for Stanislas Rouvelin for the idea
2009-06-02 Duncan Ferguson <duncan_ferguson@user.sf.net> - v3.26-1
* Allow user to set a different ConnectTimeout and -o string (Tony Mancill)

View file

@ -28,5 +28,6 @@ Peter Palfrader
David F. Skoll
Bogdan Pintea
Gerfried Fuchs
Stanislas Rouvelin
$Id$

View file

@ -266,6 +266,8 @@ sub load_config_defaults() {
$config{command} = q{};
$config{max_host_menu_items} = 30;
$config{max_addhost_menu_cluster_items} = 6;
}
# load in config file settings
@ -1474,10 +1476,17 @@ sub add_host_by_name() {
return;
}
logmsg( 2, "host=$menus{host_entry}" );
if ( $menus{host_entry} ) {
logmsg( 2, "host=", $menus{host_entry} );
open_client_windows(
resolve_names( split( /\s+/, $menus{host_entry} ) ) );
}
open_client_windows(
resolve_names( split( /\s+/, $menus{host_entry} ) ) );
if ( $menus{listbox}->curselection() ) {
my @hosts = $menus{listbox}->get( $menus{listbox}->curselection() );
logmsg( 2, "host=", join( ' ', @hosts ) );
open_client_windows( resolve_names(@hosts) );
}
build_hosts_menu();
$menus{host_entry} = "";
@ -1671,7 +1680,9 @@ sub create_windows() {
my $paste_text = '';
# SelectionGet is fatal if no selection is given
Tk::catch { $paste_text = $windows{main_window}->SelectionGet };
Tk::catch {
$paste_text = $windows{main_window}->SelectionGet;
};
if ( !length($paste_text) ) {
warn("Got empty paste event\n");
@ -1724,6 +1735,27 @@ sub create_windows() {
-default_button => 'Add',
);
if ( $config{max_addhost_menu_cluster_items}
&& scalar keys %clusters )
{
if ( scalar keys %clusters < $config{max_addhost_menu_cluster_items} )
{
$menus{listbox} = $windows{addhost}->Listbox(
-selectmode => 'extended',
-height => scalar keys %clusters,
)->pack();
}
else {
$menus{listbox} = $windows{addhost}->Scrolled(
'Listbox',
-scrollbars => 'e',
-selectmode => 'extended',
-height => $config{max_addhost_menu_cluster_items},
)->pack();
}
$menus{listbox}->insert( 'end', sort keys %clusters );
}
$windows{host_entry} = $windows{addhost}->add(
'LabEntry',
-textvariable => \$menus{host_entry},
@ -1773,41 +1805,41 @@ sub capture_map_events() {
}
);
# $windows{main_window}->bind(
# '<Unmap>' => sub {
# logmsg( 3, "Entering UNMAP" );
#
# my $state = $windows{main_window}->state();
# logmsg( 3,
# "state=$state previous=$config{internal_previous_state}" );
#
# if ( $config{internal_previous_state} eq $state ) {
# logmsg( 3, "repeating the same" );
# }
#
# if ( $config{internal_previous_state} eq "mid-change" ) {
# logmsg( 3, "dropping out as mid-change" );
# return;
# }
#
# if ( $config{internal_previous_state} eq "normal" ) {
# logmsg( 3, "withdrawing all windows" );
# foreach my $server ( reverse( keys(%servers) ) ) {
# $xdisplay->req( 'UnmapWindow', $servers{$server}{wid} );
# if ( $config{unmap_on_redraw} =~ /yes/i ) {
# $xdisplay->req( 'UnmapWindow',
# $servers{$server}{wid} );
# }
# }
# $xdisplay->flush();
# }
#
# if ( $config{internal_previous_state} ne $state ) {
# logmsg( 3, "resetting prev_state" );
# $config{internal_previous_state} = $state;
# }
# }
# );
# $windows{main_window}->bind(
# '<Unmap>' => sub {
# logmsg( 3, "Entering UNMAP" );
#
# my $state = $windows{main_window}->state();
# logmsg( 3,
# "state=$state previous=$config{internal_previous_state}" );
#
# if ( $config{internal_previous_state} eq $state ) {
# logmsg( 3, "repeating the same" );
# }
#
# if ( $config{internal_previous_state} eq "mid-change" ) {
# logmsg( 3, "dropping out as mid-change" );
# return;
# }
#
# if ( $config{internal_previous_state} eq "normal" ) {
# logmsg( 3, "withdrawing all windows" );
# foreach my $server ( reverse( keys(%servers) ) ) {
# $xdisplay->req( 'UnmapWindow', $servers{$server}{wid} );
# if ( $config{unmap_on_redraw} =~ /yes/i ) {
# $xdisplay->req( 'UnmapWindow',
# $servers{$server}{wid} );
# }
# }
# $xdisplay->flush();
# }
#
# if ( $config{internal_previous_state} ne $state ) {
# logmsg( 3, "resetting prev_state" );
# $config{internal_previous_state} = $state;
# }
# }
# );
}
# for all key event, event hotkeys so there is only 1 key binding
@ -1848,11 +1880,14 @@ sub key_event {
if ( $combo =~ /^$key$/ ) {
if ( $event eq "KeyRelease" ) {
logmsg( 2, "Received hotkey: $hotkey" );
send_clientname() if ( $hotkey eq "key_clientname" );
add_host_by_name() if ( $hotkey eq "key_addhost" );
retile_hosts("force") if ( $hotkey eq "key_retilehosts" );
show_history() if ( $hotkey eq "key_history" );
exit_prog() if ( $hotkey eq "key_quit" );
send_clientname()
if ( $hotkey eq "key_clientname" );
add_host_by_name()
if ( $hotkey eq "key_addhost" );
retile_hosts("force")
if ( $hotkey eq "key_retilehosts" );
show_history() if ( $hotkey eq "key_history" );
exit_prog() if ( $hotkey eq "key_quit" );
}
return;
}
@ -1860,7 +1895,8 @@ sub key_event {
}
# look for a <Control>-d and no hosts, so quit
exit_prog() if ( $state =~ /Control/ && $keysym eq "d" and !%servers );
exit_prog()
if ( $state =~ /Control/ && $keysym eq "d" and !%servers );
update_display_text( $keycodetosym{$keysymdec} )
if ( $event eq "KeyPress" && $keycodetosym{$keysymdec} );
@ -1978,7 +2014,8 @@ sub create_menubar() {
# Note: getopts returned "" if it finds any options it doesnt recognise
# so use this to print out basic help
pod2usage( -verbose => 1 ) if ( !GetOptions( \%options, @options_spec ) );
pod2usage( -verbose => 1 )
if ( !GetOptions( \%options, @options_spec ) );
pod2usage( -verbose => 1 ) if ( $options{'?'} || $options{help} );
pod2usage( -verbose => 2 ) if ( $options{H} || $options{man} );
@ -2492,6 +2529,11 @@ See below notes on shortcuts.
Default key sequence to retile host windows. See below notes on shortcuts.
=item max_addhost_menu_cluster_items = 6
Maximum number of entries in the 'Add Host' menu cluster list before
scrollbars are used
=item max_host_menu_items = 30
Maximum number of hosts to put into the host menu before starting a new column