From 87712cf0e43fed624f8a9f610be42b1fe174b9fe Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sun, 7 Oct 2012 12:59:37 +0100 Subject: [PATCH 1/3] Show the program version in the Help header. 1. On startup read the file git-rev if exists and initialize a new global G_program_version. 2. In filechooser's help page's header show the version. This helps to easily identify what version the user is running without asking him to cat git-rev file manually. --- filechooser.lua | 3 ++- reader.lua | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/filechooser.lua b/filechooser.lua index 7cde6e144..a6fdcb86c 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -498,7 +498,8 @@ function FileChooser:addAllCommands() self.commands:add(KEY_H,nil,"H", "show help page", function(self) - HelpPage:show(0, G_height, self.commands) + local title="Hotkeys "..G_program_version + HelpPage:show(0, G_height, self.commands, title) self.pagedirty = true end ) diff --git a/reader.lua b/reader.lua index afddbc65f..57c6d1ba6 100755 --- a/reader.lua +++ b/reader.lua @@ -99,6 +99,15 @@ if optarg["G"] ~= nil then globalgamma = optarg["G"] end +local vfile = io.open("git-rev", "r") +if vfile then + G_program_version = vfile:read("*a") or "?" + G_program_version = G_program_version:gsub("[\n\r]+", "") + vfile.close() +else + G_program_version = "(unknown version)" +end + if util.isEmulated()==1 then input.open("") -- SDL key codes From e9913dce40ae864c82595201e7066e71ac1cec5c Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sun, 7 Oct 2012 15:05:00 +0100 Subject: [PATCH 2/3] Generate git-rev file at compile time. The file git-rev containing the program's version should be generated at kpdfview compile time rather than package generation time. --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3664d5ba8..916e5c930 100644 --- a/Makefile +++ b/Makefile @@ -109,7 +109,9 @@ POPENNSLIB := $(POPENNSDIR)/libpopen_noshell.a all: kpdfview +VERSION?=$(shell git describe HEAD) kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o input.o $(POPENNSLIB) util.o ft.o lfs.o mupdfimg.o $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) djvu.o $(DJVULIBS) cre.o $(CRENGINELIBS) + echo $(VERSION) > git-rev $(CC) \ $(CFLAGS) \ kpdfview.o \ @@ -246,7 +248,6 @@ INSTALL_DIR=kindlepdfviewer LUA_FILES=alt_getopt.lua commands.lua crereader.lua dialog.lua djvureader.lua extentions.lua filechooser.lua filehistory.lua fileinfo.lua filesearcher.lua font.lua graphics.lua helppage.lua image.lua inputbox.lua keys.lua pdfreader.lua reader.lua rendertext.lua screen.lua selectmenu.lua settings.lua unireader.lua widget.lua -VERSION?=$(shell git describe HEAD) customupdate: all # ensure that build binary is for ARM file kpdfview | grep ARM || exit 1 @@ -254,12 +255,11 @@ customupdate: all rm -f kindlepdfviewer-$(VERSION).zip rm -rf $(INSTALL_DIR) mkdir -p $(INSTALL_DIR)/{history,screenshots} - echo $(VERSION) > $(INSTALL_DIR)/git-rev cp -p README.md COPYING kpdfview kpdf.sh $(LUA_FILES) $(INSTALL_DIR) mkdir $(INSTALL_DIR)/data cp -rpL data/*.css $(INSTALL_DIR)/data cp -rpL fonts $(INSTALL_DIR) - cp -r resources $(INSTALL_DIR) + cp -r git-rev resources $(INSTALL_DIR) mkdir $(INSTALL_DIR)/fonts/host zip -9 -r kindlepdfviewer-$(VERSION).zip $(INSTALL_DIR) launchpad/ kite/ rm -rf $(INSTALL_DIR) From 7fe288ace349d993209dd709d22f0f58061ca8ce Mon Sep 17 00:00:00 2001 From: Tigran Aivazian Date: Sun, 7 Oct 2012 15:20:31 +0100 Subject: [PATCH 3/3] No need for the local variable 'title' --- filechooser.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/filechooser.lua b/filechooser.lua index a6fdcb86c..f1b4f4aad 100644 --- a/filechooser.lua +++ b/filechooser.lua @@ -498,8 +498,7 @@ function FileChooser:addAllCommands() self.commands:add(KEY_H,nil,"H", "show help page", function(self) - local title="Hotkeys "..G_program_version - HelpPage:show(0, G_height, self.commands, title) + HelpPage:show(0, G_height, self.commands, "Hotkeys "..G_program_version) self.pagedirty = true end )