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:
15
gtk/gui.py
15
gtk/gui.py
@@ -151,16 +151,10 @@ class appGui(object):
|
|||||||
self.wTree = gtk.Builder()
|
self.wTree = gtk.Builder()
|
||||||
self.wTree.add_from_file(gladefile)
|
self.wTree.add_from_file(gladefile)
|
||||||
self.window = self.wTree.get_object("window1")
|
self.window = self.wTree.get_object("window1")
|
||||||
size = daemon.ReadWindowSize("main")
|
width = int(gtk.gdk.screen_width() / 2)
|
||||||
width = size[0]
|
if width > 530:
|
||||||
height = size[1]
|
width = 530
|
||||||
if width > -1 and height > -1:
|
self.window.resize(width, int(gtk.gdk.screen_height() / 1.7))
|
||||||
self.window.resize(int(width), int(height))
|
|
||||||
else:
|
|
||||||
width = int(gtk.gdk.screen_width() / 2)
|
|
||||||
if width > 530:
|
|
||||||
width = 530
|
|
||||||
self.window.resize(width, int(gtk.gdk.screen_height() / 1.7))
|
|
||||||
|
|
||||||
dic = { "refresh_clicked" : self.refresh_clicked,
|
dic = { "refresh_clicked" : self.refresh_clicked,
|
||||||
"quit_clicked" : self.exit,
|
"quit_clicked" : self.exit,
|
||||||
@@ -772,7 +766,6 @@ class appGui(object):
|
|||||||
'org.wicd.daemon')
|
'org.wicd.daemon')
|
||||||
[width, height] = self.window.get_size()
|
[width, height] = self.window.get_size()
|
||||||
try:
|
try:
|
||||||
daemon.WriteWindowSize(width, height, "main")
|
|
||||||
daemon.SetGUIOpen(False)
|
daemon.SetGUIOpen(False)
|
||||||
except DBusException:
|
except DBusException:
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
|||||||
self.set_default_size()
|
self.set_default_size()
|
||||||
|
|
||||||
self.connect('show', lambda *a, **k: 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.
|
# Set up the Advanced Settings Dialog.
|
||||||
self.txt_ip = LabelEntry(language['ip'])
|
self.txt_ip = LabelEntry(language['ip'])
|
||||||
@@ -141,17 +140,13 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
|||||||
|
|
||||||
|
|
||||||
def set_default_size(self):
|
def set_default_size(self):
|
||||||
width, height = daemon.ReadWindowSize('netprop')
|
width, height = self.get_size()
|
||||||
if width > -1 and height > -1:
|
s_height = gtk.gdk.screen_height()
|
||||||
self.resize(int(width), int(height))
|
if s_height < 768:
|
||||||
|
height = s_height * .75
|
||||||
else:
|
else:
|
||||||
width, height = self.get_size()
|
height = 600
|
||||||
s_height = gtk.gdk.screen_height()
|
self.resize(int(width), int(height))
|
||||||
if s_height < 768:
|
|
||||||
height = s_height * .75
|
|
||||||
else:
|
|
||||||
height = 600
|
|
||||||
self.resize(int(width), int(height))
|
|
||||||
|
|
||||||
def set_defaults(self, widget=None, event=None):
|
def set_defaults(self, widget=None, event=None):
|
||||||
""" Put some default values into entries to help the user out. """
|
""" Put some default values into entries to help the user out. """
|
||||||
@@ -247,10 +242,6 @@ class AdvancedSettingsDialog(gtk.Dialog):
|
|||||||
self.destroy()
|
self.destroy()
|
||||||
del self
|
del self
|
||||||
|
|
||||||
def write_size(self):
|
|
||||||
w, h = self.get_size()
|
|
||||||
daemon.WriteWindowSize(w, h, 'netprop')
|
|
||||||
|
|
||||||
def save_settings(self):
|
def save_settings(self):
|
||||||
""" Save settings common to wired and wireless settings dialogs. """
|
""" Save settings common to wired and wireless settings dialogs. """
|
||||||
if self.chkbox_static_ip.get_active():
|
if self.chkbox_static_ip.get_active():
|
||||||
|
|||||||
15
gtk/prefs.py
15
gtk/prefs.py
@@ -248,7 +248,6 @@ class PreferencesDialog(object):
|
|||||||
daemon.SetSudoApp(sudo_tool)
|
daemon.SetSudoApp(sudo_tool)
|
||||||
|
|
||||||
[width, height] = self.dialog.get_size()
|
[width, height] = self.dialog.get_size()
|
||||||
daemon.WriteWindowSize(width, height, "pref")
|
|
||||||
|
|
||||||
not_path = os.path.join(USER_SETTINGS_DIR, 'USE_NOTIFICATIONS')
|
not_path = os.path.join(USER_SETTINGS_DIR, 'USE_NOTIFICATIONS')
|
||||||
if self.notificationscheckbox.get_active():
|
if self.notificationscheckbox.get_active():
|
||||||
@@ -316,16 +315,10 @@ class PreferencesDialog(object):
|
|||||||
self.dialog.set_title(language['preferences'])
|
self.dialog.set_title(language['preferences'])
|
||||||
if os.path.exists(os.path.join(wpath.images, "wicd.png")):
|
if os.path.exists(os.path.join(wpath.images, "wicd.png")):
|
||||||
self.dialog.set_icon_from_file(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 = int(gtk.gdk.screen_width() / 2.4)
|
||||||
width = size[0]
|
if width > 450:
|
||||||
height = size[1]
|
width = 450
|
||||||
if width > -1 and height > -1:
|
self.dialog.resize(width, int(gtk.gdk.screen_height() / 2))
|
||||||
self.dialog.resize(int(width), int(height))
|
|
||||||
else:
|
|
||||||
width = int(gtk.gdk.screen_width() / 2.4)
|
|
||||||
if width > 450:
|
|
||||||
width = 450
|
|
||||||
self.dialog.resize(width, int(gtk.gdk.screen_height() / 2))
|
|
||||||
|
|
||||||
self.wiredcheckbox = setup_label("pref_always_check",
|
self.wiredcheckbox = setup_label("pref_always_check",
|
||||||
'wired_always_on')
|
'wired_always_on')
|
||||||
|
|||||||
@@ -91,18 +91,6 @@ This specifies the default search domain to be used by the resolver.
|
|||||||
0 = disabled
|
0 = disabled
|
||||||
.br
|
.br
|
||||||
1 = enabled
|
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"
|
.SH "SEE ALSO"
|
||||||
|
|||||||
@@ -79,9 +79,6 @@ Dit verzekert je ervan dat je niet per ongeluk met een ander netwerk verbind dat
|
|||||||
.br
|
.br
|
||||||
1 = Gebruik globale instellingen
|
1 = Gebruik globale instellingen
|
||||||
.TP
|
.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>
|
.BI "beforescript = " <None|willekeurig_script>
|
||||||
Dit definieert een script dat gestart moet worden voordat Wicd gaat verbinden.
|
Dit definieert een script dat gestart moet worden voordat Wicd gaat verbinden.
|
||||||
Dit script moet een Bourne-compatibel script zijn en moet uitvoerbaar zijn.
|
Dit script moet een Bourne-compatibel script zijn en moet uitvoerbaar zijn.
|
||||||
|
|||||||
@@ -91,18 +91,6 @@ This specifies the default search domain to be used by the resolver.
|
|||||||
0 = disabled
|
0 = disabled
|
||||||
.br
|
.br
|
||||||
1 = enabled
|
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"
|
.SH "SEE ALSO"
|
||||||
|
|||||||
@@ -83,10 +83,6 @@ of commercial routers in use with "linksys" as the essid.
|
|||||||
.br
|
.br
|
||||||
1 = Use settings globally
|
1 = Use settings globally
|
||||||
.TP
|
.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>
|
.BI "beforescript = " <None|arbitrary_script>
|
||||||
This defines a script to run before Wicd brings up the connection.
|
This defines a script to run before Wicd brings up the connection.
|
||||||
.br
|
.br
|
||||||
|
|||||||
@@ -690,55 +690,6 @@ class WicdDaemon(dbus.service.Object):
|
|||||||
self.sudo_app = sudo_app
|
self.sudo_app = sudo_app
|
||||||
self.config.set("Settings", "sudo_app", sudo_app, write=True)
|
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):
|
def _wired_autoconnect(self, fresh=True):
|
||||||
""" Attempts to autoconnect to a wired network. """
|
""" Attempts to autoconnect to a wired network. """
|
||||||
wiredb = self.wired_bus
|
wiredb = self.wired_bus
|
||||||
@@ -1218,11 +1169,8 @@ class WirelessDaemon(dbus.service.Object):
|
|||||||
elif self.config.has_section(bssid_key):
|
elif self.config.has_section(bssid_key):
|
||||||
section = bssid_key
|
section = bssid_key
|
||||||
else:
|
else:
|
||||||
cur_network["has_profile"] = False
|
|
||||||
return "500: Profile Not Found"
|
return "500: Profile Not Found"
|
||||||
|
|
||||||
cur_network["has_profile"] = True
|
|
||||||
|
|
||||||
for x in self.config.options(section):
|
for x in self.config.options(section):
|
||||||
if not cur_network.has_key(x) or x.endswith("script"):
|
if not cur_network.has_key(x) or x.endswith("script"):
|
||||||
cur_network[x] = misc.Noneify(self.config.get(section, x))
|
cur_network[x] = misc.Noneify(self.config.get(section, x))
|
||||||
@@ -1260,9 +1208,11 @@ class WirelessDaemon(dbus.service.Object):
|
|||||||
self.config.add_section(essid_key)
|
self.config.add_section(essid_key)
|
||||||
|
|
||||||
for x in cur_network:
|
for x in cur_network:
|
||||||
self.config.set(bssid_key, x, cur_network[x])
|
# There's no reason to save these to a configfile...
|
||||||
if cur_network.get("use_settings_globally", False):
|
if x not in ['quality', 'strength', 'bitrates', 'has_profile']:
|
||||||
self.config.set(essid_key, x, cur_network[x])
|
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])
|
||||||
|
|
||||||
write_script_ent(bssid_key, "beforescript")
|
write_script_ent(bssid_key, "beforescript")
|
||||||
write_script_ent(bssid_key, "afterscript")
|
write_script_ent(bssid_key, "afterscript")
|
||||||
@@ -1337,7 +1287,7 @@ class WirelessDaemon(dbus.service.Object):
|
|||||||
self.Scan(sync=True)
|
self.Scan(sync=True)
|
||||||
|
|
||||||
for x, network in enumerate(self.LastScan):
|
for x, network in enumerate(self.LastScan):
|
||||||
if bool(network["has_profile"]):
|
if self.config.has_section(network['bssid']):
|
||||||
if self.debug_mode:
|
if self.debug_mode:
|
||||||
print network["essid"] + ' has profile'
|
print network["essid"] + ' has profile'
|
||||||
if bool(network.get('automatic')):
|
if bool(network.get('automatic')):
|
||||||
|
|||||||
Reference in New Issue
Block a user