本文整理汇总了Python中gtweak.tweakmodel.Tweak.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Tweak.__init__方法的具体用法?Python Tweak.__init__怎么用?Python Tweak.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gtweak.tweakmodel.Tweak
的用法示例。
在下文中一共展示了Tweak.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, **options):
Tweak.__init__(self, "Shell theme", "Install custom or user themes for gnome-shell", **options)
#check the shell is running and the usertheme extension is present
error = "Unknown"
try:
self._shell = GnomeShell()
except:
error = "Shell not running"
try:
extensions = self._shell.list_extensions()
if ThemeInstaller.THEME_EXT_NAME in extensions and extensions[ThemeInstaller.THEME_EXT_NAME]["state"] == 1:
#check the correct gsettings key is present
try:
self._settings = GSettingsSetting(ThemeInstaller.THEME_GSETTINGS_SCHEMA)
name = self._settings.get_value(ThemeInstaller.THEME_GSETTINGS_NAME)
print "!!!!", name
error = None
except:
error = "User Theme extension schema missing"
else:
error = "User Theme extension not enabled"
except Exception, e:
error = "Could not list shell extensions"
示例2: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, **options):
Tweak.__init__(self, "Shell theme", "Install custom or user themes for gnome-shell", **options)
#check the shell is running and the usertheme extension is present
error = _("Unknown error")
try:
self._shell = GnomeShellFactory().get_shell()
except:
logging.warning("Shell not running", exc_info=True)
error = _("Shell not running")
try:
extensions = self._shell.list_extensions()
if ShellThemeTweak.THEME_EXT_NAME in extensions and extensions[ShellThemeTweak.THEME_EXT_NAME]["state"] == 1:
#check the correct gsettings key is present
try:
self._settings = GSettingsSetting(ShellThemeTweak.THEME_GSETTINGS_SCHEMA)
name = self._settings.get_string(ShellThemeTweak.THEME_GSETTINGS_NAME)
ext = extensions[ShellThemeTweak.THEME_EXT_NAME]
logging.debug("Shell user-theme extension\n%s" % pprint.pformat(ext))
error = None
except:
logging.warning(
"Could not find user-theme extension in %s" % ','.join(extensions.keys()),
exc_info=True)
error = _("Shell user-theme extension incorrectly installed")
else:
error = _("Shell user-theme extension not enabled")
except Exception, e:
logging.warning("Could not list shell extensions", exc_info=True)
error = _("Could not list shell extensions")
示例3: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, df, **options):
Gtk.ListBoxRow.__init__(self)
Tweak.__init__(self,
df.get_name(),
df.get_description(),
**options)
grid = Gtk.Grid(column_spacing=10)
icn = df.get_icon()
if icn:
img = Gtk.Image.new_from_gicon(icn,Gtk.IconSize.DIALOG)
grid.attach(img, 0, 0, 1, 1)
else:
img = None #attach_next_to treats this correctly
lbl = Gtk.Label(df.get_name(), xalign=0.0)
grid.attach_next_to(lbl,img,Gtk.PositionType.RIGHT,1,1)
lbl.props.hexpand = True
lbl.props.halign = Gtk.Align.START
btn = Gtk.Button(_("Remove"))
grid.attach_next_to(btn,lbl,Gtk.PositionType.RIGHT,1,1)
btn.props.vexpand = False
btn.props.valign = Gtk.Align.CENTER
self.add(grid)
self.props.margin = 5
self.get_style_context().add_class('tweak-white')
self.btn = btn
示例4: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, group_id, parent_settings, xkb_info, **options):
try:
desc = xkb_info.description_for_group(group_id)
except AttributeError:
desc = group_id
Gtk.Expander.__init__(self)
Tweak.__init__(self, desc, desc, **options)
self.set_label(self.name)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=3)
vbox.set_margin_start(15)
self.add(vbox)
self._multiple_selection = not group_id in { 'keypad', 'kpdl', 'caps', 'altwin', 'nbsp', 'esperanto' }
self._group_id = group_id
self._parent_settings = parent_settings
self._xkb_info = xkb_info
self._possible_values = []
model_values = []
if not self._multiple_selection:
model_values.append((None, _("Disabled")))
for option_id in self._xkb_info.get_options_for_group(group_id):
desc = self._xkb_info.description_for_option(group_id, option_id)
model_values.append((option_id, desc))
self._possible_values.append(option_id)
def values_cmp((av, ad), (bv, bd)):
if not av:
return -1
elif not bv:
return 1
else:
return cmp(ad, bd)
示例5: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.VERTICAL)
Tweak.__init__(self, _("Enable dark theme for all applications"),
_("Enable the dark theme hint for all the applications in the session"),
**options)
self._gtksettings = GtkSettingsManager()
w = Gtk.Switch()
w.set_active(self._gtksettings.get_integer("gtk-application-prefer-dark-theme"))
title = _("Global Dark Theme")
description = _("Applications need to be restarted for change to take effect")
w.connect("notify::active", self._on_switch_changed)
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
hbox.props.spacing = UI_BOX_SPACING
lbl = Gtk.Label(label=title)
lbl.props.ellipsize = Pango.EllipsizeMode.END
lbl.props.xalign = 0.0
hbox.pack_start(lbl, True, True, 0)
hbox.pack_start(w, False, False, 0)
lbl_des = Gtk.Label()
lbl_des.props.xalign = 0.0
lbl_des.set_markup("<span size='x-small'>"+description+"</span>")
self.pack_start(hbox, False, False, 0)
self.pack_start(lbl_des, False, False,0)
self.widget_for_size_group = None
示例6: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, shell, ext, **options):
Tweak.__init__(self, ext["name"], ext.get("description",""), **options)
self._shell = shell
state = ext.get("state")
sw = Gtk.Switch()
sw.set_active(self._shell.extension_is_active(state, ext["uuid"]))
sw.connect('notify::active', self._on_extension_toggled, ext["uuid"])
info = None
warning = None
sensitive = False
if state == GnomeShell.EXTENSION_STATE["ENABLED"] or \
state == GnomeShell.EXTENSION_STATE["DISABLED"] or \
state == GnomeShell.EXTENSION_STATE["INITIALIZED"]:
sensitive = True
elif state == GnomeShell.EXTENSION_STATE["DOWNLOADING"]:
info = _("Extension downloading")
elif state == GnomeShell.EXTENSION_STATE["ERROR"]:
warning = _("Error loading extension")
elif state == GnomeShell.EXTENSION_STATE["OUT_OF_DATE"]:
warning = _("Extension does not support shell version")
else:
warning = _("Unknown extension error")
logging.critical(warning)
sw.set_sensitive(sensitive)
self.widget = build_label_beside_widget(
_("%s Extension") % ext["name"],
sw,
warning=warning)
self.widget_for_size_group = sw
示例7: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, schema_name, key_name, **options):
self.schema_name = schema_name
self.key_name = key_name
self.settings = GSettingsSetting(schema_name, **options)
Tweak.__init__(self,
self.settings.schema_get_summary(key_name),
self.settings.schema_get_description(key_name),
**options)
示例8: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, name, description, **options):
Tweak.__init__(self, name, description, **options)
self.widget = build_label_beside_widget(
name,
Gtk.Button(options.get("test_button_name",name)),
info=options.get("tweak_info"),
warning=options.get("tweak_warning"))
示例9: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, name, description, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
Tweak.__init__(self, name, description, **options)
widget = Gtk.Button(name)
widget.connect("clicked", self._on_click)
self.add(widget)
self._need_action = options.get("_need_action")
self._need_logout = options.get("_need_logout")
示例10: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, **options):
Gtk.ListBoxRow.__init__(self)
Tweak.__init__(self, _("New startup application"),
_("Add a new application to be run at startup"),
**options)
img = Gtk.Image()
img.set_from_icon_name("list-add-symbolic", Gtk.IconSize.BUTTON)
self.btn = Gtk.Button(label="", image=img, always_show_image=True)
self.btn.get_style_context().remove_class("button")
self.add(self.btn)
self.get_style_context().add_class('tweak-startup')
示例11: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, schema_name, key_name, **options):
self.schema_name = schema_name
self.key_name = key_name
try:
self.settings = GSettingsSetting(schema_name, **options)
Tweak.__init__(self,
options.get("summary",self.settings.schema_get_summary(key_name)),
options.get("description",self.settings.schema_get_description(key_name)),
**options)
except GSettingsMissingError, e:
self.settings = GSettingsFakeSetting()
Tweak.__init__(self,"","")
self.loaded = False
logging.info("Missing gsettings %s (key %s)" % (e.message, key_name))
示例12: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
Tweak.__init__(self, _("Window scaling"), _("Adjust GDK window scaling factor for HiDPI"), **options)
self._xsettings = XSettingsOverrides()
adjustment = Gtk.Adjustment(lower=1, upper=2, step_increment=1, page_increment=1)
w = Gtk.SpinButton()
w.set_adjustment(adjustment)
w.set_digits(0)
adjustment.set_value(self._xsettings.get_window_scaling_factor())
w.connect("value-changed", self._on_value_changed)
build_label_beside_widget(self.name, w, hbox=self)
self.widget_for_size_group = w
示例13: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, **options):
Tweak.__init__(self, "Dynamic workspaces", "Disable gnome-shell dynamic workspace management, use static workspaces", **options)
settings = GSettingsSetting(self.NUM_WORKSPACES_SCHEMA, **options)
adj = Gtk.Adjustment(1, 1, 99, 1)
sb = Gtk.SpinButton(adjustment=adj, digits=0)
settings.bind(self.NUM_WORKSPACES_KEY, adj, "value", Gio.SettingsBindFlags.DEFAULT)
settings = GSettingsSetting(self.DYNAMIC_SCHEMA, **options)
sw = Gtk.Switch()
settings.bind(self.DYNAMIC_KEY, sw, "active", Gio.SettingsBindFlags.DEFAULT)
#sw.bind_property ("active", sb, "sensitive", GObject.BindingFlags.SYNC_CREATE)
sb.set_sensitive(not settings[self.DYNAMIC_KEY])
sw.connect('notify::active', lambda _sw,_param,_sb: _sb.set_sensitive(not _sw.get_active()), sb)
hb = Gtk.HBox(spacing = 4)
hb.pack_start(sw, False, False, 0)
hb.pack_start(sb, True, True, 0)
self.widget = build_label_beside_widget(self.name, hb)
self.widget_for_size_group = hb
示例14: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, shell, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
Tweak.__init__(self, _("Install Shell Extension"), "", **options)
self._shell = shell
chooser = FileChooserButton(
_("Select an extension"),
True,
["application/zip"])
chooser.connect("file-set", self._on_file_set)
hb = Gtk.HBox(spacing=UI_BOX_SPACING)
hb.pack_start(
Gtk.LinkButton.new_with_label("https://extensions.gnome.org",_("Get more extensions")),
False, False, 0)
hb.pack_start(chooser, False, False, 0)
build_label_beside_widget(self.name, hb, hbox=self)
self.widget_for_size_group = hb
self.loaded = self._shell is not None
示例15: __init__
# 需要导入模块: from gtweak.tweakmodel import Tweak [as 别名]
# 或者: from gtweak.tweakmodel.Tweak import __init__ [as 别名]
def __init__(self, **options):
Gtk.Box.__init__(self, orientation=Gtk.Orientation.HORIZONTAL)
Tweak.__init__(self, _("Shell theme"), _("Install custom or user themes for gnome-shell"), **options)
#check the shell is running and the usertheme extension is present
error = _("Unknown error")
self._shell = _shell
if self._shell is None:
logging.warning("Shell not running", exc_info=True)
error = _("Shell not running")
else:
try:
extensions = self._shell.list_extensions()
if ShellThemeTweak.THEME_EXT_NAME in extensions and extensions[ShellThemeTweak.THEME_EXT_NAME]["state"] == 1:
#check the correct gsettings key is present
try:
if os.path.exists(ShellThemeTweak.THEME_GSETTINGS_DIR):
self._settings = GSettingsSetting(ShellThemeTweak.THEME_GSETTINGS_SCHEMA,
schema_dir=ShellThemeTweak.THEME_GSETTINGS_DIR)
else:
self._settings = GSettingsSetting(ShellThemeTweak.THEME_GSETTINGS_SCHEMA)
name = self._settings.get_string(ShellThemeTweak.THEME_GSETTINGS_NAME)
ext = extensions[ShellThemeTweak.THEME_EXT_NAME]
logging.debug("Shell user-theme extension\n%s" % pprint.pformat(ext))
error = None
except:
logging.warning(
"Could not find user-theme extension in %s" % ','.join(extensions.keys()),
exc_info=True)
error = _("Shell user-theme extension incorrectly installed")
else:
error = _("Shell user-theme extension not enabled")
except Exception, e:
logging.warning("Could not list shell extensions", exc_info=True)
error = _("Could not list shell extensions")