From 8408cea4b579984aa852e8b4bcfce94f3f34c9cb Mon Sep 17 00:00:00 2001 From: Nick Hall Date: Tue, 4 Feb 2020 15:41:27 +0000 Subject: [PATCH] Move beta warning into the status bar --- gramps/gen/config.py | 1 - gramps/gen/const.py | 5 ++-- gramps/gui/displaystate.py | 46 ++++++++++++++++++++++++++++++++- gramps/gui/grampsgui.py | 46 --------------------------------- gramps/gui/widgets/statusbar.py | 9 +++++++ gramps/version.py | 1 + 6 files changed, 58 insertions(+), 50 deletions(-) diff --git a/gramps/gen/config.py b/gramps/gen/config.py index f2426815c..d98764208 100644 --- a/gramps/gen/config.py +++ b/gramps/gen/config.py @@ -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") diff --git a/gramps/gen/const.py b/gramps/gen/const.py index aff4a22d1..4e2dc5f53 100644 --- a/gramps/gen/const.py +++ b/gramps/gen/const.py @@ -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,7 +145,8 @@ 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]) -VERSION += git_revision +if DEV_VERSION: + VERSION += git_revision #VERSION += "-1" # diff --git a/gramps/gui/displaystate.py b/gramps/gui/displaystate.py index e3a7ac9b8..904b2d102 100644 --- a/gramps/gui/displaystate.py +++ b/gramps/gui/displaystate.py @@ -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' : '', + 'bold_end' : ''}, + parent=self.window) diff --git a/gramps/gui/grampsgui.py b/gramps/gui/grampsgui.py index 2443acec2..702049798 100644 --- a/gramps/gui/grampsgui.py +++ b/gramps/gui/grampsgui.py @@ -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' : '', - 'bold_end' : ''}, - 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() diff --git a/gramps/gui/widgets/statusbar.py b/gramps/gui/widgets/statusbar.py index df1632af4..a5329b1d5 100644 --- a/gramps/gui/widgets/statusbar.py +++ b/gramps/gui/widgets/statusbar.py @@ -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) diff --git a/gramps/version.py b/gramps/version.py index c6a297d86..fd5e4ae49 100644 --- a/gramps/version.py +++ b/gramps/version.py @@ -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