ftp_paradise 1.4.5 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ftp_paradise might be problematic. Click here for more details.

Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +152 -28
  3. data/bin/{iftp → ftp_paradise_shell} +1 -1
  4. data/doc/README.gen +97 -15
  5. data/doc/todo/{TODO_FOR_FTP_PARADISE_PROJECT.md → todo_for_the_ftp_paradise_project.md} +0 -0
  6. data/ftp_paradise.gemspec +30 -39
  7. data/lib/ftp_paradise/base/base.rb +375 -0
  8. data/lib/ftp_paradise/colours/colours.rb +27 -27
  9. data/lib/ftp_paradise/colours/use_colours.rb +6 -1
  10. data/lib/ftp_paradise/configuration/configuration.rb +7 -4
  11. data/lib/ftp_paradise/connection/README.md +0 -0
  12. data/lib/ftp_paradise/connection/connection.rb +2782 -15
  13. data/lib/ftp_paradise/constants/constants.rb +91 -5
  14. data/lib/ftp_paradise/entry/entry.rb +42 -5
  15. data/lib/ftp_paradise/{connection → gui/gtk3/ftp_client}/constants.rb +33 -21
  16. data/lib/ftp_paradise/gui/{shared_code/ftp_paradise/ftp_paradise_module.rb → gtk3/ftp_client/ftp_client.rb} +658 -170
  17. data/lib/ftp_paradise/gui/gtk3/ftp_client/misc.rb +27 -0
  18. data/lib/ftp_paradise/project/project.rb +11 -15
  19. data/lib/ftp_paradise/requires/require_class_connection.rb +7 -0
  20. data/lib/ftp_paradise/requires/require_net_ftp.rb +7 -0
  21. data/lib/ftp_paradise/requires/require_the_ftp_paradise_project.rb +4 -3
  22. data/lib/ftp_paradise/requires/require_the_ftp_paradise_project_with_the_GUI_bindings.rb +1 -1
  23. data/lib/ftp_paradise/requires/require_the_toplevel_methods.rb +1 -0
  24. data/lib/ftp_paradise/{interactive_ftp → shell}/menu.rb +554 -448
  25. data/lib/ftp_paradise/shell/shell.rb +2321 -0
  26. data/lib/ftp_paradise/toplevel_methods/connect.rb +3 -0
  27. data/lib/ftp_paradise/toplevel_methods/dataset.rb +111 -0
  28. data/lib/ftp_paradise/toplevel_methods/file_related_actions.rb +4 -3
  29. data/lib/ftp_paradise/toplevel_methods/ftp_object.rb +6 -5
  30. data/lib/ftp_paradise/toplevel_methods/login_name.rb +6 -4
  31. data/lib/ftp_paradise/toplevel_methods/misc.rb +19 -0
  32. data/lib/ftp_paradise/toplevel_methods/opn.rb +1 -1
  33. data/lib/ftp_paradise/toplevel_methods/password.rb +4 -2
  34. data/lib/ftp_paradise/toplevel_methods/port.rb +4 -1
  35. data/lib/ftp_paradise/toplevel_methods/remote_url.rb +11 -5
  36. data/lib/ftp_paradise/toplevel_methods/upload_and_download.rb +1 -0
  37. data/lib/ftp_paradise/version/version.rb +6 -1
  38. data/lib/ftp_paradise/www/web_interface.cgi +1 -1
  39. data/lib/ftp_paradise/yaml/automatically_connect_on_startup_of_the_interactive_ftp_shell.yml +0 -0
  40. data/lib/ftp_paradise/yaml/debug.yml +0 -0
  41. data/lib/ftp_paradise/yaml/open_in_default_editor.yml +0 -0
  42. data/lib/ftp_paradise/yaml/show_full_names.yml +0 -0
  43. data/lib/ftp_paradise/yaml/use_colours.yml +0 -0
  44. data/test/testing_minimal_pure_net_ftp_example_to_connect.rb +13 -3
  45. metadata +52 -126
  46. data/lib/ftp_paradise/base/cliner.rb +0 -23
  47. data/lib/ftp_paradise/base/colours.rb +0 -83
  48. data/lib/ftp_paradise/base/prototype.rb +0 -171
  49. data/lib/ftp_paradise/base/reset.rb +0 -29
  50. data/lib/ftp_paradise/connection/data.rb +0 -164
  51. data/lib/ftp_paradise/connection/debug.rb +0 -78
  52. data/lib/ftp_paradise/connection/directory_handling.rb +0 -271
  53. data/lib/ftp_paradise/connection/do_login.rb +0 -108
  54. data/lib/ftp_paradise/connection/download.rb +0 -86
  55. data/lib/ftp_paradise/connection/file_handling.rb +0 -174
  56. data/lib/ftp_paradise/connection/ftp_object.rb +0 -21
  57. data/lib/ftp_paradise/connection/initialize.rb +0 -88
  58. data/lib/ftp_paradise/connection/initialize_a_new_net_ftp_object_with_this_url.rb +0 -20
  59. data/lib/ftp_paradise/connection/is_connected.rb +0 -46
  60. data/lib/ftp_paradise/connection/misc.rb +0 -474
  61. data/lib/ftp_paradise/connection/notify.rb +0 -71
  62. data/lib/ftp_paradise/connection/password.rb +0 -47
  63. data/lib/ftp_paradise/connection/port.rb +0 -33
  64. data/lib/ftp_paradise/connection/remote_pwd.rb +0 -72
  65. data/lib/ftp_paradise/connection/remote_url.rb +0 -164
  66. data/lib/ftp_paradise/connection/remove.rb +0 -143
  67. data/lib/ftp_paradise/connection/reset.rb +0 -78
  68. data/lib/ftp_paradise/connection/run.rb +0 -18
  69. data/lib/ftp_paradise/connection/set_array_available_hosts.rb +0 -27
  70. data/lib/ftp_paradise/connection/set_input.rb +0 -18
  71. data/lib/ftp_paradise/connection/show.rb +0 -153
  72. data/lib/ftp_paradise/connection/sync_ftp_object_onto_the_main_namespace.rb +0 -24
  73. data/lib/ftp_paradise/connection/transfer_mode.rb +0 -163
  74. data/lib/ftp_paradise/connection/upload.rb +0 -253
  75. data/lib/ftp_paradise/connection/use_default_dataset.rb +0 -40
  76. data/lib/ftp_paradise/connection/username.rb +0 -42
  77. data/lib/ftp_paradise/constants/misc.rb +0 -57
  78. data/lib/ftp_paradise/constants/namespace.rb +0 -14
  79. data/lib/ftp_paradise/constants/newline.rb +0 -14
  80. data/lib/ftp_paradise/constants/roebe.rb +0 -31
  81. data/lib/ftp_paradise/constants/roebe_ftp_constants.rb +0 -233
  82. data/lib/ftp_paradise/gui/gtk2/ftp_paradise.rb +0 -34
  83. data/lib/ftp_paradise/gui/gtk3/ftp_paradise.rb +0 -34
  84. data/lib/ftp_paradise/interactive_ftp/constants.rb +0 -103
  85. data/lib/ftp_paradise/interactive_ftp/directory_handling.rb +0 -216
  86. data/lib/ftp_paradise/interactive_ftp/help.rb +0 -50
  87. data/lib/ftp_paradise/interactive_ftp/initialize.rb +0 -27
  88. data/lib/ftp_paradise/interactive_ftp/interactive_ftp.rb +0 -998
  89. data/lib/ftp_paradise/interactive_ftp/main_loop.rb +0 -51
  90. data/lib/ftp_paradise/interactive_ftp/misc.rb +0 -208
  91. data/lib/ftp_paradise/interactive_ftp/mode.rb +0 -124
  92. data/lib/ftp_paradise/interactive_ftp/readline.rb +0 -113
  93. data/lib/ftp_paradise/interactive_ftp/remove.rb +0 -97
  94. data/lib/ftp_paradise/interactive_ftp/reset.rb +0 -90
  95. data/lib/ftp_paradise/interactive_ftp/run.rb +0 -22
  96. data/lib/ftp_paradise/interactive_ftp/show.rb +0 -184
  97. data/lib/ftp_paradise/interactive_ftp/upload.rb +0 -90
  98. data/lib/ftp_paradise/interactive_ftp/user_input.rb +0 -53
  99. data/lib/ftp_paradise/toplevel_methods/can_connect_to_remote_site.rb +0 -28
  100. data/lib/ftp_paradise/toplevel_methods/clear_user_dataset.rb +0 -28
  101. data/lib/ftp_paradise/toplevel_methods/data.rb +0 -31
  102. data/lib/ftp_paradise/toplevel_methods/determine_user_dataset_from_this_hash.rb +0 -37
