Esempio n. 1
0
    def on_signin(self, widget):
        """

        :param widget:
        """
        auth = OAuth()
        webbrowser.open(auth.get_oauth_url(), new=2)
        pin = get_input(widget.get_toplevel(), _("Enter PIN"))
        #
        if auth.get_tokens(pin):
            self.emit_signal_with_args(
                "account-added", (auth.oauth_token, auth.oauth_token_secret))
        else:
            error_dialog(widget.get_toplevel(), _("Error signing in"),
                         _("Invalid Twitter credentials. Please, try again."))
Esempio n. 2
0
    def on_signin(self, widget):
        """

        :param widget:
        """
        auth = OAuth()
        webbrowser.open(auth.get_oauth_url(), new=2)
        pin = get_input(widget.get_toplevel(), _("Enter PIN"))
        #
        if auth.get_tokens(pin):
            self.emit_signal_with_args(
                "account-added", (auth.oauth_token, auth.oauth_token_secret))
        else:
            error_dialog(widget.get_toplevel(), _("Error signing in"),
                         _("Invalid Twitter credentials. Please, try again."))
Esempio n. 3
0
    def on_search_cb(self, data, txt):
        if len(data['statuses']):
            data = data['statuses']

            for x in range(len(data)):
                self.on_new_search_received(data[x], False)

            index = len(data) - 1

            if index >= 0:
                self.search_list.oldest_id = data[index]['id']
                self.last_search_txt = txt
        else:
            GLib.idle_add(lambda: error_dialog(self.window, _("Searching"),
                                               _("No more results.")))
Esempio n. 4
0
    def on_search_cb(self, data, txt):
        if len(data['statuses']):
            data = data['statuses']

            for x in range(len(data)):
                self.on_new_search_received(data[x], False)

            index = len(data) - 1

            if index >= 0:
                self.search_list.oldest_id = data[index]['id']
                self.last_search_txt = txt
        else:
            GLib.idle_add(lambda: error_dialog(self.window,
                                               _("Searching"),
                                               _("No more results.")))
Esempio n. 5
0
    def on_initialized(self, oauth_token,
                       oauth_token_secret, connect_signals=True):
        """
        Get threaded timelines and initialize the main streamer
        :param oauth_token: str
        :param oauth_token_secret: str
        :return:
        """
        try:
            self.twitter = Twitter(oauth_token, oauth_token_secret)
        except TwythonError as e:
            error_dialog(self.window, "Twitter error", str(e))
            self.twitter = None
            self.home_stream_thread = None
            return

        self.update_account_in_file()

        if connect_signals:
            # timelines
            self.home_tweet_list.more.connect(
                "clicked", self.get_home_timeline_th)
            self.activity_list.more.connect(
                "clicked", self.get_mentions_th)
            self.dm_inbox_list.more.connect("clicked", self.get_dm_th)
            self.dm_outbox_list.more.connect("clicked", self.get_dm_th)
            self.tweets_list.more.connect(
                "clicked", self.get_tweets_th,
                self.active_account.screen_name)
            self.favorites_list.more.connect(
                "clicked", self.get_favorites_th,
                self.active_account.screen_name)
            self.search_list.more.connect("clicked", self.on_search)
            self.users_more_tweets = self.users_list.more.connect(
                "clicked", self.get_tweets_th, None, self.users_list)

            # actions
            self.window.new_tweet.connect(
                "clicked", self.on_new_tweet_composer)
            self.window.connect_signal("search", self.on_search)

        if self.twitter.authenticated_user and self.active_account:
            # set profile
            GLib.idle_add(lambda: self.window.user_box.set(self.twitter.authenticated_user,
                                                        self.active_account))

            # get a fresh home timeline, before firing up the streamer
            self.get_home_timeline_th(None)

            self.home_stream_thread = self.init_streamer(
                self.active_account.token, self.active_account.secret)

            # get mentions
            self.get_mentions_th(None)

            # get dm
            self.get_dm_th(None)
            self.get_dm_outbox_th(None)

            # get profile
            self.get_tweets_th(None, self.active_account.screen_name)
            self.get_favorites_th(None, self.active_account.screen_name)

            self.window.stack.set_visible_child_name('home')
Esempio n. 6
0
 def twitter_error(self, e):
     GLib.idle_add(lambda: error_dialog(self.window,
                   "Twitter error", e.message))
Esempio n. 7
0
    def on_initialized(self,
                       oauth_token,
                       oauth_token_secret,
                       connect_signals=True):
        """
        Get threaded timelines and initialize the main streamer
        :param oauth_token: str
        :param oauth_token_secret: str
        :return:
        """
        try:
            self.twitter = Twitter(oauth_token, oauth_token_secret)
        except TwythonError as e:
            error_dialog(self.window, "Twitter error", str(e))
            self.twitter = None
            self.home_stream_thread = None
            return

        self.update_account_in_file()

        if connect_signals:
            # timelines
            self.home_tweet_list.more.connect("clicked",
                                              self.get_home_timeline_th)
            self.activity_list.more.connect("clicked", self.get_mentions_th)
            self.dm_inbox_list.more.connect("clicked", self.get_dm_th)
            self.dm_outbox_list.more.connect("clicked", self.get_dm_th)
            self.tweets_list.more.connect("clicked", self.get_tweets_th,
                                          self.active_account.screen_name)
            self.favorites_list.more.connect("clicked", self.get_favorites_th,
                                             self.active_account.screen_name)
            self.search_list.more.connect("clicked", self.on_search)
            self.users_more_tweets = self.users_list.more.connect(
                "clicked", self.get_tweets_th, None, self.users_list)

            # actions
            self.window.new_tweet.connect("clicked",
                                          self.on_new_tweet_composer)
            self.window.connect_signal("search", self.on_search)

        if self.twitter.authenticated_user and self.active_account:
            # set profile
            GLib.idle_add(lambda: self.window.user_box.set(
                self.twitter.authenticated_user, self.active_account))

            # get a fresh home timeline, before firing up the streamer
            self.get_home_timeline_th(None)

            self.home_stream_thread = self.init_streamer(
                self.active_account.token, self.active_account.secret)

            # get mentions
            self.get_mentions_th(None)

            # get dm
            self.get_dm_th(None)
            self.get_dm_outbox_th(None)

            # get profile
            self.get_tweets_th(None, self.active_account.screen_name)
            self.get_favorites_th(None, self.active_account.screen_name)

            self.window.stack.set_visible_child_name('home')
Esempio n. 8
0
 def twitter_error(self, e):
     GLib.idle_add(
         lambda: error_dialog(self.window, "Twitter error", e.message))