Started adding tabbed panes so multiple feeds / filters can be seen... currently, just managed to break everything
This commit is contained in:
parent
589879686f
commit
bb262a7970
|
@ -77,6 +77,14 @@
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkMenuItem" id="view_menu">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">_View</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
</widget>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="padding">0</property>
|
<property name="padding">0</property>
|
||||||
|
@ -86,22 +94,17 @@
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkScrolledWindow" id="tweet_view">
|
<widget class="GtkNotebook" id="tweet_notebook">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
|
<property name="show_tabs">True</property>
|
||||||
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
|
<property name="show_border">True</property>
|
||||||
<property name="shadow_type">GTK_SHADOW_NONE</property>
|
<property name="tab_pos">GTK_POS_TOP</property>
|
||||||
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
|
<property name="scrollable">True</property>
|
||||||
<signal name="grab_focus" handler="set_tweets_read" last_modification_time="Mon, 12 Apr 2010 01:09:46 GMT"/>
|
<property name="enable_popup">True</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkViewport" id="viewport1">
|
<widget class="GtkVBox" id="vbox1">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="shadow_type">GTK_SHADOW_IN</property>
|
|
||||||
|
|
||||||
<child>
|
|
||||||
<widget class="GtkVBox" id="tweet_box">
|
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="homogeneous">False</property>
|
<property name="homogeneous">False</property>
|
||||||
<property name="spacing">0</property>
|
<property name="spacing">0</property>
|
||||||
|
@ -110,8 +113,33 @@
|
||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="tab_expand">False</property>
|
||||||
|
<property name="tab_fill">True</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="home_tab_label">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="label" translatable="yes">Home</property>
|
||||||
|
<property name="use_underline">False</property>
|
||||||
|
<property name="use_markup">False</property>
|
||||||
|
<property name="justify">GTK_JUSTIFY_LEFT</property>
|
||||||
|
<property name="wrap">False</property>
|
||||||
|
<property name="selectable">False</property>
|
||||||
|
<property name="xalign">0.5</property>
|
||||||
|
<property name="yalign">0.5</property>
|
||||||
|
<property name="xpad">0</property>
|
||||||
|
<property name="ypad">0</property>
|
||||||
|
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
|
||||||
|
<property name="width_chars">-1</property>
|
||||||
|
<property name="single_line_mode">False</property>
|
||||||
|
<property name="angle">0</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="type">tab</property>
|
||||||
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
|
116
mytwitter.py
116
mytwitter.py
|
@ -25,6 +25,7 @@ class MyTwitter():
|
||||||
if self.refresh_time < 10:
|
if self.refresh_time < 10:
|
||||||
self.refresh_time = 10
|
self.refresh_time = 10
|
||||||
|
|
||||||
|
self.tweet_panes = []
|
||||||
self.tweets = []
|
self.tweets = []
|
||||||
self.list = None
|
self.list = None
|
||||||
self.reply_id = None
|
self.reply_id = None
|
||||||
|
@ -45,20 +46,21 @@ class MyTwitter():
|
||||||
|
|
||||||
|
|
||||||
def init_widgets(self):
|
def init_widgets(self):
|
||||||
|
# Get widgets from glade
|
||||||
self.list_select = self.widget_tree.get_widget('list_select')
|
self.list_select = self.widget_tree.get_widget('list_select')
|
||||||
self.tweet_box = self.widget_tree.get_widget('tweet_box')
|
self.tweet_notebook = self.widget_tree.get_widget('tweet_notebook')
|
||||||
|
self.view_menu = self.widget_tree.get_widget('view_menu')
|
||||||
self.update_entry = self.widget_tree.get_widget('update_entry')
|
self.update_entry = self.widget_tree.get_widget('update_entry')
|
||||||
self.update_count = self.widget_tree.get_widget('update_count')
|
self.update_count = self.widget_tree.get_widget('update_count')
|
||||||
self.status_bar = self.widget_tree.get_widget('status_bar')
|
self.status_bar = self.widget_tree.get_widget('status_bar')
|
||||||
self.context_id = self.status_bar.get_context_id('message')
|
self.context_id = self.status_bar.get_context_id('message')
|
||||||
|
|
||||||
# Build us some labels...
|
self.tweet_notebook.remove_page(0) # kill the page that glade makes us have
|
||||||
for i in range(0, self.num_entries):
|
|
||||||
self.tweets.append(TweetBox())
|
# Add the Home tab to the notebook
|
||||||
self.tweet_box.pack_start(self.tweets[i])
|
self.tweet_panes.append(TweetPane('Home', self))
|
||||||
self.tweets[i].connect('reply', self.on_reply)
|
self.tweet_notebook.append_page(self.tweet_panes[0])
|
||||||
self.tweets[i].connect('retweet', self.on_retweet)
|
self.tweet_notebook.set_tab_label_text(self.tweet_panes[0], 'Home')
|
||||||
self.tweet_box.show_all()
|
|
||||||
|
|
||||||
# Fill the ComboBox with entries
|
# Fill the ComboBox with entries
|
||||||
self.list_select.append_text('@' + self.username)
|
self.list_select.append_text('@' + self.username)
|
||||||
|
@ -84,30 +86,7 @@ class MyTwitter():
|
||||||
else:
|
else:
|
||||||
statuses = self.api.GetListStatuses(self.list, per_page=self.num_entries)
|
statuses = self.api.GetListStatuses(self.list, per_page=self.num_entries)
|
||||||
|
|
||||||
# If this is our first load of this list, don't treat anything as new!
|
self.tweet_panes[0].update_window(statuses)
|
||||||
if self.last_tweet_read is None:
|
|
||||||
self.last_tweet_read = statuses[0].id
|
|
||||||
|
|
||||||
# Keep count of the new tweets for posting a status message
|
|
||||||
num_new_tweets = 0
|
|
||||||
|
|
||||||
for i in range(0, self.num_entries):
|
|
||||||
read = True
|
|
||||||
if i < len(statuses):
|
|
||||||
if statuses[i].id > self.last_tweet_read:
|
|
||||||
num_new_tweets += 1
|
|
||||||
read = False
|
|
||||||
self.tweets[i].set_status(statuses[i], read)
|
|
||||||
else:
|
|
||||||
self.tweets[i].clear_status()
|
|
||||||
|
|
||||||
self.latest_tweet = statuses[0].id
|
|
||||||
self.status_bar.pop(self.context_id)
|
|
||||||
if num_new_tweets > 0:
|
|
||||||
status_text = str(num_new_tweets) + ' new tweet'
|
|
||||||
if num_new_tweets > 1:
|
|
||||||
status_text += 's'
|
|
||||||
self.status_bar.push(self.context_id, status_text)
|
|
||||||
|
|
||||||
|
|
||||||
def update_window_callback(self, widget):
|
def update_window_callback(self, widget):
|
||||||
|
@ -165,9 +144,82 @@ class MyTwitter():
|
||||||
print 'debug: set_tweets_read()'
|
print 'debug: set_tweets_read()'
|
||||||
self.last_tweet_read = self.latest_tweet
|
self.last_tweet_read = self.latest_tweet
|
||||||
|
|
||||||
|
|
||||||
|
def set_tweets_read_callback(self, event):
|
||||||
|
self.set_tweets_read()
|
||||||
|
|
||||||
### end class MyTwitter
|
### end class MyTwitter
|
||||||
|
|
||||||
|
|
||||||
|
class TweetPane(gtk.ScrolledWindow):
|
||||||
|
'''
|
||||||
|
Box that holds all the TweetBoxes for a given feed
|
||||||
|
|
||||||
|
This box will not update itself, the parent should do that.
|
||||||
|
|
||||||
|
It will connect num_entries listeners to its parent's on_reply() and on_retweet()
|
||||||
|
|
||||||
|
It also gets some data from its parent, including num_entries
|
||||||
|
'''
|
||||||
|
|
||||||
|
def __init__(self, list_name, mytwitter):
|
||||||
|
gtk.ScrolledWindow.__init__(self)
|
||||||
|
|
||||||
|
self.list_name = list_name
|
||||||
|
self.mytwitter = mytwitter
|
||||||
|
|
||||||
|
# These handle determining which tweets are unread
|
||||||
|
self.last_tweet_read = None
|
||||||
|
self.latest_tweet = None
|
||||||
|
|
||||||
|
self.tweets = []
|
||||||
|
|
||||||
|
self.init_widgets()
|
||||||
|
|
||||||
|
|
||||||
|
def init_widgets(self):
|
||||||
|
tweet_box = gtk.VBox()
|
||||||
|
viewport = gtk.Viewport()
|
||||||
|
|
||||||
|
# Build us some labels...
|
||||||
|
for i in range(0, self.mytwitter.num_entries):
|
||||||
|
self.tweets.append(TweetBox())
|
||||||
|
tweet_box.pack_start(self.tweets[i])
|
||||||
|
self.tweets[i].connect('reply', self.mytwitter.on_reply)
|
||||||
|
self.tweets[i].connect('retweet', self.mytwitter.on_retweet)
|
||||||
|
tweet_box.show_all()
|
||||||
|
|
||||||
|
viewport.add(tweet_box)
|
||||||
|
self.add(viewport)
|
||||||
|
self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
|
||||||
|
|
||||||
|
|
||||||
|
def update_window(self, statuses):
|
||||||
|
# If this is our first load of this list, don't treat anything as new!
|
||||||
|
if self.last_tweet_read is None:
|
||||||
|
self.last_tweet_read = statuses[0].id
|
||||||
|
|
||||||
|
# Keep count of the new tweets for posting a status message
|
||||||
|
num_new_tweets = 0
|
||||||
|
|
||||||
|
for i in range(0, self.mytwitter.num_entries):
|
||||||
|
read = True
|
||||||
|
if i < len(statuses):
|
||||||
|
if statuses[i].id > self.last_tweet_read:
|
||||||
|
num_new_tweets += 1
|
||||||
|
read = False
|
||||||
|
self.tweets[i].set_status(statuses[i], read)
|
||||||
|
else:
|
||||||
|
self.tweets[i].clear_status()
|
||||||
|
|
||||||
|
self.latest_tweet = statuses[0].id
|
||||||
|
|
||||||
|
if num_new_tweets > 0:
|
||||||
|
pass # fixme: change the label here, or maybe in mytwitter?
|
||||||
|
|
||||||
|
### end class TweetPane
|
||||||
|
|
||||||
|
|
||||||
class TweetBox(gtk.VBox):
|
class TweetBox(gtk.VBox):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
Reference in New Issue
Block a user