From f86b663668fa4eabf9c4a3257b6ee8bd7013d04b Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 21 May 2010 16:48:00 -0400 Subject: [PATCH] Improved appearance and layout of the UserBox --- twitterwidgets.py | 53 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/twitterwidgets.py b/twitterwidgets.py index 085bbe1..6e26038 100644 --- a/twitterwidgets.py +++ b/twitterwidgets.py @@ -49,15 +49,15 @@ class TweetPane(gtk.ScrolledWindow): tweet_box = gtk.VBox() viewport = gtk.Viewport() - # Build us some labels... - tweet_box.pack_start(self.message) - if self.is_user: self.user_box = UserBox() self.user_box.connect('at-clicked', self.on_at_clicked) self.user_box.connect('follow-clicked', self.on_follow_clicked) tweet_box.pack_start(self.user_box) + tweet_box.pack_start(self.message) + + # Build us some labels... for i in range(0, self.num_entries): self.tweets.append(TweetBox(self.conversation, self.is_user)) tweet_box.pack_start(self.tweets[i], expand=False) @@ -83,6 +83,9 @@ class TweetPane(gtk.ScrolledWindow): for tweet in self.tweets: tweet.hide() + if self.is_user: + self.user_box.hide_widgets() + def update_window(self, statuses): if statuses is None: @@ -482,6 +485,9 @@ class UserBox(gtk.VBox): self.user_name = None self.following = False self.verified = False + + self.info_loaded = False + self.init_widgets() @@ -490,14 +496,18 @@ class UserBox(gtk.VBox): self.avatar = gtk.Image() self.avatar.set_padding(5, 5) self.follow_button = gtk.Button() - at_button = gtk.Button('@') + self.at_button = gtk.Button('@') self.follow_label = gtk.Label('You are following this user') self.verified_label = gtk.Label('Verified account') + + self.name_label.set_alignment(0.0, 0.0) + self.follow_label.set_alignment(0.0, 0.0) + self.verified_label.set_alignment(0.0, 0.0) text_col = gtk.VBox() text_col.pack_start(self.name_label, expand=False) - text_col.pack_start(self.follow_label, expand=False) text_col.pack_start(self.verified_label, expand=False) + text_col.pack_start(self.follow_label, expand=False) info_row = gtk.HBox() info_row.pack_start(self.avatar, expand=False) @@ -505,18 +515,16 @@ class UserBox(gtk.VBox): button_row = gtk.HBox() button_row.pack_start(self.follow_button, expand=False) - button_row.pack_start(at_button, expand=False) + button_row.pack_start(self.at_button, expand=False) self.pack_start(info_row, expand=False) self.pack_start(button_row, expand=False) - at_button.connect('clicked', self.on_at_clicked) + self.at_button.connect('clicked', self.on_at_clicked) self.follow_button.connect('clicked', self.on_follow_clicked) self.show_all() - self.verified_label.hide() - self.follow_label.hide() - + def update_info(self, user): self.user_name = user.screen_name @@ -536,6 +544,18 @@ class UserBox(gtk.VBox): else: self.verified_label.hide() + if self.following: + self.follow_label.show() + else: + self.follow_label.hide() + + self.name_label.show() + self.avatar.show() + self.at_button.show() + self.follow_button.show() + + self.info_loaded = True + def on_follow_clicked(self, event): if self.following: @@ -565,11 +585,22 @@ class UserBox(gtk.VBox): self.following = following if following: self.follow_button.set_label('Unfollow') - self.follow_label.show() + if self.info_loaded: + self.follow_label.show() else: self.follow_button.set_label('Follow') self.follow_label.hide() + + # Hide widgets until update_user_info is done + def hide_widgets(self): + self.at_button.hide() + self.follow_button.hide() + self.follow_label.hide() + self.verified_label.hide() + self.name_label.hide() + self.avatar.hide() + # end class UserBox # signals for UserBox