Esempio n. 1
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
Esempio n. 2
0
    def on_hostname_button_clicked(self, widget, label):
        dialog = QuestionDialog(_('Please enter your new hostname. Blank characters should not be used.'),
            title = _('New hostname'))

        vbox = dialog.vbox
        entry = gtk.Entry()
        vbox.pack_start(entry, False, False, 0)
        vbox.show_all()

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

        if res == gtk.RESPONSE_YES:
            new_name = entry.get_text()
            proxy.exec_command('hostname %s' % new_name)
            if os.popen('hostname').read().strip() == new_name:
                label.set_label(new_name)
Esempio n. 3
0
    def on_hostname_button_clicked(self, widget, label):
        old_name = os.uname()[1]
        dialog = QuestionDialog(_('Please enter your new hostname. Blank characters should not be used.'),
            title = _('New hostname'))

        entry = gtk.Entry()
        dialog.add_widget(entry)

        res = dialog.run()
        new_name = entry.get_text()
        dialog.destroy()

        if res == gtk.RESPONSE_YES:
            ret = proxy.exec_command('hostname %s' % new_name)
            ret = proxy.exec_command('echo %s > /etc/hostname' % new_name)
            ret = proxy.exec_command("sed -i 's/%s/%s/g' /etc/hosts" % (old_name, new_name))
            log.debug("New name is: %s, The ret is: %s" % (new_name, ret))
            if os.popen('hostname').read().strip() == new_name:
                label.set_label(new_name)
Esempio n. 4
0
    def on_hostname_button_clicked(self, widget, label):
        old_name = os.uname()[1]
        dialog = QuestionDialog(_(
            'Please enter your new hostname. Blank characters should not be used.'
        ),
                                title=_('New hostname'))

        entry = gtk.Entry()
        dialog.add_widget(entry)

        res = dialog.run()
        new_name = entry.get_text()
        dialog.destroy()

        if res == gtk.RESPONSE_YES:
            ret = proxy.exec_command('hostname %s' % new_name)
            ret = proxy.exec_command('echo %s > /etc/hostname' % new_name)
            ret = proxy.exec_command("sed -i 's/%s/%s/g' /etc/hosts" %
                                     (old_name, new_name))
            log.debug("New name is: %s, The ret is: %s" % (new_name, ret))
            if os.popen('hostname').read().strip() == new_name:
                label.set_label(new_name)
    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 image with 64x64 size (*.png)"))
        filter.add_mime_type("image/png")
        dialog.set_current_folder(os.path.expanduser("~"))
        dialog.add_filter(filter)

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

        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:
                pixbuf = gtk.gdk.pixbuf_new_from_file(filename)
                w, h = pixbuf.get_width(), pixbuf.get_height()
                if 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))
                    log.debug("Copy %s to %s" % (filename, dest))
                    proxy.exec_command('cp "%s" "%s"' % (filename, dest))

                    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
Esempio n. 6
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