def menu_edit_clicked(self, button): program_id = self.list.get_active_text() program_data = self.get_program_data_from_id(program_id) icon = icons.get_icon_pixbuf_from_program( program_data, self.dialog_edit_program.icon.get_pixel_size() ) command = comment = uninstall = '' app_type = 'application' # NOTE: These are the default key names for program data in python-wine. # VineyardCommand and so on are only used internally by python-wine. if 'programcommand' in program_data: command = program_data['programcommand'] elif 'programexe' in program_data: if os.path.exists(program_data['programexe']): command = wine.util.unixtowin(program_data['programexe']) else: command = program_data['programexe'] command = "'{0}'".format(command) if 'description' in program_data: comment = program_data['description'] if 'programterminal' in program_data and program_data['programterminal']: app_type = 'terminal' if 'uninstall' in program_data: uninstall = program_data['uninstall'] icon = program_data.get( 'icon', program_data.get( 'programicon', program_data.get( 'programexe', program_data.get( 'exe', None ) ) ) ) #icon = wine.programs.get_icon(program_data) self.dialog_edit_program.set( id = program_id, name = program_data['name'], command = command, comment = comment, uninstall = uninstall, type = app_type, icon = icon, category = program_data.get('category', 'Wine'), showinmenu = program_data.get('showinmenu', True), disablepulseaudio = program_data.get('disablepulseaudio', False) ) self.dialog_edit_program.show_all()
def _model_add_section(self, model, header, program_dict, first=False): if first == True: model.append([None, None, '<header first>%s</header>' % header]) else: model.append([None, None, '<header>%s</header>' % header]) #for program_id in sorted(program_dict.keys(), key=unicode.lower): for program_index in sorted( program_dict, key=lambda i: program_dict[i]['name'].lower()): program_data = program_dict[program_index] model.append((program_index, icons.get_icon_pixbuf_from_program(program_data), self._get_markup_from_program_data(program_data)))
def _model_add_section(self, model, header, program_dict, first=False): if first == True: model.append([None, None, '<header first>%s</header>' % header]) else: model.append([None, None, '<header>%s</header>' % header]) #for program_id in sorted(program_dict.keys(), key=unicode.lower): for program_index in sorted(program_dict, key=lambda i: program_dict[i]['name'].lower()): program_data = program_dict[program_index] model.append(( program_index, icons.get_icon_pixbuf_from_program(program_data), self._get_markup_from_program_data(program_data) ))
def menu_edit_clicked(self, button): program_id = self.list.get_active_text() program_data = self.get_program_data_from_id(program_id) icon = icons.get_icon_pixbuf_from_program( program_data, self.dialog_edit_program.icon.get_pixel_size()) command = comment = uninstall = '' app_type = 'application' # NOTE: These are the default key names for program data in python-wine. # VineyardCommand and so on are only used internally by python-wine. if 'programcommand' in program_data: command = program_data['programcommand'] elif 'programexe' in program_data: if os.path.exists(program_data['programexe']): command = wine.util.unixtowin(program_data['programexe']) else: command = program_data['programexe'] command = "'{0}'".format(command) if 'description' in program_data: comment = program_data['description'] if 'programterminal' in program_data and program_data[ 'programterminal']: app_type = 'terminal' if 'uninstall' in program_data: uninstall = program_data['uninstall'] icon = program_data.get( 'icon', program_data.get( 'programicon', program_data.get('programexe', program_data.get('exe', None)))) #icon = wine.programs.get_icon(program_data) self.dialog_edit_program.set( id=program_id, name=program_data['name'], command=command, comment=comment, uninstall=uninstall, type=app_type, icon=icon, category=program_data.get('category', 'Wine'), showinmenu=program_data.get('showinmenu', True), disablepulseaudio=program_data.get('disablepulseaudio', False)) self.dialog_edit_program.show_all()
def _on_edit_program_response(self, dialog, response): if response == gtk.RESPONSE_OK: new_values = dialog.get() if new_values['id'] == 'adding': program_data = {} program_data['_registrykey'] = 'vineyard-{name}'.format( name=wine.util.string_safe_chars( new_values['name'].lower(), extra_safe_chars=' ,.-_')) program_data['id'] = len( self.settings[self.settings_key]['new_list']) program_data['name'] = new_values['name'] program_data['type'] = new_values['type'] if new_values['icon'] is not None and len(new_values['icon']): program_data['icon'] = new_values['icon'] if len(new_values['comment']): program_data['description'] = new_values['comment'] if len(new_values['command']): program_data['programcommand'] = new_values['command'] if len(new_values['uninstall']): program_data['uninstall'] = new_values['uninstall'] if len(new_values['category']): program_data['category'] = new_values['category'] program_data['showinmenu'] = new_values['showinmenu'] program_data['disablepulseaudio'] = new_values[ 'disablepulseaudio'] else: program_data = wine.common.copy( self.get_program_data_from_id(new_values['id'])) program_data['id'] = new_values['id'] program_data['name'] = new_values['name'] if len(new_values['comment']) or 'description' in program_data: program_data['description'] = new_values['comment'] if len(new_values['command'] ) or 'programcommand' in program_data: program_data['programcommand'] = new_values['command'] if len(new_values['uninstall']) or 'uninstall' in program_data: program_data['uninstall'] = new_values['uninstall'] if program_data.get('programterminal', None) != new_values['type']: program_data['programterminal'] = ( new_values['type'] == 'terminal') if new_values['icon'] != None or 'icon' in program_data: program_data['icon'] = new_values['icon'] if len(new_values['category']) or 'category' in program_data: program_data['category'] = new_values['category'] program_data['showinmenu'] = new_values['showinmenu'] program_data['disablepulseaudio'] = new_values[ 'disablepulseaudio'] existing_program = self.get_program_data_from_id( program_data['id']) if existing_program is not None: # Create a copy of the program dict object with the extra default # values that the edit dialog will have created, so we can match # without matching default values existing_program_for_matching = dict(existing_program) existing_program_for_matching.setdefault('category', 'Wine;') existing_program_for_matching.setdefault( 'disablepulseaudio', False) existing_program_for_matching.setdefault( 'id', program_data['id']) existing_program_for_matching.setdefault( 'programterminal', False) existing_program_for_matching.setdefault('showinmenu', False) else: existing_program_for_matching = existing_program if program_data != existing_program_for_matching: if 'programterminal' in program_data: del program_data['programterminal'] self.settings[self.settings_key]['new_list'][ program_data['id']] = program_data # New program (add) if existing_program is None: self.list.insert_in_section(_('Programs'), self._create_row_from_program( program_data['id'], program_data), alphabetically=True) # Existing program (edit) else: row_nr = self.list.get_row_nr_by_text(program_data['id']) self.list.set_cell_value( row_nr, 1, icons.get_icon_pixbuf_from_program(program_data)) self.list.set_cell_value( row_nr, 2, self._get_markup_from_program_data(program_data)) self.gobject.emit('settings-changed', self.settings_key, self.set_function, (self.settings[self.settings_key], )) dialog.hide()
def _create_row_from_program(self, index, program_data): return (index, icons.get_icon_pixbuf_from_program(program_data), self._get_markup_from_program_data(program_data))
def _on_edit_program_response(self, dialog, response): if response == gtk.RESPONSE_OK: new_values = dialog.get() if new_values['id'] == 'adding': program_data = {} program_data['_registrykey'] = 'vineyard-{name}'.format( name = wine.util.string_safe_chars( new_values['name'].lower(), extra_safe_chars = ' ,.-_' ) ) program_data['id'] = len(self.settings[self.settings_key]['new_list']) program_data['name'] = new_values['name'] program_data['type'] = new_values['type'] if new_values['icon'] is not None and len(new_values['icon']): program_data['icon'] = new_values['icon'] if len(new_values['comment']): program_data['description'] = new_values['comment'] if len(new_values['command']): program_data['programcommand'] = new_values['command'] if len(new_values['uninstall']): program_data['uninstall'] = new_values['uninstall'] if len(new_values['category']): program_data['category'] = new_values['category'] program_data['showinmenu'] = new_values['showinmenu'] program_data['disablepulseaudio'] = new_values['disablepulseaudio'] else: program_data = wine.common.copy( self.get_program_data_from_id(new_values['id']) ) program_data['id'] = new_values['id'] program_data['name'] = new_values['name'] if len(new_values['comment']) or 'description' in program_data: program_data['description'] = new_values['comment'] if len(new_values['command']) or 'programcommand' in program_data: program_data['programcommand'] = new_values['command'] if len(new_values['uninstall']) or 'uninstall' in program_data: program_data['uninstall'] = new_values['uninstall'] if program_data.get('programterminal', None) != new_values['type']: program_data['programterminal'] = (new_values['type'] == 'terminal') if new_values['icon'] != None or 'icon' in program_data: program_data['icon'] = new_values['icon'] if len(new_values['category']) or 'category' in program_data: program_data['category'] = new_values['category'] program_data['showinmenu'] = new_values['showinmenu'] program_data['disablepulseaudio'] = new_values['disablepulseaudio'] existing_program = self.get_program_data_from_id(program_data['id']) if existing_program is not None: # Create a copy of the program dict object with the extra default # values that the edit dialog will have created, so we can match # without matching default values existing_program_for_matching = dict(existing_program) existing_program_for_matching.setdefault('category', 'Wine;') existing_program_for_matching.setdefault('disablepulseaudio', False) existing_program_for_matching.setdefault('id', program_data['id']) existing_program_for_matching.setdefault('programterminal', False) existing_program_for_matching.setdefault('showinmenu', False) else: existing_program_for_matching = existing_program if program_data != existing_program_for_matching: if 'programterminal' in program_data: del program_data['programterminal'] self.settings[self.settings_key]['new_list'][ program_data['id']] = program_data # New program (add) if existing_program is None: self.list.insert_in_section( _('Programs'), self._create_row_from_program( program_data['id'], program_data ), alphabetically = True ) # Existing program (edit) else: row_nr = self.list.get_row_nr_by_text(program_data['id']) self.list.set_cell_value(row_nr, 1, icons.get_icon_pixbuf_from_program(program_data)) self.list.set_cell_value(row_nr, 2, self._get_markup_from_program_data(program_data)) self.gobject.emit('settings-changed', self.settings_key, self.set_function, (self.settings[self.settings_key],)) dialog.hide()
def _create_row_from_program(self, index, program_data): return ( index, icons.get_icon_pixbuf_from_program(program_data), self._get_markup_from_program_data(program_data) )