1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-19 20:38:00 +01:00

Don't store useless variables inside configfiles

This commit is contained in:
David Paleino
2011-08-07 22:16:36 +02:00
parent e10e1e9b48
commit 1797845a12
8 changed files with 20 additions and 124 deletions

View File

@@ -151,12 +151,6 @@ class appGui(object):
self.wTree = gtk.Builder()
self.wTree.add_from_file(gladefile)
self.window = self.wTree.get_object("window1")
size = daemon.ReadWindowSize("main")
width = size[0]
height = size[1]
if width > -1 and height > -1:
self.window.resize(int(width), int(height))
else:
width = int(gtk.gdk.screen_width() / 2)
if width > 530:
width = 530
@@ -772,7 +766,6 @@ class appGui(object):
'org.wicd.daemon')
[width, height] = self.window.get_size()
try:
daemon.WriteWindowSize(width, height, "main")
daemon.SetGUIOpen(False)
except DBusException:
pass

View File

@@ -68,7 +68,6 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.set_default_size()
self.connect('show', lambda *a, **k: self.set_default_size())
self.connect('hide', lambda *a, **k: self.write_size())
# Set up the Advanced Settings Dialog.
self.txt_ip = LabelEntry(language['ip'])
@@ -141,10 +140,6 @@ class AdvancedSettingsDialog(gtk.Dialog):
def set_default_size(self):
width, height = daemon.ReadWindowSize('netprop')
if width > -1 and height > -1:
self.resize(int(width), int(height))
else:
width, height = self.get_size()
s_height = gtk.gdk.screen_height()
if s_height < 768:
@@ -247,10 +242,6 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.destroy()
del self
def write_size(self):
w, h = self.get_size()
daemon.WriteWindowSize(w, h, 'netprop')
def save_settings(self):
""" Save settings common to wired and wireless settings dialogs. """
if self.chkbox_static_ip.get_active():

View File

@@ -248,7 +248,6 @@ class PreferencesDialog(object):
daemon.SetSudoApp(sudo_tool)
[width, height] = self.dialog.get_size()
daemon.WriteWindowSize(width, height, "pref")
not_path = os.path.join(USER_SETTINGS_DIR, 'USE_NOTIFICATIONS')
if self.notificationscheckbox.get_active():
@@ -316,12 +315,6 @@ class PreferencesDialog(object):
self.dialog.set_title(language['preferences'])
if os.path.exists(os.path.join(wpath.images, "wicd.png")):
self.dialog.set_icon_from_file(os.path.join(wpath.images, "wicd.png"))
size = daemon.ReadWindowSize("pref")
width = size[0]
height = size[1]
if width > -1 and height > -1:
self.dialog.resize(int(width), int(height))
else:
width = int(gtk.gdk.screen_width() / 2.4)
if width > 450:
width = 450

View File

@@ -91,18 +91,6 @@ This specifies the default search domain to be used by the resolver.
0 = disabled
.br
1 = enabled
.TP
.BI "window_height = " <integer_value> " (in pixels)"
This determines the height of the client window.
.TP
.BI "window_width = " <integer_value> " (in pixels)"
This determines the width of the client window.
.TP
.BI "pref_height = " <integer_value> " (in pixels)"
This determines the height of the "Preferences" window when launched from the client.
.TP
.BI "pref_width = " <integer_value> " (in pixels)"
This determines the width of the "Preferences" window when launched from the client.
.SH "SEE ALSO"

View File

@@ -79,9 +79,6 @@ Dit verzekert je ervan dat je niet per ongeluk met een ander netwerk verbind dat
.br
1 = Gebruik globale instellingen
.TP
.BI "has_profile = " <True|False>
Deze parameter wordt alleen intern door Wicd gebruikt en heeft geen effect voor de gebruiker zover de gebruiker kan zien.
.TP
.BI "beforescript = " <None|willekeurig_script>
Dit definieert een script dat gestart moet worden voordat Wicd gaat verbinden.
Dit script moet een Bourne-compatibel script zijn en moet uitvoerbaar zijn.

View File

@@ -91,18 +91,6 @@ This specifies the default search domain to be used by the resolver.
0 = disabled
.br
1 = enabled
.TP
.BI "window_height = " <integer_value> " (in pixels)"
This determines the height of the client window.
.TP
.BI "window_width = " <integer_value> " (in pixels)"
This determines the width of the client window.
.TP
.BI "pref_height = " <integer_value> " (in pixels)"
This determines the height of the "Preferences" window when launched from the client.
.TP
.BI "pref_width = " <integer_value> " (in pixels)"
This determines the width of the "Preferences" window when launched from the client.
.SH "SEE ALSO"

View File

@@ -83,10 +83,6 @@ of commercial routers in use with "linksys" as the essid.
.br
1 = Use settings globally
.TP
.BI "has_profile = " <True|False>
This parameter is used internally by Wicd and has no effect as far as the
user is concerned.
.TP
.BI "beforescript = " <None|arbitrary_script>
This defines a script to run before Wicd brings up the connection.
.br

View File

@@ -690,55 +690,6 @@ class WicdDaemon(dbus.service.Object):
self.sudo_app = sudo_app
self.config.set("Settings", "sudo_app", sudo_app, write=True)
@dbus.service.method('org.wicd.daemon')
def WriteWindowSize(self, width, height, win_name):
""" Write the desired default window size.
win_name should be either 'main' or 'pref', and specifies
whether the size being given applies to the main GUI window
or the preferences dialog window.
"""
if win_name:
height_str = '%s_height' % win_name
width_str = '%s_width' % win_name
# probably don't need the else, but the previous code
# had an else that caught everything
else:
height_str = "pref_height"
width_str = "pref_width"
self.config.set("Settings", width_str, width)
self.config.set("Settings", height_str, height)
self.config.write()
@dbus.service.method('org.wicd.daemon')
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.
"""
default_width, default_height = (-1, -1)
if win_name:
height_str = '%s_height' % win_name
width_str = '%s_width' % win_name
# probably don't need the else, but the previous code
# had an else that caught everything
else:
height_str = "pref_height"
width_str = "pref_width"
width = self.config.get("Settings", width_str, default=default_width)
height = self.config.get("Settings", height_str, default=default_height)
self.config.write()
size = []
size.append(int(width))
size.append(int(height))
return size
def _wired_autoconnect(self, fresh=True):
""" Attempts to autoconnect to a wired network. """
wiredb = self.wired_bus
@@ -1218,11 +1169,8 @@ class WirelessDaemon(dbus.service.Object):
elif self.config.has_section(bssid_key):
section = bssid_key
else:
cur_network["has_profile"] = False
return "500: Profile Not Found"
cur_network["has_profile"] = True
for x in self.config.options(section):
if not cur_network.has_key(x) or x.endswith("script"):
cur_network[x] = misc.Noneify(self.config.get(section, x))
@@ -1260,6 +1208,8 @@ class WirelessDaemon(dbus.service.Object):
self.config.add_section(essid_key)
for x in cur_network:
# There's no reason to save these to a configfile...
if x not in ['quality', 'strength', 'bitrates', 'has_profile']:
self.config.set(bssid_key, x, cur_network[x])
if cur_network.get("use_settings_globally", False):
self.config.set(essid_key, x, cur_network[x])
@@ -1337,7 +1287,7 @@ class WirelessDaemon(dbus.service.Object):
self.Scan(sync=True)
for x, network in enumerate(self.LastScan):
if bool(network["has_profile"]):
if self.config.has_section(network['bssid']):
if self.debug_mode:
print network["essid"] + ' has profile'
if bool(network.get('automatic')):