2013-06-30 15:38:06 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2015-03-06 23:31:46 +00:00
|
|
|
# Copyright (C) 2013 Christian T. Jacobs.
|
2013-06-30 15:38:06 +00:00
|
|
|
|
|
|
|
# This file is part of PyQSO.
|
|
|
|
|
|
|
|
# PyQSO is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# PyQSO is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with PyQSO. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
from gi.repository import Gtk, GObject
|
|
|
|
import logging
|
2013-06-30 22:04:37 +00:00
|
|
|
import ConfigParser
|
|
|
|
import os.path
|
2013-07-01 00:20:06 +00:00
|
|
|
import base64
|
2013-07-01 22:23:43 +00:00
|
|
|
from math import ceil
|
2013-07-27 18:22:54 +00:00
|
|
|
try:
|
|
|
|
import Hamlib
|
2013-09-14 19:31:12 +00:00
|
|
|
have_hamlib = True
|
2013-09-14 20:10:52 +00:00
|
|
|
except ImportError:
|
2015-04-29 20:53:54 +00:00
|
|
|
logging.warning("Could not import the Hamlib module!")
|
2013-09-14 19:31:12 +00:00
|
|
|
have_hamlib = False
|
2013-07-01 22:23:43 +00:00
|
|
|
|
2015-02-08 01:09:05 +00:00
|
|
|
from pyqso.adif import AVAILABLE_FIELD_NAMES_FRIENDLY, AVAILABLE_FIELD_NAMES_ORDERED, MODES
|
2013-06-30 22:04:37 +00:00
|
|
|
|
2013-06-30 15:38:06 +00:00
|
|
|
class PreferencesDialog(Gtk.Dialog):
|
|
|
|
|
2013-08-03 19:11:00 +00:00
|
|
|
def __init__(self, parent):
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Setting up the preferences dialog...")
|
2013-06-30 15:38:06 +00:00
|
|
|
|
2013-08-03 19:11:00 +00:00
|
|
|
Gtk.Dialog.__init__(self, title="Preferences", parent=parent, flags=Gtk.DialogFlags.DESTROY_WITH_PARENT, buttons=(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OK, Gtk.ResponseType.OK))
|
2013-06-30 15:38:06 +00:00
|
|
|
|
|
|
|
self.preferences = Gtk.Notebook()
|
|
|
|
|
2013-06-30 22:04:37 +00:00
|
|
|
self.general = GeneralPage()
|
|
|
|
self.preferences.insert_page(self.general, Gtk.Label("General"), 0)
|
|
|
|
|
2013-06-30 23:56:32 +00:00
|
|
|
self.view = ViewPage()
|
2013-06-30 22:04:37 +00:00
|
|
|
self.preferences.insert_page(self.view, Gtk.Label("View"), 1)
|
2013-06-30 15:38:06 +00:00
|
|
|
|
2013-07-27 18:22:54 +00:00
|
|
|
self.hamlib = HamlibPage()
|
|
|
|
self.preferences.insert_page(self.hamlib, Gtk.Label("Hamlib"), 2)
|
|
|
|
|
2014-03-23 01:54:24 +00:00
|
|
|
self.records = RecordsPage()
|
|
|
|
self.preferences.insert_page(self.records, Gtk.Label("Records"), 2)
|
|
|
|
|
2013-06-30 22:04:37 +00:00
|
|
|
self.vbox.pack_start(self.preferences, True, True, 2)
|
2013-06-30 15:38:06 +00:00
|
|
|
self.show_all()
|
|
|
|
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Preferences dialog ready!")
|
|
|
|
|
2013-06-30 15:38:06 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
def commit(self):
|
2013-09-14 20:10:52 +00:00
|
|
|
""" Commit the user preferences to the configuration file. """
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Committing the user preferences to the configuration file...")
|
2013-06-30 23:56:32 +00:00
|
|
|
general_data = self.general.get_data()
|
|
|
|
view_data = self.view.get_data()
|
2013-07-27 18:22:54 +00:00
|
|
|
hamlib_data = self.hamlib.get_data()
|
2014-03-23 01:54:24 +00:00
|
|
|
records_data = self.records.get_data()
|
2013-06-30 23:56:32 +00:00
|
|
|
|
|
|
|
config = ConfigParser.ConfigParser()
|
|
|
|
|
|
|
|
# General
|
|
|
|
config.add_section("general")
|
|
|
|
for key in general_data.keys():
|
|
|
|
config.set("general", key.lower(), general_data[key])
|
|
|
|
|
|
|
|
# View
|
|
|
|
config.add_section("view")
|
|
|
|
for key in view_data.keys():
|
|
|
|
config.set("view", key.lower(), view_data[key])
|
2013-07-27 18:22:54 +00:00
|
|
|
|
|
|
|
# Hamlib
|
|
|
|
config.add_section("hamlib")
|
|
|
|
for key in hamlib_data.keys():
|
|
|
|
config.set("hamlib", key.lower(), hamlib_data[key])
|
2013-06-30 23:56:32 +00:00
|
|
|
|
2014-03-23 01:54:24 +00:00
|
|
|
# Records
|
|
|
|
config.add_section("records")
|
|
|
|
for key in records_data.keys():
|
|
|
|
config.set("records", key.lower(), records_data[key])
|
|
|
|
|
2013-06-30 23:56:32 +00:00
|
|
|
with open(os.path.expanduser('~/.pyqso.ini'), 'w') as f:
|
|
|
|
config.write(f)
|
|
|
|
|
2013-06-30 15:38:06 +00:00
|
|
|
return
|
2013-06-30 22:04:37 +00:00
|
|
|
|
|
|
|
class GeneralPage(Gtk.VBox):
|
|
|
|
|
|
|
|
def __init__(self):
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Setting up the General page of the preferences dialog...")
|
2013-06-30 22:04:37 +00:00
|
|
|
|
|
|
|
Gtk.VBox.__init__(self, spacing=2)
|
|
|
|
|
2013-06-30 23:56:32 +00:00
|
|
|
# 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')) != [])
|
|
|
|
|
2013-06-30 22:04:37 +00:00
|
|
|
self.sources = {}
|
|
|
|
|
|
|
|
frame = Gtk.Frame()
|
|
|
|
frame.set_label("Startup")
|
|
|
|
hbox = Gtk.HBox()
|
|
|
|
self.sources["SHOW_TOOLBOX"] = Gtk.CheckButton("Show toolbox by default")
|
2014-03-31 09:44:46 +00:00
|
|
|
(section, option) = ("general", "show_toolbox")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["SHOW_TOOLBOX"].set_active(config.get(section, option) == "True")
|
2013-06-30 23:56:32 +00:00
|
|
|
else:
|
|
|
|
self.sources["SHOW_TOOLBOX"].set_active(False)
|
2013-06-30 22:04:37 +00:00
|
|
|
hbox.pack_start(self.sources["SHOW_TOOLBOX"], False, False, 2)
|
|
|
|
frame.add(hbox)
|
2013-07-01 22:23:43 +00:00
|
|
|
self.pack_start(frame, False, False, 2)
|
2013-06-30 22:04:37 +00:00
|
|
|
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("General page of the preferences dialog ready!")
|
2013-06-30 22:04:37 +00:00
|
|
|
return
|
|
|
|
|
2013-06-30 23:56:32 +00:00
|
|
|
def get_data(self):
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Retrieving data from the General page of the preferences dialog...")
|
2013-06-30 23:56:32 +00:00
|
|
|
data = {}
|
|
|
|
data["SHOW_TOOLBOX"] = self.sources["SHOW_TOOLBOX"].get_active()
|
|
|
|
return data
|
|
|
|
|
2013-06-30 22:04:37 +00:00
|
|
|
class ViewPage(Gtk.VBox):
|
|
|
|
|
|
|
|
def __init__(self):
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Setting up the View page of the preferences dialog...")
|
2013-06-30 22:04:37 +00:00
|
|
|
|
|
|
|
Gtk.VBox.__init__(self, spacing=2)
|
|
|
|
|
2013-07-01 22:23:43 +00:00
|
|
|
config = ConfigParser.ConfigParser()
|
|
|
|
have_config = (config.read(os.path.expanduser('~/.pyqso.ini')) != [])
|
|
|
|
|
2013-06-30 23:56:32 +00:00
|
|
|
self.sources = {}
|
|
|
|
|
2014-03-27 10:09:38 +00:00
|
|
|
# Visible fields frame
|
|
|
|
frame = Gtk.Frame()
|
|
|
|
frame.set_label("Visible fields")
|
|
|
|
|
2013-07-01 22:23:43 +00:00
|
|
|
# Divide the list of available field names up into multiple columns (of maximum length 'max_buttons_per_column')
|
2014-03-27 10:09:38 +00:00
|
|
|
# so we don't make the Preferences dialog too long.
|
2013-07-01 22:23:43 +00:00
|
|
|
hbox = Gtk.HBox(spacing=2)
|
|
|
|
max_buttons_per_column = 6
|
|
|
|
number_of_columns = int( len(AVAILABLE_FIELD_NAMES_ORDERED)/max_buttons_per_column ) + 1 # Number of check buttons per column
|
|
|
|
for i in range(0, number_of_columns):
|
|
|
|
vbox = Gtk.VBox(spacing=2)
|
|
|
|
for j in range(0, max_buttons_per_column):
|
|
|
|
if(i*max_buttons_per_column + j >= len(AVAILABLE_FIELD_NAMES_ORDERED)):
|
|
|
|
break
|
|
|
|
field_name = AVAILABLE_FIELD_NAMES_ORDERED[i*max_buttons_per_column + j]
|
|
|
|
button = Gtk.CheckButton(AVAILABLE_FIELD_NAMES_FRIENDLY[field_name ])
|
2014-03-31 09:44:46 +00:00
|
|
|
if(have_config and config.has_option("view", field_name.lower())):
|
2013-07-01 22:23:43 +00:00
|
|
|
button.set_active(config.get("view", field_name.lower()) == "True")
|
2013-07-03 10:48:51 +00:00
|
|
|
else:
|
|
|
|
button.set_active(True)
|
2013-07-01 22:23:43 +00:00
|
|
|
self.sources[field_name] = button
|
|
|
|
vbox.pack_start(button, False, False, 2)
|
|
|
|
hbox.pack_start(vbox, False, False, 2)
|
2014-03-27 10:09:38 +00:00
|
|
|
frame.add(hbox)
|
|
|
|
self.pack_start(frame, False, False, 2)
|
|
|
|
|
2013-06-30 23:56:32 +00:00
|
|
|
self.label = Gtk.Label("Note: View-related changes will not take effect\nuntil PyQSO is restarted.")
|
2013-07-01 22:23:43 +00:00
|
|
|
self.pack_start(self.label, False, False, 2)
|
2013-06-30 22:04:37 +00:00
|
|
|
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("View page of the preferences dialog ready!")
|
2013-06-30 22:04:37 +00:00
|
|
|
return
|
|
|
|
|
2013-06-30 23:56:32 +00:00
|
|
|
def get_data(self):
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Retrieving data from the View page of the preferences dialog...")
|
2013-06-30 23:56:32 +00:00
|
|
|
data = {}
|
2013-07-01 22:23:43 +00:00
|
|
|
for field_name in AVAILABLE_FIELD_NAMES_ORDERED:
|
|
|
|
data[field_name] = self.sources[field_name].get_active()
|
2013-06-30 23:56:32 +00:00
|
|
|
return data
|
|
|
|
|
2013-07-27 18:22:54 +00:00
|
|
|
class HamlibPage(Gtk.VBox):
|
|
|
|
|
|
|
|
def __init__(self):
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Setting up the Hamlib page of the preferences dialog...")
|
2013-07-27 18:22:54 +00:00
|
|
|
|
|
|
|
Gtk.VBox.__init__(self, spacing=2)
|
|
|
|
|
|
|
|
config = ConfigParser.ConfigParser()
|
|
|
|
have_config = (config.read(os.path.expanduser('~/.pyqso.ini')) != [])
|
|
|
|
|
|
|
|
self.sources = {}
|
|
|
|
|
|
|
|
frame = Gtk.Frame()
|
|
|
|
frame.set_label("Hamlib support")
|
|
|
|
|
|
|
|
vbox_inner = Gtk.VBox(spacing=2)
|
|
|
|
|
|
|
|
self.sources["AUTOFILL"] = Gtk.CheckButton("Auto-fill Frequency field")
|
2014-03-31 09:44:46 +00:00
|
|
|
(section, option) = ("hamlib", "autofill")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["AUTOFILL"].set_active(config.get(section, option) == "True")
|
2013-07-27 18:22:54 +00:00
|
|
|
else:
|
|
|
|
self.sources["AUTOFILL"].set_active(False)
|
|
|
|
vbox_inner.pack_start(self.sources["AUTOFILL"], False, False, 2)
|
|
|
|
|
|
|
|
hbox_temp = Gtk.HBox(spacing=0)
|
|
|
|
label = Gtk.Label("Model: ")
|
|
|
|
label.set_alignment(0, 0.5)
|
|
|
|
label.set_width_chars(17)
|
|
|
|
hbox_temp.pack_start(label, False, False, 2)
|
|
|
|
|
2013-09-14 19:31:12 +00:00
|
|
|
# Get the list of rig models
|
|
|
|
models = ["RIG_MODEL_NONE"]
|
|
|
|
if(have_hamlib):
|
|
|
|
try:
|
|
|
|
for item in dir(Hamlib):
|
|
|
|
if(item.startswith("RIG_MODEL_")):
|
|
|
|
models.append(item)
|
|
|
|
except:
|
|
|
|
logging.error("Could not obtain rig models list via Hamlib!")
|
|
|
|
else:
|
|
|
|
logging.debug("Hamlib module not present. Could not obtain a list of rig models.")
|
2013-07-27 18:22:54 +00:00
|
|
|
|
|
|
|
self.sources["RIG_MODEL"] = Gtk.ComboBoxText()
|
|
|
|
for model in models:
|
|
|
|
self.sources["RIG_MODEL"].append_text(model)
|
2014-03-31 09:44:46 +00:00
|
|
|
(section, option) = ("hamlib", "rig_model")
|
|
|
|
if(have_config and config.has_option("hamlib", "rig_model")):
|
2013-07-27 18:22:54 +00:00
|
|
|
self.sources["RIG_MODEL"].set_active(models.index(config.get("hamlib", "rig_model")))
|
|
|
|
else:
|
|
|
|
self.sources["RIG_MODEL"].set_active(models.index("RIG_MODEL_NONE")) # Set to RIG_MODEL_NONE as the default option.
|
|
|
|
hbox_temp.pack_start(self.sources["RIG_MODEL"], True, True, 2)
|
|
|
|
vbox_inner.pack_start(hbox_temp, False, False, 2)
|
|
|
|
|
|
|
|
# Path to rig
|
|
|
|
hbox_temp = Gtk.HBox()
|
|
|
|
label = Gtk.Label("Path to radio device: ")
|
|
|
|
label.set_width_chars(17)
|
|
|
|
label.set_alignment(0, 0.5)
|
|
|
|
hbox_temp.pack_start(label, False, False, 2)
|
|
|
|
self.sources["RIG_PATHNAME"] = Gtk.Entry()
|
2014-03-31 09:44:46 +00:00
|
|
|
(section, option) = ("hamlib", "rig_pathname")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["RIG_PATHNAME"].set_text(config.get(section, option))
|
2013-07-27 18:22:54 +00:00
|
|
|
hbox_temp.pack_start(self.sources["RIG_PATHNAME"], True, True, 2)
|
|
|
|
vbox_inner.pack_start(hbox_temp, False, False, 2)
|
|
|
|
|
|
|
|
frame.add(vbox_inner)
|
|
|
|
self.pack_start(frame, True, True, 2)
|
|
|
|
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Hamlib page of the preferences dialog ready!")
|
2013-07-27 18:22:54 +00:00
|
|
|
return
|
|
|
|
|
|
|
|
def get_data(self):
|
2013-09-15 03:29:44 +00:00
|
|
|
logging.debug("Retrieving data from the Hamlib page of the preferences dialog...")
|
2013-07-27 18:22:54 +00:00
|
|
|
data = {}
|
|
|
|
data["AUTOFILL"] = self.sources["AUTOFILL"].get_active()
|
|
|
|
data["RIG_PATHNAME"] = self.sources["RIG_PATHNAME"].get_text()
|
|
|
|
data["RIG_MODEL"] = self.sources["RIG_MODEL"].get_active_text()
|
|
|
|
return data
|
|
|
|
|
2014-03-23 01:54:24 +00:00
|
|
|
class RecordsPage(Gtk.VBox):
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
logging.debug("Setting up the Records page of the preferences dialog...")
|
|
|
|
|
|
|
|
Gtk.VBox.__init__(self, spacing=2)
|
|
|
|
|
|
|
|
# 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')) != [])
|
|
|
|
|
|
|
|
self.sources = {}
|
|
|
|
|
2014-03-27 10:09:38 +00:00
|
|
|
# Autocomplete frame
|
2014-03-23 01:54:24 +00:00
|
|
|
frame = Gtk.Frame()
|
2014-03-24 03:06:47 +00:00
|
|
|
frame.set_label("Autocomplete")
|
|
|
|
vbox = Gtk.VBox()
|
2014-03-23 01:54:24 +00:00
|
|
|
self.sources["AUTOCOMPLETE_BAND"] = Gtk.CheckButton("Autocomplete the Band field")
|
2014-03-31 09:44:46 +00:00
|
|
|
(section, option) = ("records", "autocomplete_band")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["AUTOCOMPLETE_BAND"].set_active(config.get(section, option) == "True")
|
2014-03-23 01:54:24 +00:00
|
|
|
else:
|
|
|
|
self.sources["AUTOCOMPLETE_BAND"].set_active(True)
|
2014-03-24 03:06:47 +00:00
|
|
|
vbox.pack_start(self.sources["AUTOCOMPLETE_BAND"], False, False, 2)
|
|
|
|
|
|
|
|
self.sources["USE_UTC"] = Gtk.CheckButton("Use UTC when autocompleting the Date and Time")
|
2014-03-31 09:44:46 +00:00
|
|
|
(section, option) = ("records", "use_utc")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["USE_UTC"].set_active(config.get(section, option) == "True")
|
2014-03-24 03:06:47 +00:00
|
|
|
else:
|
|
|
|
self.sources["USE_UTC"].set_active(True)
|
|
|
|
vbox.pack_start(self.sources["USE_UTC"], False, False, 2)
|
|
|
|
|
|
|
|
frame.add(vbox)
|
2014-03-23 01:54:24 +00:00
|
|
|
self.pack_start(frame, False, False, 2)
|
|
|
|
|
2015-02-08 01:09:05 +00:00
|
|
|
|
|
|
|
## Default values frame
|
|
|
|
frame = Gtk.Frame()
|
|
|
|
frame.set_label("Default values")
|
|
|
|
vbox = Gtk.VBox()
|
|
|
|
|
|
|
|
# Mode
|
|
|
|
hbox_temp = Gtk.HBox()
|
|
|
|
label = Gtk.Label("Mode: ")
|
|
|
|
label.set_width_chars(17)
|
|
|
|
label.set_alignment(0, 0.5)
|
|
|
|
hbox_temp.pack_start(label, False, False, 2)
|
|
|
|
|
|
|
|
self.sources["DEFAULT_MODE"] = Gtk.ComboBoxText()
|
|
|
|
for mode in MODES:
|
|
|
|
self.sources["DEFAULT_MODE"].append_text(mode)
|
|
|
|
(section, option) = ("records", "default_mode")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["DEFAULT_MODE"].set_active(MODES.index(config.get(section, option)))
|
|
|
|
else:
|
|
|
|
self.sources["DEFAULT_MODE"].set_active(MODES.index(""))
|
|
|
|
hbox_temp.pack_start(self.sources["DEFAULT_MODE"], False, False, 2)
|
|
|
|
vbox.pack_start(hbox_temp, False, False, 2)
|
|
|
|
|
|
|
|
# Power
|
|
|
|
hbox_temp = Gtk.HBox()
|
|
|
|
label = Gtk.Label("TX Power (W): ")
|
|
|
|
label.set_width_chars(17)
|
|
|
|
label.set_alignment(0, 0.5)
|
|
|
|
hbox_temp.pack_start(label, False, False, 2)
|
|
|
|
|
|
|
|
self.sources["DEFAULT_POWER"] = Gtk.Entry()
|
|
|
|
(section, option) = ("records", "default_power")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["DEFAULT_POWER"].set_text(config.get(section, option))
|
|
|
|
else:
|
|
|
|
self.sources["DEFAULT_POWER"].set_text("")
|
|
|
|
hbox_temp.pack_start(self.sources["DEFAULT_POWER"], False, False, 2)
|
|
|
|
vbox.pack_start(hbox_temp, False, False, 2)
|
|
|
|
|
|
|
|
frame.add(vbox)
|
|
|
|
self.pack_start(frame, False, False, 2)
|
|
|
|
|
|
|
|
|
2014-05-13 15:27:31 +00:00
|
|
|
# Callsign lookup frame
|
|
|
|
frame = Gtk.Frame()
|
|
|
|
frame.set_label("Callsign lookup")
|
|
|
|
vbox = Gtk.VBox()
|
|
|
|
|
2015-04-28 22:04:03 +00:00
|
|
|
# Callsign database
|
|
|
|
hbox_temp = Gtk.HBox()
|
|
|
|
label = Gtk.Label("Database: ")
|
|
|
|
label.set_width_chars(17)
|
|
|
|
label.set_alignment(0, 0.5)
|
|
|
|
hbox_temp.pack_start(label, False, False, 2)
|
|
|
|
|
|
|
|
self.sources["CALLSIGN_DATABASE"] = Gtk.ComboBoxText()
|
|
|
|
callsign_database = ["", "qrz.com", "hamqth.com"]
|
|
|
|
for database in callsign_database:
|
|
|
|
self.sources["CALLSIGN_DATABASE"].append_text(database)
|
|
|
|
(section, option) = ("records", "callsign_database")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["CALLSIGN_DATABASE"].set_active(callsign_database.index(config.get(section, option)))
|
|
|
|
else:
|
|
|
|
self.sources["CALLSIGN_DATABASE"].set_active(callsign_database.index(""))
|
|
|
|
hbox_temp.pack_start(self.sources["CALLSIGN_DATABASE"], False, False, 2)
|
|
|
|
vbox.pack_start(hbox_temp, False, False, 2)
|
|
|
|
|
|
|
|
# Login details
|
2014-05-13 15:27:31 +00:00
|
|
|
subframe = Gtk.Frame()
|
2015-04-28 22:04:03 +00:00
|
|
|
subframe.set_label("Login details")
|
2014-05-13 15:27:31 +00:00
|
|
|
inner_vbox = Gtk.VBox()
|
|
|
|
|
|
|
|
hbox = Gtk.HBox()
|
|
|
|
label = Gtk.Label("Username: ")
|
|
|
|
label.set_width_chars(9)
|
|
|
|
label.set_alignment(0, 0.5)
|
|
|
|
hbox.pack_start(label, False, False, 2)
|
2015-04-28 22:04:03 +00:00
|
|
|
self.sources["CALLSIGN_DATABASE_USERNAME"] = Gtk.Entry()
|
|
|
|
(section, option) = ("records", "callsign_database_username")
|
2014-05-13 15:27:31 +00:00
|
|
|
if(have_config and config.has_option(section, option)):
|
2015-04-28 22:04:03 +00:00
|
|
|
self.sources["CALLSIGN_DATABASE_USERNAME"].set_text(config.get(section, option))
|
|
|
|
hbox.pack_start(self.sources["CALLSIGN_DATABASE_USERNAME"], False, False, 2)
|
2014-05-13 15:27:31 +00:00
|
|
|
inner_vbox.pack_start(hbox, False, False, 2)
|
|
|
|
|
|
|
|
hbox = Gtk.HBox()
|
|
|
|
label = Gtk.Label("Password: ")
|
|
|
|
label.set_width_chars(9)
|
|
|
|
label.set_alignment(0, 0.5)
|
|
|
|
hbox.pack_start(label, False, False, 2)
|
2015-04-28 22:04:03 +00:00
|
|
|
self.sources["CALLSIGN_DATABASE_PASSWORD"] = Gtk.Entry()
|
|
|
|
self.sources["CALLSIGN_DATABASE_PASSWORD"].set_visibility(False) # Mask the password with the "*" character.
|
|
|
|
(section, option) = ("records", "callsign_database_password")
|
2014-05-13 15:27:31 +00:00
|
|
|
if(have_config and config.has_option(section, option)):
|
2015-04-28 22:04:03 +00:00
|
|
|
self.sources["CALLSIGN_DATABASE_PASSWORD"].set_text(base64.b64decode(config.get(section, option)))
|
|
|
|
hbox.pack_start(self.sources["CALLSIGN_DATABASE_PASSWORD"], False, False, 2)
|
2014-05-13 15:27:31 +00:00
|
|
|
inner_vbox.pack_start(hbox, False, False, 2)
|
|
|
|
|
|
|
|
label = Gtk.Label("Warning: Login details are currently stored as\nBase64-encoded plain text in the configuration file.")
|
|
|
|
inner_vbox.pack_start(label, False, False, 2)
|
|
|
|
|
|
|
|
subframe.add(inner_vbox)
|
|
|
|
vbox.pack_start(subframe, False, False, 2)
|
|
|
|
|
|
|
|
self.sources["IGNORE_PREFIX_SUFFIX"] = Gtk.CheckButton("Ignore callsign prefixes and/or suffixes")
|
|
|
|
(section, option) = ("records", "ignore_prefix_suffix")
|
|
|
|
if(have_config and config.has_option(section, option)):
|
|
|
|
self.sources["IGNORE_PREFIX_SUFFIX"].set_active(config.get(section, option) == "True")
|
|
|
|
else:
|
|
|
|
self.sources["IGNORE_PREFIX_SUFFIX"].set_active(True)
|
|
|
|
vbox.pack_start(self.sources["IGNORE_PREFIX_SUFFIX"], False, False, 2)
|
|
|
|
|
|
|
|
frame.add(vbox)
|
|
|
|
self.pack_start(frame, False, False, 2)
|
|
|
|
|
2014-03-23 01:54:24 +00:00
|
|
|
logging.debug("Records page of the preferences dialog ready!")
|
|
|
|
return
|
|
|
|
|
|
|
|
def get_data(self):
|
|
|
|
logging.debug("Retrieving data from the Records page of the preferences dialog...")
|
|
|
|
data = {}
|
|
|
|
data["AUTOCOMPLETE_BAND"] = self.sources["AUTOCOMPLETE_BAND"].get_active()
|
2014-03-24 03:06:47 +00:00
|
|
|
data["USE_UTC"] = self.sources["USE_UTC"].get_active()
|
2015-02-08 01:09:05 +00:00
|
|
|
|
|
|
|
data["DEFAULT_MODE"] = self.sources["DEFAULT_MODE"].get_active_text()
|
|
|
|
data["DEFAULT_POWER"] = self.sources["DEFAULT_POWER"].get_text()
|
|
|
|
|
2015-04-28 22:04:03 +00:00
|
|
|
data["CALLSIGN_DATABASE"] = self.sources["CALLSIGN_DATABASE"].get_active_text()
|
|
|
|
data["CALLSIGN_DATABASE_USERNAME"] = self.sources["CALLSIGN_DATABASE_USERNAME"].get_text()
|
|
|
|
data["CALLSIGN_DATABASE_PASSWORD"] = base64.b64encode(self.sources["CALLSIGN_DATABASE_PASSWORD"].get_text())
|
2014-05-13 15:27:31 +00:00
|
|
|
data["IGNORE_PREFIX_SUFFIX"] = self.sources["IGNORE_PREFIX_SUFFIX"].get_active()
|
2014-03-23 01:54:24 +00:00
|
|
|
return data
|
|
|
|
|