Ejemplo n.º 1
0
 def on_add_item(self, widget, treeview):
     dialog = AutoStartDialog(parent=widget.get_toplevel())
     if dialog.run() == gtk.RESPONSE_OK:
         name = dialog.pm_name.get_text()
         cmd = dialog.pm_cmd.get_text()
         if not name:
             ErrorDialog(
                 _("The name of the startup program cannot be empty")
             ).launch()
         elif not cmd:
             ErrorDialog(
                 _("Text field was empty (or contained only whitespace)")
             ).launch()
         else:
             path = os.path.join(treeview.userdir,
                                 os.path.basename(cmd) + ".desktop")
             desktopentry = DesktopEntry(path)
             desktopentry.set("Name", dialog.pm_name.get_text())
             desktopentry.set("Exec", dialog.pm_cmd.get_text())
             desktopentry.set("Comment", dialog.pm_comment.get_text())
             desktopentry.set("Type", "Application")
             desktopentry.set("Version", "1.0")
             desktopentry.set("X-GNOME-Autostart-enabled", "true")
             desktopentry.write()
             treeview.update_items(
                 all=self.show_all_button.get_active(),
                 comment=self.show_comment_button.get_active())
             dialog.destroy()
             return
     dialog.destroy()
Ejemplo n.º 2
0
    def on_edit_item(self, widget, treeview):
        model, iter = treeview.get_selection().get_selected()

        if iter:
            path = model.get_value(iter, COLUMN_PATH)
            if path[1:4] == "etc":
                shutil.copy(path, treeview.userdir)
                path = os.path.join(treeview.userdir, os.path.basename(path))
            dialog = AutoStartDialog(DesktopEntry(path), widget.get_toplevel())
            if dialog.run() == gtk.RESPONSE_OK:
                name = dialog.pm_name.get_text()
                cmd = dialog.pm_cmd.get_text()
                if not name:
                    ErrorDialog(
                        _("The name of the startup program cannot be empty")
                    ).launch()
                elif not cmd:
                    ErrorDialog(
                        _("Text field was empty (or contained only whitespace)"
                          )).launch()
                else:
                    desktopentry = DesktopEntry(path)
                    desktopentry.set("Name", name, locale=True)
                    desktopentry.set("Exec", cmd)
                    desktopentry.set("Comment",
                                     dialog.pm_comment.get_text(),
                                     locale=True)
                    desktopentry.write()
                    treeview.update_items(
                        all=self.show_all_button.get_active(),
                        comment=self.show_comment_button.get_active())
                    dialog.destroy()
                    return
            dialog.destroy()
Ejemplo n.º 3
0
 def on_restart_button_clicked(self, widget):
     global SYSTEM_DIR, USER_DIR 
     SYSTEM_DIR, USER_DIR = update_dir()
     if is_right_path():
         self.remove_all_children()
         self.create_interface()
     else:
         ErrorDialog(_('The templates path is still incorrect, please reset it!')).launch()
Ejemplo n.º 4
0
 def on_apply_clicked(self, widget, entrys):
     for entry in entrys:
         if entry.is_changed():
             if os.popen('which %s' % entry.get_text()).read():
                 entry.on_edit_finished_cb(entry)
             else:
                 ErrorDialog(_('Please enter a valid application command line.'), title=_('"%s" is not available.') % entry.get_text()).launch()
                 entry.reset()
     self.apply_button.set_sensitive(False)
Ejemplo n.º 5
0
    def on_delete_from_disk(self, widget, data=None):
        model, iter = self.get_selection().get_selected()

        if iter:
            path = model.get_value(iter, COLUMN_PATH)
            if self.is_defaultitem(path):
                ErrorDialog(_("Can't delete system item from disk.")).launch()
            else:
                os.remove(path)

        self.update_items()
