1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-22 22:27:59 +01:00

Added support for resizing the preferences window to any size. Also added support for remembing the size of the preferences window.

This commit is contained in:
imdano
2008-03-24 20:37:46 +00:00
parent ef9b5cc7f3
commit f64b207005
3 changed files with 624 additions and 579 deletions

View File

@@ -1206,34 +1206,52 @@ class ConnectionWizard(dbus.service.Object):
return "100: Loaded Profile"
@dbus.service.method('org.wicd.daemon.config')
def WriteWindowSize(self, width, height):
def WriteWindowSize(self, width, height, win_name):
"""Write the desired default window size"""
if win_name == "main":
height_str = "window_height"
width_str = "window_width"
else:
height_str = "pref_height"
width_str = "pref_width"
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.set("Settings", width_str, width)
config.set("Settings", height_str, height)
config.write(open(self.app_conf, "w"))
@dbus.service.method('org.wicd.daemon.config')
def ReadWindowSize(self):
def ReadWindowSize(self, win_name):
"""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.
"""
if win_name == "main":
default_width = 605
default_height = 400
width_str = "window_width"
height_str = "window_height"
else:
default_width = 125
default_height = 590
width_str = "pref_width"
height_str = "pref_height"
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")
if config.has_option("Settings", width_str):
width = config.get("Settings", width_str)
else:
width = 605
if config.has_option("Settings", "window_height"):
height = config.get("Settings", "window_height")
width = default_width
if config.has_option("Settings", height_str):
height = config.get("Settings", height_str)
else:
height = 400
height = default_height
size = []
size.append(int(width))
size.append(int(height))

View File

@@ -446,16 +446,31 @@
</widget>
<widget class="GtkDialog" id="pref_dialog">
<property name="title" translatable="yes">Preferences</property>
<property name="default_width">125</property>
<property name="default_height">590</property>
<property name="icon">.</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox4">
<property name="visible">True</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<child>
<widget class="GtkViewport" id="viewport2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="resize_mode">GTK_RESIZE_QUEUE</property>
<child>
<widget class="GtkNotebook" id="notebook2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkVBox" id="vbox6">
<widget class="GtkVBox" id="vbox5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
@@ -480,7 +495,7 @@
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox16">
<widget class="GtkHBox" id="hbox10">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="pref_wifi_label">
@@ -510,7 +525,7 @@
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox18">
<widget class="GtkHBox" id="hbox11">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="pref_wired_label">
@@ -554,7 +569,7 @@
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox20">
<widget class="GtkHBox" id="hbox12">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="pref_dns1_label">
@@ -588,7 +603,7 @@
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox22">
<widget class="GtkHBox" id="hbox13">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="pref_dns2_label">
@@ -622,7 +637,7 @@
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox24">
<widget class="GtkHBox" id="hbox14">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="pref_dns3_label">
@@ -715,7 +730,7 @@
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator5">
<widget class="GtkHSeparator" id="hseparator3">
<property name="width_request">2</property>
<property name="height_request">8</property>
<property name="visible">True</property>
@@ -797,11 +812,11 @@
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox7">
<widget class="GtkVBox" id="vbox6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkVBox" id="vbox8">
<widget class="GtkVBox" id="vbox7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
@@ -878,7 +893,7 @@
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator6">
<widget class="GtkHSeparator" id="hseparator4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
@@ -889,7 +904,7 @@
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox9">
<widget class="GtkVBox" id="vbox8">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">5</property>
@@ -952,7 +967,7 @@
</packing>
</child>
<child>
<widget class="GtkHSeparator" id="hseparator7">
<widget class="GtkHSeparator" id="hseparator5">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
@@ -963,7 +978,7 @@
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox10">
<widget class="GtkVBox" id="vbox9">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
@@ -1041,6 +1056,10 @@
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
@@ -1050,7 +1069,7 @@
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="cancelbutton1">
<widget class="GtkButton" id="cancelbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>
@@ -1060,7 +1079,7 @@
</widget>
</child>
<child>
<widget class="GtkButton" id="okbutton1">
<widget class="GtkButton" id="okbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="can_default">True</property>

12
gui.py
View File

@@ -1167,6 +1167,7 @@ class appGui:
self.is_visible = True
self.pulse_active = False
self.standalone = standalone
self.wpadrivercombo = None
self.window.connect('delete_event', self.exit)
@@ -1179,7 +1180,7 @@ class appGui:
else:
self.wTree.get_widget("iface_menu_enable_wired").hide()
size = config.ReadWindowSize()
size = config.ReadWindowSize("main")
width = size[0]
height = size[1]
if width > -1 and height > -1:
@@ -1255,6 +1256,11 @@ class appGui:
""" Displays a general settings dialog. """
dialog = self.wTree.get_widget("pref_dialog")
dialog.set_title(language['preferences'])
size = config.ReadWindowSize("pref")
width = size[0]
height = size[1]
if width > -1 and height > -1:
dialog.resize(int(width), int(height))
wiredcheckbox = self.wTree.get_widget("pref_always_check")
wiredcheckbox.set_label(language['wired_always_on'])
wiredcheckbox.set_active(wired.GetAlwaysShowWiredInterface())
@@ -1444,6 +1450,8 @@ class appGui:
daemon.SetFlushTool(flush_tool)
dialog.hide()
[width, height] = dialog.get_size()
config.WriteWindowSize(width, height, "pref")
def set_label(self, glade_str, label):
""" Sets the label for the given widget in wicd.glade. """
@@ -1903,7 +1911,7 @@ class appGui:
"""
self.window.hide()
[width, height] = self.window.get_size()
config.WriteWindowSize(width, height)
config.WriteWindowSize(width, height, "main")
if self.standalone:
self.window.destroy()