diff --git a/daemon.py b/daemon.py index b69cc88..073c504 100644 --- a/daemon.py +++ b/daemon.py @@ -1045,6 +1045,40 @@ class ConnectionWizard(dbus.service.Object): return "500: Profile Not Found" #end function ReadWirelessNetworkProfile + @dbus.service.method('org.wicd.daemon.config') + def WriteWindowSize(self, width, height): + """Write the desired default window size""" + config = ConfigParser.ConfigParser() + config.read(self.app_conf) + if config.has_section("Settings"): + config.set("Settings", "window_width", width) + config.set("Settings", "window_height", height) + config.write(open(self.app_conf, "w")) + + @dbus.service.method('org.wicd.daemon.config') + def ReadWindowSize(self): + """Returns a list containing the desired default window size + + Attempts to read the default size from the config file, + and if that fails, returns a default of 605 x 400. + + """ + config = ConfigParser.ConfigParser() + config.read(self.app_conf) + if config.has_section("Settings"): + if config.has_option("Settings", "window_width"): + width = config.get("Settings", "window_width") + else: + width = 605 + if config.has_option("Settings", "window_height"): + height = config.get("Settings", "window_height") + else: + height = 400 + size = [] + size.append(int(width)) + size.append(int(height)) + return size + ############################################# ########## INTERNAL FUNCTIONS ############### ############################################# diff --git a/data/wicd.glade b/data/wicd.glade index e9fe4b5..7d696aa 100644 --- a/data/wicd.glade +++ b/data/wicd.glade @@ -3,8 +3,8 @@ - 580 - 600 + 605 + 400 True Wicd Manager GTK_WIN_POS_CENTER_ALWAYS diff --git a/gui.py b/gui.py index 2c2d0f3..648b293 100644 --- a/gui.py +++ b/gui.py @@ -928,6 +928,11 @@ class appGui: self.is_visible = True self.window.connect('delete_event', self.exit) + size = config.ReadWindowSize() + width = size[0] + height = size[1] + if width > -1 and height > -1: + self.window.resize(int(width), int(height)) gobject.timeout_add(600, self.update_statusbar) gobject.timeout_add(100, self.pulse_progress_bar) @@ -1330,6 +1335,8 @@ class appGui: def exit(self, widget=None, event=None): self.window.hide() self.is_visible = False + [width, height] = self.window.get_size() + config.WriteWindowSize(width, height) while gtk.events_pending(): gtk.main_iteration() return True