def __init__(self, editing=False, new_subscription=False):
     self.editing = editing
     self.new_subscription = new_subscription
     self.matching_store = None
     self.icon_matching = GdkPixbuf.Pixbuf.new_from_file(get_resource("match.png"))
     self.icon_nonmatching = GdkPixbuf.Pixbuf.new_from_file(get_resource("no_match.png"))
     self.labels = None
    def setup(self):
        self.glade = gtk.glade.XML(get_resource("dialog_subscription.glade"))
        self.glade.signal_autoconnect({
                "on_txt_regex_include_changed":         self.on_txt_regex_changed,
                "on_txt_regex_exclude_changed":         self.on_txt_regex_changed,
                "on_button_cancel_clicked":             self.on_button_cancel_clicked,
                "on_button_save_clicked":               self.on_button_save_subscription_clicked,
                "on_button_add_notication_clicked":     self.on_button_add_notication_clicked,
                "on_button_remove_notication_clicked":  self.on_button_remove_notication_clicked,
                "on_rssfeed_selected":                  self.on_rssfeed_selected,
                "on_button_fetch_clicked":              self.on_rssfeed_selected,
                "on_button_last_matched_reset_clicked": self.on_button_last_matched_reset_clicked,
                "on_button_last_matched_now_clicked":   self.on_button_last_matched_now_clicked,
                "on_general_checkBox_toggled":          self.on_general_checkBox_toggled,
                "on_key_pressed":                       self.on_key_pressed,
        })

        # This is to make testing of the GUI possible (unit tests)
        self.method_perform_rssfeed_selection = self.perform_rssfeed_selection
        self.dialog = self.glade.get_widget("window_subscription")
        self.dialog.set_title("Edit Subscription" if "key" in self.subscription_data else "Add Subscription")
        self.setup_rssfeed_combobox()
        self.setup_move_completed_combobox()
        self.setup_download_location_combobox()
        self.setup_messages_combobox()
        self.setup_messages_list()
        self.treeview = self.create_matching_tree()
        self.set_custom_text_tooltip()
        self.load_subscription_data()
    def __init__(self, max_visible_rows=20, auto_complete=True, use_completer_popup=True):
        gtk.HBox.__init__(self)
        gobject.GObject.__init__(self)
        self._stored_values_popping_down = False
        self.filechooser_visible = True
        self.properties_enabled = True
        self.builder = gtk.Builder()
        self.popup_buttonbox = self.builder.get_object("buttonbox")
        self.builder.add_from_file(get_resource("path_combo_chooser.ui"))
        self.button_toggle = self.builder.get_object("button_toggle_dropdown")
        self.entry = self.builder.get_object("entry_text")
        self.filechooser_button = self.builder.get_object("filechooser_button")
        self.button_properties = self.builder.get_object("button_properties")
        combo_hbox = self.builder.get_object("entry_combox_hbox")
        # Change the parent of the hbox from the glade Window to this hbox.
        combo_hbox.reparent(self)
        StoredValuesPopup.__init__(self, self.builder, self, max_visible_rows)

        self.auto_completer = PathAutoCompleter(self.builder, self, max_visible_rows)
        self.auto_completer.set_use_popup(use_completer_popup)
        self.auto_completer.auto_complete_enabled = auto_complete
        self.setup_config_dialog()

        signal_handlers = {
            "on_button_toggle_dropdown_toggled": self._on_button_toggle_dropdown_toggled,
            'on_entry_text_key_press_event': self._on_entry_text_key_press_event,
            'on_stored_values_popup_window_hide': self._on_stored_values_popup_window_hide,
            "on_button_toggle_dropdown_button_press_event": self._on_button_toggle_dropdown_button_press_event,
            "on_filechooser_button_current_folder_changed": self._on_filechooser_button_current_folder_changed,
            "on_filechooser_button_show": self._on_filechooser_button_show,
            }
        signal_handlers.update(self.signal_handlers)
        signal_handlers.update(self.auto_completer.signal_handlers)
        signal_handlers.update(self.config_dialog_signal_handlers)
        self.builder.connect_signals(signal_handlers)
    def test_atoma_parsing(self):
        import atoma
        atoma.rss.supported_rss_versions = []
        filename = "ettv-rss-1.xml"
        file_path = common.get_resource(filename, path="tests/data/feeds/")
        parsed_feeds = atoma.parse_rss_file(file_path)

        self.assertEquals('The top100 torrents', parsed_feeds.description)
        self.assertEquals('https://therss.so', parsed_feeds.link)
        self.assertEquals(None, parsed_feeds.ttl)
    def __init__(self, gtkUI, rssfeed):
        self.gtkUI = gtkUI
        self.rssfeed = rssfeed

        self.glade = gtk.glade.XML(get_resource("dialog_rssfeed.glade"))
        self.glade.signal_autoconnect({
                "on_button_cancel_clicked":self.on_button_cancel_clicked,
                "on_button_save_clicked": self.on_button_save_clicked
        })
        self.populate_data_fields()
