Beispiel #1
0
    def do_activate(self, _):
        # birdie is not activated
        if not self.window:
            # widgets
            self.home_tweet_list = TweetList()
            self.activity_list = TweetList()
            self.dm_inbox_list = TweetList()
            self.dm_outbox_list = TweetList()
            self.tweets_list = TweetList()
            self.favorites_list = TweetList()
            self.search_list = TweetList()
            self.users_list = TweetList()

            # start twitter.com availability thread
            self.network = Network()
            self.network.connect_signal("twitter-down", self.twitter_down)
            self.network.connect_signal("twitter-up", self.twitter_up)
            self.network.start()

            # start downloader thread
            self.downloader = Download()
            self.downloader.start()

            # Initialize notification manager
            self.notification = NotificationManager()

            # initialize settings
            self.settings = Settings()
            self.tweet_count = self.settings.get('tweet_count')

            # start datetime updater thread
            self.update_tl_thread = Thread(target=self.update_datetimes,
                                           args=(60, ))
            self.update_tl_thread.daemon = True

            # initialize the top level window
            self.window = MainWindow(self.settings)
            self.window.welcome.connect_signal(
                "account-added", lambda x, y:
                (self.save_new_account(x, y), self.on_initialized(x, y)))
            self.add_window(self.window)

            # connect exit signal
            self.window.connect_signal("exit", self.on_exit)

            # status icon object
            if self.settings.get("use_status_icon") == "true":
                self.tray = StatusIcon()
                self.tray.connect_signal("new-tweet-compose",
                                         self.on_new_tweet_composer)
                self.tray.connect_signal("toggle-window-visibility",
                                         self.window.toggle_visibility)
                self.tray.connect_signal("on-exit", self.window.on_exit_event)

            # hide, if settings indicate that birdie should start minimized
            if self.settings.get("start_minimized") == "true":
                self.window.hide()

            # add lists to scrolled views
            self.window.home_scrolled.add(self.home_tweet_list)
            self.window.activity_scrolled.add(self.activity_list)
            self.window.dm_inbox_scrolled.add(self.dm_inbox_list)
            self.window.dm_outbox_scrolled.add(self.dm_outbox_list)
            self.window.tweets_scrolled.add(self.tweets_list)
            self.window.favorites_scrolled.add(self.favorites_list)
            self.window.search_scrolled.add(self.search_list)
            self.window.users_scrolled.add(self.users_list)

            self.window.users_box.connect_signal("follow", self.on_follow_th)
            self.window.users_box.connect_signal("unfollow",
                                                 self.on_unfollow_th)

            # load accounts info
            self.accounts = load_pickle(BIRDIE_LOCAL_SHARE_PATH +
                                        "accounts.obj")
            self.window.add_account_menu(self.accounts,
                                         self.set_active_account)

            for account in self.accounts:
                if account.active:
                    self.active_account = account
                    self.on_initialized(self.active_account.token,
                                        self.active_account.secret)

            # load cached users
            self.users = load_users(BIRDIE_LOCAL_SHARE_PATH + "users.obj")

            # start thread to update timedates as daemon
            self.update_tl_thread.start()

        # if birdie is already activated
        self.window.present()

        for argl in self.args:
            if not hasattr(argl, 'url'):
                continue
            for arg in argl.url:
                if arg:
                    if "birdie://user/" in arg:
                        user = arg.replace("birdie://user/", "")
                        if "/" in user:
                            user = user.replace("/", "")
                        if "@" in user:
                            user = user.replace("@", "")
                        self.show_profile(user)
                    elif "birdie://hashtag/" in arg:
                        hashtag = arg.replace("birdie://hashtag/", "")
                        if "/" in hashtag:
                            hashtag = hashtag.replace("/", "")
                        if "" in hashtag:
                            hashtag = hashtag.replace("%23", "")
                        self.on_search(None, "#" + hashtag)