Skip to content

Commit

Permalink
Updates to version 2.3.0.0. Switches to cross compatible XdgCache pat…
Browse files Browse the repository at this point in the history
…h for temporary frames.
  • Loading branch information
lettier committed Sep 21, 2017
1 parent 755ed9d commit 33b9eb6
Show file tree
Hide file tree
Showing 9 changed files with 263 additions and 549 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Changelog

### 2.2.0.1
### 2.3.0.0

#### Downstreams

Expand All @@ -12,10 +12,12 @@

- Support for GTK 3.10
- Logo to about dialog
- `findOrCreateTemporaryDirectory` to Gifcurry library API

#### Changed

- Switched icon from ICO to PNG
- Use XdgCache location for cross compatible way of storing temporary files

#### Removed

Expand Down
2 changes: 1 addition & 1 deletion Gifcurry.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Gifcurry
version: 2.2.0.1
version: 2.3.0.0
synopsis: GIF creation utility.
description: Create animated GIFs, optionally overlaid with text, from video files.
homepage: https://github.com/lettier/gifcurry
Expand Down
311 changes: 90 additions & 221 deletions logo/logo-1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ STACK_GHC_EXE=`$(STACK) path --compiler-exe`
STACK_GHC_BIN=`$(STACK) path --compiler-bin`
STACK_PATHS=$(STACK_PATH_LOCAL_BIN):$(STACK_GHC_BIN)
CABAL=env PATH=$(PATH):$(STACK_PATHS) $(STACK_PATH_LOCAL_BIN)/cabal
VERSION='2.2.0.1'
VERSION='2.3.0.0'

export PATH := $(PATH):$(STACK_PATH_LOCAL_BIN)

Expand Down
2 changes: 1 addition & 1 deletion packaging/linux/gifcurry-gui-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# (C) 2017 David Lettier
# lettier.com

GIFCURRY_VERSION="2.2.0.1"
GIFCURRY_VERSION="2.3.0.0"
GIFCURRY_RELEASES_DOWNLOAD="https://github.com/lettier/gifcurry/releases/download/$GIFCURRY_VERSION"
GIFCURRY_PACKAGING_LINUX="https://raw.githubusercontent.com/lettier/gifcurry/master/packaging/linux"
GIFCURRY_APP_IMAGE="gifcurry-$GIFCURRY_VERSION-x86_64.AppImage"
Expand Down
400 changes: 91 additions & 309 deletions src/data/gifcurry-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/data/gui.glade
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ Author: David Lettier
<property name="transient_for">gifcurry-window</property>
<property name="attached_to">gifcurry-window</property>
<property name="program_name">Gifcurry</property>
<property name="version">2.2.0.1</property>
<property name="version">2.3.0.0</property>
<property name="copyright" translatable="yes">(C) 2016 David Lettier
lettier.com</property>
<property name="website">https://github.com/lettier/gifcurry</property>
Expand Down
71 changes: 61 additions & 10 deletions src/gui/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import qualified Gifcurry (
, defaultGifParams
, gifParamsValid
, getVideoDurationInSeconds
, findOrCreateTemporaryDirectory
)
import qualified GtkMainSyncAsync (gtkMainSync, gtkMainAsync)

Expand Down Expand Up @@ -75,6 +76,8 @@ main = do
GI.Gtk.dialogAddActionWidget longGifGtkMessageDialog yesGtkButton (enumToInt32 GI.Gtk.ResponseTypeYes)
GI.Gtk.dialogAddActionWidget longGifGtkMessageDialog noGtkButton (enumToInt32 GI.Gtk.ResponseTypeNo)

temporaryDirectory <- Gifcurry.findOrCreateTemporaryDirectory

_ <- GI.Gtk.onFileChooserButtonFileSet inputFileButton $ do
setStatusEntryReady statusEntry
GI.Gtk.imageSetFromIconName firstFrameImage
Expand All @@ -91,14 +94,31 @@ main = do
_ <- GI.Gtk.entrySetText startTimeEntry startText
_ <- GI.Gtk.entrySetText durationTimeEntry durationText
unless (Data.Text.null startText || Data.Text.null durationText) (
makeFirstFramePreview inputFileButton startTimeEntry durationTimeEntry firstFrameImage lastFrameImage
makeFirstFramePreview
inputFileButton
startTimeEntry
durationTimeEntry
firstFrameImage
lastFrameImage
temporaryDirectory
)

_ <- GI.Gtk.onEditableChanged startTimeEntry $
makeFirstFramePreview inputFileButton startTimeEntry durationTimeEntry firstFrameImage lastFrameImage
makeFirstFramePreview
inputFileButton
startTimeEntry
durationTimeEntry
firstFrameImage
lastFrameImage
temporaryDirectory

_ <- GI.Gtk.onEditableChanged durationTimeEntry $
makeLastFramePreview inputFileButton startTimeEntry durationTimeEntry lastFrameImage
makeLastFramePreview
inputFileButton
startTimeEntry
durationTimeEntry
lastFrameImage
temporaryDirectory

_ <- GI.Gtk.onWidgetButtonReleaseEvent createButton $ \ _ -> do
inputFilePathName <- inputFileButtonGetText inputFileButton
Expand Down Expand Up @@ -238,10 +258,22 @@ ioSuccess = fmap isRight
framePreviewDirectoryName :: String
framePreviewDirectoryName = "gifcurry-frame-previews"