Exemple #6
0
    def create_ui(self):
        self.glade = Gtk.Builder.new_from_file(get_resource("yarss_main.ui"))
        self.glade.connect_signals({
            "on_button_add_subscription_clicked": self.on_button_add_subscription_clicked,
            "on_button_delete_subscription_clicked": self.on_button_delete_subscription_clicked,
            "on_button_edit_subscription_clicked": self.on_button_edit_subscription_clicked,

            "on_button_add_rssfeed_clicked": self.on_button_add_rssfeed_clicked,
            "on_button_delete_rssfeed_clicked": self.on_button_delete_rssfeed_clicked,
            "on_button_edit_rssfeed_clicked": self.on_button_edit_rssfeed_clicked,

            "on_button_add_cookie_clicked": self.on_button_add_cookie_clicked,
            "on_button_edit_cookie_clicked": self.on_button_edit_cookie_clicked,
            "on_button_delete_cookie_clicked": self.on_button_delete_cookie_clicked,

            "on_button_add_message_clicked": self.on_button_add_message_clicked,
            "on_button_edit_message_clicked": self.on_button_edit_message_clicked,
            "on_button_delete_message_clicked": self.on_button_delete_message_clicked,

            "on_checkbox_email_authentication_toggled": self.on_checkbox_email_authentication_toggled,
            "on_checkbutton_show_log_messages_gui_toggled": self.on_checkbutton_show_log_messages_gui_toggled,
        })

        component.get("Preferences").add_page("YaRSS2", self.glade.get_object("notebook_main"))
        component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
        self.gtkui_log = GTKUILogger(self.glade.get_object('textview_log'))
        self.log = logging.getLogger(__name__, gtkui_logger=self.gtkui_log)

        self.subscriptions = {}
        self.rssfeeds = {}

        self.selected_path_subscriptions = None
        self.selected_path_rssfeeds = None
        self.selected_path_email_message = None
        self.selected_path_cookies = None

        self.label_enabled = False

        # key, enabled, name, site, download_location
        self.subscriptions_store = Gtk.ListStore(str, bool, str, str, str, str, str)

        # key, active, name, site, Update interval, Last update, subscripions, URL
        self.rssfeeds_store = Gtk.ListStore(str, bool, str, str, str, str, str, str)

        # key, active, site, value
        self.cookies_store = Gtk.ListStore(str, bool, str, str)

        # key, active, name, to-address, subject, message-content
        self.email_messages_store = Gtk.ListStore(str, bool, str, str, str, str)

        self.create_subscription_pane()
        self.create_rssfeeds_pane()
        self.create_cookies_pane()
        self.create_email_messages_pane()
 def __init__(self, gtkUI,
              logger,
              subscription_data,
              rssfeeds,
              move_completed_list,
              download_location_list,
              email_messages,
              cookies):
     self.gtkUI = gtkUI
     self.rssfeeds = rssfeeds
     self.move_completed_list = move_completed_list
     self.download_location_list = download_location_list
     self.email_messages = email_messages
     self.rssfeeds_dict = {}
     self.matching_store = None
     self.icon_matching = gtk.gdk.pixbuf_new_from_file(get_resource("match.png"))
     self.icon_nonmatching = gtk.gdk.pixbuf_new_from_file(get_resource("no_match.png"))
     self.subscription_data = subscription_data
     self.cookies = cookies
     self.log = logger
     self.rssfeedhandler = RSSFeedHandler(self.log)
    def createUI(self):
        self.glade = gtk.glade.XML(get_resource("yarss_main.glade"))
        self.glade.signal_autoconnect({
                "on_button_add_subscription_clicked":       self.on_button_add_subscription_clicked,
                "on_button_delete_subscription_clicked":    self.on_button_delete_subscription_clicked,
                "on_button_edit_subscription_clicked" :     self.on_button_edit_subscription_clicked,

                "on_button_add_rssfeed_clicked":            self.on_button_add_rssfeed_clicked,
                "on_button_delete_rssfeed_clicked":         self.on_button_delete_rssfeed_clicked,
                "on_button_edit_rssfeed_clicked" :          self.on_button_edit_rssfeed_clicked,

                "on_button_add_cookie_clicked" :            self.on_button_add_cookie_clicked,
                "on_button_edit_cookie_clicked" :           self.on_button_edit_cookie_clicked,
                "on_button_delete_cookie_clicked":          self.on_button_delete_cookie_clicked,

                "on_button_add_message_clicked" :           self.on_button_add_message_clicked,
                "on_button_edit_message_clicked" :          self.on_button_edit_message_clicked,
                "on_button_delete_message_clicked":         self.on_button_delete_message_clicked,

                "on_checkbox_email_authentication_toggled": self.on_checkbox_email_authentication_toggled,
                })

        component.get("Preferences").add_page("YaRSS2", self.glade.get_widget("notebook_main"))
        component.get("PluginManager").register_hook("on_apply_prefs", self.on_apply_prefs)
        component.get("PluginManager").register_hook("on_show_prefs", self.on_show_prefs)
        self.gtkui_log = GTKUI_logger(self.glade.get_widget('textview_log'))
        self.log = Logger(gtkui_logger=self.gtkui_log)

        self.subscriptions = {}
        self.rssfeeds = {}

        self.selected_path_subscriptions = None
        self.selected_path_rssfeeds = None
        self.selected_path_email_message = None
        self.selected_path_cookies = None

        # key, enabled, name, site, download_location
        self.subscriptions_store = gtk.ListStore(str, bool, str, str, str, str, str)

        # key, active, name, site, Update interval, Last update, subscripions, URL
        self.rssfeeds_store = gtk.ListStore(str, bool, str, str, str, str, str, str)

        # key, active, site, value
        self.cookies_store = gtk.ListStore(str, bool, str, str)

        # key, active, name, to-address, subject, message-content
        self.email_messages_store = gtk.ListStore(str, bool, str, str, str, str)

        self.create_subscription_pane()
        self.create_rssfeeds_pane()
        self.create_cookies_pane()
        self.create_email_messages_pane()
 def show(self):
     self.glade = gtk.glade.XML(get_resource("dialog_email_message.glade"))
     self.glade.signal_autoconnect({
             "on_button_save_clicked": self.on_button_save_clicked,
             "on_button_cancel_clicked": self.on_button_cancel_clicked
     })
     # Add data
     if self.message_data is not None:
         self.set_initial_data(self.message_data)
     self.dialog = self.glade.get_widget("dialog_email_message")
     self.dialog.set_transient_for(component.get("Preferences").pref_dialog)
     self.dialog.set_title("Edit Message" if "key" in self.message_data else "Add Message")
     self.dialog.run()
