예제 #1
0
def filter_sources():
    newsource = []
    for item in SOURCES_DATA:
        distro = item[1]
        if is_ubuntu(distro):
            if module_check.get_codename() in distro:
                newsource.append([item[0], module_check.get_codename(), item[2], item[3]])
        else:
            newsource.append(item)

    return newsource
예제 #2
0
    def init_items(self, key):
        self.reverse_depends = {}

        distro_parser = DistroParser()

        for item in self.get_data():
            if item['fields'].has_key('distros'):
                distros = item['fields']['distros']
                distro_values = ''

                if len(distros) > 1:
                    # If the item in distros is more than 1, so it's a PPA.
                    # Try to parse its real codename, when match the local
                    # Get it, or continue
                    for id in distros:
                        if module_check.get_codename() == distro_parser.get_codename(id):
                            distro_values = distro_parser.get_codename(id)
                            break

                    if distro_values == '':
                        continue
                elif len(distros) == 1:
                    distro_values = distro_parser.get_codename(distros[0])
            else:
                #TODO Remove in the future release, only leave distros
                distro_values = item['fields']['distro']

            if module_check.is_ubuntu(distro_values) and \
                    module_check.get_codename() not in distro_values:
                continue

            item['fields']['id'] = item['pk']
            # But here, always be distro, the only distro correspond with current
            item['fields']['distro'] = distro_values
            self[item['fields'][key]] = item['fields']

            UPGRADE_DICT[item['fields']['url']] = distro_values

            id = item['pk']
            fields = item['fields']

            if fields.has_key('dependencies') and fields['dependencies']:
                for depend_id in fields['dependencies']:
                    if self.reverse_depends.has_key(depend_id):
                        self.reverse_depends[depend_id].append(id)
                    else:
                        self.reverse_depends[depend_id] = [id]
예제 #3
0
    def process_data(self, data):
        global SOURCES_DATA
        self.processing = True
        try:
            SOURCES_DATA = self.server.getsource(os.getenv('LANG'), module_check.get_codename())
        except:
            self.error = True

        self.processing = False
