# Path: guicavane/Config.py
# class Config(Singleton):
#     """ Configuration manager. Uses json as config format. """
# 
#     def __init__(self):
#         Singleton.__init__(self)
#         self.config_file = CONFIG_FILE
# 
#         self.data = {}
# 
#         if os.path.exists(self.config_file):
#             with open(self.config_file) as filehandler:
#                 data = filehandler.read()
# 
#                 try:
#                     self.data = json.loads(data)
#                 except ValueError:
#                     self.data = DEFAULT_VALUES
#         else:
#             self.data = DEFAULT_VALUES
# 
#         self.save()
# 
#     def get_key(self, key):
#         """ Returns the value of the given key or the default
#         value if it isn't set on the config or None
#         if the key doesn't exists. """
# 
#         return self.data.get(key, get_default(key))
# 
#     def set_key(self, key, value):
#         """ Sets the value of the key and writes the config file. """
# 
#         self.data[key] = value
#         self.save()
# 
#     def append_key(self, key, value):
#         """ If the key is a list, appends the value to the list. """
# 
#         assert type(self.data[key]) == list
# 
#         if not key in self.data:
#             self.data[key] = get_default(key)
# 
#         assert type(self.data[key]) == list
# 
#         self.data[key].append(value)
# 
#         self.save()
# 
#     def remove_key(self, key, value):
#         """ If the key is a list, removes the value from it. """
# 
#         assert type(self.data[key]) == list
#         assert value in self.data[key]
# 
#         self.data[key].remove(value)
#         self.save()
# 
#     def save(self):
#         """ Saves the config on the disk file and fills
#         the empty values with default ones. """
# 
#         for key in DEFAULT_VALUES:
#             if key not in self.data:
#                 self.data[key] = get_default(key)
# 
#         with open(self.config_file, "w") as filehandler:
#             json_data = json.dumps(self.data, sort_keys=True, indent=4)
#             filehandler.write(json_data + "\n")
# 
# Path: guicavane/Paths.py
# SETTINGS_GUI_FILE = GUI_DIR + SEP + "settings.glade"


import gtk
import base64
from guicavane.Config import Config
from guicavane.Paths import SETTINGS_GUI_FILE
#!/usr/bin/env python
# encoding: utf-8
# pylint: disable-msg=E1101

"""
Settings. Manages the gui of the settings.
"""


# Dict with host -> (username_input, password_input) to retrive the
# accounts information
HOSTS_INPUTS = {
    "megaupload": ("megaupload_username", "megaupload_password"),
    "wupload": ("wupload_username", "wupload_password"),
}


class SettingsDialog(object):
    """ Settings interface manager. """

    def __init__(self, gui_manager):
        """ Creates the window and initializes the attributes. """

        # Gtk builder
        self.builder = gtk.Builder()
        self.builder.add_from_file(SETTINGS_GUI_FILE)
        self.builder.connect_signals(self)

        self.gui_manager = gui_manager

# Path: guicavane/Config.py
# class Config(Singleton):
#     """ Configuration manager. Uses json as config format. """
# 
#     def __init__(self):
#         Singleton.__init__(self)
#         self.config_file = CONFIG_FILE
# 
#         self.data = {}
# 
#         if os.path.exists(self.config_file):
#             with open(self.config_file) as filehandler:
#                 data = filehandler.read()
# 
#                 try:
#                     self.data = json.loads(data)
#                 except ValueError:
#                     self.data = DEFAULT_VALUES
#         else:
#             self.data = DEFAULT_VALUES
# 
#         self.save()
# 
#     def get_key(self, key):
#         """ Returns the value of the given key or the default
#         value if it isn't set on the config or None
#         if the key doesn't exists. """
# 
#         return self.data.get(key, get_default(key))
# 
#     def set_key(self, key, value):
#         """ Sets the value of the key and writes the config file. """
# 
#         self.data[key] = value
#         self.save()
# 
#     def append_key(self, key, value):
#         """ If the key is a list, appends the value to the list. """
# 
#         assert type(self.data[key]) == list
# 
#         if not key in self.data:
#             self.data[key] = get_default(key)
# 
#         assert type(self.data[key]) == list
# 
#         self.data[key].append(value)
# 
#         self.save()
# 
#     def remove_key(self, key, value):
#         """ If the key is a list, removes the value from it. """
# 
#         assert type(self.data[key]) == list
#         assert value in self.data[key]
# 
#         self.data[key].remove(value)
#         self.save()
# 
#     def save(self):
#         """ Saves the config on the disk file and fills
#         the empty values with default ones. """
# 
#         for key in DEFAULT_VALUES:
#             if key not in self.data:
#                 self.data[key] = get_default(key)
# 
#         with open(self.config_file, "w") as filehandler:
#             json_data = json.dumps(self.data, sort_keys=True, indent=4)
#             filehandler.write(json_data + "\n")
# 
# Path: guicavane/Paths.py
# SETTINGS_GUI_FILE = GUI_DIR + SEP + "settings.glade"


# Path: guicavane/Settings.py
import gtk
import base64
from guicavane.Config import Config
from guicavane.Paths import SETTINGS_GUI_FILE

#!/usr/bin/env python
# encoding: utf-8
# pylint: disable-msg=E1101

"""
Settings. Manages the gui of the settings.
"""


# Dict with host -> (username_input, password_input) to retrive the
# accounts information
HOSTS_INPUTS = {
    "megaupload": ("megaupload_username", "megaupload_password"),
    "wupload": ("wupload_username", "wupload_password"),
}


class SettingsDialog(object):
    """ Settings interface manager. """

    def __init__(self, gui_manager):
        """ Creates the window and initializes the attributes. """

        # Gtk builder
        self.builder = gtk.Builder()
        self.builder.add_from_file(SETTINGS_GUI_FILE)
        self.builder.connect_signals(self)

        self.gui_manager = gui_manager

        self.config = Config.get()