Move beta warning into the status bar

This commit is contained in:
Nick Hall 2020-02-04 15:41:27 +00:00
parent fd380e345c
commit 8408cea4b5
6 changed files with 58 additions and 50 deletions

View File

@ -133,7 +133,6 @@ register('behavior.addmedia-image-dir', '')
register('behavior.addmedia-relative-path', False)
register('behavior.autoload', False)
register('behavior.avg-generation-gap', 20)
register('behavior.betawarn', False)
register('behavior.check-for-addon-updates', 0)
register('behavior.check-for-addon-update-types', ["new"])
register('behavior.last-check-for-addon-updates', "1970/01/01")

View File

@ -41,7 +41,7 @@ import uuid
#-------------------------------------------------------------------------
from .git_revision import get_git_revision
from .constfunc import get_env_var
from ..version import VERSION, VERSION_TUPLE, major_version
from ..version import VERSION, VERSION_TUPLE, major_version, DEV_VERSION
from .utils.resourcepath import ResourcePath
from .utils.grampslocale import GrampsLocale
@ -145,6 +145,7 @@ sys.path.insert(0, ROOT_DIR)
git_revision = get_git_revision(ROOT_DIR).replace('\n', '')
if sys.platform == 'win32' and git_revision == "":
git_revision = get_git_revision(os.path.split(ROOT_DIR)[1])
if DEV_VERSION:
VERSION += git_revision
#VERSION += "-1"

View File

@ -66,8 +66,10 @@ from .glade import Glade
from gramps.gen.utils.db import navigation_label
from gramps.gen.errors import HandleError
from .widgets.progressdialog import ProgressMonitor, GtkProgressDialog
from .dialog import ErrorDialog
from .dialog import ErrorDialog, WarningDialog
from .uimanager import ActionGroup
from ..version import VERSION_QUALIFIER, DEV_VERSION
from gramps.gen.const import VERSION
DISABLED = -1
@ -421,6 +423,7 @@ class DisplayState(Callback):
self.status = status
self.status_id = status.get_context_id('GRAMPS')
self.progress = status.get_progress_bar()
self.status_ver = status.get_version_btn()
self.history_lookup = {}
self.gwm = GrampsWindowManager(uimanager)
self.widget = None
@ -444,6 +447,16 @@ class DisplayState(Callback):
# but this connection is still made!
# self.dbstate.connect('database-changed', self.db_changed)
if DEV_VERSION or VERSION_QUALIFIER:
ver_btn = status.get_version_btn()
ver_btn.set_label(VERSION)
if DEV_VERSION:
msg = 'master'
else:
msg = VERSION_QUALIFIER[1:]
ver_btn.connect('clicked', self.__develop_warn, msg)
ver_btn.show()
def set_backup_timer(self):
"""
Set the backup timer.
@ -682,3 +695,34 @@ class DisplayState(Callback):
def reload_symbols(self):
self.symbols = config.get('utf8.in-use')
self.death_symbol = config.get('utf8.death-symbol')
def __develop_warn(self, button, warning_type):
"""
Display a development warning message to the user, with the
warning_type in it.
:param warning_type: the general name of the warning, e.g. "master"
:type warning_type: str
"""
WarningDialog(
_('Danger: This is unstable code!'),
_("This Gramps ('%s') is a development release.\n"
) % warning_type +
_("This version is not meant for normal usage. Use "
"at your own risk.\n"
"\n"
"This version may:\n"
"1) Work differently than you expect.\n"
"2) Fail to run at all.\n"
"3) Crash often.\n"
"4) Corrupt your data.\n"
"5) Save data in a format that is incompatible with the "
"official release.\n"
"\n"
"%(bold_start)sBACKUP%(bold_end)s "
"your existing databases before opening "
"them with this version, and make sure to export your "
"data to XML every now and then."
) % {'bold_start' : '<b>',
'bold_end' : '</b>'},
parent=self.window)

View File

@ -485,50 +485,6 @@ except ImportError:
#
#-------------------------------------------------------------------------
def _display_welcome_message(parent=None):
"""
Display a welcome message to the user.
(This docstring seems very legacy/historical, not accurate.)
"""
_display_generic_message("master", 'behavior.betawarn', parent=parent)
def _display_generic_message(warning_type, config_key, parent=None):
"""
Display a generic warning message to the user, with the
warning_type in it -- if the config_key key is not set
:param warning_type: the general name of the warning, e.g. "master"
:type warning_type: str
:param config_key: name of gramps.ini config key, e.g. "behavior.betawarn"
:type config_key: str
"""
if not config.get(config_key):
from .dialog import WarningDialog
WarningDialog(
_('Danger: This is unstable code!'),
_("This Gramps ('%s') is a development release.\n"
) % warning_type +
_("This version is not meant for normal usage. Use "
"at your own risk.\n"
"\n"
"This version may:\n"
"1) Work differently than you expect.\n"
"2) Fail to run at all.\n"
"3) Crash often.\n"
"4) Corrupt your data.\n"
"5) Save data in a format that is incompatible with the "
"official release.\n"
"\n"
"%(bold_start)sBACKUP%(bold_end)s "
"your existing databases before opening "
"them with this version, and make sure to export your "
"data to XML every now and then."
) % {'bold_start' : '<b>',
'bold_end' : '</b>'},
parent=parent)
config.set('behavior.autoload', False)
config.set(config_key, True)
def _display_gtk_gettext_message(parent=None):
"""
Display a GTK-translations-missing message to the user.
@ -618,8 +574,6 @@ class Gramps:
and not gettext.find(GTK_GETTEXT_DOMAIN)):
_display_gtk_gettext_message(parent=self._vm.window)
_display_welcome_message(parent=self._vm.window)
_display_translator_message(parent=self._vm.window)
self._vm.init_interface()

View File

@ -60,6 +60,10 @@ class Statusbar(Gtk.Box):
self.__warnbtn = WarnButton()
self.__version = Gtk.Button()
self.__version.set_relief(Gtk.ReliefStyle.NONE)
self.__version.get_style_context().add_class("destructive-action")
self.__status = Gtk.Statusbar()
self.__status.show()
@ -71,6 +75,7 @@ class Statusbar(Gtk.Box):
self.pack_start(self.__progress, False, True, 4)
self.pack_start(self.__status, True, True, 4)
self.pack_end(self.__filter, False, True, 4)
self.pack_end(self.__version, False, True, 4)
def get_warning_button(self):
"""Return the warning button widget."""
@ -80,6 +85,10 @@ class Statusbar(Gtk.Box):
"""Return the progress bar widget."""
return self.__progress
def get_version_btn(self):
"""Return the version button widget."""
return self.__version
def get_context_id(self, context_description):
"""Return a new or existing context identifier."""
return self.__status.get_context_id(context_description)

View File

@ -18,6 +18,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
DEV_VERSION = True
VERSION_TUPLE = (5, 2, 0)
VERSION_QUALIFIER = ""
VERSION = '.'.join(map(str,VERSION_TUPLE)) + VERSION_QUALIFIER