Exemple #10
0
 def __init__(self, gtkui, logger, subscription_data, rssfeeds,
              move_completed_list, download_location_list, email_messages,
              cookies):
     self.gtkUI = gtkui
     self.rssfeeds = rssfeeds
     self.move_completed_list = move_completed_list
     self.download_location_list = download_location_list
     self.email_messages = email_messages
     self.rssfeeds_dict = {}
     self.matching_store = None
     self.icon_matching = gtk.gdk.pixbuf_new_from_file(
         get_resource("match.png"))
     self.icon_nonmatching = gtk.gdk.pixbuf_new_from_file(
         get_resource("no_match.png"))
     self.subscription_data = subscription_data
     self.cookies = cookies
     self.log = logger
     self.rssfeedhandler = RSSFeedHandler(self.log)
     self.new_subscription = "key" not in subscription_data
     self.labels = None
     self.editing = True if len(
         self.subscription_data.get("rssfeed_key", "")) != 0 else False
    def __init__(self, gtkui, rssfeed):
        self.gtkUI = gtkui
        self.rssfeed = rssfeed

        self.glade = gtk.glade.XML(get_resource("dialog_rssfeed.glade"))
        self.glade.signal_autoconnect({
            "on_button_cancel_clicked":
            self.on_button_cancel_clicked,
            "on_button_save_clicked":
            self.on_button_save_clicked,
            "on_dialog_rssfeed_response":
            self.on_response,
        })
        self.populate_data_fields()
    def test_feedparser_ampersant_in_url(self):
        """A bug in feedparser resulted in URL containing &amp when XML Parser was not available.
        This test disables XML Parser and verifies that the URL is correct
        """
        file_path = common.get_resource("rss_with_ampersand_link.rss", path="tests")
        # This is the link in rss_with_ampersand_link.rss
        url = "http://hostname.com/Fetch?hash=2f21d4e59&digest=865178f9bc"
        expected = "http://hostname.com/Fetch?hash=2f21d4e59&digest=865178f9bc"
        # Disable XML Parser
        feedparser._XML_AVAILABLE = 0
        parsed_feeds = feedparser.parse(file_path)

        for item in parsed_feeds['items']:
            self.assertEquals(expected, item["link"])
            break
    def test_feedparser_ampersant_in_url(self):
        """A bug in feedparser resulted in URL containing &amp when XML Parser was not available.
        This test disables XML Parser and verifies that the URL is correct
        """
        from yarss2.lib import feedparser
        file_path = common.get_resource("rss_with_ampersand_link.rss", path="tests")
        # This is the link in rss_with_ampersand_link.rss
        expected = "http://hostname.com/Fetch?hash=2f21d4e59&digest=865178f9bc"
        # Disable XML Parser
        feedparser.feedparser._XML_AVAILABLE = 0
        parsed_feeds = feedparser.feedparser.parse(file_path)

        for item in parsed_feeds['items']:
            self.assertEquals(expected, item["link"])
            break
