Improved appearance and layout of the UserBox

This commit is contained in:
Anna 2010-05-21 16:48:00 -04:00
parent 30a9713d88
commit f86b663668

View File

@ -49,15 +49,15 @@ class TweetPane(gtk.ScrolledWindow):
tweet_box = gtk.VBox() tweet_box = gtk.VBox()
viewport = gtk.Viewport() viewport = gtk.Viewport()
# Build us some labels...
tweet_box.pack_start(self.message)
if self.is_user: if self.is_user:
self.user_box = UserBox() self.user_box = UserBox()
self.user_box.connect('at-clicked', self.on_at_clicked) self.user_box.connect('at-clicked', self.on_at_clicked)
self.user_box.connect('follow-clicked', self.on_follow_clicked) self.user_box.connect('follow-clicked', self.on_follow_clicked)
tweet_box.pack_start(self.user_box) 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): for i in range(0, self.num_entries):
self.tweets.append(TweetBox(self.conversation, self.is_user)) self.tweets.append(TweetBox(self.conversation, self.is_user))
tweet_box.pack_start(self.tweets[i], expand=False) tweet_box.pack_start(self.tweets[i], expand=False)
@ -83,6 +83,9 @@ class TweetPane(gtk.ScrolledWindow):
for tweet in self.tweets: for tweet in self.tweets:
tweet.hide() tweet.hide()
if self.is_user:
self.user_box.hide_widgets()
def update_window(self, statuses): def update_window(self, statuses):
if statuses is None: if statuses is None:
@ -482,6 +485,9 @@ class UserBox(gtk.VBox):
self.user_name = None self.user_name = None
self.following = False self.following = False
self.verified = False self.verified = False
self.info_loaded = False
self.init_widgets() self.init_widgets()
@ -490,14 +496,18 @@ class UserBox(gtk.VBox):
self.avatar = gtk.Image() self.avatar = gtk.Image()
self.avatar.set_padding(5, 5) self.avatar.set_padding(5, 5)
self.follow_button = gtk.Button() 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.follow_label = gtk.Label('You are following this user')
self.verified_label = gtk.Label('Verified account') 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 = gtk.VBox()
text_col.pack_start(self.name_label, expand=False) 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.verified_label, expand=False)
text_col.pack_start(self.follow_label, expand=False)
info_row = gtk.HBox() info_row = gtk.HBox()
info_row.pack_start(self.avatar, expand=False) info_row.pack_start(self.avatar, expand=False)
@ -505,17 +515,15 @@ class UserBox(gtk.VBox):
button_row = gtk.HBox() button_row = gtk.HBox()
button_row.pack_start(self.follow_button, expand=False) 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(info_row, expand=False)
self.pack_start(button_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.follow_button.connect('clicked', self.on_follow_clicked)
self.show_all() self.show_all()
self.verified_label.hide()
self.follow_label.hide()
def update_info(self, user): def update_info(self, user):
@ -536,6 +544,18 @@ class UserBox(gtk.VBox):
else: else:
self.verified_label.hide() 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): def on_follow_clicked(self, event):
if self.following: if self.following:
@ -565,11 +585,22 @@ class UserBox(gtk.VBox):
self.following = following self.following = following
if following: if following:
self.follow_button.set_label('Unfollow') self.follow_button.set_label('Unfollow')
if self.info_loaded:
self.follow_label.show() self.follow_label.show()
else: else:
self.follow_button.set_label('Follow') self.follow_button.set_label('Follow')
self.follow_label.hide() 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 # end class UserBox
# signals for UserBox # signals for UserBox