def __init__(self, username):
     self.client = Gio.Settings(
         "net.launchpad.gm-notify.account",
         "/net/launchpad/gm-notify/" + username + "/")
示例#2
0
    def on_module_selected(self):
        if not self.loaded:
            print "Loading Windows module"

            self.sidePage.stack = SettingsStack()
            self.sidePage.add_widget(self.sidePage.stack)

            # Titlebar

            page = SettingsPage()
            self.sidePage.stack.add_titled(page, "titlebar", _("Titlebar"))

            widget = TitleBarButtonsOrderSelector()
            page.add(widget)

            settings = page.add_section(_("Actions"))

            action_options = [["toggle-shade",
                               _("Toggle Shade")],
                              ["toggle-maximize",
                               _("Toggle Maximize")],
                              [
                                  "toggle-maximize-horizontally",
                                  _("Toggle Maximize Horizontally")
                              ],
                              [
                                  "toggle-maximize-vertically",
                                  _("Toggle Maximize Vertically")
                              ],
                              ["toggle-stuck",
                               _("Toggle on all workspaces")],
                              ["toggle-above",
                               _("Toggle always on top")],
                              ["minimize", _("Minimize")], ["menu",
                                                            _("Menu")],
                              ["lower", _("Lower")], ["none",
                                                      _("None")]]

            size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL)

            widget = GSettingsComboBox(_("Action on title bar double-click"),
                                       "org.cinnamon.desktop.wm.preferences",
                                       "action-double-click-titlebar",
                                       action_options,
                                       size_group=size_group)
            settings.add_row(widget)

            widget = GSettingsComboBox(_("Action on title bar middle-click"),
                                       "org.cinnamon.desktop.wm.preferences",
                                       "action-middle-click-titlebar",
                                       action_options,
                                       size_group=size_group)
            settings.add_row(widget)

            widget = GSettingsComboBox(_("Action on title bar right-click"),
                                       "org.cinnamon.desktop.wm.preferences",
                                       "action-right-click-titlebar",
                                       action_options,
                                       size_group=size_group)
            settings.add_row(widget)

            scroll_options = [["none", _("Nothing")],
                              ["shade", _("Shade and unshade")],
                              ["opacity", _("Adjust opacity")]]

            widget = GSettingsComboBox(
                _("Action on title bar with mouse scroll"),
                "org.cinnamon.desktop.wm.preferences",
                "action-scroll-titlebar",
                scroll_options,
                size_group=size_group)
            settings.add_row(widget)

            spin = GSettingsSpinButton(_("Minimum opacity"),
                                       "org.cinnamon.desktop.wm.preferences",
                                       "min-window-opacity", _("%"))
            settings.add_reveal_row(spin)

            spin.revealer.settings = Gio.Settings(
                "org.cinnamon.desktop.wm.preferences")
            spin.revealer.settings.bind_with_mapping(
                "action-scroll-titlebar", spin.revealer, "reveal-child",
                Gio.SettingsBindFlags.GET, lambda x: x == "opacity", None)

            # Behavior

            page = SettingsPage()
            self.sidePage.stack.add_titled(page, "behavior", _("Behavior"))

            settings = page.add_section(_("Window Focus"))

            focus_options = [["click", _("Click")], ["sloppy",
                                                     _("Sloppy")],
                             ["mouse", _("Mouse")]]
            widget = GSettingsComboBox(_("Window focus mode"),
                                       "org.cinnamon.desktop.wm.preferences",
                                       "focus-mode", focus_options)
            settings.add_row(widget)

            widget = GSettingsSwitch(_("Automatically raise focused windows"),
                                     "org.cinnamon.desktop.wm.preferences",
                                     "auto-raise")
            settings.add_row(widget)

            widget = GSettingsSwitch(
                _("Bring windows which require attention to the current workspace"
                  ), "org.cinnamon", "bring-windows-to-current-workspace")
            settings.add_row(widget)

            widget = GSettingsSwitch(_("Prevent focus stealing"),
                                     "org.cinnamon", "prevent-focus-stealing")
            settings.add_row(widget)

            widget = GSettingsSwitch(
                _("Attach dialog windows to the parent window"),
                "org.cinnamon.muffin", "attach-modal-dialogs")
            settings.add_row(widget)

            settings = page.add_section(_("Moving and Resizing Windows"))

            size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL)

            placement_options = [["automatic", _("Automatic")],
                                 ["pointer", _("Cursor")],
                                 ["manual", _("Manual")],
                                 ["center", _("Center")]]
            widget = GSettingsComboBox(_("Location of newly opened windows"),
                                       "org.cinnamon.muffin",
                                       "placement-mode",
                                       placement_options,
                                       size_group=size_group)
            settings.add_row(widget)

            special_key_options = [["", _("Disabled")], ["<Alt>", "<Alt>"],
                                   ["<Super>", "<Super>"],
                                   ["<Control>", "<Control>"]]
            widget = GSettingsComboBox(
                _("Special key to move and resize windows"),
                "org.cinnamon.desktop.wm.preferences",
                "mouse-button-modifier",
                special_key_options,
                size_group=size_group)
            widget.set_tooltip_text(
                _("While the special key is pressed, windows can be dragged with the left mouse button and resized with the right mouse button."
                  ))
            settings.add_row(widget)

            widget = GSettingsSpinButton(_("Window drag/resize threshold"),
                                         "org.cinnamon.muffin",
                                         "resize-threshold",
                                         _("Pixels"),
                                         1,
                                         100,
                                         size_group=size_group)
            settings.add_row(widget)

            widget = GSettingsSwitch(_("Edge resistance with other windows"),
                                     "org.cinnamon.muffin",
                                     "edge-resistance-window")
            widget.set_tooltip_text(
                _("Make window borders stick when moved or resized near other windows."
                  ))
            settings.add_row(widget)

            # Alt Tab

            page = SettingsPage()
            self.sidePage.stack.add_titled(page, "alttab", _("Alt-Tab"))

            settings = page.add_section(_("Alt-Tab"))

            alttab_styles = [["icons", _("Icons only")],
                             ["thumbnails", _("Thumbnails only")],
                             ["icons+thumbnails",
                              _("Icons and thumbnails")],
                             ["icons+preview",
                              _("Icons and window preview")],
                             ["preview",
                              _("Window preview (no icons)")],
                             ["coverflow", _("Coverflow (3D)")],
                             ["timeline", _("Timeline (3D)")]]
            widget = GSettingsComboBox(_("Alt-Tab switcher style"),
                                       "org.cinnamon", "alttab-switcher-style",
                                       alttab_styles)
            settings.add_row(widget)

            widget = GSettingsSwitch(
                _("Display the alt-tab switcher on the primary monitor instead of the active one"
                  ), "org.cinnamon", "alttab-switcher-enforce-primary-monitor")
            settings.add_row(widget)

            widget = GSettingsSpinButton(
                _("Delay before displaying the alt-tab switcher"),
                "org.cinnamon",
                "alttab-switcher-delay",
                units=_("milliseconds"),
                mini=0,
                maxi=1000,
                step=50,
                page=150)
            settings.add_row(widget)
