budgie_rotation_lock.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:budgie-extras 作者: UbuntuBudgie 项目源码 文件源码
def __init__(self, uuid):
        Budgie.Applet.__init__(self)
        self.box = Gtk.EventBox()
        self.lockicon = Gtk.Image.new_from_icon_name(
            "budgie-rotation-lock-button",
            Gtk.IconSize.MENU,
        )

        self.unlockicon = Gtk.Image.new_from_icon_name(
            "budgie-rotation-button",
            Gtk.IconSize.MENU,
        )

        if Gtk.get_major_version() == 3 and \
                Gtk.get_minor_version() == 18:
            # GTK+3.18
            schema = "org.gnome.settings-daemon.plugins.orientation"
            self.key = "active"
        else:
            # > GTK+3.18
            schema = "org.gnome.settings-daemon.peripherals.touchscreen"
            self.key = "orientation-lock"

        self.settings = Gio.Settings.new(schema)

        if self.settings.get_boolean(self.key):
            if self.key == "active":
                self.displayicon = self.unlockicon
            else:
                self.displayicon = self.lockicon
        else:
            if self.key == "active":
                self.displayicon = self.lockicon
            else:
                self.displayicon = self.unlockicon

        self.box.add(self.displayicon)
        self.add(self.box)
        self.box.show_all()
        self.show_all()
        self.box.connect("button-press-event", self.on_press)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号