Ejemplo n.º 6
0
    def on_source_data_downloaded(self, widget):
        path = widget.get_downloaded_file()
        tarfile = utdata.create_tarfile(path)

        if tarfile.is_valid():
            tarfile.extract(consts.CONFIG_ROOT)
            self.update_source_data()
            utdata.save_synced_timestamp(SOURCE_ROOT)
            self.update_timestamp()
        else:
            ErrorDialog(
                _('An error occurred whilst downloading the file')).launch()
Ejemplo n.º 7
0
 def upgrade_sources(self):
     dialog = QuestionDialog(_(
         'After a successful distribution upgrade, '
         'any third-party sources you use will be disabled by default.\n'
         'Would you like to re-enable any sources disabled by Update Manager?'
     ),
                             title=_('Upgrade Third Party Sources'))
     response = dialog.run()
     dialog.destroy()
     if response == gtk.RESPONSE_YES:
         proxy.upgrade_sources(self.__get_disable_string(), UPGRADE_DICT)
         if not self.check_source_upgradable():
             InfoDialog(_('Upgrade Successful!')).launch()
         else:
             ErrorDialog(_('Upgrade Failed!')).launch()
         self.emit('call', 'ubuntutweak.modules.sourceeditor',
                   'update_source_combo', {})
         self.update_thirdparty()
Ejemplo n.º 8
0
    def show_installed_status(self, to_add, to_rm):
        done = True

        for pkg in to_add:
            if not PackageInfo(pkg).check_installed():
                done = False
                break

        for pkg in to_rm:
            try:
                if PackageInfo(pkg).check_installed():
                    done = False
                    break
            except:
                pass

        if done:
            InfoDialog(_('Update Successful!')).launch()
        else:
            ErrorDialog(_('Update Failed!')).launch()
Ejemplo n.º 9
0
    def on_add_button_clicked(self, widget):
        dialog = AddAppDialog(self.types[0], widget.get_toplevel())
        if dialog.run() == gtk.RESPONSE_ACCEPT:
            if dialog.get_command_runable():
                we = dialog.get_command_or_appinfo()
                if type(we) == gio.unix.DesktopAppInfo:
                    app = we
                else:
                    app = gio.AppInfo(we)
                for filetype in self.types:
                    app.set_as_default_for_type(filetype)

                self.update_model()
                self.emit('update', self.types)
            else:
                ErrorDialog(_('Could not find %s') %
                            dialog.get_command_or_appinfo(),
                            title=_('Could not find application')).launch()

        dialog.destroy()
Ejemplo n.º 10
0
    def on_apply_button_clicked(self, widget, data=None):
        to_rm = self.appview.to_rm
        to_add = self.appview.to_add
        self.package_worker.perform_action(widget.get_toplevel(), to_add,
                                           to_rm)

        self.package_worker.update_apt_cache(True)

        done = self.package_worker.get_install_status(to_add, to_rm)

        if done:
            self.apply_button.set_sensitive(False)
            InfoDialog(_('Update Successful!')).launch()
        else:
            ErrorDialog(_('Update Failed!')).launch()

        self.emit('call', 'ubuntutweak.modules.updatemanager', 'update_list',
                  {})

        self.appview.to_add = []
        self.appview.to_rm = []
        self.appview.clear_model()
        self.appview.update_model()
Ejemplo n.º 11
0
 def on_sync_button_clicked(self, widget):
     dialog = CheckSourceDialog(widget.get_toplevel(), self.url)
     dialog.run()
     dialog.destroy()
     if dialog.status == True:
         dialog = QuestionDialog(
             _("Update available, Would you like to update?"))
         response = dialog.run()
         dialog.destroy()
         if response == gtk.RESPONSE_YES:
             dialog = FetchingDialog(parent=self.get_toplevel(),
                                     url=get_source_data_url())
             dialog.connect('destroy', self.on_source_data_downloaded)
             dialog.run()
             dialog.destroy()
     elif dialog.error == True:
         ErrorDialog(
             _("Network Error, Please check your network connection or the remote server is down."
               )).launch()
     else:
         utdata.save_synced_timestamp(SOURCE_ROOT)
         self.update_timestamp()
         InfoDialog(_("No update available.")).launch()