Exemple #14
0
    def show(self):
        self.glade = Gtk.Builder.new_from_file(get_resource("dialog_email_message.ui"))

        self.glade.connect_signals({
            "on_button_save_clicked": self.on_button_save_clicked,
            "on_button_cancel_clicked": self.on_button_cancel_clicked,
            "on_dialog_email_message_response": self.on_response,
            "on_txt_to_adress_query_tooltip": self.on_txt_to_adress_query_tooltip,
        })
        # Add data
        if self.message_data is not None:
            self.set_initial_data(self.message_data)
        self.dialog = self.glade.get_object("dialog_email_message")
        self.dialog.set_transient_for(component.get("Preferences").pref_dialog)
        self.dialog.set_title("Edit Message" if "key" in self.message_data else "Add Message")
        self.dialog.run()
    def __init__(self, gtkUI, cookie_data):
        self.gtkUI = gtkUI
        self.cookie_data = cookie_data
        self.glade = gtk.glade.XML(get_resource("dialog_cookie.glade"))
        self.glade.signal_autoconnect({
                "on_button_add_cookie_data_clicked": self.on_button_add_cookie_data_clicked,
                "on_button_remove_cookie_data_clicked": self.on_button_remove_cookie_data_clicked,
                "on_button_save_clicked": self.on_button_save_clicked,
                "on_button_cancel_clicked": self.on_button_cancel_clicked
        })
        self.treeview = self.setup_cookie_list()

        if self.cookie_data:
            self.glade.get_widget("text_site").set_text(self.cookie_data["site"])

        # Update cookie data list
        self.update_cookie_values_list()
    def __init__(self, gtkui, cookie_data):
        self.gtkUI = gtkui
        self.cookie_data = cookie_data
        self.glade = gtk.glade.XML(get_resource("dialog_cookie.glade"))
        self.glade.signal_autoconnect({
            "on_button_add_cookie_data_clicked": self.on_button_add_cookie_data_clicked,
            "on_button_remove_cookie_data_clicked": self.on_button_remove_cookie_data_clicked,
            "on_button_save_clicked": self.on_button_save_clicked,
            "on_button_cancel_clicked": self.on_button_cancel_clicked,
            "on_dialog_cookies_response": self.on_response,
        })
        self.treeview = self.setup_cookie_list()

        if self.cookie_data:
            self.glade.get_widget("text_site").set_text(self.cookie_data["site"])

        # Update cookie data list
        self.update_cookie_values_list()
    def __init__(self, gtkui, cookie_data):
        self.gtkUI = gtkui
        self.cookie_data = cookie_data
        self.glade = Gtk.Builder.new_from_file(get_resource("dialog_cookie.ui"))
        self.glade.connect_signals({
            "on_button_add_cookie_data_clicked": self.on_button_add_cookie_data_clicked,
            "on_button_remove_cookie_data_clicked": self.on_button_remove_cookie_data_clicked,
            "on_button_save_clicked": self.on_button_save_clicked,
            "on_button_cancel_clicked": self.on_button_cancel_clicked,
            "on_dialog_cookies_response": self.on_response,
        })
        self.treeview = self.setup_cookie_list()

        if self.cookie_data:
            self.glade.get_object("text_site").set_text(self.cookie_data["site"])

        # Update cookie data list
        self.update_cookie_values_list()
