Write configuration files to ~/.config to keep the user's home directory uncluttered.

pull/41/head
Christian Jacobs 2015-11-29 22:25:41 +00:00
rodzic cc933a3a9c
commit 7d941ce2fe
8 zmienionych plików z 27 dodań i 15 usunięć

Wyświetl plik

@ -15,6 +15,7 @@
- Various code cleanups (thanks to András Veres-Szentkirályi).
- Brought the list of valid modes up-to-date.
- Updated the list of bands and their frequency ranges.
- Configuration files are now written to ~/.config to keep the user's home directory uncluttered.
## [0.2] - 2015-03-07
### Added

Wyświetl plik

@ -53,11 +53,16 @@ class PyQSO(Gtk.Window):
# Call the constructor of the super class (Gtk.Window)
Gtk.Window.__init__(self, title="PyQSO")
# Get any application-specific preferences from the configuration file
# Check that the directory for holding PyQSO configuration files exists. If it doesn't, create it now.
if not os.path.exists(os.path.expanduser('~/.config/pyqso')):
os.makedirs(os.path.expanduser('~/.config/pyqso'))
# Get any application-specific preferences from the configuration file
config = configparser.ConfigParser()
# Check that the configuration file actually exists (and is readable)
# otherwise, we will resort to the defaults.
have_config = (config.read(os.path.expanduser("~/.pyqso.ini")) != [])
have_config = (config.read(os.path.expanduser("~/.config/pyqso/preferences.ini")) != [])
self.set_size_request(800, 600) # Default to an 800 x 600 resolution.
self.set_position(Gtk.WindowPosition.CENTER)

Wyświetl plik

@ -235,7 +235,7 @@ class ADIF:
# ADIF-related configuration options
config = configparser.ConfigParser()
have_config = (config.read(expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
(section, option) = ("adif", "merge_comment")
if(have_config and config.has_option(section, option) and config.get(section, option) == "True"):
merge_comment = True

Wyświetl plik

@ -27,7 +27,7 @@ import os.path
from pyqso.telnet_connection_dialog import *
BOOKMARKS_FILE = os.path.expanduser('~/.pyqso_bookmarks.ini')
BOOKMARKS_FILE = os.path.expanduser('~/.config/pyqso/bookmarks.ini')
class DXCluster(Gtk.VBox):
""" A tool for connecting to a DX cluster (specifically Telnet-based DX clusters). """
@ -146,6 +146,9 @@ class DXCluster(Gtk.VBox):
config.set(host, "username", username)
config.set(host, "password", password)
# Write the bookmarks to file.
if not os.path.exists(os.path.expanduser('~/.config/pyqso')):
os.makedirs(os.path.expanduser('~/.config/pyqso'))
with open(BOOKMARKS_FILE, 'w') as f:
config.write(f)

Wyświetl plik

@ -499,7 +499,7 @@ class Logbook(Gtk.Notebook):
column.connect("clicked", self.sort_log, i+1)
config = configparser.ConfigParser()
have_config = (config.read(expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
(section, option) = ("view", AVAILABLE_FIELD_NAMES_ORDERED[i].lower())
if(have_config and config.has_option(section, option)):
column.set_visible(config.get(section, option) == "True")

Wyświetl plik

@ -210,7 +210,7 @@ class Menu(Gtk.MenuBar):
mitem_toolbox = Gtk.CheckMenuItem("Toolbox")
config = configparser.ConfigParser()
have_config = (config.read(os.path.expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(os.path.expanduser('~/.config/pyqso/preferences.ini')) != [])
(section, option) = ("general", "show_toolbox")
if(have_config and config.has_option(section, option)):
mitem_toolbox.set_active(config.get(section, option) == "True")

Wyświetl plik

@ -31,6 +31,8 @@ except ImportError:
from pyqso.adif import *
PREFERENCES_FILE = os.path.expanduser("~/.config/pyqso/preferences.ini")
class PreferencesDialog(Gtk.Dialog):
""" A dialog to specify the PyQSO preferences. """
@ -102,7 +104,8 @@ class PreferencesDialog(Gtk.Dialog):
for key in list(records_data.keys()):
config.set("records", key.lower(), str(records_data[key]))
with open(os.path.expanduser('~/.pyqso.ini'), 'w') as f:
# Write the preferences to file.
with open(os.path.expanduser(PREFERENCES_FILE), 'w') as f:
config.write(f)
return
@ -118,7 +121,7 @@ class GeneralPage(Gtk.VBox):
# Remember that the have_config conditional in the PyQSO class may be out-of-date the next time the user opens up the preferences dialog
# because a configuration file may have been created after launching the application. Let's check to see if one exists again...
config = configparser.ConfigParser()
have_config = (config.read(os.path.expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(PREFERENCES_FILE) != [])
self.sources = {}
@ -153,7 +156,7 @@ class ViewPage(Gtk.VBox):
Gtk.VBox.__init__(self, spacing=2)
config = configparser.ConfigParser()
have_config = (config.read(os.path.expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(PREFERENCES_FILE) != [])
self.sources = {}
@ -205,7 +208,7 @@ class HamlibPage(Gtk.VBox):
Gtk.VBox.__init__(self, spacing=2)
config = configparser.ConfigParser()
have_config = (config.read(os.path.expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(PREFERENCES_FILE) != [])
self.sources = {}
@ -289,7 +292,7 @@ class RecordsPage(Gtk.VBox):
# Remember that the have_config conditional in the PyQSO class may be out-of-date the next time the user opens up the preferences dialog
# because a configuration file may have been created after launching the application. Let's check to see if one exists again...
config = configparser.ConfigParser()
have_config = (config.read(os.path.expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(PREFERENCES_FILE) != [])
self.sources = {}
@ -491,7 +494,7 @@ class ADIFPage(Gtk.VBox):
# Remember that the have_config conditional in the PyQSO class may be out-of-date the next time the user opens up the preferences dialog
# because a configuration file may have been created after launching the application. Let's check to see if one exists again...
config = configparser.ConfigParser()
have_config = (config.read(os.path.expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(PREFERENCES_FILE) != [])
self.sources = {}

Wyświetl plik

@ -55,7 +55,7 @@ class RecordDialog(Gtk.Dialog):
# Check if a configuration file is present, since we might need it to set up the rest of the dialog.
config = configparser.ConfigParser()
have_config = (config.read(expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
## QSO DATA FRAME
qso_frame = Gtk.Frame()
@ -517,7 +517,7 @@ class RecordDialog(Gtk.Dialog):
# Get the database name.
config = configparser.ConfigParser()
have_config = (config.read(expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
try:
if(have_config and config.has_option("records", "callsign_database")):
database = config.get("records", "callsign_database")
@ -588,7 +588,7 @@ class RecordDialog(Gtk.Dialog):
# Check if a configuration file is present.
config = configparser.ConfigParser()
have_config = (config.read(expanduser('~/.pyqso.ini')) != [])
have_config = (config.read(expanduser('~/.config/pyqso/preferences.ini')) != [])
# Do we want to use UTC or the computer's local time?
(section, option) = ("records", "use_utc")