Ejemplo n.º 12
0
    def on_logo_button_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 64x64 size or SVG images"))
        filter.add_pattern('*.png')
        filter.add_pattern('*.svg')
        dialog.set_current_folder(os.path.expanduser('~'))
        dialog.add_filter(filter)

        dest = os.path.expanduser(
            '~gdm/.icons/%s/apps/64/%s' %
            (self.icon_theme_setting.get_value(user='******'),
             self.icon_setting.get_value(user='******')))

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

        HAVE_ICON = proxy.is_exists(dest + '.png') or proxy.is_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]
                pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                w, h = pixbuf.get_width(), pixbuf.get_height()

                if ext == '.png' and (w != 64 or h != 64):
                    ErrorDialog(
                        _("This image size isn't suitable for the logo.\nIt should be 64x64."
                          )).launch()
                    return
                else:
                    proxy.exec_command('mkdir -p %s' % os.path.dirname(dest))
                    proxy.exec_command('rm -rf %s.*' % dest)
                    dest = dest + ext
                    log.debug('Copy %s to %s' % (filename, dest))
                    proxy.exec_command('cp "%s" "%s"' % (filename, dest))

                    if ext == '.svg':
                        pixbuf = pixbuf.scale_simple(64, 64,
                                                     gtk.gdk.INTERP_BILINEAR)

                    self.logo_image.set_from_pixbuf(
                        gtk.gdk.pixbuf_new_from_file(filename))
        elif response == gtk.RESPONSE_DELETE_EVENT:
            dialog.destroy()
            proxy.exec_command('rm -rf %s.*' % dest)
            self.__setup_logo_image()
        else:
            dialog.destroy()
            return
Ejemplo n.º 13
0
def show_message(*args):
    from ubuntutweak.ui.dialogs import ErrorDialog
    message = _('The Ubuntu Tweak daemon didn\'t start correctly. This means that some '
            'advanced features may not work.\n'
            'If you want to help developers debugging, try to run "<b>sudo /usr/share/ubuntu-tweak/ubuntu-tweak-daemon</b>" in a terminal.')
    ErrorDialog(message).launch()
Ejemplo n.º 14
0
 def show_failed_dialog(self):
     ErrorDialog(_('Clean up failed!')).launch()