Exemple #18
0
 def show(self):
     self.glade = gtk.glade.XML(get_resource("dialog_email_message.glade"))
     self.glade.signal_autoconnect({
         "on_button_save_clicked":
         self.on_button_save_clicked,
         "on_button_cancel_clicked":
         self.on_button_cancel_clicked,
         "on_dialog_email_message_response":
         self.on_response,
     })
     # Add data
     if self.message_data is not None:
         self.set_initial_data(self.message_data)
     self.dialog = self.glade.get_widget("dialog_email_message")
     self.dialog.set_transient_for(component.get("Preferences").pref_dialog)
     self.dialog.set_title("Edit Message" if "key" in
                           self.message_data else "Add Message")
     self.dialog.run()
Exemple #19
0
    def setup(self):
        self.glade = gtk.glade.XML(get_resource("dialog_subscription.glade"))
        self.glade.signal_autoconnect({
            "on_txt_regex_include_changed":
            self.on_txt_regex_changed,
            "on_txt_regex_exclude_changed":
            self.on_txt_regex_changed,
            "on_button_cancel_clicked":
            self.on_button_cancel_clicked,
            "on_button_save_clicked":
            self.on_button_save_subscription_clicked,
            "on_button_add_notication_clicked":
            self.on_button_add_notication_clicked,
            "on_button_remove_notication_clicked":
            self.on_button_remove_notication_clicked,
            "on_rssfeed_selected":
            self.on_rssfeed_selected,
            "on_button_fetch_clicked":
            self.on_rssfeed_selected,
            "on_button_last_matched_reset_clicked":
            self.on_button_last_matched_reset_clicked,
            "on_button_last_matched_now_clicked":
            self.on_button_last_matched_now_clicked,
            "on_general_checkbox_toggled":
            self.on_general_checkbox_toggled,
            "on_key_pressed":
            self.on_key_pressed,
        })

        # This is to make testing of the GUI possible (unit tests)
        self.method_perform_rssfeed_selection = self.perform_rssfeed_selection
        self.dialog = self.glade.get_widget("window_subscription")
        self.dialog.set_title(
            "Edit Subscription" if self.editing else "Add Subscription")
        self.setup_rssfeed_combobox()
        self.setup_move_completed_combobox()
        self.setup_download_location_combobox()
        self.setup_messages_combobox()
        self.setup_messages_list()
        self.treeview = self.create_matching_tree()
        self.setup_labels()
        self.set_custom_text_tooltip()
        self.load_subscription_data()
    def setup_gui(self):
        self.glade = Gtk.Builder.new_from_file(get_resource("dialog_subscription.ui"))
        self.glade.connect_signals({
            "on_txt_regex_include_changed": self.on_txt_regex_changed,
            "on_txt_regex_exclude_changed": self.on_txt_regex_changed,
            "on_check_regex_include_toggled": self.on_txt_regex_changed,
            "on_check_regex_exclude_toggled": self.on_txt_regex_changed,
            "on_button_cancel_clicked": self.on_button_cancel_clicked,
            "on_button_destroy_clicked": self.on_button_cancel_clicked,
            "on_button_save_clicked": self.on_button_save_subscription_clicked,
            "on_button_add_notication_clicked": self.on_button_add_notication_clicked,
            "on_button_remove_notication_clicked": self.on_button_remove_notication_clicked,
            "on_rssfeed_selected": self.on_rssfeed_selected,
            "on_button_fetch_clicked": self.on_rssfeed_selected,
            "on_button_last_matched_reset_clicked": self.on_button_last_matched_reset_clicked,
            "on_button_last_matched_now_clicked": self.on_button_last_matched_now_clicked,
            "on_general_checkbox_toggled": self.on_general_checkbox_toggled,
            "on_key_pressed": self.on_key_pressed,
            "on_textview_custom_text_move_cursor": lambda x, y: x,
            "on_panel_matching_move_handle": lambda x, y: x,
            "on_dialog_subscription_response": self.on_dialog_subscription_response_signal,
            "on_txt_filter_include_query_tooltip": self.on_txt_filter_include_query_tooltip,
            "on_txt_filter_exclude_query_tooltip": self.on_txt_filter_exclude_query_tooltip,
        })

        self.dialog = self.get_object("dialog_subscription")
        self.dialog.set_title("Edit Subscription" if self.editing else "Add Subscription")

        self.setup_rssfeed_combobox()
        self.setup_move_completed_combobox()
        self.setup_download_location_combobox()
        self.setup_messages_combobox()
        self.setup_messages_list()
        self.treeview = self.create_matching_tree()
        self.setup_labels()
        self.set_custom_text_tooltip()
    def update_data_from_config(self, config):
        self.subscriptions = config.get('subscriptions', {})
        self.rssfeeds = config.get('rssfeeds', {})
        self.cookies = config.get('cookies', {})
        self.email_messages = config.get('email_messages', {})
        self.email_config = config.get('email_configurations', {})
        self.default_values = config.get('default_values', {})

        # When connecting to a second host, the glade object returns None for all the fields,
        # so reload the glade file here to avoid this problem.
        if self.glade.get_widget("textview_default_message") is None:
            self.glade = gtk.glade.XML(get_resource("yarss_main.glade"))

        # Update GUI
        self.update_subscription_list(self.subscriptions_store)
        self.update_rssfeeds_list(self.rssfeeds_store)
        self.update_cookies_list(self.cookies_store)
        self.update_email_messages_list(self.email_messages_store)

        # Set selection for each treeview
        if self.selected_path_subscriptions and self.subscriptions_treeview.get_selection():
            self.subscriptions_treeview.get_selection().select_path(self.selected_path_subscriptions)

        if self.selected_path_rssfeeds and self.rssfeeds_treeview.get_selection():
            self.rssfeeds_treeview.get_selection().select_path(self.selected_path_rssfeeds)

        if self.selected_path_email_message and self.email_messages_treeview.get_selection():
            self.email_messages_treeview.get_selection().select_path(self.selected_path_email_message)

        if self.selected_path_cookies and self.cookies_treeview.get_selection():
            self.cookies_treeview.get_selection().select_path(self.selected_path_cookies)

        # Email configurations
        send_email_checkbox = self.glade.get_widget("checkbutton_send_email_on_torrent_events")
        from_addr = self.glade.get_widget("txt_email_from")
        smtp_server = self.glade.get_widget("txt_email_server")
        smtp_port = self.glade.get_widget("txt_email_port")
        smtp_username = self.glade.get_widget("txt_email_username")
        smtp_password = self.glade.get_widget("txt_email_password")
        enable_auth = self.glade.get_widget("checkbox_email_enable_authentication")

        default_to_address = self.glade.get_widget("txt_default_to_address")
        default_subject = self.glade.get_widget("txt_default_subject")
        default_message = self.glade.get_widget("textview_default_message")

        default_message = default_message.get_buffer()
        from_addr.set_text(self.email_config["from_address"])
        smtp_server.set_text(self.email_config["smtp_server"])
        smtp_port.set_text(self.email_config["smtp_port"])

        enable_auth.set_active(self.email_config["smtp_authentication"])
        smtp_username.set_text(self.email_config["smtp_username"])
        smtp_password.set_text(self.email_config["smtp_password"])

        default_to_address.set_text(self.email_config["default_email_to_address"])
        default_subject.set_text(self.email_config["default_email_subject"])
        default_message.set_text(self.email_config["default_email_message"])

        # Must be last, since it will cause callback on
        # method on_checkbutton_send_email_on_torrent_events_toggled
        send_email_checkbox.set_active(self.email_config["send_email_on_torrent_events"])
