Bound Ctrl+W to close the current pane
This commit is contained in:
parent
e605e5333f
commit
2ae8eb11e6
|
@ -21,6 +21,7 @@
|
||||||
<property name="focus_on_map">True</property>
|
<property name="focus_on_map">True</property>
|
||||||
<property name="urgency_hint">False</property>
|
<property name="urgency_hint">False</property>
|
||||||
<signal name="hide" handler="gtk_main_quit" last_modification_time="Fri, 09 Apr 2010 03:40:14 GMT"/>
|
<signal name="hide" handler="gtk_main_quit" last_modification_time="Fri, 09 Apr 2010 03:40:14 GMT"/>
|
||||||
|
<signal name="key_press_event" handler="global_key_press_handler" last_modification_time="Fri, 16 Apr 2010 15:35:22 GMT"/>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkVBox" id="main_box">
|
<widget class="GtkVBox" id="main_box">
|
||||||
|
@ -61,6 +62,7 @@
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="label" translatable="yes">_View</property>
|
<property name="label" translatable="yes">_View</property>
|
||||||
<property name="use_underline">True</property>
|
<property name="use_underline">True</property>
|
||||||
|
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkMenu" id="view_menu">
|
<widget class="GtkMenu" id="view_menu">
|
||||||
</widget>
|
</widget>
|
||||||
|
|
19
mytwitter.py
19
mytwitter.py
|
@ -167,7 +167,7 @@ class MyTwitter():
|
||||||
|
|
||||||
# Remove one of the views from the tweet notebook.
|
# Remove one of the views from the tweet notebook.
|
||||||
# Called when the close button is clicked on one of the views
|
# Called when the close button is clicked on one of the views
|
||||||
def remove_view(self, event, name):
|
def remove_view(self, name):
|
||||||
for i in range(self.tweet_notebook.get_n_pages()):
|
for i in range(self.tweet_notebook.get_n_pages()):
|
||||||
pane = self.tweet_notebook.get_nth_page(i)
|
pane = self.tweet_notebook.get_nth_page(i)
|
||||||
if (pane.get_list_name() == name):
|
if (pane.get_list_name() == name):
|
||||||
|
@ -175,6 +175,10 @@ class MyTwitter():
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
def remove_view_callback(self, event, name):
|
||||||
|
self.remove_view(name)
|
||||||
|
|
||||||
|
|
||||||
def add_to_notebook(self, name, single_tweet=None):
|
def add_to_notebook(self, name, single_tweet=None):
|
||||||
# If it already exists, don't add it, just switch to it
|
# If it already exists, don't add it, just switch to it
|
||||||
for i in range(self.tweet_notebook.get_n_pages()):
|
for i in range(self.tweet_notebook.get_n_pages()):
|
||||||
|
@ -197,7 +201,7 @@ class MyTwitter():
|
||||||
following = self.check_following(name)
|
following = self.check_following(name)
|
||||||
new_pane = TweetPane(name, num_entries=self.num_entries, single_tweet=single_tweet, is_user=is_user, following=following)
|
new_pane = TweetPane(name, num_entries=self.num_entries, single_tweet=single_tweet, is_user=is_user, following=following)
|
||||||
self.tweet_notebook.append_page_menu(new_pane, new_pane.get_tab_label(), gtk.Label(name))
|
self.tweet_notebook.append_page_menu(new_pane, new_pane.get_tab_label(), gtk.Label(name))
|
||||||
new_pane.get_tab_label().connect('close-clicked', self.remove_view, name)
|
new_pane.get_tab_label().connect('close-clicked', self.remove_view_callback, name)
|
||||||
new_pane.connect('tweet-reply', self.on_reply)
|
new_pane.connect('tweet-reply', self.on_reply)
|
||||||
new_pane.connect('tweet-retweet', self.on_retweet)
|
new_pane.connect('tweet-retweet', self.on_retweet)
|
||||||
new_pane.connect('tweet-in-reply-to', self.on_reply_to)
|
new_pane.connect('tweet-in-reply-to', self.on_reply_to)
|
||||||
|
@ -285,6 +289,17 @@ class MyTwitter():
|
||||||
self.add_to_notebook('@' + user_name)
|
self.add_to_notebook('@' + user_name)
|
||||||
|
|
||||||
|
|
||||||
|
def global_key_press_handler(self, widget, event):
|
||||||
|
keyname = gtk.gdk.keyval_name(event.keyval)
|
||||||
|
if keyname == 'w' and event.state & gtk.gdk.CONTROL_MASK:
|
||||||
|
self.close_current_tab()
|
||||||
|
|
||||||
|
|
||||||
|
def close_current_tab(self):
|
||||||
|
current_pane = self.tweet_notebook.get_nth_page(self.tweet_notebook.get_current_page())
|
||||||
|
self.remove_view(current_pane.get_list_name())
|
||||||
|
|
||||||
|
|
||||||
### end class MyTwitter
|
### end class MyTwitter
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
|
|
||||||
|
|
||||||
def init_widgets(self):
|
def init_widgets(self):
|
||||||
self.tab_label.connect('label_clicked', self.set_tweets_read_callback)
|
self.tab_label.connect('label-clicked', self.set_tweets_read_callback)
|
||||||
|
|
||||||
tweet_box = gtk.VBox()
|
tweet_box = gtk.VBox()
|
||||||
viewport = gtk.Viewport()
|
viewport = gtk.Viewport()
|
||||||
|
@ -59,7 +59,7 @@ class TweetPane(gtk.ScrolledWindow):
|
||||||
|
|
||||||
# Several different actions should mark the tweets as 'read'
|
# Several different actions should mark the tweets as 'read'
|
||||||
self.connect('focus', self.set_tweets_read_callback)
|
self.connect('focus', self.set_tweets_read_callback)
|
||||||
viewport.connect('button_press_event', self.set_tweets_read_callback)
|
viewport.connect('button-press-event', self.set_tweets_read_callback)
|
||||||
self.connect('scroll-event', self.set_tweets_read_callback)
|
self.connect('scroll-event', self.set_tweets_read_callback)
|
||||||
self.connect('scroll-child', self.set_tweets_read_callback)
|
self.connect('scroll-child', self.set_tweets_read_callback)
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user