示例#3
0
    def __init__(self):
        super(NemoTerminalPreferencesWindow, self).__init__()

        self.set_icon_name("terminal")
        self.set_title(_("Nemo-Terminal Preferences"))
        self.set_skip_taskbar_hint(False)
        self.set_type_hint(Gdk.WindowTypeHint.NORMAL)
        self.set_default_size(-1, -1)

        self.connect("destroy", Gtk.main_quit)

        self.settings = Gio.Settings(
            schema_id="org.nemo.extensions.nemo-terminal")

        # Basic

        page = Page()

        frame = Gtk.Frame()
        frame.get_style_context().add_class("view")

        page.add(frame)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        frame.add(box)

        switch = Gtk.Switch()
        self.settings.bind("default-visible", switch, "active",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(_("Visible by default"), switch)
        box.pack_start(widget, False, False, 6)

        combo = Gtk.ComboBoxText()
        combo.append("top", _("Top"))
        combo.append("bottom", _("Bottom"))
        self.settings.bind("terminal-position", combo, "active-id",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(_("Terminal position"), combo)
        box.pack_start(widget, False, False, 6)

        combo = Gtk.ComboBoxText()
        combo.append("None", _("Independent"))
        combo.append("Terminal follows Nemo",
                     _("Terminal follows view location"))
        # combo.append("Nemo follows Terminal", _("View follows terminal location"))
        # combo.append("Nemo and Terminal Synchronized", _("Keep locations synchronized"))
        self.settings.bind("default-follow-mode", combo, "active-id",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(_("Location mode"), combo)
        box.pack_start(widget, False, False, 6)

        switch = Gtk.Switch()
        self.settings.bind("audible-bell", switch, "active",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(_("Terminal bell"), switch)
        box.pack_start(widget, False, False, 6)

        spinner = Gtk.SpinButton.new_with_range(5, 1000, 1)
        spinner.set_digits(0)
        self.settings.bind("default-terminal-height", spinner, "value",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(_("Default number of lines for the terminal"),
                             spinner)
        box.pack_start(widget, False, False, 6)

        frame = Gtk.Frame()
        treeview = Gtk.TreeView(headers_visible=False,
                                enable_search=False,
                                hover_selection=True)
        cell = Gtk.CellRendererAccel(editable=True,
                                     accel_mode=Gtk.CellRendererAccelMode.GTK,
                                     width=140,
                                     xalign=0.5,
                                     yalign=0.5)

        col = Gtk.TreeViewColumn("binding", cell, accel_key=0, accel_mods=1)
        treeview.append_column(col)

        store = Gtk.ListStore(int, Gdk.ModifierType)
        treeview.set_model(store)

        def update_accel_from_settings(settings, data=None):
            accel_string = settings.get_string("terminal-hotkey")

            k, m = Gtk.accelerator_parse(accel_string)

            store.clear()
            store.append((k, m))

        self.settings.connect("changed::terminal-hotkey",
                              update_accel_from_settings)
        update_accel_from_settings(self.settings)

        def on_accel_changed(accel, path, key, mods, code, data=None):
            name = Gtk.accelerator_name(key, mods)
            self.settings.set_string("terminal-hotkey", name)

            cell.set_property("text", Gtk.accelerator_get_label(key, mods))

        def on_accel_cleared(accel, path, data=None):
            self.settings.set_string("terminal-hotkey", "")

        cell.connect("accel-edited", on_accel_changed)
        cell.connect("accel-cleared", on_accel_cleared)

        frame.add(treeview)

        widget = LabeledItem(_("Keyboard shortcut"), frame)
        box.pack_start(widget, False, False, 6)

        self.add_page(page, "main", _("Basic"))

        # Advanced

        page = Page()

        frame = Gtk.Frame()
        frame.get_style_context().add_class("view")

        page.add(frame)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        frame.add(box)

        entry = Gtk.Entry()
        self.settings.bind("terminal-shell", entry, "text",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(
            _("Shell to use (leave blank for system default)"), entry)
        box.pack_start(widget, False, False, 6)

        frame = Gtk.Frame()
        frame.get_style_context().add_class("view")

        page.add(frame)

        box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
        frame.add(box)

        entry = Gtk.Entry()
        self.settings.bind("terminal-erase-line", entry, "text",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(_("Terminal erase line key sequence"), entry)
        box.pack_start(widget, False, False, 6)

        entry = Gtk.Entry()
        self.settings.bind("terminal-restore-line", entry, "text",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(_("Terminal restore line key sequence"), entry)
        box.pack_start(widget, False, False, 6)

        entry = Gtk.Entry()
        self.settings.bind("terminal-change-directory-command", entry, "text",
                           Gio.SettingsBindFlags.DEFAULT)

        widget = LabeledItem(_("Change directory command"), entry)
        box.pack_start(widget, False, False, 6)

        box.pack_start(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL),
                       False, False, 6)

        button = Gtk.Button(_("Restore defaults"))
        button.set_valign(Gtk.Align.CENTER)

        def on_reset_clicked(button, data=None):
            for key in self.settings.list_keys():
                self.settings.reset(key)

        button.connect("clicked", on_reset_clicked)

        widget = LabeledItem(
            _("Sequences must be escaped according to python rules. ") +
            _("'%s' is replaced by the quoted directory name."), button)
        widget.label_widget.set_line_wrap(True)
        widget.label_widget.set_max_width_chars(40)
        widget.label_widget.set_justify(Gtk.Justification.FILL)

        box.pack_start(widget, False, False, 6)

        self.add_page(page, "advanced", _("Advanced"))

        self.show_all()

        self.present()
示例#4
0
#!/usr/bin/python3

import gettext
gettext.install("mintupdate", "/usr/share/locale")
import html
from gi.repository import Gio

# These updates take priority over other updates.
# If a new version of these packages is available, nothing else is listed.
PRIORITY_UPDATES = ['mintupdate', 'mint-upgrade-info']

settings = Gio.Settings("com.linuxmint.updates")

SUPPORTED_KERNEL_TYPES = [
    "-generic", "-lowlatency", "-aws", "-azure", "-gcp", "-kvm", "-oem",
    "-oracle"
]
KERNEL_PKG_NAMES = ['linux-headers-VERSION', 'linux-headers-VERSION-KERNELTYPE', 'linux-image-VERSION-KERNELTYPE', \
    'linux-modules-VERSION-KERNELTYPE', 'linux-modules-extra-VERSION-KERNELTYPE']
KERNEL_PKG_NAMES.append('linux-image-extra-VERSION-KERNELTYPE'
                        )  # Naming convention in 16.04, until 4.15 series

CONFIGURED_KERNEL_TYPE = settings.get_string("selected-kernel-type")
if CONFIGURED_KERNEL_TYPE not in SUPPORTED_KERNEL_TYPES:
    CONFIGURED_KERNEL_TYPE = "-generic"


def get_release_dates():
    """ Get distro release dates for support duration calculation """
    import os
    import time
示例#5
0
#! /usr/bin/python3

from gi.repository import Gio

# Background settings, the only one interested in this is Backgrounds in
# singletons.py, and then only for the "changed" signal - it reloads
# any individual gsettings internally.

bg_settings = Gio.Settings(schema_id="org.cinnamon.desktop.background")

# Screensaver settings - we have no need to listen to changes here,
# They're read anew each time they're used, and while the screensaver
# is active, the user won't be changing them.

ss_settings = Gio.Settings(schema_id="org.cinnamon.desktop.screensaver")
DEFAULT_MESSAGE_KEY = "default-message"
SCREENSAVER_NAME_KEY = "screensaver-name"
USER_SWITCH_ENABLED_KEY = "user-switch-enabled"
IDLE_ACTIVATE_KEY = "idle-activation-enabled"
LOCK_ENABLED_KEY = "lock-enabled"
LOCK_DELAY_KEY = "lock-delay"
USE_CUSTOM_FORMAT_KEY = "use-custom-format"
DATE_FORMAT_KEY = "date-format"
TIME_FORMAT_KEY = "time-format"
FONT_DATE_KEY = "font-date"
FONT_MESSAGE_KEY = "font-message"
FONT_TIME_KEY = "font-time"
KB_LAYOUT_KEY = "layout-group"

SHOW_CLOCK_KEY = "show-clock"
SHOW_ALBUMART = "show-album-art"
示例#6
0
#!/usr/bin/python3

import gettext
gettext.install("mintupdate", "/usr/share/locale")
import html
from gi.repository import Gio


# These updates take priority over other updates.
# If a new version of these packages is available, nothing else is listed.
PRIORITY_UPDATES = ['mintupdate', 'mint-upgrade-info']

settings = Gio.Settings(schema_id="com.linuxmint.updates")

SUPPORTED_KERNEL_TYPES = ["-generic", "-lowlatency", "-aws", "-azure", "-gcp", "-kvm", "-oem", "-oracle"]
KERNEL_PKG_NAMES = ['linux-headers-VERSION', 'linux-headers-VERSION-KERNELTYPE', 'linux-image-VERSION-KERNELTYPE', \
    'linux-modules-VERSION-KERNELTYPE', 'linux-modules-extra-VERSION-KERNELTYPE']
KERNEL_PKG_NAMES.append('linux-image-extra-VERSION-KERNELTYPE') # Naming convention in 16.04, until 4.15 series

CONFIGURED_KERNEL_TYPE = settings.get_string("selected-kernel-type")
if CONFIGURED_KERNEL_TYPE not in SUPPORTED_KERNEL_TYPES:
    CONFIGURED_KERNEL_TYPE = "-generic"

def get_release_dates():
    """ Get distro release dates for support duration calculation """
    import os
    import time
    from datetime import datetime

    release_dates = {}
    distro_info = []
示例#7
0
    def setUp(self):
        self.check_logind_gnome_session()
        self.start_logind()
        self.daemon_death_expected = False
        self.session_log_write = open(
            os.path.join(self.workdir, 'gnome-session.log'), 'wb')
        self.session = subprocess.Popen([
            'gnome-session', '-f', '-a',
            os.path.join(self.workdir, 'autostart'), '--session=dummy',
            '--debug'
        ],
                                        stdout=self.session_log_write,
                                        stderr=subprocess.STDOUT)

        # wait until the daemon is on the bus
        try:
            self.wait_for_bus_object('org.gnome.SessionManager',
                                     '/org/gnome/SessionManager')
        except:
            # on failure, print log
            with open(self.session_log_write.name) as f:
                print('----- session log -----\n%s\n------' % f.read())
            raise

        self.session_log = open(self.session_log_write.name)

        self.obj_session_mgr = self.session_bus_con.get_object(
            'org.gnome.SessionManager', '/org/gnome/SessionManager')

        # start mock upowerd
        (self.upowerd,
         self.obj_upower) = self.spawn_server_template('upower', {
             'OnBattery': True,
             'LidIsClosed': False
         },
                                                       stdout=subprocess.PIPE)
        gsdtestcase.set_nonblock(self.upowerd.stdout)

        # start mock gnome-shell screensaver
        (self.screensaver, self.obj_screensaver) = self.spawn_server_template(
            'gnome_screensaver', stdout=subprocess.PIPE)
        gsdtestcase.set_nonblock(self.screensaver.stdout)

        self.start_mutter()

        # Set up the gnome-session presence
        obj_session_presence = self.session_bus_con.get_object(
            'org.gnome.SessionManager', '/org/gnome/SessionManager/Presence')
        self.obj_session_presence_props = dbus.Interface(
            obj_session_presence, dbus.PROPERTIES_IFACE)

        # ensure that our tests don't lock the screen when the screensaver
        # gets active
        self.settings_screensaver = Gio.Settings(
            'org.gnome.desktop.screensaver')
        self.settings_screensaver['lock-enabled'] = False

        # Ensure we set up the external monitor state
        self.set_has_external_monitor(False)

        self.settings_gsd_power = Gio.Settings(
            'org.gnome.settings-daemon.plugins.power')

        # start power plugin
        self.settings_gsd_power['active'] = False
        # As hibernate is not available, suspend by default on critical
        self.settings_gsd_power['critical-battery-action'] = 'suspend'
        Gio.Settings.sync()
        self.plugin_log_write = open(
            os.path.join(self.workdir, 'plugin_power.log'), 'wb')
        # avoid painfully long delays of actions for tests
        env = os.environ.copy()
        # Disable the use of the PolicyKit helper for brightness
        env['GSD_DISABLE_BACKLIGHT_HELPER'] = '1'
        # Disable PulseAudio output from libcanberra
        env['CANBERRA_DRIVER'] = 'null'

        self.daemon = subprocess.Popen(
            [os.path.join(builddir, 'gsd-test-power')],
            # comment out this line if you want to see the logs in real time
            stdout=self.plugin_log_write,
            stderr=subprocess.STDOUT,
            env=env)

        # you can use this for reading the current daemon log in tests
        self.plugin_log = open(self.plugin_log_write.name)

        # wait until plugin is ready
        timeout = 100
        while timeout > 0:
            time.sleep(0.1)
            timeout -= 1
            log = self.plugin_log.read()
            if 'System inhibitor fd is' in log:
                break

        # always start with zero idle time
        self.reset_idle_timer()

        # flush notification log
        try:
            self.p_notify.stdout.read()
        except IOError:
            pass
示例#8
0
    def __init__(self, config):
        self.config = config  # configParser

        self.settings_sourceoutputs = Gio.Settings(
            'com.github.wwmm.pulseeffects.sourceoutputs.pitch')
示例#9
0
def get_social_help():
    settings = Gio.Settings('org.sugarlabs.collaboration')
    return settings.get_string('social-help-server')
示例#10
0
 def __init__(self):
     gobject.GObject.__init__(self)
     self._settings = gio.Settings(schema_id='org.gnome.Hamster')
示例#11
0
    def __init__(self, config):
        self.config = config  # configParser

        self.settings_sinkinputs = Gio.Settings(
            'com.github.wwmm.pulseeffects.sinkinputs.panorama')
def main():
    if check_gpu():
        return 1
    GlxWindows = []
    GlxRotate = []
    subprocess.call("pkill 'glxgears|firefox'", shell=True)

    Html5Video = Html5VideoThread()
    Html5Video.start()

    source = Gio.SettingsSchemaSource.get_default()

    for i in range(2):
        GlxWindows.append(GlxThread())
        GlxWindows[i].start()
        time.sleep(5)
        try:
            windows = subprocess.check_output(
                        'wmctrl -l | grep glxgears',
                        shell=True)
        except subprocess.CalledProcessError as er:
            print("WARNING: Got an exception %s" % er)
            windows = ""
        for app in sorted(windows.splitlines(), reverse=True):
            if b'glxgears' not in app:
                continue
            GlxWindows[i].id = str(
                re.match(b'^(0x\w+)', app).group(0), 'utf-8')  # noqa: W605
            break
        if hasattr(GlxWindows[i], "id"):
            rotator = RotateGlxThread(GlxWindows[i].id, i + 1)
            GlxRotate.append(rotator)
            rotator.start()
        else:
            print("WARNING: Window {} not found, not rotating it.".format(i))

    hsize = vsize = 2
    hsize_ori = vsize_ori = None
    if source.lookup("org.compiz.core", True):
        settings = Gio.Settings(
            "org.compiz.core",
            "/org/compiz/profiles/unity/plugins/core/"
        )
        hsize_ori = settings.get_int("hsize")
        vsize_ori = settings.get_int("vsize")
        settings.set_int("hsize", hsize)
        settings.set_int("vsize", vsize)
        time.sleep(5)
    else:
        hsize = int(subprocess.check_output(
            'gconftool --get /apps/compiz-1/general/screen0/options/hsize',
            shell=True))
        vsize = int(subprocess.check_output(
            'gconftool --get /apps/compiz-1/general/screen0/options/vsize',
            shell=True))
    (x_res, y_res) = re.search(
        b'DG:\s+(\d+)x(\d+)',  # noqa: W605
        subprocess.check_output('wmctrl -d', shell=True)).groups()
    DesktopSwitch = ChangeWorkspace(
        hsize, vsize, int(x_res) // hsize, int(y_res) // vsize)
    DesktopSwitch.start()

    time.sleep(35)

    for i in range(len(GlxRotate)):
        GlxRotate[i].cancel = True
    for i in range(len(GlxWindows)):
        GlxWindows[i].terminate()
    DesktopSwitch.cancel = True
    time.sleep(10)
    Html5Video.terminate()
    if check_gpu() or not Html5Video.html5_path:
        return 1

    if source.lookup("org.compiz.core", True):
        settings = Gio.Settings(
            "org.compiz.core",
            "/org/compiz/profiles/unity/plugins/core/")
        settings.set_int("hsize", hsize_ori)
        settings.set_int("vsize", vsize_ori)
        Gio.Settings.sync()
示例#13
0
def on_icon_changed(settings: Gio.Settings, key: str):
    icon: str = settings.get_value(ICON_KEY).get_string()
    try:
        QT5CT_CONFIG_LOCK.acquire()

        QT5CT_CONFIG.touch(0o644)
        with QT5CT_CONFIG.open('r+') as file:
            config = ConfigParser()
            config.read_file(file)
            config.setdefault('Appearance', {})
            config['Appearance']['icon_theme'] = icon
            file.seek(0)
            config.write(file)
            file.truncate()
    except Exception as error:
        raise error
    finally:
        QT5CT_CONFIG_LOCK.release()


desktop_settings: Gio.Settings = Gio.Settings(
    schema='org.gnome.desktop.interface')

on_theme_changed(desktop_settings, THEME_KEY)
on_icon_changed(desktop_settings, ICON_KEY)

desktop_settings.connect('changed::' + THEME_KEY, on_theme_changed)
desktop_settings.connect('changed::' + ICON_KEY, on_icon_changed)

GLib.MainLoop().run()
示例#14
0
文件: util.py 项目: mereghost/gmate
def gsettings_fb(name):
    settings = Gio.Settings('org.gnome.gedit.plugins.filebrowser')
    lambda_get = [settings.get_strv]
    key = ['filter-mode']
    index = key.index(name)
    return lambda_get[index](name)
示例#15
0
    def __init__(self, application):

        self.application = application
        self.settings = Gio.Settings(schema_id="com.linuxmint.report")

        os.system("mkdir -p %s" % TMP_DIR)
        os.system("rm -rf %s/*" % TMP_DIR)
        os.system("mkdir -p %s" % UNPACK_DIR)
        os.system("cp -R %s/* %s/" % (DATA_DIR, TMP_DIR))

        self._cache = None
        # Set the Glade file
        gladefile = "/usr/share/linuxmint/mintreport/mintreport.ui"
        self.builder = Gtk.Builder()
        self.builder.set_translation_domain(APP)
        self.builder.add_from_file(gladefile)
        self.window = self.builder.get_object("main_window")
        self.window.set_title(_("System Reports"))
        self.window.set_icon_name("mintreport")

        self.stack = self.builder.get_object("crash_stack")
        self.spinner = self.builder.get_object("crash_spinner")

        # Fill in the sysinfo pane
        self.load_sysinfo()
        self.builder.get_object("button_sysinfo_copy").connect(
            "clicked", self.copy_sysinfo)
        self.builder.get_object("button_sysinfo_upload").connect(
            "clicked", self.upload_sysinfo)

        # the crashes treeview
        self.treeview_crashes = self.builder.get_object("treeview_crashes")

        def render_date(column, cell, model, i, *args):
            cell.props.text = " ".join([
                model[i][COL_CRASH_DAY], model[i][COL_CRASH_DATE],
                model[i][COL_CRASH_TIME], model[i][COL_CRASH_TIMEZONE]
            ])

        def sort_by_date(model, a, b, *args):
            date_a = datetime.date.from_iso_format(model[a][COL_CRASH_DATE])
            date_b = datetime.date.from_iso_format(model[b][COL_CRASH_DATE])

            if date_a < date_b:
                return -1
            elif date_a > date_b:
                return 1

            time_a = datetime.time.fromisoformat(model[a][COL_CRASH_TIME])
            time_b = datetime.time.fromisoformat(model[b][COL_CRASH_TIME])

            if time_a < time_b:
                return -1
            elif time_a > time_b:
                return 1

            return 0

        cell_renderer = Gtk.CellRendererText()
        column = Gtk.TreeViewColumn('', cell_renderer)
        column.set_cell_data_func(cell_renderer, render_date)
        column.set_resizable(True)
        self.treeview_crashes.append_column(column)
        column = Gtk.TreeViewColumn("",
                                    Gtk.CellRendererText(),
                                    text=COL_CRASH_PID)
        column.set_sort_column_id(COL_CRASH_PID)
        column.set_resizable(True)
        self.treeview_crashes.append_column(column)
        column = Gtk.TreeViewColumn("",
                                    Gtk.CellRendererText(),
                                    text=COL_CRASH_EXE)
        column.set_sort_column_id(COL_CRASH_EXE)
        column.set_resizable(True)
        self.treeview_crashes.append_column(column)
        self.treeview_crashes.show()
        self.model_crashes = Gtk.ListStore(
            str, str, str, str, str, str,
            object)  # timestamp, pid, exe, object
        self.model_crashes.set_sort_func(COL_CRASH_DATE, sort_by_date)
        self.treeview_crashes.set_model(self.model_crashes)

        self.buffer = GtkSource.Buffer()
        self.language_manager = GtkSource.LanguageManager()
        style_manager = GtkSource.StyleSchemeManager()
        self.buffer.set_style_scheme(style_manager.get_scheme("oblivion"))
        self.sourceview = GtkSource.View.new_with_buffer(self.buffer)
        self.builder.get_object("scrolledwindow_crash").add(self.sourceview)
        self.sourceview.show()

        self.treeview_crashes.get_selection().connect("changed",
                                                      self.on_crash_selected)

        self.bugtracker = "https://bugs.launchpad.net/"

        self.localfiles_button = self.builder.get_object(
            "button_browse_crash_report")
        self.bugtracker_button = self.builder.get_object(
            "button_open_bugtracker")
        self.pastebin_button = self.builder.get_object("button_pastebin")
        self.localfiles_button.connect(
            "clicked", self.on_button_browse_crash_report_clicked)
        self.bugtracker_button.connect("clicked",
                                       self.on_button_open_bugtracker_clicked)
        self.pastebin_button.connect("clicked",
                                     self.on_button_pastebin_clicked)

        # the info treeview
        self.info_button_box = self.builder.get_object("info_button_box")
        self.info_descriptions_box = self.builder.get_object(
            "info_descriptions_box")

        self.treeview_info = self.builder.get_object("treeview_info")
        renderer = Gtk.CellRendererPixbuf()
        column = Gtk.TreeViewColumn("", renderer, icon_name=COL_INFO_ICON)
        self.treeview_info.append_column(column)

        column = Gtk.TreeViewColumn("",
                                    Gtk.CellRendererText(),
                                    text=COL_INFO_TITLE)
        column.set_sort_column_id(COL_INFO_TITLE)
        column.set_resizable(True)
        self.treeview_info.append_column(column)
        self.treeview_info.show()
        self.model_info = Gtk.TreeStore(str, str, object)  # icon, name, report
        self.model_info.set_sort_column_id(COL_INFO_TITLE,
                                           Gtk.SortType.ASCENDING)
        self.treeview_info.set_model(self.model_info)

        self.treeview_info.get_selection().connect("changed",
                                                   self.on_info_selected)

        if os.path.exists("/usr/bin/coredumpctl"):
            self.builder.get_object(
                "crash_internal_stack").set_visible_child_name("page_reports")
            self.load_crashes()
        else:
            self.builder.get_object(
                "crash_internal_stack").set_visible_child_name("page_error")

        self.load_info()

        accel_group = Gtk.AccelGroup()
        self.window.add_accel_group(accel_group)

        # Menubar
        menubar = self.builder.get_object("menubar")
        menu = Gtk.MenuItem.new_with_mnemonic(_("_File"))
        menubar.append(menu)
        submenu = Gtk.Menu()
        menu.set_submenu(submenu)

        item = Gtk.ImageMenuItem(label=_("Refresh"))
        image = Gtk.Image.new_from_icon_name("view-refresh-symbolic",
                                             Gtk.IconSize.MENU)
        item.set_image(image)
        item.connect('activate', self.on_menu_refresh)
        key, mod = Gtk.accelerator_parse("<Control>R")
        item.add_accelerator("activate", accel_group, key, mod,
                             Gtk.AccelFlags.VISIBLE)
        submenu.append(item)
        item = Gtk.ImageMenuItem(label=_("Restore ignored reports"))
        item.connect('activate', self.on_menu_restore)
        submenu.append(item)
        submenu.append(Gtk.SeparatorMenuItem())
        item = Gtk.ImageMenuItem(label=_("Quit"))
        image = Gtk.Image.new_from_icon_name("application-exit-symbolic",
                                             Gtk.IconSize.MENU)
        item.set_image(image)
        item.connect('activate', self.on_menu_quit)
        key, mod = Gtk.accelerator_parse("<Control>Q")
        item.add_accelerator("activate", accel_group, key, mod,
                             Gtk.AccelFlags.VISIBLE)
        key, mod = Gtk.accelerator_parse("<Control>W")
        item.add_accelerator("activate", accel_group, key, mod,
                             Gtk.AccelFlags.VISIBLE)
        submenu.append(item)
        menubar.show_all()

        menu = Gtk.MenuItem.new_with_mnemonic(_("_Help"))
        menubar.append(menu)
        submenu = Gtk.Menu()
        menu.set_submenu(submenu)
        item = Gtk.ImageMenuItem()
        item.set_image(
            Gtk.Image.new_from_icon_name("help-about-symbolic",
                                         Gtk.IconSize.MENU))
        item.set_label(_("About"))
        item.connect("activate", self.open_about)
        submenu.append(item)
示例#16
0
def get_jabber():
    settings = Gio.Settings('org.sugarlabs.collaboration')
    return settings.get_string('jabber-server')
示例#17
0
import gettext

gettext.install("cinnamon", "/usr/share/cinnamon/locale")

# Keybindings page - check if we need to store custom
# keybindings to gsettings key as well as GConf (In Mint 14 this is changed)
CUSTOM_KEYS_PARENT_SCHEMA = "org.cinnamon.keybindings"
CUSTOM_KEYS_BASENAME = "/org/cinnamon/keybindings/custom-keybindings"
CUSTOM_KEYS_SCHEMA = "org.cinnamon.keybindings.custom-keybinding"

MUFFIN_KEYBINDINGS_SCHEMA = "org.cinnamon.muffin.keybindings"
MEDIA_KEYS_SCHEMA = "org.cinnamon.settings-daemon.plugins.media-keys"

HAS_DEDICATED_TERMINAL_SHORTCUT = False

schema = Gio.Settings(MEDIA_KEYS_SCHEMA)
key_list = schema.list_keys()
for key in key_list:
    if key == "terminal":
        HAS_DEDICATED_TERMINAL_SHORTCUT = True

FORBIDDEN_KEYVALS = [
    Gdk.KEY_Home, Gdk.KEY_Left, Gdk.KEY_Up, Gdk.KEY_Right, Gdk.KEY_Down,
    Gdk.KEY_Page_Up, Gdk.KEY_Page_Down, Gdk.KEY_End, Gdk.KEY_Tab,
    Gdk.KEY_KP_Enter, Gdk.KEY_Return, Gdk.KEY_space, Gdk.KEY_Mode_switch
]

KEYBINDINGS = [
    #   KB Label                        Schema                  Key name               Array?  Category
    # Cinnamon stuff
    [
示例#18
0
    def on_button_layout_clicked(self, button, style):

        applets_legacy = [
            'panel1:left:0:[email protected]',
            'panel1:left:1:[email protected]',
            'panel1:left:2:[email protected]',
            'panel1:left:3:[email protected]',
            'panel1:right:0:[email protected]',
            'panel1:right:1:[email protected]',
            'panel1:right:2:[email protected]',
            'panel1:right:3:[email protected]',
            'panel1:right:4:[email protected]',
            'panel1:right:5:[email protected]',
            'panel1:right:6:[email protected]',
            'panel1:right:7:[email protected]',
            'panel1:right:8:[email protected]',
            'panel1:right:9:[email protected]',
            'panel1:right:10:[email protected]'
        ]

        applets_new = [
            'panel1:left:0:[email protected]',
            'panel1:left:1:[email protected]',
            'panel1:left:2:[email protected]',
            'panel1:right:0:[email protected]',
            'panel1:right:1:[email protected]',
            'panel1:right:2:[email protected]',
            'panel1:right:3:[email protected]',
            'panel1:right:4:[email protected]',
            'panel1:right:5:[email protected]',
            'panel1:right:6:[email protected]',
            'panel1:right:7:[email protected]',
            'panel1:right:8:[email protected]',
            'panel1:right:9:[email protected]',
            'panel1:right:10:[email protected]'
        ]

        settings = Gio.Settings("org.cinnamon")
        settings.set_strv("panels-enabled", ['1:0:bottom'])

        applets = applets_new
        left_icon_size = 0
        center_icon_size = 0
        right_icon_size = 0
        if style == LAYOUT_STYLE_LEGACY:
            applets = applets_legacy
            panel_size = 27
            menu_label = "Menu"
        elif style == LAYOUT_STYLE_NEW:
            panel_size = 40
            right_icon_size = 24
            menu_label = ""

        settings.set_strv("panels-height", ['1:%s' % panel_size])
        settings.set_strv("enabled-applets", applets)
        settings.set_string("app-menu-label", menu_label)
        settings.set_string(
            "panel-zone-icon-sizes",
            "[{\"panelId\": 1, \"left\": %s, \"center\": %s, \"right\": %s}]" %
            (left_icon_size, center_icon_size, right_icon_size))
        os.system("cinnamon --replace &")
示例#19
0
文件: main.py 项目: kwikadi/sugar
def setup_timezone():
    settings = Gio.Settings('org.sugarlabs.date')
    timezone = settings.get_string('timezone')
    if timezone is not None and timezone:
        os.environ['TZ'] = timezone
示例#20
0
    def __init__(self):
        builder = Gtk.Builder()
        builder.set_translation_domain("mintwelcome")
        builder.add_from_file(
            '/usr/share/linuxmint/mintwelcome/mintwelcome.ui')

        window = builder.get_object("main_window")
        window.set_icon_name("mintwelcome")
        window.set_position(Gtk.WindowPosition.CENTER)
        window.connect("destroy", Gtk.main_quit)

        with open("/etc/linuxmint/info") as f:
            config = dict([line.strip().split("=") for line in f])
        codename = config['CODENAME'].capitalize()
        edition = config['EDITION'].replace('"', '')
        release = config['RELEASE']
        desktop = config['DESKTOP']
        release_notes = config['RELEASE_NOTES_URL']
        new_features = config['NEW_FEATURES_URL']
        architecture = "64-bit"
        if platform.machine() != "x86_64":
            architecture = "32-bit"

        # distro-specific
        dist_name = "Linux Mint"
        if os.path.exists(
                "/usr/share/doc/debian-system-adjustments/copyright"):
            dist_name = "LMDE"

        # Setup the labels in the Mint badge
        builder.get_object("label_version").set_text("%s %s" %
                                                     (dist_name, release))
        builder.get_object("label_edition").set_text("%s %s" %
                                                     (edition, architecture))

        # Setup the main stack
        self.stack = Gtk.Stack()
        builder.get_object("center_box").pack_start(self.stack, True, True, 0)
        self.stack.set_transition_type(Gtk.StackTransitionType.CROSSFADE)
        self.stack.set_transition_duration(150)

        # Action buttons
        builder.get_object("button_forums").connect(
            "clicked", self.visit, "https://forums.linuxmint.com")
        builder.get_object("button_documentation").connect(
            "clicked", self.visit, "https://linuxmint.com/documentation.php")
        builder.get_object("button_contribute").connect(
            "clicked", self.visit, "https://linuxmint.com/getinvolved.php")
        builder.get_object("button_irc").connect(
            "clicked", self.visit, "irc://irc.spotchat.org/linuxmint-help")
        builder.get_object("button_codecs").connect(
            "clicked", self.visit, "apt://mint-meta-codecs?refresh=yes")
        builder.get_object("button_new_features").connect(
            "clicked", self.visit, new_features)
        builder.get_object("button_release_notes").connect(
            "clicked", self.visit, release_notes)
        builder.get_object("button_mintupdate").connect(
            "clicked", self.launch, "mintupdate")
        builder.get_object("button_mintinstall").connect(
            "clicked", self.launch, "mintinstall")
        builder.get_object("button_timeshift").connect("clicked", self.pkexec,
                                                       "timeshift-gtk")
        builder.get_object("button_mintdrivers").connect(
            "clicked", self.pkexec, "driver-manager")
        builder.get_object("button_gufw").connect("clicked", self.launch,
                                                  "gufw")
        builder.get_object("button_layout_legacy").connect(
            "clicked", self.on_button_layout_clicked, LAYOUT_STYLE_LEGACY)
        builder.get_object("button_layout_new").connect(
            "clicked", self.on_button_layout_clicked, LAYOUT_STYLE_NEW)

        # Settings button depends on DE
        de_is_cinnamon = False
        self.theme = None
        if os.getenv("XDG_CURRENT_DESKTOP") in ["Cinnamon", "X-Cinnamon"]:
            builder.get_object("button_settings").connect(
                "clicked", self.launch, "cinnamon-settings")
            de_is_cinnamon = True
            self.theme = Gio.Settings(schema="org.cinnamon.desktop.interface"
                                      ).get_string("gtk-theme")
        elif os.getenv("XDG_CURRENT_DESKTOP") == "MATE":
            builder.get_object("button_settings").connect(
                "clicked", self.launch, "mate-control-center")
        elif os.getenv("XDG_CURRENT_DESKTOP") == "XFCE":
            builder.get_object("button_settings").connect(
                "clicked", self.launch, "xfce4-settings-manager")
        else:
            # Hide settings
            builder.get_object("box_first_steps").remove(
                builder.get_object("box_settings"))

        # Hide Cinnamon layout settings in other DEs
        if not de_is_cinnamon:
            builder.get_object("box_first_steps").remove(
                builder.get_object("box_cinnamon"))

        # Hide codecs box if they're already installed
        add_codecs = False
        cache = apt.Cache()
        if "mint-meta-codecs" in cache:
            pkg = cache["mint-meta-codecs"]
            if not pkg.is_installed:
                add_codecs = True
        if not add_codecs:
            builder.get_object("box_first_steps").remove(
                builder.get_object("box_codecs"))

        # Hide drivers if mintdrivers is absent (LMDE)
        if not os.path.exists("/usr/bin/mintdrivers"):
            builder.get_object("box_first_steps").remove(
                builder.get_object("box_drivers"))

        # Hide new features page for LMDE
        if dist_name == "LMDE":
            builder.get_object("box_documentation").remove(
                builder.get_object("box_new_features"))

        # Construct the stack switcher
        list_box = builder.get_object("list_navigation")

        page = builder.get_object("page_home")
        self.stack.add_named(page, "page_home")
        list_box.add(SidebarRow(page, _("Welcome"), "go-home-symbolic"))
        self.stack.set_visible_child(page)

        page = builder.get_object("page_first_steps")
        self.stack.add_named(page, "page_first_steps")
        list_box.add(
            SidebarRow(page, _("First Steps"), "dialog-information-symbolic"))

        page = builder.get_object("page_documentation")
        self.stack.add_named(page, "page_documentation")
        list_box.add(
            SidebarRow(page, _("Documentation"),
                       "accessories-dictionary-symbolic"))

        page = builder.get_object("page_help")
        self.stack.add_named(page, "page_help")
        list_box.add(SidebarRow(page, _("Help"), "help-browser-symbolic"))

        page = builder.get_object("page_contribute")
        self.stack.add_named(page, "page_contribute")
        list_box.add(SidebarRow(page, _("Contribute"), "starred-symbolic"))

        list_box.connect("row-activated", self.sidebar_row_selected_cb)

        # Construct the bottom toolbar
        box = builder.get_object("toolbar_bottom")
        checkbox = Gtk.CheckButton()
        checkbox.set_label(_("Show this dialog at startup"))
        if not os.path.exists(NORUN_FLAG):
            checkbox.set_active(True)
        checkbox.connect("toggled", self.on_button_toggled)
        box.pack_end(checkbox)

        scale = window.get_scale_factor()

        self.color = "green"
        self.dark_mode = False

        # Use HIDPI pictures if appropriate
        if scale == 1:
            surface = self.surface_for_path(
                "/usr/share/linuxmint/mintwelcome/legacy.png", scale)
            builder.get_object("img_legacy").set_from_surface(surface)
            surface = self.surface_for_path(
                "/usr/share/linuxmint/mintwelcome/modern.png", scale)
            builder.get_object("img_modern").set_from_surface(surface)
        else:
            surface = self.surface_for_path(
                "/usr/share/linuxmint/mintwelcome/legacy-hidpi.png", scale)
            builder.get_object("img_legacy").set_from_surface(surface)
            surface = self.surface_for_path(
                "/usr/share/linuxmint/mintwelcome/modern-hidpi.png", scale)
            builder.get_object("img_modern").set_from_surface(surface)

        path = "/usr/share/linuxmint/mintwelcome/colors/"
        if scale == 2:
            path = "/usr/share/linuxmint/mintwelcome/colors/hidpi/"
        for color in [
                "green", "aqua", "blue", "brown", "grey", "orange", "pink",
                "purple", "red", "sand", "teal"
        ]:
            builder.get_object("img_" + color).set_from_surface(
                self.surface_for_path("%s/%s.png" % (path, color), scale))
            builder.get_object("button_" + color).connect(
                "clicked", self.on_color_button_clicked, color)

        builder.get_object("switch_dark").connect("state-set",
                                                  self.on_dark_mode_changed)

        window.set_default_size(800, 500)
        window.show_all()
示例#21
0
    def create_window(self):

        self.settings = Gio.Settings(schema="com.pia.manager")
        self.skip_dns = self.settings.get_boolean(SKIP_DNS_KEY)

        gladefile = "/usr/share/pia-manager/main.ui"
        self.builder = Gtk.Builder()
        self.builder.add_from_file(gladefile)

        self.window = self.builder.get_object("main_window")
        self.username = self.builder.get_object("entry_username")
        self.password = self.builder.get_object("entry_password")
        self.gateway = self.builder.get_object("combobox_gateway")
        self.button = self.builder.get_object("button_ok")

        self.window.set_title("PIA")
        self.window.set_icon_name("pia-manager")

        self.builder.get_object("link_forgot_password").set_markup(
            "<a href='#'>%s</a>" %
            self.builder.get_object("link_forgot_password").get_text())

        (username, password, self.gateway_value) = self.read_configuration()
        self.username.set_text(username)
        self.password.set_text(password)

        renderer = Gtk.CellRendererText()
        self.gateway.pack_start(renderer, True)
        self.gateway.add_attribute(renderer, "text", 1)

        self.load_combo()

        self.window.show()

        self.add_window(self.window)

        self.infobar = self.builder.get_object("infobar")
        self.infobar.hide()

        # Configuration
        self.use_ip_addresses_checkbox = self.builder.get_object(
            "menuitem_skip_dns")
        self.use_ip_addresses_checkbox.set_active(self.skip_dns)

        # Signals
        self.use_ip_addresses_checkbox.connect(
            "toggled", self.on_menuitem_use_ip_addresses_toggled)
        self.builder.get_object("menuitem_quit").connect(
            "activate", self.on_quit)
        self.builder.get_object("menuitem_help_contents").connect(
            "activate", self.on_menuitem_help_contents_activated)
        self.builder.get_object("menuitem_help_about").connect(
            "activate", self.on_menuitem_help_about_activated)
        self.builder.get_object("entry_password").connect(
            "icon-press", self.on_entry_icon_pressed)
        self.builder.get_object("button_cancel").connect(
            "clicked", self.on_quit)
        self.builder.get_object("link_forgot_password").connect(
            "activate-link", self.on_forgot_password_clicked)
        self.builder.get_object("button_refresh").connect(
            "clicked", self.on_button_refresh_clicked)
        self.username.connect("changed", self.check_entries)
        self.password.connect("changed", self.check_entries)
        self.gateway.connect("changed", self.on_combo_changed)
        self.button.connect("clicked", self.save_configuration)
示例#22
0
 def test_set_views(self):
     self.target = _MOCK_LIST
     with self.run_view("gtk_main"):
         settings = Gio.Settings(_DESKTOP_CONF_DIR)
         variant = GLib.Variant('aa{ss}', self.target)
         settings.set_value(_HOMEVIEWS_KEY, variant)
示例#23
0
VERSION = '1.0'
URL = 'https://github.com/ion201/BulkRename'

##############################

import sys
import os
import re
import tkinter as tk
from tkinter import font
from io import StringIO
import traceback
try:
    from gi.repository import Gio
    gsettings = Gio.Settings('org.gnome.desktop.interface')
except ImportError:
    # Not a gnome based desktop. Use this default font
    gsettings = {'font-name': 'Cantarell 11'}


MAX_SHOWN_FILES = 200

W_WIDTH = 600
W_HEIGHT = 400


def AddExitBindings(widget, key_code='KeyPress-Escape'):
    widget.event_add('<<close>>', '<%s>' % key_code)
    widget.bind('<<close>>', PleaseExit)
    # If widget is a root, also bind any exit to PleaseExit()
示例#24
0
 def tearDown(self):
     self.target = self._save_homeviews.unpack()
     settings = Gio.Settings(_DESKTOP_CONF_DIR)
     settings.set_value(_HOMEVIEWS_KEY, self._save_homeviews)
示例#25
0
 def __init__(self):
     super(FadeToSong, self).__init__()
     self._app = Gio.Application.get_default()
     self.settings = Gio.Settings(DCONF_DIR)
     self.default_volume = 1.0
示例#26
0
def get_schema(schema):
    return gio.Settings(schema)
示例#27
0
_ = gettext.gettext

PREFS_SCHEMA = "com.linuxmint.warp.preferences"

FOLDER_NAME_KEY = "receiving-folder"
START_WITH_WINDOW_KEY = "start-with-window"
# START_PINNED_KEY = "default-pinned"
AUTOSTART_KEY = "autostart"
ASK_PERMISSION_KEY = "ask-for-send-permission"
NO_OVERWRITE_KEY = "no-overwrite"
PORT_KEY = "port"
SHOW_NOTIFICATIONS_KEY = "show-notifications"
FAVORITES_KEY = "favorites"
TRAY_ICON_KEY = "use-tray-icon"

prefs_settings = Gio.Settings(schema_id=PREFS_SCHEMA)


def get_port():
    return prefs_settings.get_int(PORT_KEY)


def get_save_uri():
    uri = prefs_settings.get_string(FOLDER_NAME_KEY)

    if uri == "":
        uri = Gio.File.new_for_path(GLib.get_home_dir()).get_uri()

    return uri

示例#28
0
    def on_module_selected(self):
        if not self.loaded:
            print "Loading Backgrounds module"

            self.sidePage.stack = SettingsStack()
            self.sidePage.add_widget(self.sidePage.stack)

            self.shown_collection = None  # Which collection is displayed in the UI

            self._background_schema = Gio.Settings(
                schema="org.cinnamon.desktop.background")
            self._slideshow_schema = Gio.Settings(
                schema="org.cinnamon.desktop.background.slideshow")
            self._slideshow_schema.connect("changed::slideshow-enabled",
                                           self.on_slideshow_enabled_changed)
            self.add_folder_dialog = Gtk.FileChooserDialog(
                title=_("Add Folder"),
                action=Gtk.FileChooserAction.SELECT_FOLDER,
                buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                         Gtk.STOCK_OPEN, Gtk.ResponseType.OK))

            self.xdg_pictures_directory = os.path.expanduser("~/Pictures")
            xdg_config = os.path.expanduser("~/.config/user-dirs.dirs")
            if os.path.exists(xdg_config) and os.path.exists(
                    "/usr/bin/xdg-user-dir"):
                path = commands.getoutput("xdg-user-dir PICTURES")
                if os.path.exists(path):
                    self.xdg_pictures_directory = path

            self.get_user_backgrounds()

            # Images

            mainbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 2)
            mainbox.expand = True
            mainbox.set_border_width(8)

            self.sidePage.stack.add_titled(mainbox, "images", _("Images"))

            left_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
            right_vbox = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)

            folder_scroller = Gtk.ScrolledWindow.new(None, None)
            folder_scroller.set_shadow_type(Gtk.ShadowType.IN)
            folder_scroller.set_policy(Gtk.PolicyType.AUTOMATIC,
                                       Gtk.PolicyType.AUTOMATIC)
            folder_scroller.set_property("min-content-width", 150)

            self.folder_tree = Gtk.TreeView.new()
            self.folder_tree.set_headers_visible(False)
            folder_scroller.add(self.folder_tree)

            button_toolbar = Gtk.Toolbar.new()
            button_toolbar.set_icon_size(1)
            Gtk.StyleContext.add_class(
                Gtk.Widget.get_style_context(button_toolbar), "inline-toolbar")
            self.add_folder_button = Gtk.ToolButton.new(None, None)
            self.add_folder_button.set_icon_name("list-add-symbolic")
            self.add_folder_button.set_tooltip_text(_("Add new folder"))
            self.add_folder_button.connect("clicked",
                                           lambda w: self.add_new_folder())
            self.remove_folder_button = Gtk.ToolButton.new(None, None)
            self.remove_folder_button.set_icon_name("list-remove-symbolic")
            self.remove_folder_button.set_tooltip_text(
                _("Remove selected folder"))
            self.remove_folder_button.connect("clicked",
                                              lambda w: self.remove_folder())
            button_toolbar.insert(self.add_folder_button, 0)
            button_toolbar.insert(self.remove_folder_button, 1)

            image_scroller = Gtk.ScrolledWindow.new(None, None)
            image_scroller.set_shadow_type(Gtk.ShadowType.IN)
            image_scroller.set_policy(Gtk.PolicyType.AUTOMATIC,
                                      Gtk.PolicyType.AUTOMATIC)

            self.icon_view = ThreadedIconView()
            image_scroller.add(self.icon_view)
            self.icon_view.connect("selection-changed",
                                   self.on_wallpaper_selection_changed)

            right_vbox.pack_start(image_scroller, True, True, 0)
            left_vbox.pack_start(folder_scroller, True, True, 0)
            left_vbox.pack_start(button_toolbar, False, False, 0)

            mainbox.pack_start(left_vbox, False, False, 2)
            mainbox.pack_start(right_vbox, True, True, 2)

            left_vbox.set_border_width(2)
            right_vbox.set_border_width(2)

            self.collection_store = Gtk.ListStore(
                bool,  # is separator
                str,  # Icon name
                str,  # Display name
                str,  # Path
                str)  # Type of collection
            cell = Gtk.CellRendererText()
            cell.set_alignment(0, 0)
            pb_cell = Gtk.CellRendererPixbuf()
            self.folder_column = Gtk.TreeViewColumn()
            self.folder_column.pack_start(pb_cell, False)
            self.folder_column.pack_start(cell, True)
            self.folder_column.add_attribute(pb_cell, "icon-name", 1)
            self.folder_column.add_attribute(cell, "text", 2)

            self.folder_column.set_alignment(0)

            self.folder_tree.append_column(self.folder_column)
            self.folder_tree.connect("cursor-changed",
                                     self.on_folder_source_changed)

            self.get_system_backgrounds()

            tree_separator = [True, None, None, None, None]
            self.collection_store.append(tree_separator)

            if len(self.user_backgrounds) > 0:
                for item in self.user_backgrounds:
                    self.collection_store.append(item)

            self.folder_tree.set_model(self.collection_store)
            self.folder_tree.set_row_separator_func(self.is_row_separator,
                                                    None)

            self.get_initial_path()

            # Settings

            page = SettingsPage()

            settings = page.add_section(_("Background Settings"))

            size_group = Gtk.SizeGroup.new(Gtk.SizeGroupMode.HORIZONTAL)

            self.sidePage.stack.add_titled(page, "settings", _("Settings"))

            widget = GSettingsSwitch(
                _("Play backgrounds as a slideshow"),
                "org.cinnamon.desktop.background.slideshow",
                "slideshow-enabled")
            settings.add_row(widget)

            widget = GSettingsSpinButton(
                _("Delay"), "org.cinnamon.desktop.background.slideshow",
                "delay", _("minutes"), 1, 120)
            settings.add_reveal_row(
                widget, "org.cinnamon.desktop.background.slideshow",
                "slideshow-enabled")

            widget = GSettingsSwitch(
                _("Play images in random order"),
                "org.cinnamon.desktop.background.slideshow", "random-order")
            settings.add_reveal_row(
                widget, "org.cinnamon.desktop.background.slideshow",
                "slideshow-enabled")

            widget = GSettingsComboBox(_("Picture aspect"),
                                       "org.cinnamon.desktop.background",
                                       "picture-options",
                                       BACKGROUND_PICTURE_OPTIONS,
                                       size_group=size_group)
            settings.add_row(widget)

            widget = GSettingsComboBox(_("Background gradient"),
                                       "org.cinnamon.desktop.background",
                                       "color-shading-type",
                                       BACKGROUND_COLOR_SHADING_TYPES,
                                       size_group=size_group)
            settings.add_row(widget)

            widget = GSettingsColorChooser(_("Gradient start color"),
                                           "org.cinnamon.desktop.background",
                                           "primary-color",
                                           size_group=size_group)
            settings.add_row(widget)

            widget = GSettingsColorChooser(_("Gradient end color"),
                                           "org.cinnamon.desktop.background",
                                           "secondary-color",
                                           size_group=size_group)
            settings.add_row(widget)
示例#29
0
def get_publish_information():
    settings = Gio.Settings('org.sugarlabs.collaboration')
    publish = settings.get_boolean('publish-gadget')
    return publish
示例#30
0
 def settings(self):
     """Get the GSettings object."""
     if self._settings is None:
         self._settings = Gio.Settings('com.kissuki.yaner')
     return self._settings