Exemple #22
0
    def update_data_from_config(self, config):
        self.subscriptions = config.get('subscriptions', {})
        self.rssfeeds = config.get('rssfeeds', {})
        self.cookies = config.get('cookies', {})
        self.email_messages = config.get('email_messages', {})
        self.email_config = config.get('email_configurations', {})
        self.default_values = config.get('default_values', {})
        self.general_config = config.get('general', {})

        # When connecting to a second host, the glade object returns None for all the fields,
        # so reload the glade file here to avoid this problem.
        if self.glade.get_object("textview_default_message") is None:
            self.glade = Gtk.Builder.new_from_file(get_resource("yarss_main.ui"))

        # Update GUI
        self.update_subscription_list(self.subscriptions_store)
        self.update_rssfeeds_list(self.rssfeeds_store)
        self.update_cookies_list(self.cookies_store)
        self.update_email_messages_list(self.email_messages_store)

        # Set selection for each treeview
        if self.selected_path_subscriptions and self.subscriptions_treeview.get_selection():
            self.subscriptions_treeview.get_selection().select_path(self.selected_path_subscriptions)

        if self.selected_path_rssfeeds and self.rssfeeds_treeview.get_selection():
            self.rssfeeds_treeview.get_selection().select_path(self.selected_path_rssfeeds)

        if self.selected_path_email_message and self.email_messages_treeview.get_selection():
            self.email_messages_treeview.get_selection().select_path(self.selected_path_email_message)

        if self.selected_path_cookies and self.cookies_treeview.get_selection():
            self.cookies_treeview.get_selection().select_path(self.selected_path_cookies)

        # Email configurations
        send_email_checkbox = self.glade.get_object("checkbutton_send_email_on_torrent_events")
        from_addr = self.glade.get_object("txt_email_from")
        smtp_server = self.glade.get_object("txt_email_server")
        smtp_port = self.glade.get_object("txt_email_port")
        smtp_username = self.glade.get_object("txt_email_username")
        smtp_password = self.glade.get_object("txt_email_password")
        enable_auth = self.glade.get_object("checkbox_email_enable_authentication")

        default_to_address = self.glade.get_object("txt_default_to_address")
        default_subject = self.glade.get_object("txt_default_subject")
        default_message = self.glade.get_object("textview_default_message")

        default_message = default_message.get_buffer()
        from_addr.set_text(self.email_config["from_address"])
        smtp_server.set_text(self.email_config["smtp_server"])
        smtp_port.set_text(self.email_config["smtp_port"])

        enable_auth.set_active(self.email_config["smtp_authentication"])
        smtp_username.set_text(self.email_config["smtp_username"])
        smtp_password.set_text(self.email_config["smtp_password"])

        default_to_address.set_text(self.email_config["default_email_to_address"])
        default_subject.set_text(self.email_config["default_email_subject"])
        default_message.set_text(self.email_config["default_email_message"])

        # Must be last, since it will cause callback on
        # method on_checkbutton_send_email_on_torrent_events_toggled
        send_email_checkbox.set_active(self.email_config["send_email_on_torrent_events"])

        show_log_in_gui = self.general_config.get('show_log_in_gui', True)
        self.gtkui_log.show_log_in_gui = show_log_in_gui
        self.glade.get_object("checkbutton_show_log_messages_gui").set_active(show_log_in_gui)