<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ --> <title>src/HSFM/GUI/Gtk/Data.hs</title> <link type='text/css' rel='stylesheet' href='hscolour.css' /> </head> <body> <pre><a name="line-1"></a><span class='hs-comment'>{-- <a name="line-2"></a>HSFM, a filemanager written in Haskell. <a name="line-3"></a>Copyright (C) 2016 Julian Ospald <a name="line-4"></a> <a name="line-5"></a>This program is free software; you can redistribute it and/or <a name="line-6"></a>modify it under the terms of the GNU General Public License <a name="line-7"></a>version 2 as published by the Free Software Foundation. <a name="line-8"></a> <a name="line-9"></a>This program is distributed in the hope that it will be useful, <a name="line-10"></a>but WITHOUT ANY WARRANTY; without even the implied warranty of <a name="line-11"></a>MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the <a name="line-12"></a>GNU General Public License for more details. <a name="line-13"></a> <a name="line-14"></a>You should have received a copy of the GNU General Public License <a name="line-15"></a>along with this program; if not, write to the Free Software <a name="line-16"></a>Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <a name="line-17"></a>--}</span> <a name="line-18"></a> <a name="line-19"></a><span class='hs-comment'>{-# OPTIONS_HADDOCK ignore-exports #-}</span> <a name="line-20"></a> <a name="line-21"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>HSFM</span><span class='hs-varop'>.</span><span class='hs-conid'>GUI</span><span class='hs-varop'>.</span><span class='hs-conid'>Gtk</span><span class='hs-varop'>.</span><span class='hs-conid'>Data</span> <span class='hs-keyword'>where</span> <a name="line-22"></a> <a name="line-23"></a> <a name="line-24"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Concurrent</span><span class='hs-varop'>.</span><span class='hs-conid'>MVar</span> <a name="line-25"></a> <span class='hs-layout'>(</span> <a name="line-26"></a> <span class='hs-conid'>MVar</span> <a name="line-27"></a> <span class='hs-layout'>)</span> <a name="line-28"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Control</span><span class='hs-varop'>.</span><span class='hs-conid'>Concurrent</span><span class='hs-varop'>.</span><span class='hs-conid'>STM</span> <a name="line-29"></a> <span class='hs-layout'>(</span> <a name="line-30"></a> <span class='hs-conid'>TVar</span> <a name="line-31"></a> <span class='hs-layout'>)</span> <a name="line-32"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Graphics</span><span class='hs-varop'>.</span><span class='hs-conid'>UI</span><span class='hs-varop'>.</span><span class='hs-conid'>Gtk</span> <span class='hs-varid'>hiding</span> <span class='hs-layout'>(</span><span class='hs-conid'>MenuBar</span><span class='hs-layout'>)</span> <a name="line-33"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HPath</span> <a name="line-34"></a> <span class='hs-layout'>(</span> <a name="line-35"></a> <span class='hs-conid'>Abs</span> <a name="line-36"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>Path</span> <a name="line-37"></a> <span class='hs-layout'>)</span> <a name="line-38"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HSFM</span><span class='hs-varop'>.</span><span class='hs-conid'>FileSystem</span><span class='hs-varop'>.</span><span class='hs-conid'>FileType</span> <a name="line-39"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>HSFM</span><span class='hs-varop'>.</span><span class='hs-conid'>FileSystem</span><span class='hs-varop'>.</span><span class='hs-conid'>UtilTypes</span> <a name="line-40"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>System</span><span class='hs-varop'>.</span><span class='hs-conid'>INotify</span> <a name="line-41"></a> <span class='hs-layout'>(</span> <a name="line-42"></a> <span class='hs-conid'>INotify</span> <a name="line-43"></a> <span class='hs-layout'>)</span> <a name="line-44"></a> <a name="line-45"></a> <a name="line-46"></a> <a name="line-47"></a> <span class='hs-comment'>------------------</span> <a name="line-48"></a> <span class='hs-comment'>--[ Base Types ]--</span> <a name="line-49"></a> <span class='hs-comment'>------------------</span> <a name="line-50"></a> <a name="line-51"></a> <a name="line-52"></a><a name="MyGUI"></a><span class='hs-comment'>-- |Monolithic object passed to various GUI functions in order</span> <a name="line-53"></a><a name="MyGUI"></a><span class='hs-comment'>-- to keep the API stable and not alter the parameters too much.</span> <a name="line-54"></a><a name="MyGUI"></a><span class='hs-comment'>-- This only holds GUI widgets that are needed to be read during</span> <a name="line-55"></a><a name="MyGUI"></a><span class='hs-comment'>-- runtime.</span> <a name="line-56"></a><a name="MyGUI"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>MyGUI</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkMyGUI</span> <span class='hs-layout'>{</span> <a name="line-57"></a> <span class='hs-comment'>-- |main Window</span> <a name="line-58"></a> <span class='hs-varid'>rootWin</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Window</span> <a name="line-59"></a> <a name="line-60"></a> <span class='hs-comment'>-- widgets on the main window</span> <a name="line-61"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>menubar</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>MenuBar</span> <a name="line-62"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>statusBar</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Statusbar</span> <a name="line-63"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>clearStatusBar</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Button</span> <a name="line-64"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>notebook</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Notebook</span> <a name="line-65"></a> <a name="line-66"></a> <span class='hs-comment'>-- other</span> <a name="line-67"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fprop</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>FilePropertyGrid</span> <a name="line-68"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>settings</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>TVar</span> <span class='hs-conid'>FMSettings</span><span class='hs-layout'>)</span> <a name="line-69"></a> <a name="line-70"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>operationBuffer</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>TVar</span> <span class='hs-conid'>FileOperation</span><span class='hs-layout'>)</span> <a name="line-71"></a><span class='hs-layout'>}</span> <a name="line-72"></a> <a name="line-73"></a> <a name="line-74"></a><a name="MyView"></a><span class='hs-comment'>-- |This describes the contents of the current view and is separated from MyGUI,</span> <a name="line-75"></a><a name="MyView"></a><span class='hs-comment'>-- because we might want to have multiple views.</span> <a name="line-76"></a><a name="MyView"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>MyView</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkMyView</span> <span class='hs-layout'>{</span> <a name="line-77"></a> <span class='hs-varid'>view</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>TVar</span> <span class='hs-conid'>FMView</span><span class='hs-layout'>)</span> <a name="line-78"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>cwd</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>MVar</span> <span class='hs-conid'>Item</span><span class='hs-layout'>)</span> <a name="line-79"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rawModel</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>TVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>ListStore</span> <span class='hs-conid'>Item</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <a name="line-80"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>sortedModel</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>TVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>TypedTreeModelSort</span> <span class='hs-conid'>Item</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <a name="line-81"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>filteredModel</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>TVar</span> <span class='hs-layout'>(</span><span class='hs-conid'>TypedTreeModelFilter</span> <span class='hs-conid'>Item</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <a name="line-82"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>inotify</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>MVar</span> <span class='hs-conid'>INotify</span><span class='hs-layout'>)</span> <a name="line-83"></a> <a name="line-84"></a> <span class='hs-comment'>-- the first part of the tuple represents the "go back"</span> <a name="line-85"></a> <span class='hs-comment'>-- the second part the "go forth" in the history</span> <a name="line-86"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>history</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>TVar</span> <span class='hs-layout'>(</span><span class='hs-keyglyph'>[</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>,</span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>Path</span> <span class='hs-conid'>Abs</span><span class='hs-keyglyph'>]</span><span class='hs-layout'>)</span><span class='hs-layout'>)</span> <a name="line-87"></a> <a name="line-88"></a> <span class='hs-comment'>-- sub-widgets</span> <a name="line-89"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>scroll</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ScrolledWindow</span> <a name="line-90"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>viewBox</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Box</span> <a name="line-91"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcmenu</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>RightClickMenu</span> <a name="line-92"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>upViewB</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Button</span> <a name="line-93"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>homeViewB</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Button</span> <a name="line-94"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>refreshViewB</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Button</span> <a name="line-95"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>urlBar</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-96"></a><span class='hs-layout'>}</span> <a name="line-97"></a> <a name="line-98"></a> <a name="line-99"></a><a name="MenuBar"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>MenuBar</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkMenuBar</span> <span class='hs-layout'>{</span> <a name="line-100"></a> <span class='hs-varid'>menubarFileQuit</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-101"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>menubarHelpAbout</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-102"></a><span class='hs-layout'>}</span> <a name="line-103"></a> <a name="line-104"></a><a name="RightClickMenu"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>RightClickMenu</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkRightClickMenu</span> <span class='hs-layout'>{</span> <a name="line-105"></a> <span class='hs-varid'>rcMenu</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Menu</span> <a name="line-106"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileOpen</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-107"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileExecute</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-108"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileNewRegFile</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-109"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileNewDir</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-110"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileNewTab</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-111"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileNewTerm</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-112"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileCut</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-113"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileCopy</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-114"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileRename</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-115"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFilePaste</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-116"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileDelete</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-117"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileProperty</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-118"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileIconView</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-119"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rcFileTreeView</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>ImageMenuItem</span> <a name="line-120"></a><span class='hs-layout'>}</span> <a name="line-121"></a> <a name="line-122"></a><a name="FilePropertyGrid"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>FilePropertyGrid</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkFilePropertyGrid</span> <span class='hs-layout'>{</span> <a name="line-123"></a> <span class='hs-varid'>fpropGrid</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Grid</span> <a name="line-124"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fpropFnEntry</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-125"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fpropLocEntry</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-126"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fpropTsEntry</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-127"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fpropModEntry</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-128"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fpropAcEntry</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-129"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fpropFTEntry</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-130"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fpropPermEntry</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-131"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fpropLDEntry</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Entry</span> <a name="line-132"></a><span class='hs-layout'>}</span> <a name="line-133"></a> <a name="line-134"></a> <a name="line-135"></a><a name="FMSettings"></a><span class='hs-comment'>-- |FM-wide settings.</span> <a name="line-136"></a><a name="FMSettings"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>FMSettings</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkFMSettings</span> <span class='hs-layout'>{</span> <a name="line-137"></a> <span class='hs-varid'>showHidden</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Bool</span> <a name="line-138"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>isLazy</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Bool</span> <a name="line-139"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>iconSize</span> <span class='hs-keyglyph'>::</span> <span class='hs-varop'>!</span><span class='hs-conid'>Int</span> <a name="line-140"></a><span class='hs-layout'>}</span> <a name="line-141"></a> <a name="line-142"></a><a name="FMView"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>FMView</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>FMTreeView</span> <span class='hs-varop'>!</span><span class='hs-conid'>TreeView</span> <a name="line-143"></a> <span class='hs-keyglyph'>|</span> <span class='hs-conid'>FMIconView</span> <span class='hs-varop'>!</span><span class='hs-conid'>IconView</span> <a name="line-144"></a> <a name="line-145"></a><a name="Item"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>Item</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>File</span> <span class='hs-conid'>FileInfo</span> <a name="line-146"></a> <a name="line-147"></a> <a name="line-148"></a> <a name="line-149"></a><a name="fmViewToContainer"></a><span class='hs-definition'>fmViewToContainer</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>FMView</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Container</span> <a name="line-150"></a><span class='hs-definition'>fmViewToContainer</span> <span class='hs-layout'>(</span><span class='hs-conid'>FMTreeView</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>castToContainer</span> <span class='hs-varop'>.</span> <span class='hs-varid'>toGObject</span> <span class='hs-varop'>$</span> <span class='hs-varid'>x</span> <a name="line-151"></a><span class='hs-definition'>fmViewToContainer</span> <span class='hs-layout'>(</span><span class='hs-conid'>FMIconView</span> <span class='hs-varid'>x</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>castToContainer</span> <span class='hs-varop'>.</span> <span class='hs-varid'>toGObject</span> <span class='hs-varop'>$</span> <span class='hs-varid'>x</span> <a name="line-152"></a> </pre></body> </html>