From 324bd13120c74e43f712e9a333636a2c57e72bb2 Mon Sep 17 00:00:00 2001 From: Anna Date: Mon, 17 May 2010 23:58:45 -0400 Subject: [PATCH] Default to window size from last session, added -n option to suppress. Apparently introduced some weird race condition that is causing start-up segfaults again, but it is very intermittent --- default.glade | 1 + mytwitter.py | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/default.glade b/default.glade index ece8e70..1bb187b 100644 --- a/default.glade +++ b/default.glade @@ -22,6 +22,7 @@ False + diff --git a/mytwitter.py b/mytwitter.py index 719b27c..8bf1d35 100755 --- a/mytwitter.py +++ b/mytwitter.py @@ -13,7 +13,9 @@ class MyTwitter(): """ Display Tweets, post to twitter """ - def __init__(self, config_file): + def __init__(self, config_file, resize): + self.resize = resize + config = ConfigParser.ConfigParser() config.read(os.path.expanduser(config_file)) @@ -82,6 +84,7 @@ class MyTwitter(): self.widget_tree.signal_autoconnect(self) # Get widgets from glade + self.window = self.widget_tree.get_widget('window') 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') @@ -95,6 +98,10 @@ class MyTwitter(): def init_widgets(self): + # Set the main window size + if self.resize and self.db.has_key('width') and self.db.has_key('height'): + self.window.resize(self.db['width'], self.db['height']) + self.context_id = self.status_bar.get_context_id('message') # Manual tweaks to the glade UI, to overcome its limitations @@ -454,15 +461,22 @@ class MyTwitter(): outer_menu_item.show() + + def on_resize(self, widget, event): + self.db['width'] = event.width + self.db['height'] = event.height + + ### end class MyTwitter # main parser = optparse.OptionParser() -parser.add_option('-c' ,'--config', dest="filename", default="~/.mytwitter.conf") +parser.add_option('-c' ,'--config', dest="filename", default="~/.mytwitter.conf", help="read configuration from FILENAME instead of the default ~/.mytwitter.conf") +parser.add_option('-n' ,'--no-resize', dest="resize", action='store_false', default=True, help="use the default window size instead of the size from the last session") (options, args) = parser.parse_args() -my_twitter = MyTwitter(options.filename) +my_twitter = MyTwitter(options.filename, options.resize) gtk.gdk.threads_init() gtk.gdk.threads_enter()