~cubic-wizard/cubic/experimental

« back to all changes in this revision

Viewing changes to usr/share/cubic/cubic/pages/start_page.py

  • Committer: PJ Singh
  • Date: 2021-11-30 01:31:16 UTC
  • Revision ID: psingh.cubic@gmail.com-20211130013116-yspl57zt59xfr1e5
* Fixed Bug #1951662, On the Copy pages, pause to allow the user to view the results before automatically transitioning away from the page. * Fixed Bug #1951693, On the Copy pages, clicking the Cancel button may be unresponsive. * Fixed Bug #1951695, Show error status on the Copy pages. * Fixed Bug #1951715, On the Generate page, clicking the Back during update checksums may be unresponsive. * Experimental fix for issue, Cannot install Cubic in Linux Mint 19.x.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
 
70
70
        display_version = constructor.get_major_minor_version(model.application.cubic_version)
71
71
        about_dialog = model.builder.get_object('about_dialog')
72
 
        about_dialog.set_version('<small>%s</small>' % display_version)
73
 
        displayer.update_label('start_page__version_label', 'Version %s' % display_version)
 
72
        about_dialog.set_version(f'<small>{display_version}</small>')
 
73
        displayer.update_label('start_page__version_label', f'Version {display_version}')
74
74
        displayer.update_label('start_page__project_directory_message', 'Select a project directory.')
75
75
 
 
76
        # Initialize the list of previous projects.
 
77
        load_previous_projects_list()
 
78
        displayer.remove_all_combo_box_text('start_page__project_directory_combo_box_text')
 
79
        for directory in model.application.projects:
 
80
            displayer.append_combo_box_text('start_page__project_directory_combo_box_text', directory)
 
81
 
76
82
        displayer.reset_buttons(
77
83
            back_button_label='❬Back',
78
84
            back_action='back',
93
99
        # The validate_page() function in the enter action will assign
94
100
        # the correct button labels, actions, and styles.
95
101
 
 
102
        # Initialize the list of previous projects.
 
103
        displayer.remove_all_combo_box_text('start_page__project_directory_combo_box_text')
 
104
        for directory in model.application.projects:
 
105
            displayer.append_combo_box_text('start_page__project_directory_combo_box_text', directory)
 
106
 
96
107
        displayer.reset_buttons(
97
108
            back_button_label=None,
98
109
            back_action=None,
127
138
 
128
139
    else:
129
140
 
130
 
        logger.log_value('Error', BOLD_RED + 'Unknown action for setup' + NORMAL)
 
141
        logger.log_value('Error', f'{BOLD_RED}Unknown action for setup{NORMAL}')
131
142
 
132
143
        return 'unknown'
133
144
 
153
164
 
154
165
    else:
155
166
 
156
 
        logger.log_value('Error', BOLD_RED + 'Unknown action for enter' + NORMAL)
 
167
        logger.log_value('Error', f'{BOLD_RED}Unknown action for enter{NORMAL}')
157
168
 
158
169
        return 'unknown'
159
170
 
186
197
        # model.project.custom_root_directory = constructor.construct_custom_root_directory(model.project.directory)
187
198
        # model.project.custom_disk_directory = constructor.construct_custom_disk_directory(model.project.directory)
188
199
 
 
200
        save_previous_projects_list()
 
201
 
189
202
        return
190
203
 
191
204
    elif action == 'migrate':
214
227
        # model.project.custom_root_directory = constructor.construct_custom_root_directory(model.project.directory)
215
228
        # model.project.custom_disk_directory = constructor.construct_custom_disk_directory(model.project.directory)
216
229
 
 
230
        save_previous_projects_list()
 
231
 
217
232
        return
218
233
 
219
234
    elif action == 'quit':
224
239
 
225
240
    else:
226
241
 
227
 
        logger.log_value('Error', BOLD_RED + 'Unknown action for leave' + NORMAL)
 
242
        logger.log_value('Error', f'{BOLD_RED}Unknown action for leave{NORMAL}')
228
243
 
229
244
        return 'unknown'
230
245
 
236
251
 
237
252
def on_clicked__start_page__project_directory_open_button(widget):
238
253
 
239
 
    logger.log_title('Clicked project directory page project directory file chooser open button')
 
254
    logger.log_label('Clicked start page project directory open button')
240
255
 
241
256
    directory_chooser.open(selected_project_directory, model.project.directory)
242
257
 
257
272
 
258
273
def test(project_directory):
259
274
 
260
 
    logger.log_title('Clicked project directory page project directory file chooser open button')
 
275
    logger.log_label('Simulated clicked start page project directory open button')
261
276
 
262
277
    selected_project_directory(project_directory)
263
278
 
270
285
    displayer.update_entry('start_page__project_directory_entry', directory)
271
286
 
272
287
 
 
288
def load_previous_projects_list():
 
289
 
 
290
    # Initialize the list of previous projects.
 
291
    file_path = os.path.join(model.application.user_home, '.config', 'cubic', 'projects.conf')
 
292
    model.application.projects = file_utilities.read_lines(file_path)
 
293
 
 
294
 
 
295
def save_previous_projects_list():
 
296
 
 
297
    # Append the selected project directory to the list of previous
 
298
    # project directories, ensuring there are no duplicates. Truncate
 
299
    # the list to five items.
 
300
    model.application.projects = list(dict.fromkeys([model.project.directory] + model.application.projects))[0:5]
 
301
 
 
302
    # Ensure the Cubic configuration directory exists.
 
303
    file_path = os.path.join(model.application.user_home, '.config', 'cubic')
 
304
    file_utilities.make_directories(file_path)
 
305
 
 
306
    # Save the list of project directories.
 
307
    file_path = os.path.join(model.application.user_home, '.config', 'cubic', 'projects.conf')
 
308
    file_utilities.write_lines(model.application.projects, file_path)
 
309
 
 
310
 
273
311
########################################################################
274
312
# Validation Functions
275
313
########################################################################
318
356
            is_next_sensitive=False,
319
357
            is_next_visible=True)
320
358
 
 
359
        # Remove the invalid directory from list of previous projects.
 
360
        if model.project.directory in model.application.projects:
 
361
            logger.log_value('Remove inaccessible directory from projects list', model.project.directory)
 
362
            model.application.projects.remove(model.project.directory)
 
363
 
321
364
        displayer.update_label('start_page__project_directory_message', '<span foreground="red">Error. Cannot access directory.</span>')
322
365
        displayer.set_entry_error('start_page__project_directory_entry', ERROR)
323
366
 
342
385
            is_next_sensitive=False,
343
386
            is_next_visible=True)
