# Path: deluge/ui/client.py
# RPC_RESPONSE = 1
# RPC_ERROR = 2
# RPC_EVENT = 3
# def format_kwargs(kwargs):
#     def __init__(self, method, args, kwargs, exception_type, exception_msg, traceback):
#     def __repr__(self):
#     def format_message(self):
#     def connectionMade(self):
#     def dataReceived(self, data):
#     def send_request(self, request):
#     def __init__(self, daemon, event_handlers):
#     def startedConnecting(self, connector):
#     def clientConnectionFailed(self, connector, reason):
#     def clientConnectionLost(self, connector, reason):
#     def __init__(self, event_handlers={}):
#     def connect(self, host, port, username, password):
#     def disconnect(self):
#     def call(self, method, *args, **kwargs):
#     def pop_deferred(self, request_id):
#     def register_event_handler(self, event, handler):
#     def deregister_event_handler(self, event, handler):
#     def __rpcError(self, error_data):
#     def __on_connect(self, result, username, password):
#     def __on_connect_fail(self, reason):
#     def __on_login(self, result, username):
#     def __on_login_fail(self, result):
#     def set_disconnect_callback(self, cb):
#     def get_bytes_recv(self):
#     def get_bytes_sent(self):
#     def __init__(self, event_handlers={}):
#     def disconnect(self):
#     def call(self, method, *args, **kwargs):
#     def register_event_handler(self, event, handler):
#     def deregister_event_handler(self, event, handler):
#     def __init__(self, daemon, method):
#     def __call__(self, *args, **kwargs):
#     def __getattr__(self, name):
#     def __call__(self, *args, **kwargs):
#     def __init__(self):
#     def connect(self, host="127.0.0.1", port=58846, username="", password=""):
#         def on_connect_fail(result):
#     def disconnect(self):
#     def start_classic_mode(self):
#     def start_daemon(self, port, config):
#     def is_localhost(self):
#     def is_classicmode(self):
#     def connected(self):
#     def connection_info(self):
#     def register_event_handler(self, event, handler):
#     def deregister_event_handler(self, event, handler):
#     def force_call(self, block=False):
#     def __getattr__(self, method):
#     def set_disconnect_callback(self, cb):
#     def __on_disconnect(self):
#     def get_bytes_recv(self):
#     def get_bytes_sent(self):
# class DelugeRPCError(object):
# class DelugeRPCRequest(object):
# class DelugeRPCProtocol(Protocol):
# class DelugeRPCClientFactory(ClientFactory):
# class DaemonProxy(object):
# class DaemonSSLProxy(DaemonProxy):
# class DaemonClassicProxy(DaemonProxy):
# class DottedObject(object):
# class RemoteMethod(DottedObject):
# class Client(object):


import gtk
import deluge.component as component
import deluge.common
import os
from deluge.log import LOG as log
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
from common import get_resource
        if not options.get('queue_to_top', True):
            self.glade.get_widget('isnt_queue_to_top').set_active(True)
        if not options.get('auto_managed', True):
            self.glade.get_widget('isnt_auto_managed').set_active(True)
        for field in ['move_completed_path', 'path', 'download_location']:
            if client.is_localhost():
                self.glade.get_widget(field+"_chooser").set_filename(options.get(field, os.path.expanduser("~")))
                self.glade.get_widget(field+"_chooser").show()
                self.glade.get_widget(field+"_entry").hide()
            else:
                self.glade.get_widget(field+"_entry").set_text(options.get(field, ""))
                self.glade.get_widget(field+"_entry").show()
                self.glade.get_widget(field+"_chooser").hide()
        self.set_sensitive()
                
        def on_get_enabled_plugins(result):
            if 'Label' in result: 
                self.glade.get_widget('label_frame').show()
            else:
                self.glade.get_widget('label_frame').hide()
                self.glade.get_widget('label_toggle').set_active(False)
                
        client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins)
        
    def set_sensitive(self):
        maintoggles = ['download_location', 'append_extension', 'move_completed', 'label', \
            'max_download_speed', 'max_upload_speed', 'max_connections', \
            'max_upload_slots', 'add_paused', 'auto_managed', 'stop_at_ratio', 'queue_to_top']
        [self.on_toggle_toggled(self.glade.get_widget(x+'_toggle')) for x in maintoggles]
        