Ejemplo n.º 15
0
    def on_enable_toggled(self, cell, path):
        model = self.get_model()
        iter = model.get_iter((int(path), ))

        id = model.get_value(iter, self.COLUMN_ID)
        name = model.get_value(iter, self.COLUMN_NAME)
        enabled = model.get_value(iter, self.COLUMN_ENABLED)

        conflicts = SOURCE_PARSER.get_conflicts(id)
        dependencies = SOURCE_PARSER.get_dependencies(id)

        #Convert to real model, because will involke the set method
        if type(model) == gtk.TreeModelFilter:
            iter = model.convert_iter_to_child_iter(iter)
            model = model.get_model()

        if not enabled and conflicts:
            conflict_list = []
            conflict_name_list = []
            for conflict_id in conflicts:
                if self.get_source_enabled(conflict_id):
                    conflict_list.append(conflict_id)
                    name_list = [
                        r[self.COLUMN_NAME] for r in model
                        if r[self.COLUMN_ID] == conflict_id
                    ]
                    if name_list:
                        conflict_name_list.extend(name_list)

            if conflict_list and conflict_name_list:
                full_name = ', '.join(conflict_name_list)
                ErrorDialog(_('You can\'t enable this Source because'
                              '<b>"%(SOURCE)s"</b> conflicts with it.\nTo '
                              'continue you need to disable <b>"%(SOURCE)s"</b>' \
                              'first.') % {'SOURCE': full_name}).launch()

                model.set(iter, self.COLUMN_ENABLED, enabled)
                return

        if enabled is False and dependencies:
            depend_list = []
            depend_name_list = []
            for depend_id in dependencies:
                if self.get_source_enabled(depend_id) is False:
                    depend_list.append(depend_id)
                    name_list = [
                        r[self.COLUMN_NAME] for r in model
                        if r[self.COLUMN_ID] == depend_id
                    ]
                    if name_list:
                        depend_name_list.extend(name_list)

            if depend_list and depend_name_list:
                full_name = ', '.join(depend_name_list)

                dialog = QuestionDialog(\
                            _('To enable this Source, You need to enable <b>"%s"</b> at first.\nDo you wish to continue?') \
                            % full_name,
                            title=_('Dependency Notice'))
                if dialog.run() == gtk.RESPONSE_YES:
                    for depend_id in depend_list:
                        self.set_source_enabled(depend_id)
                    self.set_source_enabled(id)
                else:
                    model.set(iter, self.COLUMN_ENABLED, enabled)

                dialog.destroy()
                return

        if enabled and SOURCE_PARSER.has_reverse_depends(id):
            depend_list = []
            depend_name_list = []
            for depend_id in SOURCE_PARSER.get_reverse_depends(id):
                if self.get_source_enabled(depend_id):
                    depend_list.append(depend_id)
                    name_list = [
                        r[self.COLUMN_NAME] for r in model
                        if r[self.COLUMN_ID] == depend_id
                    ]
                    if name_list:
                        depend_name_list.extend(name_list)

            if depend_list and depend_name_list:
                full_name = ', '.join(depend_name_list)

                ErrorDialog(_('You can\'t disable this Source because '
                            '<b>"%(SOURCE)s"</b> depends on it.\nTo continue '
                            'you need to disable <b>"%(SOURCE)s"</b> first.') \
                                 % {'SOURCE': full_name}).launch()

                model.set(iter, self.COLUMN_ENABLED, enabled)
                return

        self.do_source_enable(iter, not enabled)
Ejemplo n.º 16
0
def refresh_source(parent):
    dialog = UpdateCacheDialog(parent)
    dialog.run()

    new_pkg = []
    for pkg in PACKAGE_WORKER.get_new_package():
        if pkg in APP_PARSER:
            new_pkg.append(pkg)

    new_updates = list(PACKAGE_WORKER.get_update_package())

    if new_pkg or new_updates:
        updateview = UpdateView()
        updateview.connect('select', on_select_action)

        if new_pkg:
            updateview.update_model(new_pkg)

        if new_updates:
            updateview.update_updates(new_updates)

        dialog = QuestionDialog(_(
            'You can install new applications by selecting them and choosing "Yes".\nOr you can install them at Application Center by choosing "No".'
        ),
                                title=_('New applications are available'))

        vbox = dialog.vbox
        sw = gtk.ScrolledWindow()
        sw.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
        sw.set_size_request(-1, 200)
        vbox.pack_start(sw, False, False, 0)
        sw.add(updateview)

        select_button = gtk.CheckButton(_('Select All'))
        select_button.connect('clicked', on_select_button_clicked, updateview)
        vbox.pack_start(select_button, False, False, 0)
        vbox.show_all()

        res = dialog.run()
        dialog.destroy()

        to_rm = updateview.to_rm
        to_add = updateview.to_add

        if res == gtk.RESPONSE_YES and to_add:
            PACKAGE_WORKER.perform_action(parent, to_add, to_rm)

            PACKAGE_WORKER.update_apt_cache(True)

            done = PACKAGE_WORKER.get_install_status(to_add, to_rm)

            if done:
                InfoDialog(_('Update Successful!')).launch()
            else:
                ErrorDialog(_('Update Failed!')).launch()

        return True
    else:
        dialog = InfoDialog(
            _("Your system is clean and there are no updates yet."),
            title=_('Software information is now up-to-date'))

        dialog.launch()
        return False
Ejemplo n.º 17
0
 def show_backup_failed_dialog(self):
     ErrorDialog(_("Backup Failed!")).launch()