~usb-creator-hackers/usb-creator/trunk

« back to all changes in this revision

Viewing changes to usbcreator/gtk_frontend.py

  • Committer: Evan Dandrea
  • Date: 2008-09-15 03:17:39 UTC
  • Revision ID: evan.dandrea@canonical.com-20080915031739-c15c4slz0eg85h67
* Properly set the labels of the progress dialog on install startup.
* Do not make the dialogs modal.
* Elevate privileges using gksu.
* Added a .desktop file (LP: #267788).

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        # self.translate_widgets()
51
51
 
52
52
        if os.getuid() != 0:
53
 
            self.failed('This utility must be run with administrative '
54
 
                        'privileges, and cannot continue without them.')
 
53
            os.execl('/usr/bin/gksu', 'gksu', '--desktop',
 
54
                '/usr/share/applications/usb-creator.desktop', '--',
 
55
                'usb-creator')
 
56
            #self.failed('This utility must be run with administrative '
 
57
            #            'privileges, and cannot continue without them.')
55
58
 
56
59
        self.backend = Backend(self)
57
60
 
87
90
            title = 'The installation failed.  Please see ' \
88
91
                    '~/.usb-creator.log for more details.'
89
92
        self.backend.log('Install failed: ' + title)
90
 
        dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
 
93
        dialog = gtk.MessageDialog(None, 0,
91
94
                                   gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE,
92
95
                                   title)
93
96
        dialog.run()
99
102
        self.install_window.hide()
100
103
        title = 'Installation is complete.  You may now reboot your computer' \
101
104
            ' with this USB thumb drive inserted to boot Ubuntu.'
102
 
        dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
 
105
        dialog = gtk.MessageDialog(None, 0,
103
106
                                   gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE,
104
107
                                   title)
105
108
        dialog.run()
359
362
    def install(self, widget):
360
363
        self.backend.log('Installing...')
361
364
        self.window.hide()
 
365
        self.progress_title.set_markup('<big><b>Starting up</b></big>')
 
366
        self.progress_info.set_text('')
362
367
        self.install_window.show()
363
 
        #self.progress_title.set_text('Copying files')
364
368
        m, i = self.source_treeview.get_selection().get_selected()
365
369
        if not i:
366
370
            self.failed('Install button pressed but there was no source selection.')
388
392
    def progress(self, val, desc):
389
393
        self.progress_info.set_text('%d%% complete' % val)
390
394
        self.progress_bar.set_fraction(val / 100.0)
391
 
        self.progress_title.set_text(desc)
 
395
        self.progress_title.set_markup('<big><b>' + desc + '</b></big>')
392
396
 
393
397
def format_size(size):
394
398
    """Format a partition size."""