@@ -2,60 +2,678 @@
2
2
  # Encoding: UTF-8
3
3
  # frozen_string_literal: true
4
4
  # =========================================================================== #
5
- # === FtpParadise::GUI::Gtk::FtpParadiseModule
5
+ # === FtpParadise::GUI::Gtk::FtpClient
6
6
  #
7
7
  # The purpose of this class is to provide a GTK-FTP Client, loosely
8
8
  # modelled after the client called "gftp".
9
9
  # =========================================================================== #
10
- # require 'ftp_paradise/gui/shared_code/ftp_paradise/ftp_paradise_module.rb'
11
- # include ::FtpParadise::GUI::Gtk::FtpParadiseModule
10
+ # require 'ftp_paradise/gui/gtk3/ftp_client/ftp_client.rb'
11
+ # FtpParadise::GUI::Gtk::FtpClient.run
12
12
  # =========================================================================== #
13
+ require 'gtk_paradise/require_gtk3'
14
+
13
15
  module FtpParadise
14
16
 
15
17
  module GUI
16
18
 
17
19
  module Gtk
18
20
 
19
- module FtpParadiseModule
21
+ class FtpClient < ::Gtk::Box # === FtpParadise::GUI::Gtk::FtpClient
22
+
23
+ require 'ftp_paradise/requires/require_the_toplevel_methods.rb'
24
+ require 'ftp_paradise/entry/entry.rb'
25
+ require 'ftp_paradise/gui/gtk3/ftp_client/constants.rb'
26
+ require 'ftp_paradise/gui/gtk3/ftp_client/misc.rb'
20
27
 
21
- require 'ftp_paradise/base/prototype.rb'
28
+ require 'ftp_paradise/base/base.rb'
22
29
  include ::FtpParadise::Base
23
30
 
24
- require 'net/ftp'
31
+ require 'gtk_paradise/requires/require_the_base_module.rb'
32
+ include ::Gtk::BaseModule
25
33
 
26
- require 'ftp_paradise/project/project.rb'
34
+ require 'ftp_paradise/colours/use_colours.rb'
35
+ include Colours
27
36
 
28
- require 'ftp_paradise/constants/roebe_ftp_constants.rb'
37
+ require 'ftp_paradise/connection/connection.rb'
29
38
 
30
- require 'gtk_paradise/widgets/gtk3/directory_content_widget/directory_content_widget.rb'
39
+ # ========================================================================= #
40
+ # === initialize
41
+ # ========================================================================= #
42
+ def initialize(
43
+ commandline_arguments = ARGV,
44
+ run_already = true
45
+ )
46
+ super(:vertical)
47
+ reset
48
+ set_commandline_arguments(
49
+ commandline_arguments
50
+ )
51
+ run if run_already
52
+ end
31
53
 
32
- require 'gtk_paradise/requires/require_the_base_module.rb'
33
- include ::Gtk::BaseModule
54
+ # ========================================================================= #
55
+ # === reset (reset tag)
56
+ # ========================================================================= #
57
+ def reset
58
+ reset_the_internal_variables
59
+ infer_the_namespace
60
+ # ======================================================================= #
61
+ # === @configuration
62
+ # ======================================================================= #
63
+ @configuration = [true, __dir__, namespace?]
64
+ # ======================================================================= #
65
+ # === Set the title, width, height and the font in use.
66
+ # ======================================================================= #
67
+ title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
68
+ handle_CSS
69
+ infer_the_size_automatically
70
+ # ======================================================================= #
71
+ # === @use_this_background_colour_for_the_entries
72
+ # ======================================================================= #
73
+ @use_this_background_colour_for_the_entries = '#d4ffd3' # A very light green background.
74
+ # ======================================================================= #
75
+ # === @ftp_connection
76
+ # ======================================================================= #
77
+ @ftp_connection = FtpParadise::Connection.new
78
+ # ======================================================================= #
79
+ # === @hash_remote_entries
80
+ # ======================================================================= #
81
+ @hash_remote_entries = {}
82
+ try_to_create_a_temporary_log_directory_and_cd_into_it_or_the_temp_directory
83
+ end
34
84
 
