def __init__(self, packages_to_install, parent_window=None, ignore_network=False, callback=None): self._DOWNLOADING = False self._DOWNLOAD_DIALOG = None self._DOWNLOAD_PACKAGES = packages_to_install self._INSTALL_ATTEMPT_NR = 1 self._callback_function = callback self.return_status = None self.parent_window = parent_window if self.parent_window is None: self.parent_window = common.get_main_window() # Test if the there's internet if not ignore_network and not wine.util.get_internet_available(): dialog_no_internet() return self._create_dialog() # If winetricks is installed, go ahead and install stuff if wine.winetricks_installed(): self._run_winetricks() # Else, download winetricks while showing a nice progress dialog else: self._DOWNLOAD_DIALOG.set_title(_("Downloading winetricks")) self._DOWNLOAD_DIALOG.set_markup(_('Downloading winetricks')) self._DOWNLOAD_DIALOG.set_markup_second(_('This only needs to be done this once.')) self._DOWNLOAD_DIALOG.show_all() # Start the download in a new thread and run winetricks when done THREADING.run_in_thread( wine.update_winetricks, callback = self._run_winetricks )
def _show_dialog_program_error_question(self, offer_info=True): dialog = gtk.MessageDialog(parent=common.get_main_window(), flags=gtk.DIALOG_DESTROY_WITH_PARENT, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK) dialog.set_icon_name('vineyard-preferences') dialog.set_markup('<span weight="bold" size="larger">%s</span>' % \ _("The program exited with an error")) if self.name == 'winetricks': dialog.format_secondary_markup(unicode('The installation program did ' + \ 'not exit cleanly. You may have success with simply running it again.')) else: dialog.format_secondary_markup(unicode('The program <b>%(program)s</b> did ' + \ 'not exit cleanly and any work or progress you may have ' + \ 'done in the program may have been lost.') % \ {'program': common.escape_xml(self.name)}) settings = gtk.settings_get_default() settings.set_property('gtk-alternative-button-order', True) if offer_info: button_info = gtk.Button(_("More info")) dialog.add_action_widget(button_info, 10) dialog.set_alternative_button_order([10, gtk.RESPONSE_OK]) dialog.set_default_response(gtk.RESPONSE_OK) dialog.connect("response", self._on_dialog_main_response) dialog.show_all()
def _show_dialog_program_error(self, program_name, text, error, show_explanation=False): self._error_dialog = gtk.Dialog( _("Error information for %s") % program_name, parent=common.get_main_window(), flags=gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR, buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK)) hbox = gtk.HBox(spacing=6) icon = gtk.Image() icon.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) icon.set_alignment(0.5, 0.0) hbox.pack_start(icon, expand=False, fill=True) vbox = gtk.VBox() label = gtk.Label() label.set_line_wrap(True) label.set_alignment(0.0, 0.5) label.set_markup('%s' % text) label.set_size_request(common.widget_get_char_width(label) * 80, -1) vbox.pack_start(label, expand=False, fill=True) scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolledwindow.set_size_request( common.widget_get_char_width(scrolledwindow) * 80, common.widget_get_char_height(scrolledwindow) * 6) textview = gtk.TextView() textview.get_buffer().set_text(error) textview.modify_font(pango.FontDescription('monospace')) textview.set_cursor_visible(False) scrolledwindow.add(textview) if not show_explanation: vbox.pack_start(scrolledwindow, expand=True, fill=True) else: expander = gtk.Expander(_("Detailed error information")) expander.add(scrolledwindow) vbox.pack_start(expander, expand=True, fill=True) hbox.pack_start(vbox, expand=True, fill=True) self._error_dialog.vbox.pack_start(hbox, expand=True, fill=True) self._error_dialog.connect('destroy', self._on_dialog_program_error_response) self._error_dialog.connect('response', self._on_dialog_program_error_response) self._error_dialog.show_all()
def _show_dialog_program_error(self, program_name, text, error, show_explanation=False): self._error_dialog = gtk.Dialog(_("Error information for %s") % program_name, parent = common.get_main_window(), flags = gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR, buttons = (gtk.STOCK_OK, gtk.RESPONSE_OK)) hbox = gtk.HBox(spacing=6) icon = gtk.Image() icon.set_from_stock(gtk.STOCK_DIALOG_INFO, gtk.ICON_SIZE_DIALOG) icon.set_alignment(0.5, 0.0) hbox.pack_start(icon, expand=False, fill=True) vbox = gtk.VBox() label = gtk.Label() label.set_line_wrap(True) label.set_alignment(0.0, 0.5) label.set_markup('%s' % text) label.set_size_request( common.widget_get_char_width(label)*80, -1 ) vbox.pack_start(label, expand=False, fill=True) scrolledwindow = gtk.ScrolledWindow() scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) scrolledwindow.set_size_request( common.widget_get_char_width(scrolledwindow)*80, common.widget_get_char_height(scrolledwindow)*6) textview = gtk.TextView() textview.get_buffer().set_text(error) textview.modify_font(pango.FontDescription('monospace')) textview.set_cursor_visible(False) scrolledwindow.add(textview) if not show_explanation: vbox.pack_start(scrolledwindow, expand=True, fill=True) else: expander = gtk.Expander(_("Detailed error information")) expander.add(scrolledwindow) vbox.pack_start(expander, expand=True, fill=True) hbox.pack_start(vbox, expand=True, fill=True) self._error_dialog.vbox.pack_start(hbox, expand=True, fill=True) self._error_dialog.connect('destroy', self._on_dialog_program_error_response) self._error_dialog.connect('response', self._on_dialog_program_error_response) self._error_dialog.show_all()
def __init__(self, icon=''): gtk.FileChooserDialog.__init__(self, parent=common.get_main_window(), action=gtk.FILE_CHOOSER_ACTION_OPEN, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) self.image_previewer = gtk.Image() self.set_preview_widget(self.image_previewer) self.connect('selection_changed', self._file_preview) self.set_deletable(False) self.add_filter(common.filefilters['all']) self.add_filter(common.filefilters['windows_executables_and_images']) self.set_filter(common.filefilters['windows_executables_and_images']) self.connect('delete-event', self._destroy) self.connect('destroy-event', self._destroy) self.set_deletable(False)
def __init__(self, icon = ''): gtk.FileChooserDialog.__init__( self, parent = common.get_main_window(), action = gtk.FILE_CHOOSER_ACTION_OPEN, buttons = ( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK ) ) self.image_previewer = gtk.Image() self.set_preview_widget(self.image_previewer) self.connect('selection_changed', self._file_preview) self.set_deletable(False) self.add_filter(common.filefilters['all']) self.add_filter(common.filefilters['windows_executables_and_images']) self.set_filter(common.filefilters['windows_executables_and_images']) self.connect('delete-event', self._destroy) self.connect('destroy-event', self._destroy) self.set_deletable(False)
def __init__(self): gtk.Dialog.__init__( self, title=_("Program Information"), parent=common.get_main_window(), flags=gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK)) self.set_border_width(5) self.accel_group = gtk.AccelGroup() self.add_accel_group(self.accel_group) self.hbox = gtk.HBox() self.hbox.set_spacing(6) self.vbox.pack_start(self.hbox, expand=True, fill=True, padding=0) # Icon setup self.vbox_icon = gtk.VBox() self.hbox.pack_start(self.vbox_icon, expand=False, fill=False, padding=0) self.button_icon = gtk.Button() self.button_icon.set_accel_path self.button_icon.add_accelerator('grab-focus', self.accel_group, ord('i'), gtk.gdk.MOD1_MASK, 0) self.vbox_icon.pack_start(self.button_icon, expand=False, fill=False, padding=0) self.button_icon_aspectframe = gtk.AspectFrame() self.button_icon_aspectframe.set_shadow_type(gtk.SHADOW_NONE) self.button_icon.add(self.button_icon_aspectframe) self.icon = gtk.Image() self.icon.filename = None self.button_icon_aspectframe.add(self.icon) # Fields setup self.table = gtk.Table() self.table.set_row_spacings(6) self.table.set_col_spacings(6) self.hbox.pack_start(self.table, expand=True, fill=True, padding=0) row = 0 self.label_type = gtk.Label(_('_Type:')) self.label_type.set_use_underline(True) self.label_type.set_alignment(1.0, 0.5) self.combobox_type = gtk.combo_box_new_text() self.combobox_type.append_text(_('Application')) self.combobox_type.append_text(_('Application in Terminal')) self.label_type.set_mnemonic_widget(self.combobox_type) self.table.attach(self.label_type, 0, 1, row, row + 1, gtk.FILL, 0) self.table.attach(self.combobox_type, 1, 3, row, row + 1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_name = gtk.Label(_('_Name:')) self.label_name.set_use_underline(True) self.label_name.set_alignment(1.0, 0.5) self.entry_name = gtk.Entry() self.label_name.set_mnemonic_widget(self.entry_name) self.table.attach(self.label_name, 0, 1, row, row + 1, gtk.FILL, 0) self.table.attach(self.entry_name, 1, 3, row, row + 1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_command = gtk.Label(_('Comm_and:')) self.label_command.set_use_underline(True) self.label_command.set_alignment(1.0, 0.5) self.entry_command = gtk.Entry() self.label_command.set_mnemonic_widget(self.entry_command) self.button_command = gtk.Button(_('_Browse...')) self.table.attach(self.label_command, 0, 1, row, row + 1, gtk.FILL, 0) self.table.attach(self.entry_command, 1, 2, row, row + 1, gtk.EXPAND | gtk.FILL, 0) self.table.attach(self.button_command, 2, 3, row, row + 1, gtk.FILL, 0) row += 1 self.label_comment = gtk.Label(_('Co_mment:')) self.label_comment.set_use_underline(True) self.label_comment.set_alignment(1.0, 0.5) self.entry_comment = gtk.Entry() self.label_comment.set_mnemonic_widget(self.entry_comment) self.table.attach(self.label_comment, 0, 1, row, row + 1, gtk.FILL, 0) self.table.attach(self.entry_comment, 1, 3, row, row + 1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_uninstall = gtk.Label(_('_Uninstall:')) self.label_uninstall.set_use_underline(True) self.label_uninstall.set_alignment(1.0, 0.5) self.entry_uninstall = gtk.Entry() self.label_uninstall.set_mnemonic_widget(self.entry_uninstall) self.table.attach(self.label_uninstall, 0, 1, row, row + 1, gtk.FILL, 0) self.table.attach(self.entry_uninstall, 1, 3, row, row + 1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_category = gtk.Label(_('C_ategory:')) self.label_category.set_use_underline(True) self.label_category.set_alignment(1.0, 0.5) self.combobox_category = gtk.ComboBoxEntry() self.combobox_category_completion = gtk.EntryCompletion() self.combobox_category.child.set_completion( self.combobox_category_completion) self.combobox_category_model = gtk.ListStore(str) self.combobox_category.set_model(self.combobox_category_model) self.combobox_category.set_text_column(0) self.combobox_category_completion.set_model( self.combobox_category_model) self.combobox_category_completion.set_text_column(0) for category in wine.common.XDG_MENU_CATEGORIES: self.combobox_category_model.append((category, )) self.label_category.set_mnemonic_widget(self.combobox_category) self.checkbutton_showinmenu = gtk.CheckButton(_('_Show in menu'), True) self.checkbutton_showinmenu.set_tooltip_text( _("Note that the program may not show up in the menu until you have clicked ok" )) self.table.attach(self.label_category, 0, 1, row, row + 1, gtk.FILL, 0) self.table.attach(self.combobox_category, 1, 2, row, row + 1, gtk.EXPAND | gtk.FILL, 0) self.table.attach(self.checkbutton_showinmenu, 2, 3, row, row + 1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_pulseaudio = gtk.Label(_('_PulseAudio:')) self.label_pulseaudio.set_use_underline(True) self.label_pulseaudio.set_alignment(1.0, 0.5) self.checkbutton_pulseaudio = gtk.CheckButton( _('_Disable PulseAudio whilst running'), True) self.checkbutton_pulseaudio.set_tooltip_text( _("Shut down PulseAudio when starting this program and start it again afterwards" )) self.label_pulseaudio.set_mnemonic_widget(self.checkbutton_pulseaudio) self.table.attach(self.label_pulseaudio, 0, 1, row, row + 1, gtk.FILL, 0) self.table.attach(self.checkbutton_pulseaudio, 1, 3, row, row + 1, gtk.EXPAND | gtk.FILL, 0) row += 1 self._set_default_icon() self.connect('delete-event', self._destroy) self.connect('destroy-event', self._destroy) self.set_deletable(False) self.filechooser_command = FileChooserProgram() self.filechooser_icon = FileChooserIcon() self.button_command.connect('clicked', self._on_edit_program_command) self.button_icon.connect('clicked', self._on_edit_program_icon) self.filechooser_command.connect('response', self._on_filechooser_command_response) self.filechooser_icon.connect('response', self._on_filechooser_icon_response)
def __init__(self): gtk.Dialog.__init__( self, title = _("Program Information"), parent = common.get_main_window(), flags = gtk.DIALOG_DESTROY_WITH_PARENT | gtk.DIALOG_NO_SEPARATOR, buttons = ( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK ) ) self.set_border_width(5) self.accel_group = gtk.AccelGroup() self.add_accel_group(self.accel_group) self.hbox = gtk.HBox() self.hbox.set_spacing(6) self.vbox.pack_start( self.hbox, expand = True, fill = True, padding = 0) # Icon setup self.vbox_icon = gtk.VBox() self.hbox.pack_start( self.vbox_icon, expand = False, fill = False, padding = 0) self.button_icon = gtk.Button() self.button_icon.set_accel_path self.button_icon.add_accelerator( 'grab-focus', self.accel_group, ord('i'), gtk.gdk.MOD1_MASK, 0) self.vbox_icon.pack_start( self.button_icon, expand = False, fill = False, padding = 0) self.button_icon_aspectframe = gtk.AspectFrame() self.button_icon_aspectframe.set_shadow_type(gtk.SHADOW_NONE) self.button_icon.add(self.button_icon_aspectframe) self.icon = gtk.Image() self.icon.filename = None self.button_icon_aspectframe.add(self.icon) # Fields setup self.table = gtk.Table() self.table.set_row_spacings(6) self.table.set_col_spacings(6) self.hbox.pack_start( self.table, expand = True, fill = True, padding = 0) row = 0 self.label_type = gtk.Label(_('_Type:')) self.label_type.set_use_underline(True) self.label_type.set_alignment(1.0, 0.5) self.combobox_type = gtk.combo_box_new_text() self.combobox_type.append_text(_('Application')) self.combobox_type.append_text(_('Application in Terminal')) self.label_type.set_mnemonic_widget(self.combobox_type) self.table.attach(self.label_type, 0,1, row,row+1, gtk.FILL, 0) self.table.attach(self.combobox_type, 1,3, row,row+1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_name = gtk.Label(_('_Name:')) self.label_name.set_use_underline(True) self.label_name.set_alignment(1.0, 0.5) self.entry_name = gtk.Entry() self.label_name.set_mnemonic_widget(self.entry_name) self.table.attach(self.label_name, 0,1, row,row+1, gtk.FILL, 0) self.table.attach(self.entry_name, 1,3, row,row+1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_command = gtk.Label(_('Comm_and:')) self.label_command.set_use_underline(True) self.label_command.set_alignment(1.0, 0.5) self.entry_command = gtk.Entry() self.label_command.set_mnemonic_widget(self.entry_command) self.button_command = gtk.Button(_('_Browse...')) self.table.attach(self.label_command, 0,1, row,row+1, gtk.FILL, 0) self.table.attach(self.entry_command, 1,2, row,row+1, gtk.EXPAND | gtk.FILL, 0) self.table.attach(self.button_command, 2,3, row,row+1, gtk.FILL, 0) row += 1 self.label_comment = gtk.Label(_('Co_mment:')) self.label_comment.set_use_underline(True) self.label_comment.set_alignment(1.0, 0.5) self.entry_comment = gtk.Entry() self.label_comment.set_mnemonic_widget(self.entry_comment) self.table.attach(self.label_comment, 0,1, row,row+1, gtk.FILL, 0) self.table.attach(self.entry_comment, 1,3, row,row+1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_uninstall = gtk.Label(_('_Uninstall:')) self.label_uninstall.set_use_underline(True) self.label_uninstall.set_alignment(1.0, 0.5) self.entry_uninstall = gtk.Entry() self.label_uninstall.set_mnemonic_widget(self.entry_uninstall) self.table.attach(self.label_uninstall, 0,1, row,row+1, gtk.FILL, 0) self.table.attach(self.entry_uninstall, 1,3, row,row+1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_category = gtk.Label(_('C_ategory:')) self.label_category.set_use_underline(True) self.label_category.set_alignment(1.0, 0.5) self.combobox_category = gtk.ComboBoxEntry() self.combobox_category_completion = gtk.EntryCompletion() self.combobox_category.child.set_completion(self.combobox_category_completion) self.combobox_category_model = gtk.ListStore(str) self.combobox_category.set_model(self.combobox_category_model) self.combobox_category.set_text_column(0) self.combobox_category_completion.set_model(self.combobox_category_model) self.combobox_category_completion.set_text_column(0) for category in wine.common.XDG_MENU_CATEGORIES: self.combobox_category_model.append((category,)) self.label_category.set_mnemonic_widget(self.combobox_category) self.checkbutton_showinmenu = gtk.CheckButton(_('_Show in menu'), True) self.checkbutton_showinmenu.set_tooltip_text( _("Note that the program may not show up in the menu until you have clicked ok") ) self.table.attach(self.label_category, 0,1, row,row+1, gtk.FILL, 0) self.table.attach(self.combobox_category, 1,2, row,row+1, gtk.EXPAND | gtk.FILL, 0) self.table.attach(self.checkbutton_showinmenu, 2,3, row,row+1, gtk.EXPAND | gtk.FILL, 0) row += 1 self.label_pulseaudio = gtk.Label(_('_PulseAudio:')) self.label_pulseaudio.set_use_underline(True) self.label_pulseaudio.set_alignment(1.0, 0.5) self.checkbutton_pulseaudio = gtk.CheckButton(_('_Disable PulseAudio whilst running'), True) self.checkbutton_pulseaudio.set_tooltip_text( _("Shut down PulseAudio when starting this program and start it again afterwards") ) self.label_pulseaudio.set_mnemonic_widget(self.checkbutton_pulseaudio) self.table.attach(self.label_pulseaudio, 0,1, row,row+1, gtk.FILL, 0) self.table.attach(self.checkbutton_pulseaudio, 1,3, row,row+1, gtk.EXPAND | gtk.FILL, 0) row += 1 self._set_default_icon() self.connect('delete-event', self._destroy) self.connect('destroy-event', self._destroy) self.set_deletable(False) self.filechooser_command = FileChooserProgram() self.filechooser_icon = FileChooserIcon() self.button_command.connect('clicked', self._on_edit_program_command) self.button_icon.connect('clicked', self._on_edit_program_icon) self.filechooser_command.connect('response', self._on_filechooser_command_response) self.filechooser_icon.connect('response', self._on_filechooser_icon_response)
def button_install_clicked(self, button): packages = [ self.installers[i][0] for i in self.list.get_active() ] installer.Winetricks(packages, parent_window = common.get_main_window())