# Path: deluge/ui/client.py
# RPC_RESPONSE = 1
# RPC_ERROR = 2
# RPC_EVENT = 3
# def format_kwargs(kwargs):
#     def __init__(self, method, args, kwargs, exception_type, exception_msg, traceback):
#     def __repr__(self):
#     def format_message(self):
#     def connectionMade(self):
#     def dataReceived(self, data):
#     def send_request(self, request):
#     def __init__(self, daemon, event_handlers):
#     def startedConnecting(self, connector):
#     def clientConnectionFailed(self, connector, reason):
#     def clientConnectionLost(self, connector, reason):
#     def __init__(self, event_handlers={}):
#     def connect(self, host, port, username, password):
#     def disconnect(self):
#     def call(self, method, *args, **kwargs):
#     def pop_deferred(self, request_id):
#     def register_event_handler(self, event, handler):
#     def deregister_event_handler(self, event, handler):
#     def __rpcError(self, error_data):
#     def __on_connect(self, result, username, password):
#     def __on_connect_fail(self, reason):
#     def __on_login(self, result, username):
#     def __on_login_fail(self, result):
#     def set_disconnect_callback(self, cb):
#     def get_bytes_recv(self):
#     def get_bytes_sent(self):
#     def __init__(self, event_handlers={}):
#     def disconnect(self):
#     def call(self, method, *args, **kwargs):
#     def register_event_handler(self, event, handler):
#     def deregister_event_handler(self, event, handler):
#     def __init__(self, daemon, method):
#     def __call__(self, *args, **kwargs):
#     def __getattr__(self, name):
#     def __call__(self, *args, **kwargs):
#     def __init__(self):
#     def connect(self, host="127.0.0.1", port=58846, username="", password=""):
#         def on_connect_fail(result):
#     def disconnect(self):
#     def start_classic_mode(self):
#     def start_daemon(self, port, config):
#     def is_localhost(self):
#     def is_classicmode(self):
#     def connected(self):
#     def connection_info(self):
#     def register_event_handler(self, event, handler):
#     def deregister_event_handler(self, event, handler):
#     def force_call(self, block=False):
#     def __getattr__(self, method):
#     def set_disconnect_callback(self, cb):
#     def __on_disconnect(self):
#     def get_bytes_recv(self):
#     def get_bytes_sent(self):
# class DelugeRPCError(object):
# class DelugeRPCRequest(object):
# class DelugeRPCProtocol(Protocol):
# class DelugeRPCClientFactory(ClientFactory):
# class DaemonProxy(object):
# class DaemonSSLProxy(DaemonProxy):
# class DaemonClassicProxy(DaemonProxy):
# class DottedObject(object):
# class RemoteMethod(DottedObject):
# class Client(object):


# Path: deluge/plugins/autoadd/autoadd/gtkui.py
import gtk
import deluge.component as component
import deluge.common
import os
from deluge.log import LOG as log
from deluge.ui.client import client
from deluge.plugins.pluginbase import GtkPluginBase
from common import get_resource

        if not options.get('queue_to_top', True):
            self.glade.get_widget('isnt_queue_to_top').set_active(True)
        if not options.get('auto_managed', True):
            self.glade.get_widget('isnt_auto_managed').set_active(True)
        for field in ['move_completed_path', 'path', 'download_location']:
            if client.is_localhost():
                self.glade.get_widget(field+"_chooser").set_filename(options.get(field, os.path.expanduser("~")))
                self.glade.get_widget(field+"_chooser").show()
                self.glade.get_widget(field+"_entry").hide()
            else:
                self.glade.get_widget(field+"_entry").set_text(options.get(field, ""))
                self.glade.get_widget(field+"_entry").show()
                self.glade.get_widget(field+"_chooser").hide()
        self.set_sensitive()
                
        def on_get_enabled_plugins(result):
            if 'Label' in result: 
                self.glade.get_widget('label_frame').show()
            else:
                self.glade.get_widget('label_frame').hide()
                self.glade.get_widget('label_toggle').set_active(False)
                
        client.core.get_enabled_plugins().addCallback(on_get_enabled_plugins)
        
    def set_sensitive(self):
        maintoggles = ['download_location', 'append_extension', 'move_completed', 'label', \
            'max_download_speed', 'max_upload_speed', 'max_connections', \
            'max_upload_slots', 'add_paused', 'auto_managed', 'stop_at_ratio', 'queue_to_top']
        [self.on_toggle_toggled(self.glade.get_widget(x+'_toggle')) for x in maintoggles]
        

    def on_toggle_toggled(self, tb):