コード例 #1
0
ファイル: application.py プロジェクト: theeternalsw0rd/miro
def _set_pref(key, setter_name, value):
    gconf_lock.acquire()
    try:
        client = gconf.client_get_default()
        fullkey = gconf_key(key)
        setter = getattr(client, setter_name)
        setter(fullkey, value)
    finally:
        gconf_lock.release()
コード例 #2
0
ファイル: application.py プロジェクト: zjmmjzzjm/miro
def _set_pref(key, setter_name, value):
    gconf_lock.acquire()
    try:
        client = gconf.client_get_default()
        fullkey = gconf_key(key)
        setter = getattr(client, setter_name)
        setter(fullkey, value)
    finally:
        gconf_lock.release()
コード例 #3
0
ファイル: application.py プロジェクト: theeternalsw0rd/miro
def _get_pref(key, getter_name):
    gconf_lock.acquire()
    try:
        client = gconf.client_get_default()
        fullkey = gconf_key(key)
        value = client.get(fullkey)
        if value is not None:
            getter = getattr(value, getter_name)
            return getter()
        else:
            return None
    finally:
        gconf_lock.release()
コード例 #4
0
ファイル: application.py プロジェクト: zjmmjzzjm/miro
def _get_pref(key, getter_name):
    gconf_lock.acquire()
    try:
        client = gconf.client_get_default()
        fullkey = gconf_key(key)
        value = client.get(fullkey)
        if value is not None:
            getter = getattr(value, getter_name)
            return getter()
        else:
            return None
    finally:
        gconf_lock.release()
コード例 #5
0
ファイル: associate.py プロジェクト: zjmmjzzjm/miro
def _disassociate_protocol(name, command):
    url_handlers_key = "/desktop/gnome/url-handlers/" + name + "/"
    if _is_associated(name, command):
        gconf_lock.acquire()
        try:
            gconf_client = gconf.client_get_default()
            if gconf_client.set_bool(url_handlers_key + "enabled", False):
                success = True
            else:
                success = False
        finally:
            gconf_lock.release()
    else:
        success = True
    return success
コード例 #6
0
ファイル: associate.py プロジェクト: ktan2020/miro
def _disassociate_protocol(name, command):
    url_handlers_key = "/desktop/gnome/url-handlers/" + name + "/"
    if _is_associated(name, command):
        gconf_lock.acquire()
        try:
            gconf_client = gconf.client_get_default()
            if gconf_client.set_bool(url_handlers_key + "enabled", False):
                success = True
            else:
                success = False
        finally:
            gconf_lock.release()
    else:
        success = True
    return success
コード例 #7
0
ファイル: associate.py プロジェクト: ktan2020/miro
def _associate_protocol(name, command, overwrite_existing=False):
    url_handlers_key = "/desktop/gnome/url-handlers/" + name + "/"
    if not _is_associated(name) or overwrite_existing:
        gconf_lock.acquire()
        try:
            gconf_client = gconf.client_get_default()
            if gconf_client.set_string(url_handlers_key + "command", command):
                gconf_client.set_bool(url_handlers_key + "needs_terminal", False)
                gconf_client.set_bool(url_handlers_key + "enabled", True)
                success = True
            else:
                success = False
        finally:
            gconf_lock.release()
    else:
        success = True
    return success
コード例 #8
0
ファイル: associate.py プロジェクト: zjmmjzzjm/miro
def _associate_protocol(name, command, overwrite_existing=False):
    url_handlers_key = "/desktop/gnome/url-handlers/" + name + "/"
    if not _is_associated(name) or overwrite_existing:
        gconf_lock.acquire()
        try:
            gconf_client = gconf.client_get_default()
            if gconf_client.set_string(url_handlers_key + "command", command):
                gconf_client.set_bool(url_handlers_key + "needs_terminal",
                                      False)
                gconf_client.set_bool(url_handlers_key + "enabled", True)
                success = True
            else:
                success = False
        finally:
            gconf_lock.release()
    else:
        success = True
    return success
コード例 #9
0
ファイル: associate.py プロジェクト: zjmmjzzjm/miro
def _is_associated(protocol, command=None):
    """ Checks whether a protocol currently is
        associated with the given command, or,
        if none is given, whether the protocol
        is associated with anything at all.
    """
    url_handlers_key = "/desktop/gnome/url-handlers/" + protocol + "/"
    gconf_lock.acquire()
    try:
        gconf_client = gconf.client_get_default()
        key = gconf_client.get(url_handlers_key + "command")
        if key is None:
            associated = False
        else:
            enabled = gconf_client.get(url_handlers_key + "enabled")
            if command:
                associated = key.get_string() == command and enabled.get_bool()
            else:
                associated = key.get_string() != "" and enabled.get_bool()
    finally:
        gconf_lock.release()
    return associated
コード例 #10
0
ファイル: associate.py プロジェクト: ktan2020/miro
def _is_associated(protocol, command=None):
    """ Checks whether a protocol currently is
        associated with the given command, or,
        if none is given, whether the protocol
        is associated with anything at all.
    """
    url_handlers_key = "/desktop/gnome/url-handlers/" + protocol + "/"
    gconf_lock.acquire()
    try:
        gconf_client = gconf.client_get_default()
        key = gconf_client.get(url_handlers_key + "command")
        if key is None:
            associated = False
        else:
            enabled = gconf_client.get(url_handlers_key + "enabled")
            if command:
                associated = key.get_string() == command and enabled.get_bool()
            else:
                associated = key.get_string() != "" and enabled.get_bool()
    finally:
        gconf_lock.release()
    return associated