예제 #4
0
    def process_data(self, data):
        self.processing = True
        try:
            title, locale, comment, source = data
            self.server.putsource(title, locale, comment, module_check.get_codename(), source)
        except:
            self.error = True

        self.processing = False
    def on_change_icon_clicked(self, widget):
        dialog = gtk.FileChooserDialog(_('Choose a new logo image'),
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT,
                                                 gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
        filter = gtk.FileFilter()
        filter.set_name(_("PNG image (*.png)"))
        filter.add_mime_type("image/png")
        dialog.set_current_folder(os.path.expanduser('~'))
        dialog.add_filter(filter)

        if module_check.get_codename() == 'karmic':
            dest = os.path.expanduser('~/.icons/%s/places/24/start-here.png' % self.__setting.get_icon_theme())
        else:
            dest = os.path.expanduser('~/.icons/%s/apps/24/start-here.png' % self.__setting.get_icon_theme())

        revert_button = dialog.action_area.get_children()[-1]
        if not os.path.exists(dest):
            revert_button.set_sensitive(False)

        filename = ''
        response = dialog.run()

        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            dialog.destroy()

            if filename:
                pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                w, h = pixbuf.get_width(), pixbuf.get_height()
                if w != 24 or h != 24:
                    ErrorDialog(_("This image size isn't suitable for the panel.\nIt should be 24x24.")).launch()
                    return
                else:
                    os.system('mkdir -p %s' % os.path.dirname(dest))
                    os.system('cp %s %s' % (filename, dest))

                    image = gtk.image_new_from_file(dest)
                    widget.set_image(image)
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            os.remove(dest)
            image = gtk.image_new_from_pixbuf(icon.get_from_name('start-here', size=24, force_reload=True))
            widget.set_image(image)
        else:
            dialog.destroy()
            return

        dialog = QuestionDialog(_('Do you want your changes to take effect immediately?'))
        if dialog.run() == gtk.RESPONSE_YES:
            os.system('killall gnome-panel')

        dialog.destroy()
예제 #6
0
    def enable_stable_source(self):
        self.list.refresh()

        for source in self.list:
            if self.stable_url in source.str() and source.type == 'deb' and not source.disabled:
                return

        self.set_separated_entry(self.stable_url, module_check.get_codename(),
                                 'main', 'Ubuntu Tweak Stable Source', True,
                                 'ubuntu-tweak-stable')
        self.add_apt_key_from_content(PPA_KEY)
    def on_background_button_clicked(self, widget):
        dialog = gtk.FileChooserDialog(
            _("Choose a new background image"),
            action=gtk.FILE_CHOOSER_ACTION_OPEN,
            buttons=(
                gtk.STOCK_REVERT_TO_SAVED,
                gtk.RESPONSE_DELETE_EVENT,
                gtk.STOCK_CANCEL,
                gtk.RESPONSE_CANCEL,
                gtk.STOCK_OPEN,
                gtk.RESPONSE_ACCEPT,
            ),
        )
        filter = gtk.FileFilter()
        filter.set_name(_("All images"))
        filter.add_pattern("*.jpg")
        filter.add_pattern("*.png")
        dialog.set_current_folder("/usr/share/backgrounds")
        dialog.add_filter(filter)

        if module_check.get_codename() == "karmic":
            orignal_background = "/usr/share/images/xsplash/bg_2560x1600.jpg"
        else:
            orignal_background = "/usr/share/backgrounds/warty-final-ubuntu.png"

        revert_button = dialog.action_area.get_children()[-1]

        filename = ""
        response = dialog.run()

        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            dialog.destroy()

            if filename:
                self.background_setting.set_value(user="******", value=filename)
                self.__setup_background_image()
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            self.background_setting.set_value(user="******", value=orignal_background)
            self.__setup_background_image()
        else:
            dialog.destroy()
            return
예제 #8
0
    def on_background_button_clicked(self, widget):
        dialog = gtk.FileChooserDialog(_('Choose a new background image'),
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT,
                                                 gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
        filter = gtk.FileFilter()
        filter.set_name(_('All images'))
        filter.add_pattern('*.jpg')
        filter.add_pattern('*.png')
        dialog.set_current_folder('/usr/share/backgrounds')
        dialog.add_filter(filter)

        if module_check.get_codename() == 'karmic':
            orignal_background = '/usr/share/images/xsplash/bg_2560x1600.jpg'
        else:
            orignal_background = '/usr/share/backgrounds/warty-final-ubuntu.png'

        revert_button = dialog.action_area.get_children()[-1]

        filename = ''
        response = dialog.run()

        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            log.debug("Get background file, the path is: %s" % filename)
            dialog.destroy()

            if filename:
                self.background_setting.set_value(user='******', value=filename)
                self.__setup_background_image()
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            self.background_setting.set_value(user='******',
                                              value=orignal_background)
            self.__setup_background_image()
        else:
            dialog.destroy()
            return
예제 #9
0
    COLUMN_ICON,
    COLUMN_NAME,
    COLUMN_DESC,
    COLUMN_DISPLAY,
) = range(5)

DEFAULT_SOURCE = '''deb http://archive.ubuntu.com/ubuntu/ %(distro)s main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ %(distro)s-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ %(distro)s-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ %(distro)s-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ %(distro)s-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s-backports main restricted universe multiverse''' % {'distro': module_check.get_codename()}

SOURCES_LIST = '/etc/apt/sources.list'

class SelectSourceDialog(gtk.Dialog):
    def __init__(self, parent):
        super(SelectSourceDialog, self).__init__(parent = parent)

        self.set_title(_('Choose the sources'))
        self.set_border_width(10)
        self.set_resizable(False)

        label = gtk.Label()
        label.set_markup('<b><big>%s</big></b>\n\n%s' % (_('Choose the sources'),
            _('You can read the title and comment to determine which source is suitable for you.')))
        label.set_alignment(0, 0)
예제 #10
0
    def __init__(self):
        gtk.Window.__init__(self)

        self.notify_func = None

        self.connect("destroy", self.destroy)
        self.set_title(APP)
        self.set_default_size(740, 480)
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_border_width(10)

        vbox = gtk.VBox(False, 6)
        self.add(vbox)

        self.hpaned = gtk.HPaned()
        vbox.pack_start(self.hpaned, True, True, 0)

        swindow = gtk.ScrolledWindow()
        swindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        swindow.set_size_request(150, -1)
        self.hpaned.pack1(swindow)

        self.model = self.__create_model()
        self.update_model()
        self.treeview = gtk.TreeView(self.model)
        self.treeview.set_enable_tree_lines(True)

        self.__add_columns(self.treeview)
        selection = self.treeview.get_selection()
        selection.connect("changed", self.selection_cb)
        self.treeview.expand_all()

        swindow.add(self.treeview)

        self.notebook = self.create_notebook()
        self.moduletable = {'0': 0}
        self.modules = {}
        self.hpaned.pack2(self.notebook)

        hbox = gtk.HBox(False, 12)
        vbox.pack_start(hbox, False, False, 0)
        button = gtk.Button(stock=gtk.STOCK_ABOUT)
        button.connect("clicked", self.show_about)
        hbox.pack_start(button, False, False, 0)

        d_button = gtk.Button(stock=gtk.STOCK_YES)
        set_label_for_stock_button(d_button, _('_Donate'))
        d_button.connect("clicked", self.on_d_clicked)
        hbox.pack_start(d_button, False, False, 0)

        button = gtk.Button(stock=gtk.STOCK_QUIT)
        button.connect("clicked", self.destroy)
        hbox.pack_end(button, False, False, 0)

        button = gtk.Button(stock=gtk.STOCK_PREFERENCES)
        button.connect('clicked', self.on_preferences_clicked)
        hbox.pack_end(button, False, False, 0)

        self.get_gui_state()
        self.set_icon(icon.get_from_name('ubuntu-tweak', size=48))
        self.show_all()

        if TweakSettings.get_check_update():
            log.debug("get_check_update will start after 5 seconds")
            gobject.timeout_add(5000, self.on_timeout)

        launch = TweakSettings.get_default_launch()
        try:
            if launch and not launch.isdigit():
                self.__create_newpage(launch)
        except:
            pass

        # Only check if the distribution is supported
        if module_check.get_codename():
            gobject.idle_add(self.notify_stable_source)
예제 #11
0
    def on_change_icon_clicked(self, widget):
        dialog = gtk.FileChooserDialog(_('Choose a new logo image'),
                                        action=gtk.FILE_CHOOSER_ACTION_OPEN,
                                        buttons=(gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_DELETE_EVENT,
                                                 gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                                 gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT))
        filter = gtk.FileFilter()
        filter.set_name(_("PNG images with 24x24 size or SVG images"))
        filter.add_pattern('*.png')
        filter.add_pattern('*.svg')
        dialog.set_current_folder(os.path.expanduser('~'))
        dialog.add_filter(filter)

        if module_check.get_codename() == 'karmic':
            dest = os.path.expanduser('~/.icons/%s/places/24/start-here' % self.__setting.get_icon_theme())
        else:
            dest = os.path.expanduser('~/.icons/%s/apps/24/start-here' % self.__setting.get_icon_theme())

        revert_button = dialog.action_area.get_children()[-1]

        HAVE_ICON = os.path.exists(dest + '.png') or os.path.exists(dest + '.svg')

        if not HAVE_ICON:
            revert_button.set_sensitive(False)

        filename = ''
        response = dialog.run()

        if response == gtk.RESPONSE_ACCEPT:
            filename = dialog.get_filename()
            dialog.destroy()

            if filename:
                ext = os.path.splitext(filename)[1]
                log.debug('The select file name is: %s' % ext)
                pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                w, h = pixbuf.get_width(), pixbuf.get_height()
                dest = dest + ext

                if ext == '.png' and (w != 24 or h != 24):
                    ErrorDialog(_("This image size isn't suitable for the panel.\nIt should measure 24x24.")).launch()
                    return
                else:
                    os.system('mkdir -p %s' % os.path.dirname(dest))
                    os.system('cp %s %s' % (filename, dest))

                    if ext == '.svg':
                        pixbuf = pixbuf.scale_simple(24, 24, gtk.gdk.INTERP_BILINEAR)
                    image = gtk.image_new_from_pixbuf(pixbuf)
                    widget.set_image(image)
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            for dest in glob.glob(dest + '*'):
                os.remove(dest)
            image = gtk.image_new_from_pixbuf(icon.get_from_name('start-here', force_reload=True))
            widget.set_image(image)
        else:
            dialog.destroy()
            return

        dialog = QuestionDialog(_('Do you want your changes to take effect immediately?'))
        if dialog.run() == gtk.RESPONSE_YES:
            os.system('killall gnome-panel')

        dialog.destroy()
예제 #12
0
from ubuntutweak.common.package import PACKAGE_WORKER
from ubuntutweak.widgets.dialogs import *

(COLUMN_CHECK, COLUMN_ICON, COLUMN_NAME, COLUMN_DESC, COLUMN_DISPLAY) = range(5)

DEFAULT_SOURCE = """deb http://archive.ubuntu.com/ubuntu/ %(distro)s main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ %(distro)s-security main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ %(distro)s-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ %(distro)s-proposed main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ %(distro)s-backports main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s-proposed main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ %(distro)s-backports main restricted universe multiverse""" % {
    "distro": module_check.get_codename()
}

SOURCES_LIST = "/etc/apt/sources.list"


class SelectSourceDialog(gtk.Dialog):
    def __init__(self, parent):
        super(SelectSourceDialog, self).__init__(parent=parent)

        self.set_title(_("Choose the sources"))
        self.set_border_width(10)
        self.set_resizable(False)

        label = gtk.Label()
        label.set_markup(