35
85
  # ========================================================================= #
36
- # === NAMESPACE
86
+ # === handle_CSS (CSS tag)
37
87
  # ========================================================================= #
38
- NAMESPACE = inspect
88
+ def handle_CSS
89
+ use_gtk_paradise_project_css_file
90
+ more_CSS '
91
+ grid {
92
+ border: 1px dotted steelblue;
93
+ padding: 20px;
94
+ }'
95
+ end
39
96
 
40
97
  # ========================================================================= #
41
- # === TITLE
98
+ # === padding?
42
99
  # ========================================================================= #
43
- TITLE = 'FTP Client'
100
+ def padding?
101
+ 0
102
+ end
44
103
 
45
104
  # ========================================================================= #
46
- # === WIDTH
105
+ # === border_size?
47
106
  # ========================================================================= #
48
- WIDTH = 1600
107
+ def border_size?
108
+ 0
109
+ end
49
110
 
50
111
  # ========================================================================= #
51
- # === HEIGHT
112
+ # === return_top_bar
52
113
  # ========================================================================= #
53
- HEIGHT = 800
114
+ def return_top_bar
115
+ _ = default_header_bar { :with_close_button_and_inferred_title }
116
+ return _
117
+ end
54
118
 
55
119
  # ========================================================================= #
56
- # === FTP_MAIN_ICON
120
+ # === deselect_the_main_entry
57
121
  # ========================================================================= #