344
387
 
 
388
        # Remove the invalid directory from list of previous projects.
 
389
        if model.project.directory in model.application.projects:
 
390
            logger.log_value('Remove excluded directory from projects list', model.project.directory)
 
391
            model.application.projects.remove(model.project.directory)
 
392
 
345
393
        displayer.update_label(
346
394
            'start_page__project_directory_message',
347
 
            '<span foreground="red">Error. Cannot customize Linux using the %s file system.</span>' % FILE_SYSTEM_TYPES[file_system_type])
 
395
            f'<span foreground="red">Error. Cannot customize Linux using the {FILE_SYSTEM_TYPES[file_system_type]} file system.</span>')
348
396
        displayer.set_entry_error('start_page__project_directory_entry', ERROR)
349
397
 
350
398
        return
432
480
            is_next_sensitive=True,
433
481
            is_next_visible=True)
434
482
 
 
483
        boot_configurations_string = ', '.join(model.options.boot_configurations)
435
484
        displayer.update_label(
436
485
            'start_page__project_directory_message',
437
 
            '<span foreground="red">Warning. Cubic will require the'       \
438
 
            ' original disk image to copy important files and may'         \
439
 
            ' overwrite your changes to the disk boot configurations (%s)' \
440
 
            ' or preseed files. Before proceeding, make backups of these'  \
441
 
            ' files located in %s.</span>'
442
 
            % (', '.join(model.options.boot_configurations),
443
 
               model.project.custom_disk_directory))
 
486
            '<span foreground="red">Warning. Cubic will require the'
 
487
            ' original disk image to copy important files and may'
 
488
            f' overwrite your changes to the disk boot configurations ({boot_configurations_string})'
 
489
            ' or preseed files. Before proceeding, make backups of these'
 
490
            f' files located in {model.project.custom_disk_directory}.</span>')
444
491
 
445
492
        displayer.set_entry_error('start_page__project_directory_entry', OK)
446
493
 
462
509
        is_next_sensitive=True,
463
510
        is_next_visible=True)
464
511
 
465
 
    #-------------------------------------------------------------------
 
512
    # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
466
513
    # TODO: Remove this section in a future release. (12/27/2020)
467
514
    #       Also, remove similar code from start_page and extract_page.
468
515
 
472
519
        if '{{volume_id}}' in template:
473
520
            template = template.replace('{{volume_id}}', '{volume_id}')
474
521
            model.status.iso_template = constructor.encode(template)
475
 
    #-------------------------------------------------------------------
 
522
    # ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
476
523
 
477
524
    displayer.update_label('start_page__project_directory_message', 'This directory contains an existing Cubic project.')
478
525
    displayer.set_entry_error('start_page__project_directory_entry', OK)
510
557
    model.status.is_success_extract = False
511
558
    model.status.iso_template = None
512
559
    model.status.casper_directory = None
 
560
    model.status.squashfs_file_name = None
513
561
    model.status.iso_checksum = None
514
562
    model.status.iso_checksum_file_name = None
515
563