# # # add_file "lib/perl/ManageServerBookmarks.pm" # content [ffd8ccb8c00934951b92dc89e3c6edcd34ddfc36] # # patch "lib/perl/Common.pm" # from [c3895d65117acd3f91336f502cac6c96f1d8a6b1] # to [d6df7409384166de94c655c2a24103ebdd33d4e2] # # patch "lib/perl/Preferences.pm" # from [c948f20d86d761a439331553dbba6c6d283b688d] # to [7efe98b8d386c359f092b1abba558689a081a763] # # patch "lib/ui/mtn-browse.glade" # from [14a1b707b7ed01890ee689c218fdb0a9a4bfd1ff] # to [e41c19886ad565ade73e69402c1a878e2345d01a] # # patch "mtn-browse" # from [c0fcb16dc95eba64e82f77412d950498041639b0] # to [44ebbb64d1104c09425fcd6290a5a000a53ee294] # ============================================================ --- lib/perl/ManageServerBookmarks.pm ffd8ccb8c00934951b92dc89e3c6edcd34ddfc36 +++ lib/perl/ManageServerBookmarks.pm ffd8ccb8c00934951b92dc89e3c6edcd34ddfc36 @@ -0,0 +1,474 @@ +############################################################################## +# +# File Name - ManageServerBookmarks.pm +# +# Description - The manage server bookmarks module for the mtn-browse +# application. This module contains all the routines for +# implementing manage server bookmarks window. +# +# Author - A.E.Cooper. +# +# Legal Stuff - Copyright (c) 2007 Anthony Edward Cooper +# . +# +# 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 3 of the License, 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 software; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307 USA. +# +############################################################################## +# +############################################################################## +# +# Global Data For This Module +# +############################################################################## + + + +# ***** DIRECTIVES ***** + +require 5.008005; + +use locale; +use strict; +use warnings; + +# ***** GLOBAL DATA DECLARATIONS ***** + +# The type of window that is going to be managed by this module. + +my $window_type = "manage_server_bookmarks_window"; + +# ***** FUNCTIONAL PROTOTYPES ***** + +# Public routines. + +sub manage_server_bookmarks($$); + +# Private routines. + +sub add_server_button_clicked_cb($$); +sub get_manage_server_bookmarks_window($$); +sub load_servers_treeview($); +sub remove_server_button_clicked_cb($$); +sub server_entry_changed_cb($$); +sub servers_treeview_cursor_changed_cb($$); +# +############################################################################## +# +# Routine - manage_server_bookmarks +# +# Description - Displays the manage server bookmarks window and then lets +# the user change the server bookmark list. +# +# Data - $parent : The parent window widget for the find text +# window. +# $bookmarks : The list of server bookmarks that is to be +# edited. +# Return Value : True if the server bookmarks list was +# modified, otherwise false if no changes were +# made. +# +############################################################################## + + + +sub manage_server_bookmarks($$) +{ + + my($parent, $bookmarks) = @_; + + my($changed, + $instance, + $response); + + # Only go looking for a spare find text window, creating one if necessary, + # if there isn't one already mapped for the specified textview widget. + + $instance = get_manage_server_bookmarks_window($parent, $bookmarks); + $response = $instance->{window}->run(); + $instance->{window}->hide(); + if ($response eq "ok") + { + $changed = 1; + @$bookmarks = @{$instance->{server_bookmarks}}; + } + $instance->{servers_liststore}->clear(); + $instance->{server_bookmarks} = []; + + return $changed; + +} +# +############################################################################## +# +# Routine - servers_treeview_cursor_changed_cb +# +# Description - Callback routine called when the user selects an entry in +# the servers treeview in the manage server bookmarks window. +# +# Data - $widget : The widget object that received the signal. +# $instance : The window instance that is associated with +# this widget. +# +############################################################################## + + + +sub servers_treeview_cursor_changed_cb($$) +{ + + my($widget, $instance) = @_; + + return if ($instance->{in_cb}); + local $instance->{in_cb} = 1; + + # Store the details of the newly selected file name pattern. + + $widget->get_selection()->selected_foreach + (sub { + my($model, $path, $iter) = @_; + $instance->{selected_server} = $model->get($iter, 0); + }); + + # Enable the remove server button if something was selected. + + $instance->{remove_server_button}->set_sensitive(TRUE) + if (defined($instance->{selected_server})); + +} +# +############################################################################## +# +# Routine - server_entry_changed_cb +# +# Description - Callback routine called when the user changes the value of +# the server entry field in the manage server bookmarks +# window. +# +# Data - $widget : The widget object that received the signal. +# $instance : The window instance that is associated with +# this widget. +# +############################################################################## + + + +sub server_entry_changed_cb($$) +{ + + my($widget, $instance) = @_; + + return if ($instance->{in_cb}); + local $instance->{in_cb} = 1; + + $instance->{add_server_button}->set_sensitive + ((length($instance->{server_entry}->get_text()) > 0) ? + TRUE : FALSE); + +} +# +############################################################################## +# +# Routine - add_server_button_clicked_cb +# +# Description - Callback routine called when the user clicks on the add +# server button in the manage server bookmarks window. +# +# Data - $widget : The widget object that received the signal. +# $instance : The window instance that is associated with +# this widget. +# +############################################################################## + + + +sub add_server_button_clicked_cb($$) +{ + + my($widget, $instance) = @_; + + return if ($instance->{in_cb}); + local $instance->{in_cb} = 1; + + my $server; + + # Check entry to see if it is valid. + + $server = $instance->{server_entry}->get_text(); + if ($server !~ m/^[A-Za-z0-9._-]+(:\d+)?$/) + { + my $dialog = Gtk2::MessageDialog->new + ($instance->{window}, + ["modal"], + "warning", + "close", + __x("`{server}' is an invalid server\n" + . "name ([:port] is expected).", + server => $server)); + $dialog->run(); + $dialog->destroy(); + return; + } + + # Now check for duplicate entries. + + if (grep(/^\Q$server\E$/, @{$instance->{server_bookmarks}}) > 0) + { + my $dialog = Gtk2::MessageDialog->new + ($instance->{window}, + ["modal"], + "warning", + "close", + __x("`{server}' is already entered\ninto your bookmarks list.", + server => $server)); + $dialog->run(); + $dialog->destroy(); + return; + } + + # Ok so add it to the server bookmarks list and reload the servers + # treeview. + + push(@{$instance->{server_bookmarks}}, $server); + @{$instance->{server_bookmarks}} = sort(@{$instance->{server_bookmarks}}); + load_servers_treeview($instance); + +} +# +############################################################################## +# +# Routine - remove_server_button_clicked_cb +# +# Description - Callback routine called when the user clicks on the remove +# server button in the manage server bookmarks window. +# +# Data - $widget : The widget object that received the signal. +# $instance : The window instance that is associated with +# this widget. +# +############################################################################## + + + +sub remove_server_button_clicked_cb($$) +{ + + my($widget, $instance) = @_; + + return if ($instance->{in_cb}); + local $instance->{in_cb} = 1; + + my $i; + + # Simply remove the selected file name pattern from the list. + + if (defined($instance->{selected_server})) + { + + # Locate the server and remove it from the list. + + for ($i = 0; $i < scalar(@{$instance->{server_bookmarks}}); ++ $i) + { + last if ($instance->{server_bookmarks}->[$i] + eq $instance->{selected_server}); + } + splice(@{$instance->{server_bookmarks}}, $i, 1); + + # Reload the servers treeview. + + load_servers_treeview($instance); + $instance->{remove_server_button}->set_sensitive(FALSE); + + } + +} +# +############################################################################## +# +# Routine - get_manage_server_bookmarks_window +# +# Description - Creates or prepares an existing manage server bookmarks +# window for use. +# +# Data - $parent : The parent window widget for the manage +# server bookmarks window. +# $bookmarks : The list of server bookmarks that is to be +# edited. +# Return Value : A reference to the newly created or unused +# manage server bookmarks instance record. +# +############################################################################## + + + +sub get_manage_server_bookmarks_window($$) +{ + + my($parent, $bookmarks) = @_; + + my($instance, + $new); + my $wm = WindowManager->instance(); + + # Create a new manage server bookmarks window if an unused one wasn't + # found, otherwise reuse an existing unused one. + + if (! defined($instance = $wm->find_unused($window_type))) + { + + my($renderer, + $tv_column); + + $new = 1; + $instance = {}; + $instance->{glade} = Gtk2::GladeXML->new($glade_file, + $window_type, + APPLICATION_NAME); + + # Flag to stop recursive calling of callbacks. + + $instance->{in_cb} = 0; + local $instance->{in_cb} = 1; + + # Connect Glade registered signal handlers. + + glade_signal_autoconnect($instance->{glade}, $instance); + + # Get the widgets that we are interested in. + + $instance->{window} = $instance->{glade}->get_widget($window_type); + foreach my $widget ("servers_treeview", + "server_entry", + "add_server_button", + "remove_server_button") + { + $instance->{$widget} = $instance->{glade}->get_widget($widget); + } + + # Setup the servers list. + + $instance->{servers_liststore} = Gtk2::ListStore->new("Glib::String"); + $instance->{servers_treeview}-> + set_model($instance->{servers_liststore}); + + $tv_column = Gtk2::TreeViewColumn->new(); + $tv_column->set_sizing("grow-only"); + $renderer = Gtk2::CellRendererText->new(); + $tv_column->pack_start($renderer, TRUE); + $tv_column->set_attributes($renderer, "text" => 0); + $instance->{servers_treeview}->append_column($tv_column); + + $instance->{servers_treeview}->set_search_column(0); + $instance->{servers_treeview}-> + set_search_equal_func(\&treeview_column_searcher); + + } + else + { + + my($height, + $width); + + $instance->{in_cb} = 0; + local $instance->{in_cb} = 1; + + # Reset the manage server bookmarks window's state. + + ($width, $height) = $instance->{window}->get_default_size(); + $instance->{window}->resize($width, $height); + + } + + local $instance->{in_cb} = 1; + + $instance->{selected_server} = undef; + $instance->{server_bookmarks} = []; + + # Load in the server bookmarks. + + @{$instance->{server_bookmarks}} = @$bookmarks; + load_servers_treeview($instance); + + # Disable the add and remove buttons and make sure the server entry field + # is empty. + + $instance->{server_entry}->set_text(""); + $instance->{add_server_button}->set_sensitive(FALSE); + $instance->{remove_server_button}->set_sensitive(FALSE); + + # Reparent window and display it. + + $instance->{window}->set_transient_for($parent); + $instance->{window}->show_all(); + $instance->{window}->present(); + + # Make sure that the server entry field has the focus. + + $instance->{server_entry}->grab_focus(); + $instance->{server_entry}->set_position(-1); + + # If necessary, register the window for management and set up the help + # callbacks. + + if ($new) + { + $wm->manage($instance, $window_type, $instance->{window}); + register_help_callbacks + ($instance, + {widget => undef, + help_ref => __("mtnb-xxx")}); +# TBD + } + + return $instance; + +} +# +############################################################################## +# +# Routine - load_servers_treeview +# +# Description - Load up the servers treeview with the current server +# bookmarks. +# +# Data - $instance : The associated window instance. +# +############################################################################## + + + +sub load_servers_treeview($) +{ + + my $instance = $_[0]; + + # Load up the server bookmarks treeview. + + $instance->{servers_liststore}->clear(); + foreach my $pattern (@{$instance->{server_bookmarks}}) + { + $instance->{servers_liststore}-> + set($instance->{servers_liststore}->append(), + 0, + $pattern); + } + $instance->{servers_treeview}->scroll_to_point(0, 0) + if ($instance->{servers_treeview}->realized()); + +} + +1; ============================================================ --- lib/perl/Common.pm c3895d65117acd3f91336f502cac6c96f1d8a6b1 +++ lib/perl/Common.pm d6df7409384166de94c655c2a24103ebdd33d4e2 @@ -544,8 +544,8 @@ sub open_database($$$) $message =~ s/mtn: misuse: //g; $message =~ s/^Corrupt\/missing mtn [^\n]+\n//g; $message =~ s/ at .+ line \d+$//g; + $message =~ s/\s+$//g; $message =~ s/\n/ /g; - $message =~ s/\s+$//g; $message .= "." unless ($message =~ m/.+\.$/); $dialog = Gtk2::MessageDialog->new_with_markup ($parent, ============================================================ --- lib/perl/Preferences.pm c948f20d86d761a439331553dbba6c6d283b688d +++ lib/perl/Preferences.pm 7efe98b8d386c359f092b1abba558689a081a763 @@ -80,7 +80,7 @@ use constant PREFERENCES_FILE_NAME => ". # Constant for the preferences file's format version. -use constant PREFERENCES_FORMAT_VERSION => 10; +use constant PREFERENCES_FORMAT_VERSION => 11; # Text viewable application mime types. @@ -1696,6 +1696,10 @@ sub upgrade_preferences($) $preferences->{binary_threshold} = 20; $preferences->{version} = 10; } + if ($preferences->{version} == 10) + { + $preferences->{server_bookmarks} = []; + } $preferences->{version} = PREFERENCES_FORMAT_VERSION; @@ -1766,7 +1770,8 @@ sub initialise_preferences() find_files_named => [], find_files_containing => [], find_files_modified_by => [], - find_text => []}); + find_text => []}, + server_bookmarks => []); return \%preferences; ============================================================ --- lib/ui/mtn-browse.glade 14a1b707b7ed01890ee689c218fdb0a9a4bfd1ff +++ lib/ui/mtn-browse.glade e41c19886ad565ade73e69402c1a878e2345d01a @@ -64,7 +64,7 @@ - + True gtk-new 1 @@ -86,6 +86,26 @@ + + True + Connect To _Server + True + + + + True + gtk-network + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + True GNOMEUIINFO_MENU_CLOSE_ITEM @@ -107,7 +127,7 @@ - + True gtk-quit 1 @@ -181,7 +201,7 @@ - + True gtk-help 1 @@ -203,7 +223,7 @@ - + True gtk-help 1 @@ -225,7 +245,7 @@ - + True gtk-help 1 @@ -252,7 +272,7 @@ - + True gtk-home 1 @@ -9678,4 +9698,215 @@ that you want + + True + Manage Server Bookmarks + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER_ON_PARENT + True + 420 + 200 + True + False + mtn-browse.png + True + True + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 5 + True + False + 5 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + False + False + True + + + + + + 0 + True + True + + + + + + True + 2 + 2 + False + 0 + 5 + + + + True + Add a new Monotone +server to the list + True + GTK_RELIEF_NONE + False + + + + + True + gtk-add + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 1 + 2 + 0 + 1 + fill + + + + + + + True + Remove the currently selected +Monotone server from the list + True + GTK_RELIEF_NONE + False + + + + + True + gtk-remove + 4 + 0.5 + 0.5 + 0 + 0 + + + + + 1 + 2 + 1 + 2 + fill + + + + + + + 160 + True + True + True + True + 0 + + True + * + False + + + + 0 + 1 + 0 + 1 + + + + + + 0 + False + True + + + + + 0 + True + True + + + + + + ============================================================ --- mtn-browse c0fcb16dc95eba64e82f77412d950498041639b0 +++ mtn-browse 44ebbb64d1104c09425fcd6290a5a000a53ee294 @@ -81,6 +81,7 @@ use POSIX qw(:errno_h :locale_h :sys_wai use Locale::TextDomain (APPLICATION_NAME, File::Spec->catfile(PREFIX_DIR, "share", "locale")); use POSIX qw(:errno_h :locale_h :sys_wait_h strftime); +use Socket; use Symbol qw(gensym); use Text::Tabs; use Time::Local; @@ -106,6 +107,7 @@ use History; use FindFiles; use FindText; use History; +use ManageServerBookmarks; use MultipleRevisions; use Preferences; use WindowManager; @@ -132,6 +134,11 @@ my $window_type = "main_window"; my $window_type = "main_window"; +# Whether Monotone can handle remote connections to servers (undefined for +# don't know). + +my $mtn_supports_remote_connections; + # The large logo used for the about dialog window. my $large_logo; @@ -144,6 +151,7 @@ sub close_toolbutton_clicked_cb($$); sub advanced_find_button_clicked_cb($$); sub annotate_button_clicked_cb($$); sub close_toolbutton_clicked_cb($$); +sub connect_to_server_activate_cb($$); sub context_help_activate_cb($$); sub create_browser_widgets(); sub determine_mime_type($$$$); @@ -157,6 +165,7 @@ sub main_window_delete_event_cb($$$); sub help_toolbutton_clicked_cb($$); sub home_page_activate_cb($$); sub main_window_delete_event_cb($$$); +sub manage_server_bookmarks_activate_cb($$); sub manifest_browser_treeview_cursor_changed_cb($$); sub manifest_browser_treeview_row_activated_cb($$$$); sub monotone_viz_button_clicked_cb($$); @@ -177,6 +186,7 @@ sub update_browser_state($$); sub show_line_numbers_togglebutton_toggled_cb($$); sub sigchld_handler(); sub update_browser_state($$); +sub update_server_bookmarks_menu($); sub view_button_clicked_cb($$); # ############################################################################## @@ -342,6 +352,8 @@ sub view_button_clicked_cb($$); { setup_mtn_object($mtn, $browser->{window}); $browser->{mtn} = $mtn; + $browser->{connect_to_server_menutiem}->set_sensitive(FALSE) + if (! $mtn_supports_remote_connections); Glib::Idle->add (sub { my $browser = $_[0]; @@ -388,6 +400,172 @@ sub view_button_clicked_cb($$); # ############################################################################## # +# Routine - manage_server_bookmarks_activate_cb +# +# Description - Callback routine called when the user selects the manage +# server bookmarks menu option. +# +# Data - $widget : The widget object that received the signal. +# $browser : The browser instance that is associated with +# this widget. +# +############################################################################## + + + +sub manage_server_bookmarks_activate_cb($$) +{ + + my($widget, $browser) = @_; + + return if ($browser->{in_cb}); + local $browser->{in_cb} = 1; + + if (manage_server_bookmarks($browser->{window}, + $user_preferences->{server_bookmarks})) + { + + eval + { + save_preferences($user_preferences); + }; + if ($@) + { + chomp($@); + my $dialog = Gtk2::MessageDialog->new + (undef, + ["modal"], + "warning", + "close", + __("Your preferences could not be saved:\n") . $@); + $dialog->run(); + $dialog->destroy(); + } + + # We now need to update all server bookmark menus. + + WindowManager->instance()->cond_find + ($window_type, + sub { + my $browser = $_[0]; + update_server_bookmarks_menu($browser); + return; + }); + + } + +} +# +############################################################################## +# +# Routine - connect_to_server_activate_cb +# +# Description - Callback routine called when the user selects a server +# bookmark menu option. +# +# Data - $widget : The widget object that received the signal. +# $details : A record containing the browser instance that is +# associated with this widget and the name of the +# server that is to be connected to. +# +############################################################################## + + + +sub connect_to_server_activate_cb($$) +{ + + my($widget, $details) = @_; + + return if ($details->{browser}->{in_cb}); + local $details->{browser}->{in_cb} = 1; + + my($exception, + $host, + $mtn); + my $browser = $details->{browser}; + my $wm = WindowManager->instance(); + + $wm->make_busy($browser, 1); + $wm->update_gui(); + + # See if we know about the server first. + + $host = $details->{server}; + $host =~ s/:\d+$//g; + if (! defined(inet_aton($host))) + { + my $dialog; + $dialog = Gtk2::MessageDialog->new + ($browser->{window}, + ["modal"], + "warning", + "close", + __x("Server `{server}' is not\nknown to the system.", + server => $host)); + $wm->allow_input(sub { $dialog->run(); }); + $dialog->destroy(); + } + else + { + + # Try connecting to the specified server. + + CachingAutomateStdio->register_error_handler + (MTN_SEVERITY_ALL, + sub { + my($severity, $message) = @_; + my $dialog; + $message =~ s/mtn: warning: //g; + $message =~ s/mtn: error: //g; + $message =~ s/mtn: //g; + $message =~ s/^Corrupt\/missing mtn [^\n]+\n//g; + $message =~ s/ at .+ line \d+$//g; + $message =~ s/\s+$//g; + $message =~ s/\n/ /g; + $message .= "." unless ($message =~ m/.+\.$/); + $dialog = Gtk2::MessageDialog->new_with_markup + ($browser->{window}, + ["modal"], + "warning", + "close", + __x("There is a problem connecting to the server, the " + . "details are:\n{error_message}", + error_message => + Glib::Markup::escape_text($message))); + $wm->allow_input(sub { $dialog->run(); }); + $dialog->destroy(); + die("Bad open"); + }); + $browser->{appbar}->set_status(__x("Connecting to server `{server}'", + server => $host)); + eval + { + $mtn = CachingAutomateStdio->new_from_service($details->{server}); + }; + $exception = $@; + CachingAutomateStdio->register_error_handler + (MTN_SEVERITY_ALL, \&mtn_error_handler); + $browser->{appbar}->clear_stack(); + if (! $exception) + { + + # Seems to be ok so set up the browser. + + setup_mtn_object($mtn, $browser->{window}); + $browser->{mtn} = $mtn; + &{$browser->{update_handler}}($browser, DATABASE_CHANGED); + + } + + } + + $wm->make_busy($browser, 0); + +} +# +############################################################################## +# # Routine - quit_activate_cb # # Description - Callback routine called when the user selects the quit menu @@ -1607,6 +1785,7 @@ sub get_browser_window(;$$$$$) $browser->{window} = $browser->{glade}->get_widget($window_type); foreach my $widget ("appbar", + "connect_to_server_menutiem", "file_encoding_menuitem", "main_vbox", "browser_hpaned", @@ -1634,6 +1813,25 @@ sub get_browser_window(;$$$$$) $browser->{$widget} = $browser->{glade}->get_widget($widget); } + # Setup button sensitivity groups. + + $browser->{text_file_sensitive_group} = []; + foreach my $item ("search_text", "annotate") + { + push(@{$browser->{text_file_sensitive_group}}, + $browser->{glade}->get_widget($item . "_button")); + } + $browser->{revision_sensitive_group} = []; + foreach my $item ("revision_change_history", "revision_change_log") + { + push(@{$browser->{revision_sensitive_group}}, + $browser->{glade}->get_widget($item . "_button")); + } + + # Setup the connect to server submenu. + + update_server_bookmarks_menu($browser); + # Setup the file encodings submenu. @encodings = sort(Encode->encodings(":all")); @@ -1676,6 +1874,7 @@ sub get_browser_window(;$$$$$) $menu_item->set_submenu($subsubmenu); $menu_item->show(); $submenu->append($menu_item); + $submenu->show(); $browser->{file_encoding_menuitem}->set_submenu($submenu); # Setup button sensitivity groups. @@ -2049,6 +2248,64 @@ sub create_browser_widgets() # ############################################################################## # +# Routine - update_server_bookmarks_menu +# +# Description - Creates or updates a server bookmarks menu for the +# specified browser window. +# +# Data - $browser : The browser instance that is to have its server +# bookmarks menu created or updated. +# +############################################################################## + + + +sub update_server_bookmarks_menu($) +{ + + my $browser = $_[0]; + + my($menu_item, + $old_menu, + $submenu); + + # Create a new connect to server submenu. + + $submenu = Gtk2::Menu->new(); + $menu_item = Gtk2::MenuItem->new(__("Manage Server Bookmarks")); + $menu_item->signal_connect("activate", + \&manage_server_bookmarks_activate_cb, + $browser); + $menu_item->show(); + $submenu->append($menu_item); + $menu_item = Gtk2::SeparatorMenuItem->new(); + $menu_item->show(); + $submenu->append($menu_item); + for my $server (@{$user_preferences->{server_bookmarks}}) + { + $menu_item = Gtk2::MenuItem->new(__($server)); + $menu_item->signal_connect("activate", + \&connect_to_server_activate_cb, + {browser => $browser, + server => $server}); + $menu_item->show(); + $submenu->append($menu_item); + } + $submenu->show(); + + # Replace the existing menu with the new one. + + $old_menu = $browser->{connect_to_server_menutiem}->get_submenu(); + $browser->{connect_to_server_menutiem}->set_submenu($submenu); + if (defined($old_menu)) + { + $old_menu->destroy() + } + +} +# +############################################################################## +# # Routine - update_browser_state # # Description - Update the display of the specified browser instance @@ -2100,17 +2357,27 @@ sub update_browser_state($$) $browser->{close_toolbutton}->set_sensitive(TRUE); $browser->{reload_toolbutton}->set_sensitive(TRUE); $browser->{main_vbox}->set_sensitive(TRUE); - if (! defined($browser->{mtn}->get_db_name())) + if (defined($browser->{mtn}->get_service_name())) { - $browser->{mtn}->get_option(\$db_name, "database"); - set_label_value($browser->{database_name_value_label}, - __x(" ({database_name})", - database_name => $db_name)); + set_label_value + ($browser->{database_name_value_label}, + __x(" ({service_name})", + service_name => $browser->{mtn}->get_service_name())); } else { - set_label_value($browser->{database_name_value_label}, - $browser->{mtn}->get_db_name()); + if (defined($browser->{mtn}->get_db_name())) + { + set_label_value($browser->{database_name_value_label}, + $browser->{mtn}->get_db_name()); + } + else + { + $browser->{mtn}->get_option(\$db_name, "database"); + set_label_value($browser->{database_name_value_label}, + __x(" ({database_name})", + database_name => $db_name)); + } } # Make sure that the branch comboboxentry has the focus and not the @@ -3110,6 +3377,8 @@ sub setup_mtn_object($$) my $wm = WindowManager->instance(); + # Deal with branch suspend certificate settings. + if ($user_preferences->{show_suspended}) { if ($mtn->supports(MTN_IGNORING_OF_SUSPEND_CERTS)) @@ -3148,6 +3417,23 @@ sub setup_mtn_object($$) } } + # Determine whether remote connections to servers are supported if we don't + # already know. + + if (! defined($mtn_supports_remote_connections)) + { + if ($mtn->supports(MTN_REMOTE_CONNECTIONS)) + { + $mtn_supports_remote_connections = 1; + } + else + { + $mtn_supports_remote_connections = 0; +# TBD +$mtn_supports_remote_connections = 1; + } + } + } # ##############################################################################