58
- FTP_MAIN_ICON = HOME_DIRECTORY_OF_USER_X+'DATA/images/PC/FTP/FTP.png'
122
+ def deselect_the_main_entry
123
+ Thread.new {
124
+ sleep 0.0001
125
+ @entry_connect_to_this_host.deselect_everything
126
+ }
127
+ end
128
+
129
+ # ========================================================================= #
130
+ # === set_port_to_use
131
+ # ========================================================================= #
132
+ def set_port_to_use(i)
133
+ @entry_port_to_use.set_text(i.to_s)
134
+ end
135
+
136
+ # ========================================================================= #
137
+ # === set_entry_username
138
+ # ========================================================================= #
139
+ def set_entry_username(i)
140
+ @entry_username.set_text(i)
141
+ end; alias set_the_username set_entry_username # === set_the_username
142
+
143
+ # ========================================================================= #
144
+ # === user_name?
145
+ # ========================================================================= #
146
+ def user_name?
147
+ @entry_username.text?
148
+ end; alias username? user_name? # === username?
149
+
150
+ # ========================================================================= #
151
+ # === set_the_password
152
+ # ========================================================================= #
153
+ def set_the_password(i)
154
+ @entry_password.set_text(i.to_s)
155
+ end
156
+
157
+ # ========================================================================= #
158
+ # === set_connect_to
159
+ # ========================================================================= #
160
+ def set_connect_to(i)
161
+ @entry_connect_to_this_host.set_text(i)
162
+ end
163
+
164
+ # ========================================================================= #
165
+ # === create_the_entries (entries tag, entry tag)
166
+ # ========================================================================= #
167
+ def create_the_entries
168
+ # ======================================================================= #
169
+ # === @entry_connect_to_this_host
170
+ # ======================================================================= #
171
+ @entry_connect_to_this_host = gtk_entry
172
+ @entry_connect_to_this_host.hint = 'Specify the remote host here.'
173
+ @entry_connect_to_this_host.shadow_hint = 'Specify the remote host here.'
174
+ # ======================================================================= #
175
+ # === @entry_username
176
+ # ======================================================================= #
177
+ @entry_username = gtk_entry
178
+ @entry_username.hint = 'Specify the user name here. This is '\
179
+ 'the name that is to be used for the FTP login.'
180
+ @entry_username.shadow_hint = 'Specify the user name here.'
181
+ # ======================================================================= #
182
+ # === @entry_password
183
+ # ======================================================================= #
184
+ @entry_password = gtk_entry
185
+ @entry_password.hint = "Specify the user's password here."
186
+ @entry_password.shadow_hint = "Specify the user's password here."
187
+ # ======================================================================= #
188
+ # === @entry_port_to_use
189
+ # ======================================================================= #
190
+ @entry_port_to_use = gtk_entry
191
+ @entry_port_to_use.hint = 'Specify the port to use here.'
192
+ @entry_port_to_use.shadow_hint = 'Specify the port to use here.'
193
+ all_entries?.each {|this_entry|
194
+ this_entry.clear_background
195
+ this_entry.use_this_font(SMALLER_FONT)
196
+ this_entry.very_light_yellow_background
197
+ this_entry.bblack2
198
+ this_entry.pad8px
199
+ this_entry.center
200
+ uniform_width_and_height_for_this_entry(this_entry)
201
+ }
202
+ end
203
+
204
+ # ========================================================================= #
205
+ # === uniform_width_and_height_for_this_entry
206
+ # ========================================================================= #
207
+ def uniform_width_and_height_for_this_entry(this_entry)
208
+ this_entry.width_height(460, 22)
209
+ end; alias uniform_entry_width uniform_width_and_height_for_this_entry # === uniform_entry_width
210
+
211
+ # ========================================================================= #
212
+ # === entry_connect_to_this_host?
213
+ # ========================================================================= #
214
+ def entry_connect_to_this_host?
215
+ @entry_connect_to_this_host
216
+ end; alias entry_for_the_remote_host? entry_connect_to_this_host? # === entry_for_the_remote_host?
217
+
218
+ # ========================================================================= #
219
+ # === remote_host?
220
+ # ========================================================================= #
221
+ def remote_host?
222
+ entry_for_the_remote_host?.text?
223
+ end; alias remote_host_as_text? remote_host? # === remote_host_as_text?
224
+
225
+ # ========================================================================= #
226
+ # === is_on_roebe?
227
+ # ========================================================================= #
228
+ def is_on_roebe?
229
+ ::FtpParadise.is_on_roebe?
230
+ end
231
+
232
+ # ========================================================================= #
233
+ # === create_skeleton (create tag, skeleton tag)
234
+ # ========================================================================= #
235
+ def create_skeleton
236
+ create_the_statusbar
237
+ create_text_buffer
238
+ create_the_status_icon
239
+ create_the_entries
240
+ create_the_buttons # Must come before the middle grid is created.
241
+ create_the_middle_grid_containing_the_delete_and_download_functionality
242
+ end
243
+
244
+ # ========================================================================= #
245
+ # === create_the_status_icon
246
+ # ========================================================================= #
247
+ def create_the_status_icon
248
+ @status_icon = gtk_status_icon
249
+ if File.exist? FTP_MAIN_ICON
250
+ @status_icon.pixbuf = GdkPixbuf::Pixbuf.new(file: FTP_MAIN_ICON)
251
+ end
252
+ @status_icon.hint = 'StatusIcon'
253
+ end
254
+
255
+ # ========================================================================= #
256
+ # === create_text_buffer
257
+ # ========================================================================= #
258
+ def create_text_buffer
259
+ @text_buffer = gtk_text_buffer
260
+ end
261
+
262
+ # ========================================================================= #
263
+ # === password?
264
+ # ========================================================================= #
265
+ def password?
266
+ @entry_password.text?
267
+ end; alias user_password? password? # === user_password?
268
+
269
+ # ========================================================================= #
270
+ # === try_to_return_the_ftp_listing
271
+ # ========================================================================= #
272
+ def try_to_return_the_ftp_listing
273
+ begin
274
+ @ftp_connection.list
275
+ rescue Exception => error
276
+ pp error
277
+ end
278
+ end
279
+
280
+ # ========================================================================= #
281
+ # === update_the_buffer_containing_all_remote_entries
282
+ # ========================================================================= #
283
+ def update_the_buffer_containing_all_remote_entries(
284
+ list = try_to_return_the_ftp_listing
285
+ )
286
+ if list.is_a? Array
287
+ @hash_remote_entries.clear
288
+ array = list.map {|entry|
289
+ FtpParadise::Entry.new(entry)
290
+ }
291
+ array.each {|inner_entry|
292
+ @hash_remote_entries[inner_entry.filename?] = inner_entry
293
+ }
294
+ keys = @hash_remote_entries.keys
295
+ utf8_keys = keys.map {|most_inner_entry|
296
+ ::Gtk.to_utf8(most_inner_entry)
297
+ }
298
+ @text_buffer.set_text(utf8_keys.join("\n"))
299
+ end
300
+ end; alias update_the_buffer update_the_buffer_containing_all_remote_entries # === update_the_buffer
301
+ alias update_the_main_buffer update_the_buffer_containing_all_remote_entries # === update_the_main_buffer
302
+
303
+ # ========================================================================= #
304
+ # === create_the_grid (top grid)
305
+ # ========================================================================= #
306
+ def create_the_grid
307
+ grid = default_grid
308
+ grid.left(gtk_left_aligned_label('Connect to: '))
309
+ grid.middle(@entry_connect_to_this_host)
310
+ grid.right(return_combined_checkboxes_determining_the_transfer_mode)
311
+ grid.new_row
312
+ grid.left(gtk_left_aligned_label('Username: '))
313
+ grid.middle(@entry_username)
314
+ #grid.right(button2)
315
+ grid.new_row
316
+ grid.left(gtk_left_aligned_label('Password: '))
317
+ grid.middle(@entry_password)
318
+ grid.new_row
319
+ grid.left(gtk_left_aligned_label('Port to use: '))
320
+ grid.middle(@entry_port_to_use)
321
+ @grid = grid
322
+ end
323
+
324
+ # ========================================================================= #
325
+ # === return_combined_checkboxes_determining_the_transfer_mode
326
+ # ========================================================================= #
327
+ def return_combined_checkboxes_determining_the_transfer_mode
328
+ _ = hbox
329
+ @button_use_passive_mode = check_button_is_checked('Use _passive mode')
330
+ @button_use_active_mode = check_button('Use _active mode')
331
+ @button_use_passive_mode.on_button_press_event { |widget, event|
332
+ @button_use_passive_mode.switch_state
333
+ @button_use_active_mode.switch_state
334
+ }
335
+ @button_use_active_mode.on_button_press_event { |widget, event|
336
+ @button_use_passive_mode.switch_state
337
+ @button_use_active_mode.switch_state
338
+ }
339
+ _ << @button_use_passive_mode
340
+ _ << @button_use_active_mode
341
+ return _
342
+ end
343
+
344
+ # ========================================================================= #
345
+ # === run (run tag)
346
+ # ========================================================================= #
347
+ def run
348
+ super()
349
+ if File.exist? FtpParadise.my_ftp_file?
350
+ try_to_load_the_dataset_from_this_file(FtpParadise.my_ftp_file?)
351
+ end
352
+ deselect_the_main_entry
353
+ try_to_establish_a_ftp_connection if is_on_roebe?
354
+ end
355
+
356
+ # ========================================================================= #
357
+ # === entry_for_the_upload_this_local_file_functionality?
358
+ # ========================================================================= #
359
+ def entry_for_the_upload_this_local_file_functionality?
360
+ @entry_for_the_upload_local_file_functionality
361
+ end
362
+
363
+ # ========================================================================= #
364
+ # === try_to_load_the_dataset_from_this_file
365
+ # ========================================================================= #
366
+ def try_to_load_the_dataset_from_this_file(
367
+ i = FtpParadise.my_ftp_file?,
368
+ use_this_key = 'bplaced'
369
+ )
370
+ if File.exist? i
371
+ dataset = YAML.load_file(i)
372
+ bplaced = dataset[use_this_key]
373
+ FtpParadise.determine_user_dataset_from_this_hash(bplaced)
374
+ # ===================================================================== #
375
+ # Set the values for the entries next:
376
+ # ===================================================================== #
377
+ set_connect_to(FtpParadise.remote_url?)
378
+ set_the_username(FtpParadise.login_name?)
379
+ set_the_password(FtpParadise.password?)
380
+ set_port_to_use(FtpParadise.port?)
381
+ end
382
+ end
383
+
384
+ # ========================================================================= #
385
+ # === entry_for_the_delete_remote_file_functionality?
386
+ # ========================================================================= #
387
+ def entry_for_the_delete_remote_file_functionality?
388
+ @entry_for_the_delete_remote_file_functionality
389
+ end
390
+
391
+ # ========================================================================= #
392
+ # === connect_skeleton (connect tag)
393
+ # ========================================================================= #
394
+ def connect_skeleton
395
+ abort_on_exception
396
+ minimal(return_top_bar)
397
+ create_the_grid
398
+ minimal(@grid, 2)
399
+ minimal(horizontal_spacer)
400
+
401
+ button2 = button('List the FTP content')
402
+ button2.clear_background
403
+ button2.on_clicked {
404
+ if @ftp_connection and @ftp_connection.respond_to?(:list)
405
+ update_the_buffer_containing_all_remote_entries
406
+ end
407
+ }
408
+ button2.on_hover(:lightblue)
409
+
410
+ button1 = button('Establish a FTP connection here')
411
+ button1.clear_background
412
+ button1.on_hover(:lightblue)
413
+ button1.on_clicked {
414
+ try_to_establish_a_ftp_connection
415
+ }
416
+
417
+ box_with_buttons = hbox
418
+ box_with_buttons << button1
419
+ box_with_buttons << button2
420
+ minimal(box_with_buttons, 2)
421
+
422
+ hbox1 = gtk_hbox
423
+ hbox1.pad10px
424
+ hbox1.text 'Run this command on the remote FTP server: '
425
+ entry1 = gtk_entry
426
+ hbox1 << entry1
427
+ a_button = button('← Run this command')
428
+ a_button.on_clicked {
429
+ if @ftp_connection
430
+ @ftp_connection.sendcmd(entry1.text?)
431
+ end
432
+ }
433
+ hbox1 << a_button
434
+ minimal(hbox1, 5)
435
+ minimal(@middle_grid, 5)
436
+ text_view = gtk_text_view(@text_buffer)
437
+ scrolled_window = scrolled_window(text_view) { :always }
438
+ maximal(scrolled_window)
439
+ minimal(@status_bar)
440
+ end
441
+
442
+ # ========================================================================= #
443
+ # === create_the_buttons (buttons tag, button tag)
444
+ # ========================================================================= #
445
+ def create_the_buttons
446
+ # ======================================================================= #
447
+ # === @button_upload_local_file
448
+ # ======================================================================= #
449
+ @button_upload_local_file = button('← Upload this local file')
450
+ @button_upload_local_file.hint =
451
+ 'Use this button if you wish to upload a local file.'
452
+ @button_upload_local_file.on_clicked {
453
+ do_upload_this_local_file
454
+ }
455
+ create_button_delete_remote_file
456
+ end
457
+
458
+ # ========================================================================= #
459
+ # === create_button_delete_remote_file
460
+ # ========================================================================= #
461
+ def create_button_delete_remote_file
462
+ # ======================================================================= #
463
+ # === @button_delete_remote_file
464
+ # ======================================================================= #
465
+ @button_delete_remote_file = button('← Delete this remote file') # Or: Delete remote file.
466
+ @button_delete_remote_file.hint =
467
+ 'Use this button when you wish to remove a remote file.'
468
+ @button_delete_remote_file.on_clicked {
469
+ do_delete_remote_file
470
+ }
471
+ end
472
+
473
+ # ========================================================================= #
474
+ # === do_upload_this_local_file
475
+ # ========================================================================= #
476
+ def do_upload_this_local_file(
477
+ i = entry_for_the_upload_this_local_file_functionality?
478
+ )
479
+ @ftp_connection.upload_this_local_file(i.text?)
480
+ end
481
+
482
+ # ========================================================================= #
483
+ # === do_delete_remote_file (delete tag)
484
+ #
485
+ # Wrapper to delete a remote file.
486
+ # ========================================================================= #
487
+ def do_delete_remote_file(
488
+ i = entry_for_the_delete_remote_file_functionality?
489
+ )
490
+ ftp_connection?.remove_file(i.text?) { :be_verbose }
491
+
492
+ e 'DEBUG: THE FOLLOWING 3 LINES HAVE BEEN DISABLED FOR NOW'
493
+ # efancy selection?(:right)
494
+ # @ftp_connection.remove_file( selection?(:right) )
495
+ # update_everything
496
+ update_the_buffer
497
+ end; alias try_to_delete_the_remote_file do_delete_remote_file # === try_to_delete_the_remote_file
498
+
499
+ # ========================================================================= #
500
+ # === try_to_cd_into_this_directory
501
+ # ========================================================================= #
502
+ def try_to_cd_into_this_directory(
503
+ i = @entry_for_the_local_working_directory.text?
504
+ )
505
+ cd(i)
506
+ @entry_for_the_local_working_directory.set_text(return_pwd)
507
+ @entry_for_the_local_working_directory.cursor_is_on_the_end
508
+ end
509
+
510
+ # ========================================================================= #
511
+ # === FtpParadise::GUI::Gtk::FtpClient.run
512
+ # ========================================================================= #
513
+ def self.run(
514
+ i = ARGV
515
+ )
516
+ require 'gtk_paradise/app/app.rb'
517
+ _ = ::FtpParadise::GUI::Gtk::FtpClient.new(i)
518
+ r = ::Gtk.run
519
+ r << _
520
+ r.automatic_size_then_automatic_title
521
+ r.enable_quick_exit
522
+ r.do_maximize
523
+ r.top_left_then_run
524
+ end
525
+
526
+ # ========================================================================= #
527
+ # === create_the_middle_grid_containing_the_delete_and_download_functionality
528
+ #
529
+ # This is the middle grid (middle tag).
530
+ # ========================================================================= #
531
+ def create_the_middle_grid_containing_the_delete_and_download_functionality
532
+ grid = default_grid
533
+
534
+ entry = gtk_entry
535
+ uniform_width_and_height_for_this_entry(entry)
536
+ a_button = button('← Download this remote file')
537
+ a_button.on_clicked {
538
+ if @ftp_connection
539
+ _ = entry.text?
540
+ @ftp_connection.try_to_download_this_remote_file(_) { :be_verbose }
541
+ end
542
+ }
543
+
544
+ grid.left(gtk_left_aligned_label('Download this remote file: '))
545
+ grid.middle(entry)
546
+ grid.right(a_button)
547
+ grid.new_row
548
+
549
+ @entry_for_the_delete_remote_file_functionality = gtk_entry
550
+ uniform_entry_width(@entry_for_the_delete_remote_file_functionality)
551
+ grid.left(gtk_left_aligned_label('Delete this remote file: '))
552
+ grid.middle(@entry_for_the_delete_remote_file_functionality)
553
+ grid.right(@button_delete_remote_file)
554
+ grid.new_row
555
+
556
+ # ======================================================================= #
557
+ # === @entry_for_the_upload_local_file_functionality
558
+ # ======================================================================= #
559
+ @entry_for_the_upload_local_file_functionality = gtk_entry
560
+ uniform_entry_width(@entry_for_the_upload_local_file_functionality)
561
+ grid.left(gtk_left_aligned_label('Upload this local file: '))
562
+ grid.middle(@entry_for_the_upload_local_file_functionality)
563
+ grid.right(@button_upload_local_file)
564
+ grid.new_row
565
+
566
+ # ======================================================================= #
567
+ # === @entry_for_the_local_working_directory
568
+ # ======================================================================= #
569
+ @entry_for_the_local_working_directory = gtk_entry
570
+ uniform_entry_width(@entry_for_the_local_working_directory)
571
+ grid.left(gtk_left_aligned_label('The current working directory is: '))
572
+ grid.middle(@entry_for_the_local_working_directory)
573
+ @entry_for_the_local_working_directory.set_text(return_pwd)
574
+ @entry_for_the_local_working_directory.on_enter {
575
+ try_to_cd_into_this_directory(@entry_for_the_local_working_directory.text?)
576
+ }
577
+ button_change_directory_into_this_target = button('← Change directory into')
578
+ button_change_directory_into_this_target.on_clicked {
579
+ try_to_cd_into_this_directory(@entry_for_the_local_working_directory.text?)
580
+ }
581
+ grid.right(button_change_directory_into_this_target)
582
+ grid.new_row
583
+
584
+ # ======================================================================= #
585
+ # === @entry_for_the_remote_working_directory
586
+ # ======================================================================= #
587
+ @entry_for_the_remote_working_directory = gtk_entry
588
+ uniform_entry_width(@entry_for_the_remote_working_directory)
589
+ grid.left(gtk_left_aligned_label('The remote working directory is: '))
590
+ grid.middle(@entry_for_the_remote_working_directory)
591
+ @entry_for_the_remote_working_directory.set_text('/')
592
+ @entry_for_the_remote_working_directory.on_enter {
593
+ try_to_cd_into_this_remote_directory(@entry_for_the_remote_working_directory.text?)
594
+ }
595
+ button_remote_change_directory_into_this_target = button('← Change remote directory into')
596
+ button_remote_change_directory_into_this_target.on_clicked {
597
+ try_to_cd_into_this_remote_directory(@entry_for_the_remote_working_directory.text?)
598
+ }
599
+ grid.right(button_remote_change_directory_into_this_target)
600
+ grid.new_row
601
+
602
+ @middle_grid = grid
603
+ end
604
+
605
+ # ========================================================================= #
606
+ # === try_to_cd_into_this_remote_directory
607
+ # ========================================================================= #
608
+ def try_to_cd_into_this_remote_directory(
609
+ i = @entry_for_the_remote_working_directory.text?,
610
+ ftp_object = ftp_object?
611
+ )
612
+ ftp_object.remote_cd(i)
613
+ @entry_for_the_remote_working_directory.set_text(
614
+ ftp_object.remote_directory? # Always obtain the remote working directory.
615
+ )
616
+ @entry_for_the_remote_working_directory.cursor_is_on_the_end
617
+ update_the_main_buffer
618
+ end
619
+
620
+ # ========================================================================= #
621
+ # === create_the_statusbar
622
+ #
623
+ # Create the Statusbar.
624
+ # ========================================================================= #
625
+ def create_the_statusbar
626
+ @status_bar = gtk_statusbar
627
+ if @status_bar.respond_to?(:has_resize_grip=)
628
+ @status_bar.has_resize_grip = true
629
+ end
630
+ @status_bar_context_id = @status_bar.get_context_id('Gtk Ftp Client')
631
+ end
632
+
633
+ # ========================================================================= #
634
+ # === add_status_message
635
+ #
636
+ # Use this to append to the Statusbar.
637
+ # ========================================================================= #
638
+ def add_status_message(i)
639
+ @status_bar.push(@status_bar_context_id, i)
640
+ end
641
+
642
+ # ========================================================================= #
643
+ # === try_to_establish_a_ftp_connection
644
+ #
645
+ # This method will try to establish a FTP connection to the remote
646
+ # host.
647
+ # ========================================================================= #
648
+ def try_to_establish_a_ftp_connection
649
+ e 'TODO: Change this to indicate otherwise. '\
650
+ 'Connecting now to the remove host at '+
651
+ steelblue(remote_host_as_text?)
652
+ # Instantiate a new net-ftp object next:
653
+ @ftp_connection.connect(
654
+ user_name: user_name?,
655
+ password: password?,
656
+ remote_host: remote_host_as_text?
657
+ )
658
+ if @button_use_passive_mode.checked?
659
+ @ftp_connection.binary = true
660
+ else
661
+ @ftp_connection.binary = false
662
+ end
663
+ @ftp_connection.set_passive
664
+ update_the_buffer_containing_all_remote_entries
665
+ end
666
+
667
+ # DEPRECATION STARTS HERE
668
+
669
+ module DEPRECATED_FtpParadiseModule
670
+
671
+ require 'gtk_paradise/widgets/gtk3/directory_content_widget/directory_content_widget.rb'
672
+
673
+ # ========================================================================= #
674
+ # === NAMESPACE
675
+ # ========================================================================= #
676
+ NAMESPACE = inspect
59
677
 
