From eff89532076f64f6ce8f08a2daa78ea0f645d918 Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 15 Dec 2015 10:41:10 +0100 Subject: [PATCH 1/7] Create geo_uri.lua Maps in 3.20 will be able to handle the 'geo' URI scheme. That means that if you enter the shortcut Gnome Maps will present the current window if there is one and go to location, and start a new instance of maps if there is none. --- contrib/geo_uri.lua | 96 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 contrib/geo_uri.lua diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua new file mode 100644 index 0000000..12ac1e1 --- /dev/null +++ b/contrib/geo_uri.lua @@ -0,0 +1,96 @@ +--[[ + This file is part of darktable, + Copyright 2014 by Tobias Jakobs. + + This program 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. + + This program 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 this program. If not, see . +]] +--[[ +darktable script to open a geo uri in gnome-maps + +ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT +* gnome-maps >= 3.20 + +WARNING +This script is not testet. + +USAGE +* require this script from your main lua file +* register a shortcut +]] + +local dt = require "darktable" +dt.configuration.check_version(...,{2,0,1}) + +local function checkIfBinExists(bin) + local handle = io.popen("which "..bin) + local result = handle:read() + local ret + handle:close() + if (not result) then + dt.print_error(bin.." not found") + ret = false + end + ret = true + return ret +end + +local function openLocationInGnomeMaps() + if not checkIfBinExists("gnome-maps") then + darktable.print_error("gnome-maps not found") + return + end + + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local i = 0; + + local sel_images = dt.gui.selection() + +-- Use the first image with geo information + for _,image in ipairs(sel_images) do + if ((image.longitude and image.latitude) and + (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + ) then + + i = i + 1; + + if (i == 1) then + lat1 = image.latitude; + lon1 = image.longitude; + end + + end + end + + if (lat1 and lon1) then + + local startCommand + + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" + end + + dt.print_error(startCommand) + + if coroutine.yield("RUN_COMMAND", startCommand) + then + dt.print("Command failed ...") + end + + end +end + +-- Register +dt.register_event("shortcut", openLocationInGnomeMaps, "Open Location in Gnome Maps") From c56766ef8582238e50182a178233cc5d6ac70030 Mon Sep 17 00:00:00 2001 From: supertobi Date: Wed, 16 Dec 2015 13:51:35 +0100 Subject: [PATCH 2/7] Fixed spaces --- contrib/geo_uri.lua | 84 +++++++++++++++++++++------------------------ 1 file changed, 40 insertions(+), 44 deletions(-) diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua index 12ac1e1..57f58bf 100644 --- a/contrib/geo_uri.lua +++ b/contrib/geo_uri.lua @@ -33,63 +33,59 @@ local dt = require "darktable" dt.configuration.check_version(...,{2,0,1}) local function checkIfBinExists(bin) - local handle = io.popen("which "..bin) - local result = handle:read() - local ret - handle:close() - if (not result) then - dt.print_error(bin.." not found") - ret = false - end - ret = true - return ret + local handle = io.popen("which "..bin) + local result = handle:read() + local ret + handle:close() + if (not result) then + dt.print_error(bin.." not found") + ret = false + end + ret = true + return ret end local function openLocationInGnomeMaps() - if not checkIfBinExists("gnome-maps") then - darktable.print_error("gnome-maps not found") - return - end + if not checkIfBinExists("gnome-maps") then + darktable.print_error("gnome-maps not found") + return + end - local sel_images = dt.gui.selection() - - local lat1 = 0; - local lon1 = 0; - local i = 0; - - local sel_images = dt.gui.selection() - --- Use the first image with geo information - for _,image in ipairs(sel_images) do - if ((image.longitude and image.latitude) and - (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data - ) then - - i = i + 1; - - if (i == 1) then - lat1 = image.latitude; - lon1 = image.longitude; - end - + local sel_images = dt.gui.selection() + + local lat1 = 0; + local lon1 = 0; + local i = 0; + + local sel_images = dt.gui.selection() + + -- Use the first image with geo information + for _,image in ipairs(sel_images) do + if ((image.longitude and image.latitude) and + (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data + ) then + + i = i + 1; + + if (i == 1) then + lat1 = image.latitude; + lon1 = image.longitude; end + + end end if (lat1 and lon1) then - - local startCommand - - startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" - end - + local startCommand + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" dt.print_error(startCommand) - if coroutine.yield("RUN_COMMAND", startCommand) - then + if coroutine.yield("RUN_COMMAND", startCommand) then dt.print("Command failed ...") end - end + + end end -- Register From 92dcb2901043ab9dd46316f1e7b1e3270c0e7f41 Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 4 Jan 2016 22:52:31 +0100 Subject: [PATCH 3/7] Update slideshowMusic.lua Test if old_view is nil --- contrib/slideshowMusic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index d5575a2..0ba09d9 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -59,7 +59,7 @@ local function playSlideshowMusic(_, old_view, new_view) --dt.print_error(playCommand) coroutine.yield("RUN_COMMAND", playCommand) else - if (old_view.id == "slideshow") then + if (old_view and old_view.id == "slideshow") then stopCommand = "rhythmbox-client --pause" --dt.print_error(stopCommand) coroutine.yield("RUN_COMMAND", stopCommand) From d2a34226a6cbf4055d1d1e99b434451be82b47f7 Mon Sep 17 00:00:00 2001 From: supertobi Date: Mon, 4 Jan 2016 22:53:10 +0100 Subject: [PATCH 4/7] Update slideshowMusic.lua Tested with darktable 2.0 --- contrib/slideshowMusic.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/slideshowMusic.lua b/contrib/slideshowMusic.lua index 0ba09d9..3ba8944 100644 --- a/contrib/slideshowMusic.lua +++ b/contrib/slideshowMusic.lua @@ -25,7 +25,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,2}) +dt.configuration.check_version(...,{2,0,2},{3,0,0}) local function checkIfBinExists(bin) local handle = io.popen("which "..bin) From 2e0ccef3f569b9d0943539a2d12e7d3b97dec769 Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 5 Jan 2016 10:22:47 +0100 Subject: [PATCH 5/7] Update geo_uri.lua Changes suggested from Boucman --- contrib/geo_uri.lua | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua index 57f58bf..857ae61 100644 --- a/contrib/geo_uri.lua +++ b/contrib/geo_uri.lua @@ -1,6 +1,6 @@ --[[ This file is part of darktable, - Copyright 2014 by Tobias Jakobs. + Copyright 2016 by Tobias Jakobs. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,7 +30,7 @@ USAGE ]] local dt = require "darktable" -dt.configuration.check_version(...,{2,0,1}) +dt.configuration.check_version(...,{3,0,0}) local function checkIfBinExists(bin) local handle = io.popen("which "..bin) @@ -57,34 +57,25 @@ local function openLocationInGnomeMaps() local lon1 = 0; local i = 0; - local sel_images = dt.gui.selection() - -- Use the first image with geo information for _,image in ipairs(sel_images) do if ((image.longitude and image.latitude) and (image.longitude ~= 0 and image.latitude ~= 90) -- Sometimes the north-pole but most likely just wrong data ) then - - i = i + 1; - - if (i == 1) then - lat1 = image.latitude; - lon1 = image.longitude; - end - + lat1 = image.latitude; + lon1 = image.longitude; + break end end - if (lat1 and lon1) then - local startCommand - startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" - dt.print_error(startCommand) + local startCommand + startCommand = "gnome-maps \"geo:" .. lat1 .. "," .. lon1 .."\"" + dt.print_error(startCommand) - if coroutine.yield("RUN_COMMAND", startCommand) then - dt.print("Command failed ...") - end + if coroutine.yield("RUN_COMMAND", startCommand) then + dt.print("Command failed ...") end - + end end From eff4a3abcbd27aa1d79e221f436ff3999d08ad34 Mon Sep 17 00:00:00 2001 From: supertobi Date: Tue, 5 Jan 2016 10:28:31 +0100 Subject: [PATCH 6/7] Update geo_uri.lua removed the old warning --- contrib/geo_uri.lua | 3 --- 1 file changed, 3 deletions(-) diff --git a/contrib/geo_uri.lua b/contrib/geo_uri.lua index 857ae61..34ed1c4 100644 --- a/contrib/geo_uri.lua +++ b/contrib/geo_uri.lua @@ -21,9 +21,6 @@ darktable script to open a geo uri in gnome-maps ADDITIANAL SOFTWARE NEEDED FOR THIS SCRIPT * gnome-maps >= 3.20 -WARNING -This script is not testet. - USAGE * require this script from your main lua file * register a shortcut From 29c522484c60fd4072385896510f8e77c375823a Mon Sep 17 00:00:00 2001 From: Tobias Jakobs Date: Thu, 7 Jan 2016 22:01:51 +0100 Subject: [PATCH 7/7] gettextExample.lua with po and mo files --- contrib/de_DE/LC_MESSAGES/gettextExample.mo | Bin 0 -> 596 bytes contrib/de_DE/LC_MESSAGES/gettextExample.po | 20 ++++++++ contrib/gettextExample.lua | 51 ++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 contrib/de_DE/LC_MESSAGES/gettextExample.mo create mode 100644 contrib/de_DE/LC_MESSAGES/gettextExample.po create mode 100644 contrib/gettextExample.lua diff --git a/contrib/de_DE/LC_MESSAGES/gettextExample.mo b/contrib/de_DE/LC_MESSAGES/gettextExample.mo new file mode 100644 index 0000000000000000000000000000000000000000..d0ec975e6f221cb53e8f50151df7a29177c861b0 GIT binary patch literal 596 zcmZvZ&u-K(5XJ+7OW@QqhuIs5b(&-mteh^YT3WWS6#>GZ6VhxlWL>=W%J#POL3lmx zyakgiZ7z)TljqaS*q`m+d-r}t9Cw*V%$T{)957v!%tPiq^XEntU#!#3C@P)3pgM@NMtmmcl{FF;TZEQEpr4^4AL8;|C5|0o;Hr3qfh6Q<_FSZy zNMCR&CzGdXmZsb&KG3D=cKJ_VCMWr>Z-G9D%AxTZgLM)ryHx1m4gRo84+o)_$we;@ z+chek)OP(cUZ82W*pjFS*Ai~Egofhtv-6YT5?PYQ$JPWgeAM-ZJ$Lun-)K~(fO>__ zQ<#0KPQ`TS>nwdICr(Ul8)aGv)1?aWSMiz*xt-V2QlkQ7$uxP!m7Nqv=xKvtB_WAR zy>+O?sdZ~F!EAczXL$j;boSW5Xa?DnVwitR*H_jxexZDjH?Lnb|Gq)yMN<#Cxk* literal 0 HcmV?d00001 diff --git a/contrib/de_DE/LC_MESSAGES/gettextExample.po b/contrib/de_DE/LC_MESSAGES/gettextExample.po new file mode 100644 index 0000000..25cd06b --- /dev/null +++ b/contrib/de_DE/LC_MESSAGES/gettextExample.po @@ -0,0 +1,20 @@ +msgid "" +msgstr "" +"Project-Id-Version: Lua gettextTest\n" +"POT-Creation-Date: 2016-01-07 20:33+0100\n" +"PO-Revision-Date: 2016-01-07 21:32+0100\n" +"Last-Translator: Tobias Jakobs \n" +"Language-Team: \n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.4\n" +"X-Poedit-Basepath: .\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-KeywordsList: gettext;dgettext:2;dcgettext:2;ngettext:1,2;dngettext:2,3\n" +"X-Poedit-SearchPath-0: .\n" + +#: gettextExample.lua:36 +msgid "Hello World!" +msgstr "Hallo Welt!" diff --git a/contrib/gettextExample.lua b/contrib/gettextExample.lua new file mode 100644 index 0000000..7a90410 --- /dev/null +++ b/contrib/gettextExample.lua @@ -0,0 +1,51 @@ +--[[ + This file is part of darktable, + Copyright 2016 by Tobias Jakobs. + + This program 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. + + This program 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 this program. If not, see . +]] +--[[ +darktable script to show how translations works + +To create a .mo file run: +msgfmt -v gettextExample.po -o gettextExample.mo + +USAGE +* require this script from your main lua file (Add 'require "gettextExample"' to luarc.) +* copy the script to: .config/darktable/lua/ +* copy the gettextExample.mo to .config/darktable/lua/de_DE/LC_MESSAGES + +You need to start darktable with the Lua debug option: darktable -d lua +$LANG must set to: de_DE + +The script run on darktable startup and should output this three lines: + +LUA ERROR Hello World! +LUA ERROR Bild +LUA ERROR Hallo Welt! + +]] +local dt = require "darktable" +dt.configuration.check_version(...,{3,0,0}) + +-- Not translated Text +dt.print_error("Hello World!") + +-- Translate a string using the darktable textdomain +dt.print_error(dt.gettext.gettext("image")) + +-- Tell gettext where to find the .mo file translating messages for a particular domain +dt.gettext.bindtextdomain("gettextExample",".config/darktable/lua/") +-- Translate a string using the specified textdomain +dt.print_error(dt.gettext.dgettext("gettextExample", 'Hello World!'))