module FtpParadise::GUI::Gtk::FtpParadiseModule
Constants
- DEFAULT_PASSWORD
#¶ ↑
DEFAULT_PASSWORD
¶ ↑#¶ ↑
- DEFAULT_REMOTE_HOST
#¶ ↑
DEFAULT_REMOTE_HOST
¶ ↑#¶ ↑
- DEFAULT_REMOTE_PORT
#¶ ↑
DEFAULT_REMOTE_PORT
¶ ↑#¶ ↑
- DEFAULT_USERNAME
#¶ ↑
DEFAULT_USERNAME
¶ ↑#¶ ↑
- FTP_MAIN_ICON
#¶ ↑
FTP_MAIN_ICON
¶ ↑#¶ ↑
- HEIGHT
#¶ ↑
HEIGHT
¶ ↑#¶ ↑
- MAIN_BG_COLOUR
#¶ ↑
MAIN_BG_COLOUR
¶ ↑#¶ ↑
- MAIN_BG_COLOUR_PRELIGHT
#¶ ↑
MAIN_BG_COLOUR_PRELIGHT
¶ ↑#¶ ↑
- MY_TEMP
- NAMESPACE
#¶ ↑
NAMESPACE
¶ ↑#¶ ↑
- SHALL_WE_DEBUG
#¶ ↑
SHALL_WE_DEBUG
¶ ↑#¶ ↑
- TITLE
#¶ ↑
TITLE
¶ ↑#¶ ↑
- WIDTH
#¶ ↑
WIDTH
¶ ↑#¶ ↑
- YES_THE_USER_IS_CONNECTED
#¶ ↑
YES_THE_USER_IS_CONNECTED
¶ ↑#¶ ↑
Public Class Methods
new( run_already = true )
click to toggle source
run( i = ARGV )
click to toggle source
#¶ ↑
GtkParadise::GUI::Gtk::FtpParadiseModule.run¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 429 def self.run( i = ARGV ) require 'gtk_paradise/run' _ = ::FtpParadise::GUI::Gtk::FtpParadise.new(i) r = ::Gtk.run r << _ r.set_size_request(_.width?, _.height?) r.automatic_title r.top_left_then_run end
Public Instance Methods
add_status_message(i)
click to toggle source
are_we_connected?()
click to toggle source
border_size?()
click to toggle source
clear_right_listing()
click to toggle source
connect_skeleton()
click to toggle source
#¶ ↑
connect_skeleton
(connect tag)¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 291 def connect_skeleton abort_on_exception hbox = gtk_hbox hbox.minimal(@frame_for_the_grid_user_data, 5) # ======================================================================= # # === widget2 # ======================================================================= # vbox_is_the_user_connected = gtk_vbox vbox_is_the_user_connected.set_border_width(10) event_box_for_the_connection_image = gtk_event_box(@connection_image) event_box_for_the_connection_image.fancy_tooltips = 'Click on this image to connect to the specified, remote host.' event_box_for_the_connection_image.on_clicked { do_connect_to_the_remote_host_specified } event_box_for_the_connection_image.set_size_request(50, 50) vbox_is_the_user_connected.minimal(event_box_for_the_connection_image) @label_are_we_connected = text('No') vbox_is_the_user_connected.add(@label_are_we_connected) frame_is_the_user_connected = gtk_frame frame_is_the_user_connected.set_text(' Is the user connected: ') frame_is_the_user_connected.add(vbox_is_the_user_connected) # ======================================================================= # # Next add the box for the "Actions to perform". # ======================================================================= # frame_action_to_perform = gtk_frame frame_action_to_perform.set_text(' Action to perform: ') frame_action_to_perform.label_widget.fancy_tooltips = 'Denote via this widget which action is to be performed.' vbox_action_to_perform = gtk_vbox vbox_action_to_perform.set_border_width(10) @button_upload = button('Upload') @button_upload.fancy_tooltips = '<b>Upload</b> the selected local file to the remote host.' @button_upload.on_clicked { do_upload_the_selected_file } vbox_action_to_perform.add(@button_upload) @button_download = button('Download') @button_download.fancy_tooltips = '<b>Download</b> the selected (<b>remote</b>) files/directories.' @button_download.on_clicked { do_download_the_remote_file_or_directory } vbox_action_to_perform.add(@button_download) vbox_action_to_perform.add(@button_delete_remote_file) vbox_action_to_perform.add(@button_debug) frame_action_to_perform.add(vbox_action_to_perform) draggable_widget_between_two_frames = draggable_up_and_down_pane( frame_is_the_user_connected, frame_action_to_perform ) # hbox << frame_is_the_user_connected # hbox << frame_action_to_perform hbox.add(draggable_widget_between_two_frames) minimal(hbox, 2) hbox_with_the_two_file_listing_widgets = gtk_hbox vbox1 = gtk_vbox vbox1 << text('Local directory') @entry_local_directory = gtk_entry if File.directory? MY_TEMP @entry_local_directory.set_text(MY_TEMP) else @entry_local_directory.set_text(return_pwd) end @entry_local_directory.set_font(:hack_15) vbox1 << @entry_local_directory # ======================================================================= # # === @directory_content_widget1 # ======================================================================= # @directory_content_widget1 = ::Gtk::DirectoryContentWidget.new { :do_not_use_widget_allowing_the_user_to_change_the_local_directory } @directory_content_widget1.set_start_dir(@entry_local_directory.text?) @directory_content_widget1.set_font(:hack_18) @entry_local_directory.on_enter { target = @entry_local_directory.text? if File.directory? target Dir.chdir(target) end @directory_content_widget1.set_use_this_directory( target ) @directory_content_widget1.update } vbox1.maximal(@directory_content_widget1, 5) # Right right middle-vbox: vbox2 = gtk_vbox vbox2 << text('Remote directory') @directory_content_widget2 = ::Gtk::DirectoryContentWidget.new { :do_not_use_widget_allowing_the_user_to_change_the_local_directory } # ======================================================================= # # === @directory_content_widget2 # ======================================================================= # @directory_content_widget2.set_font(:hack_18) @directory_content_widget2.clear # This widget is empty on startup. @entry_remote_directory = gtk_entry @entry_remote_directory.set_font(:hack_15) vbox2 << @entry_remote_directory vbox2 << @directory_content_widget2 # ======================================================================= # # Next add vbox1 and vbox2 together. # ======================================================================= # up_and_down_spacer = up_and_down_pane(vbox1, vbox2) up_and_down_spacer.position = 780 hbox_with_the_two_file_listing_widgets.maximal(up_and_down_spacer) minimal(hbox_with_the_two_file_listing_widgets, 2) do_style_all_buttons_in_a_uniform_manner end
connect_to_remote_host(this_host = host?)
click to toggle source
#¶ ↑
connect_to_remote_host
¶ ↑
Use this method when connecting to the remote host.
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 649 def connect_to_remote_host(this_host = host?) this_host = this_host.to_s @ftp_connection.connect_to(this_host, :be_verbose) add_status_message 'Connecting to '+this_host.to_s+' now.' try_to_sync_label_remote_dir end
create_skeleton()
click to toggle source
#¶ ↑
create_skeleton
(create tag)¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 218 def create_skeleton create_debug_button create_button_delete_remote_file create_status_icon create_statusbar @grid_user_data = gtk_grid @grid_user_data.set_column_spacing(5) @grid_user_data.set_row_spacing(5) @grid_user_data.set_size_request(300, 50) @grid_user_data.set_border_width(20) # ======================================================================= # # Populate the grid next. # ======================================================================= # @grid_user_data.set_left( text('Username:') ) @entry_username = gtk_entry @entry_username.set_size_request(300, 50) @entry_username.set_text(@hash_user_data['user_name']) @entry_username.deselect @entry_username.css_class('pad8px') @grid_user_data.set_right(@entry_username) # ======================================================================= # # === The user Password # ======================================================================= # @grid_user_data.set_left( text('Password:') ) @entry_user_password = gtk_entry @entry_user_password.set_size_request(300, 50) @entry_user_password.set_text(@hash_user_data['password']) @entry_user_password.deselect @entry_user_password.css_class('pad8px') @grid_user_data.set_right(@entry_user_password) # ======================================================================= # # === Remote host: # ======================================================================= # @grid_user_data.set_left( text('Remote host:') ) @entry_remote_host = gtk_entry @entry_remote_host.set_size_request(300, 50) @entry_remote_host.set_text(@hash_user_data['url']) @entry_remote_host.css_class('pad8px') @grid_user_data.set_right( @entry_remote_host ) @grid_user_data.set_left( text('Port:') ) @entry_port = gtk_entry @entry_port.set_size_request(300, 50) @entry_port.set_text(@hash_user_data['port'].to_s) @entry_port.css_class('pad8px') @grid_user_data.set_right( @entry_port ) @frame_for_the_grid_user_data = gtk_frame @frame_for_the_grid_user_data.set_text( ' User data for the FTP connection ' ) @frame_for_the_grid_user_data.add(@grid_user_data) @frame_for_the_grid_user_data.css_class('pad8px') @frame_for_the_grid_user_data.set_border_width(2) @frame_for_the_grid_user_data.set_size_request(400, 40) end
create_status_icon()
click to toggle source
#¶ ↑
create_status_icon
¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 568 def create_status_icon @status_icon = gtk_status_icon if File.exist? FTP_MAIN_ICON @status_icon.pixbuf = GdkPixbuf::Pixbuf.new(file: FTP_MAIN_ICON) end @status_icon.fancy_tooltips = 'StatusIcon' end
create_statusbar()
click to toggle source
#¶ ↑
create_statusbar
¶ ↑
Create the Statusbar.
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 581 def create_statusbar @status_bar = gtk_statusbar if @status_bar.respond_to?(:has_resize_grip=) @status_bar.has_resize_grip = true end @status_bar_context_id = @status_bar.get_context_id('Gtk Ftp Client') end
debug?()
click to toggle source
do_connect_to_the_remote_host_specified( remote_url = remote_url? )
click to toggle source
#¶ ↑
do_connect_to_the_remote_host_specified
¶ ↑
This is the method that will connect to the remove host specified.
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 493 def do_connect_to_the_remote_host_specified( remote_url = remote_url? ) @ftp_connection = Net::FTP.open(remote_url) # @ftp_connection.passive = true user_name = user_name? user_password = user_password? @ftp_connection.login(user_name, user_password) entries = @ftp_connection.list('*') @label_are_we_connected.set_text(YES_THE_USER_IS_CONNECTED) clear_right_listing set_remote_directory('/') modified_entries = entries.map {|line| if line.empty? or line.end_with?('.') line = nil end if line and line.end_with? ':' line = line.dup line.chop! line << '/' end line }.compact modified_entries = modified_entries.map! {|line| splitted = line.split(' ') filename = splitted.last type = 'dir or file here' # Default. if line.end_with? '/' type = 'directory' end [filename, type,'LAST_MODIFIED_GOES_IN_HERE'] } @directory_content_widget2.feed_this_data(modified_entries) end
Also aliased as: do_connect
do_delete_remote_file()
click to toggle source
#¶ ↑
do_delete_remote_file
¶ ↑
Wrapper to delete a remote file.
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 613 def do_delete_remote_file ewarn 'Deleting this remote file:' efancy selection?(:right) @ftp_connection.remove_file( selection?(:right) ) update_everything end
do_download_the_remote_file_or_directory( this_file = @directory_content_widget2.selected? )
click to toggle source
#¶ ↑
do_download_the_remote_file_or_directory
¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 458 def do_download_the_remote_file_or_directory( this_file = @directory_content_widget2.selected? ) if are_we_connected? # ===================================================================== # # In this case we can proceed to download the remote file. We have # to make sure the remote file exists, though. # ===================================================================== # begin ::FtpParadise.download( this_file, @ftp_connection ) rescue Exception => error e 'The file '+this_file.to_s+' does not exist, though.' pp error.class pp error end else e 'But there is no active FTP connection right now.' end end
do_upload_the_selected_file()
click to toggle source
initialize_the_connection_image()
click to toggle source
#¶ ↑
initialize_the_connection_image
¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 179 def initialize_the_connection_image # ======================================================================= # # === @connection_image # ======================================================================= # @connection_image = gtk_image( ::FtpParadise.project_base_dir?+'images/connection_image.png' ) @connection_image.css_class('bblack1') end
is_on_roebe?()
click to toggle source
left_tree_view?()
click to toggle source
output_coloured_line( input, optional_colour = 'yelb' )
click to toggle source
padding?()
click to toggle source
remote_url?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 125 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] # ======================================================================= # # === @title # ======================================================================= # @title = TITLE # ======================================================================= # # === @width # ======================================================================= # @width = WIDTH # ======================================================================= # # === @height # ======================================================================= # @height = HEIGHT # ======================================================================= # # === @ftp_connection # ======================================================================= # @ftp_connection = nil # ======================================================================= # # === @debug # ======================================================================= # @debug = SHALL_WE_DEBUG # ======================================================================= # # === @hash_user_data # ======================================================================= # if is_on_roebe? # ===================================================================== # # This is valid for my home-system. # ===================================================================== # @hash_user_data = ::FtpParadise::RoebeFtpConstants.hash_ftp_dataset?['podserver'] else # ===================================================================== # # Else we simply build up some default values; the regular user # has to overrule them anyway, via the GUI. # ===================================================================== # @hash_user_data = {} @hash_user_data['user_name'] = DEFAULT_USERNAME @hash_user_data['password'] = DEFAULT_PASSWORD @hash_user_data['url'] = DEFAULT_REMOTE_HOST @hash_user_data['port'] = DEFAULT_REMOTE_PORT end initialize_the_connection_image set_use_this_font(:dejavu_condensed_21) use_gtk_paradise_project_css_file infer_the_size_automatically end
return_default_user_name_based_on_selected_host( selected_host = host? )
click to toggle source
#¶ ↑
return_default_user_name_based_on_selected_host
¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 636 def return_default_user_name_based_on_selected_host( selected_host = host? ) selected_host = FtpParadise::RoebeFtpConstants. return_user_name_based_on_given_host(selected_host) return selected_host end
run()
click to toggle source
set_remote_directory(i = '/')
click to toggle source
user_name?()
click to toggle source
#¶ ↑
user_name?¶ ↑
#¶ ↑
# File lib/ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb, line 604 def user_name? @entry_username.text? end
Also aliased as: username?
user_password?()
click to toggle source