60
678
  # ========================================================================= #
61
679
  # === SHALL_WE_DEBUG
@@ -97,17 +715,6 @@ module FtpParadiseModule
97
715
  # ========================================================================= #
98
716
  YES_THE_USER_IS_CONNECTED = 'Yes!'
99
717
 
100
- # ========================================================================= #
101
- # === MY_TEMP
102
- # ========================================================================= #
103
- if ENV['MY_TEMP']
104
- MY_TEMP = ENV['MY_TEMP'].to_s+'/'
105
- elsif File.directory?('/home/Temp/')
106
- MY_TEMP = '/home/Temp/'
107
- else
108
- MY_TEMP = '/tmp/'
109
- end
110
-
111
718
  # ========================================================================= #
112
719
  # === initialize
113
720
  # ========================================================================= #
@@ -123,23 +730,6 @@ module FtpParadiseModule
123
730
  # === reset (reset tag)
124
731
  # ========================================================================= #
125
732
  def reset
126
- reset_the_internal_variables
127
- # ======================================================================= #
128
- # === @configuration
129
- # ======================================================================= #
130
- @configuration = [true, __dir__, NAMESPACE]
131
- # ======================================================================= #
132
- # === @title
133
- # ======================================================================= #
134
- @title = TITLE
135
- # ======================================================================= #
136
- # === @width
137
- # ======================================================================= #
138
- @width = WIDTH
139
- # ======================================================================= #
140
- # === @height
141
- # ======================================================================= #
142
- @height = HEIGHT
143
733
  # ======================================================================= #
