当前位置: 首页>>代码示例>>Python>>正文


Python TweakSettings.get_icon_theme方法代码示例

本文整理汇总了Python中ubuntutweak.common.config.TweakSettings.get_icon_theme方法的典型用法代码示例。如果您正苦于以下问题:Python TweakSettings.get_icon_theme方法的具体用法?Python TweakSettings.get_icon_theme怎么用?Python TweakSettings.get_icon_theme使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ubuntutweak.common.config.TweakSettings的用法示例。


在下文中一共展示了TweakSettings.get_icon_theme方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Gnome

# 需要导入模块: from ubuntutweak.common.config import TweakSettings [as 别名]
# 或者: from ubuntutweak.common.config.TweakSettings import get_icon_theme [as 别名]
class Gnome(TweakModule):
    __title__ = _('GNOME Settings')
    __desc__ = _('A lot of GNOME settings about panel, menu and others')
    __icon__ = ['gnome-desktop-config', 'control-center2']
    __category__ = 'desktop'
    __desktop__ = 'gnome'

    def __init__(self):
        TweakModule.__init__(self)

        self.__setting = TweakSettings()

        changeicon_hbox = self.create_change_icon_hbox()

        box = ListPack(_("Panel Settings"), (
                    WidgetFactory.create("GconfCheckButton", 
                                    label=_("Display warning when removing a panel"),
                                    key="confirm_panel_remove"),
                    WidgetFactory.create("GconfCheckButton", 
                                    label=_("Complete lockdown of all panels"),
                                    key="locked_down"),
                    WidgetFactory.create("GconfCheckButton", 
                                    label=_("Enable panel animations"),
                                    key="enable_animations"),
            ))
        self.add_start(box, False, False, 0)

        box = ListPack(_("Menu Settings"), (
                    WidgetFactory.create("GconfCheckButton", 
                                    label=_("Show Input Method menu on the context menu"),
                                    key="show_input_method_menu"),
                    WidgetFactory.create("GconfCheckButton",
                                    label=_("Show Unicode Method menu on the context menu"),
                                    key="show_unicode_menu"),
                    WidgetFactory.create("GconfCheckButton",
                                    label=_('Menus have icons'),
                                    key='/desktop/gnome/interface/menus_have_icons'),
                    WidgetFactory.create("GconfCheckButton",
                                    label=_('Buttons have icons'),
                                    key='/desktop/gnome/interface/buttons_have_icons'),
                    changeicon_hbox,
            ))
        self.add_start(box, False, False, 0)

        box = ListPack(_("Screensaver"), (
                    WidgetFactory.create("GconfCheckButton", 
                                         label=_("Enable user switching when screen is locked."),
                                         key="user_switch_enabled"),
            ))
        self.add_start(box, False, False, 0)

        self.recently_used = gtk.CheckButton(_('Enable system-wide "Recently Documents" list'))
        self.recently_used.connect('toggled', self.colleague_changed)
        self.recently_used.set_active(self.get_state())
        box = ListPack(_("History"), (
                    self.recently_used,
            ))
        self.add_start(box, False, False, 0)

    def create_change_icon_hbox(self):
        hbox = gtk.HBox(False, 10)
        label = gtk.Label(_('Click the button to change the menu logo'))
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, False, False, 0)

        button = gtk.Button()
        button.connect('clicked', self.on_change_icon_clicked)
        image = gtk.image_new_from_pixbuf(get_icon_with_name('start-here', 24))
        button.set_image(image)
        hbox.pack_end(button, False, False, 0)

        return hbox

    def on_change_icon_clicked(self, widget):
        dialog = gtk.FileChooserDialog(_('Choose a new logo'),
                                        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)

        dest = os.path.expanduser('~/.icons/%s/places/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()
#.........这里部分代码省略.........
开发者ID:ubuntutweak,项目名称:ubuntu-tweak,代码行数:103,代码来源:gnomesettings.py

示例2: Gnome

# 需要导入模块: from ubuntutweak.common.config import TweakSettings [as 别名]
# 或者: from ubuntutweak.common.config.TweakSettings import get_icon_theme [as 别名]

#.........这里部分代码省略.........
        box = ListPack(_("History"), (
                    self.recently_used,
            ))
        self.add_start(box, False, False, 0)

    def create_change_icon_hbox(self):
        hbox = gtk.HBox(False, 10)
        label = gtk.Label(_('Click this button to change the menu logo image'))
        label.set_alignment(0, 0.5)
        hbox.pack_start(label, False, False, 0)

        button = gtk.Button()
        button.connect('clicked', self.on_change_icon_clicked)
        image = gtk.image_new_from_pixbuf(icon.get_from_name('start-here'))
        button.set_image(image)
        hbox.pack_end(button, False, False, 0)

        return hbox

    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':
开发者ID:priteshdesai,项目名称:ubuntu-tweak,代码行数:70,代码来源:gnomesettings.py


注:本文中的ubuntutweak.common.config.TweakSettings.get_icon_theme方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。