makeLastFramePreview :: GI.Gtk.FileChooserButton -> GI.Gtk.Entry -> GI.Gtk.Entry -> GI.Gtk.Image -> IO ()
makeLastFramePreview inputFileButton startTimeEntry durationTimeEntry lastFrameImage =
makeLastFramePreview ::
GI.Gtk.FileChooserButton ->
GI.Gtk.Entry ->
GI.Gtk.Entry ->
GI.Gtk.Image ->
System.FilePath.FilePath ->
IO ()
makeLastFramePreview
inputFileButton
startTimeEntry
durationTimeEntry
lastFrameImage
temporaryDirectory
=
void $ forkIO $
withTempDirectory "." framePreviewDirectoryName $ \ tmpdir -> do
withTempDirectory temporaryDirectory framePreviewDirectoryName $ \ tmpdir -> do
inputFilePathName <- inputFileButtonGetText inputFileButton
startTimeText <- GI.Gtk.entryGetText startTimeEntry
durationTimeText <- GI.Gtk.entryGetText durationTimeEntry
Expand All @@ -258,17 +290,36 @@ makeLastFramePreview inputFileButton startTimeEntry durationTimeEntry lastFrameI
_ <- setOrResetFramePrevew doSet inputFilePathName outputFilePathName startTime lastFrameImage " LAST FRAME "
return()

makeFirstFramePreview :: GI.Gtk.FileChooserButton -> GI.Gtk.Entry -> GI.Gtk.Entry -> GI.Gtk.Image -> GI.Gtk.Image -> IO ()
makeFirstFramePreview inputFileButton startTimeEntry durationTimeEntry firstFrameImage lastFrameImage =
makeFirstFramePreview ::
GI.Gtk.FileChooserButton ->
GI.Gtk.Entry ->
GI.Gtk.Entry ->
GI.Gtk.Image ->
GI.Gtk.Image ->
System.FilePath.FilePath ->
IO ()
makeFirstFramePreview
inputFileButton
startTimeEntry
durationTimeEntry
firstFrameImage
lastFrameImage
temporaryDirectory
=
void $ forkIO $ do
withTempDirectory "." framePreviewDirectoryName $ \ tmpDir -> do
withTempDirectory temporaryDirectory framePreviewDirectoryName $ \ tmpDir -> do
inputFilePathName <- inputFileButtonGetText inputFileButton
startTime <- entryGetFloat startTimeEntry (-1.0)
let outputFilePathName = tmpDir ++ "/gifcurry-first-frame-preview.gif"
let doSet = not (Data.List.null inputFilePathName) && (startTime >= 0.0)
_ <- setOrResetFramePrevew doSet inputFilePathName outputFilePathName startTime firstFrameImage " FIRST FRAME "
return ()
makeLastFramePreview inputFileButton startTimeEntry durationTimeEntry lastFrameImage
makeLastFramePreview
inputFileButton
startTimeEntry
durationTimeEntry
lastFrameImage
temporaryDirectory

setOrResetFramePrevew :: Bool -> String -> String -> Float -> GI.Gtk.Image -> String -> IO ()
setOrResetFramePrevew False _ _ _ image _ = GtkMainSyncAsync.gtkMainAsync $ resetImage image
Expand Down
18 changes: 14 additions & 4 deletions src/lib/Gifcurry.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module Gifcurry (
, gifParamsValid
, versionNumber
, getVideoDurationInSeconds
, findOrCreateTemporaryDirectory
) where

import System.Process
Expand Down Expand Up @@ -44,7 +45,7 @@ data GifParams = GifParams {

-- | The version number.
versionNumber :: String
versionNumber = "2.2.0.1"
versionNumber = "2.3.0.0"

-- | Specifies default parameters for 'startTime', 'durationTime', 'widthSize', 'qualityPercent', and 'fontChoice'.
defaultGifParams :: GifParams
Expand Down Expand Up @@ -75,13 +76,14 @@ defaultGifParams = GifParams {
-- else return ()
-- @
gif :: GifParams -> IO (Either IOError String)
gif gifParams =
withTempDirectory "." "gifcurry-frames" $ \tmpdir -> do
gif gifParams = do
temporaryDirectory <- findOrCreateTemporaryDirectory
withTempDirectory temporaryDirectory "gifcurry-frames" $ \tmpdir -> do
printGifParams gifParams tmpdir
validParams <- gifParamsValid gifParams
if validParams
then do
fFMpegResult <- tryFfmpeg gifParams tmpdir
fFMpegResult <- tryFfmpeg gifParams tmpdir
let fFMpegSuccess = eitherBool fFMpegResult
if fFMpegSuccess
then do
Expand Down Expand Up @@ -155,6 +157,14 @@ getVideoDurationInSeconds gifParams = tryFfprobe gifParams >>= result
result (Left _) = return Nothing
result (Right durationString) = return (readMaybe durationString :: Maybe Float)

-- | Finds or creates the temporary directory for Gifcurry.
-- This directory is used for storing temporary frames.
findOrCreateTemporaryDirectory :: IO FilePath
findOrCreateTemporaryDirectory = do
filePath <- System.Directory.getXdgDirectory System.Directory.XdgCache "gifcurry"
System.Directory.createDirectoryIfMissing True filePath
return filePath

printGifParams :: GifParams -> String -> IO ()
printGifParams
GifParams {
Expand Down

0 comments on commit 33b9eb6

Please sign in to comment.