144
734
  # === @ftp_connection
145
735
  # ======================================================================= #
@@ -168,9 +758,6 @@ module FtpParadiseModule
168
758
  @hash_user_data['port'] = DEFAULT_REMOTE_PORT
169
759
  end
170
760
  initialize_the_connection_image
171
- set_use_this_font(:dejavu_condensed_21)
172
- use_gtk_paradise_project_css_file
173
- infer_the_size_automatically
174
761
  end
175
762
 
176
763
  # ========================================================================= #
@@ -183,43 +770,12 @@ module FtpParadiseModule
183
770
  @connection_image = gtk_image(
184
771
  ::FtpParadise.project_base_dir?+'images/connection_image.png'
185
772
  )
186
- @connection_image.css_class('bblack1')
187
- end
188
-
189
- # ========================================================================= #
190
- # === padding?
191
- # ========================================================================= #
192
- def padding?
193
- 2
194
- end
195
-
196
- # ========================================================================= #
197
- # === border_size?
198
- # ========================================================================= #
199
- def border_size?
200
- 2
773
+ @connection_image.bblack1
201
774
  end
202
775
 
203
- # ========================================================================= #
204
- # === create_button_delete_remote_file
205
- # ========================================================================= #
206
- def create_button_delete_remote_file
207
- @button_delete_remote_file = gtk_button('Delete remote file')
208
- @button_delete_remote_file.fancy_tooltips =
209
- 'Use this when you wish to remove a remote file.'
210
- @button_delete_remote_file.on_clicked {
211
- do_delete_remote_file
212
- }
213
- end
214
776
 
215
- # ========================================================================= #
216
- # === create_skeleton (create tag)
217
- # ========================================================================= #
218
777
  def create_skeleton
219
778
  create_debug_button
220
- create_button_delete_remote_file
221
- create_status_icon
222
- create_statusbar
223
779
  @grid_user_data = gtk_grid
224
780
  @grid_user_data.set_column_spacing(5)
225
781
  @grid_user_data.set_row_spacing(5)
@@ -298,7 +854,7 @@ module FtpParadiseModule
298
854
  vbox_is_the_user_connected = gtk_vbox
299
855
  vbox_is_the_user_connected.set_border_width(10)
300
856
  event_box_for_the_connection_image = gtk_event_box(@connection_image)
301
- event_box_for_the_connection_image.fancy_tooltips =
857
+ event_box_for_the_connection_image.hint =
302
858
  'Click on this image to connect to the specified, remote host.'
303
859
  event_box_for_the_connection_image.on_clicked {
304
860
  do_connect_to_the_remote_host_specified
@@ -316,19 +872,19 @@ module FtpParadiseModule
316
872
  # ======================================================================= #
317
873
  frame_action_to_perform = gtk_frame
318
874
  frame_action_to_perform.set_text(' Action to perform: ')
319
- frame_action_to_perform.label_widget.fancy_tooltips =
875
+ frame_action_to_perform.label_widget.hint =
320
876
  'Denote via this widget which action is to be performed.'
321
877
  vbox_action_to_perform = gtk_vbox
322
878
  vbox_action_to_perform.set_border_width(10)
323
879
  @button_upload = button('Upload')
324
- @button_upload.fancy_tooltips =
880
+ @button_upload.hint =
325
881
  '<b>Upload</b> the selected local file to the remote host.'
326
882
  @button_upload.on_clicked {
327
883
  do_upload_the_selected_file
328
884
  }
329
885
  vbox_action_to_perform.add(@button_upload)
330
886
  @button_download = button('Download')
331
- @button_download.fancy_tooltips =
887
+ @button_download.hint =
332
888
  '<b>Download</b> the selected (<b>remote</b>) files/directories.'
333
889
  @button_download.on_clicked {
334
890
  do_download_the_remote_file_or_directory
@@ -402,12 +958,6 @@ module FtpParadiseModule
402
958
  do_style_all_buttons_in_a_uniform_manner
403
959
  end
404
960
 
405
- # ========================================================================= #
406
- # === user_password?
407
- # ========================================================================= #
408
- def user_password?
409
- @entry_user_password.text?
410
- end
411
961
 
412
962
  # ========================================================================= #
413
963
  # === remote_url?
@@ -429,13 +979,11 @@ module FtpParadiseModule
429
979
  def self.run(
430
980
  i = ARGV
431
981
  )
432
- require 'gtk_paradise/run'
433
982
  _ = ::FtpParadise::GUI::Gtk::FtpParadise.new(i)
434
983
  r = ::Gtk.run
435
984
  r << _
436
985
  r.set_size_request(_.width?, _.height?)
437
986
  r.automatic_title
438
- r.top_left_then_run
439
987
  end
440
988
 
441
989
  # ========================================================================= #
@@ -478,13 +1026,6 @@ module FtpParadiseModule
478
1026
  end
479
1027
  end
480
1028
 
481
- # ========================================================================= #
482
- # === is_on_roebe?
483
- # ========================================================================= #
484
- def is_on_roebe?
485
- ::FtpParadise.is_on_roebe?
486
- end
487
-
488
1029
  # ========================================================================= #
489
1030
  # === do_connect_to_the_remote_host_specified
490
1031
  #
@@ -536,7 +1077,6 @@ module FtpParadiseModule
536
1077
  # === run (run tag)
537
1078
  # ========================================================================= #
538
1079
  def run
539
- create_skeleton_then_connect_skeleton
540
1080
  do_connect if is_on_roebe? # Connect at once on my home system.
541
1081
  end
542
1082
 
@@ -553,70 +1093,18 @@ module FtpParadiseModule
553
1093
  }
554
1094
  end
555
1095
 
556
- # ========================================================================= #
557
- # === add_status_message
558
- #
559
- # Use this to append to the Statusbar.
560
- # ========================================================================= #
561
- def add_status_message(i)
562
- @status_bar.push(@status_bar_context_id, i)
563
- end
564
-
565
- # ========================================================================= #
566
- # === create_status_icon
567
- # ========================================================================= #
568
- def create_status_icon
569
- @status_icon = gtk_status_icon
570
- if File.exist? FTP_MAIN_ICON
571
- @status_icon.pixbuf = GdkPixbuf::Pixbuf.new(file: FTP_MAIN_ICON)
572
- end
573
- @status_icon.fancy_tooltips = 'StatusIcon'
574
- end
575
-
576
- # ========================================================================= #
577
- # === create_statusbar
578
- #
579
- # Create the Statusbar.
580
- # ========================================================================= #
581
- def create_statusbar
582
- @status_bar = gtk_statusbar
583
- if @status_bar.respond_to?(:has_resize_grip=)
584
- @status_bar.has_resize_grip = true
585
- end
586
- @status_bar_context_id = @status_bar.get_context_id('Gtk Ftp Client')
587
- end
588
-
589
1096
  # ========================================================================= #
590
1097
  # === create_debug_button (debug tag, debug button)
591
1098
  # ========================================================================= #
592
1099
  def create_debug_button
593
1100
  @button_debug = gtk_button('_Debug') # The debug-button.
594
1101
  @button_debug.on_clicked {
595
- e 'Debugging FTP Client.'
1102
+ e 'Debugging the FTP Client next.'
596
1103
  ecomment ('The password is: ').ljust(20)+password?
597
1104
  ecomment 'The login name is: '+username?, token: ':'
598
1105
  }
599
1106
  end
600
1107
 
601
- # ========================================================================= #
602
- # === user_name?
603
- # ========================================================================= #
604
- def user_name?
605
- @entry_username.text?
606
- end; alias username? user_name? # === username?
607
-
608
- # ========================================================================= #
609
- # === do_delete_remote_file
610
- #
611
- # Wrapper to delete a remote file.
612
- # ========================================================================= #
613
- def do_delete_remote_file
614
- ewarn 'Deleting this remote file:'
615
- efancy selection?(:right)
616
- @ftp_connection.remove_file( selection?(:right) )
617
- update_everything
618
- end
619
-
620
1108
  # ========================================================================= #
621
1109
  # === output_coloured_line
622
1110
  #
@@ -636,7 +1124,7 @@ module FtpParadiseModule
636
1124
  def return_default_user_name_based_on_selected_host(
637
1125
  selected_host = host?
638
1126
  )
639
- selected_host = FtpParadise::RoebeFtpConstants.
1127
+ selected_host = FtpParadise.
640
1128
  return_user_name_based_on_given_host(selected_host)
641
1129
  return selected_host
642
1130
  end
@@ -672,10 +1160,12 @@ module FtpParadiseModule
672
1160
  @directory_content_widget1
673
1161
  end
674
1162
 
1163
+ end
1164
+
675
1165
  end; end; end
676
1166
 
677
1167
  # =========================================================================== #
678
- # === FtpParadise.do_start_gui
1168
+ # === FtpParadise.do_start_the_gui
679
1169
  #
680
1170
  # This will output what will be done, then start the GUI bindings.
681
1171
  #
@@ -684,17 +1174,11 @@ end; end; end
684
1174
  # ftpparadise --gui
685
1175
  #
686
1176
  # =========================================================================== #
687
- def self.do_start_gui
1177
+ def self.do_start_the_gui
688
1178
  opnn; puts 'We will next start the GUI.'
689
- FtpParadise::GUI::Gtk::FtpParadiseModule.start_gtk
690
- end
691
-
692
- # =========================================================================== #
693
- # === FtpParadise.start_gtk
694
- # =========================================================================== #
695
- def self.start_gtk
696
- FtpParadise::GUI::Gtk::FtpParadiseModule.run
697
- end
1179
+ FtpParadise::GUI::Gtk::FtpClient.run(ARGV)
1180
+ end; self.instance_eval { alias do_start_gui do_start_the_gui } # === FtpParadise.do_start_gui
1181
+ self.instance_eval { alias start_gtk do_start_the_gui } # === FtpParadise.start_gtk
698
1182
 
699
1183
  # =========================================================================== #
700
1184
  # === FtpParadise.gtk_widget
@@ -703,7 +1187,11 @@ end
703
1187
  # other applications.
704
1188
  # =========================================================================== #
705
1189
  def self.gtk_widget
706
- FtpParadise::GUI::Gtk::FtpParadiseModule
1190
+ FtpParadise::GUI::Gtk::FtpClient
1191
+ end
1192
+
707
1193
  end
708
1194
 
1195
+ if __FILE__ == $PROGRAM_NAME
1196
+ FtpParadise::GUI::Gtk::FtpClient.run
709
1197
  end