hsfm/src/HSFM-GUI-Gtk-MyGUI.html
2016-06-01 19:32:51 +02:00

109 lines
12 KiB
HTML

<?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/MyGUI.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'>{-# LANGUAGE RecordWildCards #-}</span>
<a name="line-20"></a><span class='hs-comment'>{-# OPTIONS_HADDOCK ignore-exports #-}</span>
<a name="line-21"></a>
<a name="line-22"></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'>MyGUI</span> <span class='hs-keyword'>where</span>
<a name="line-23"></a>
<a name="line-24"></a>
<a name="line-25"></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-26"></a> <span class='hs-layout'>(</span>
<a name="line-27"></a> <span class='hs-varid'>newTVarIO</span>
<a name="line-28"></a> <span class='hs-layout'>)</span>
<a name="line-29"></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>
<a name="line-30"></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-31"></a><span class='hs-keyword'>import</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>
<a name="line-32"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Paths_hsfm</span>
<a name="line-33"></a> <span class='hs-layout'>(</span>
<a name="line-34"></a> <span class='hs-varid'>getDataFileName</span>
<a name="line-35"></a> <span class='hs-layout'>)</span>
<a name="line-36"></a>
<a name="line-37"></a>
<a name="line-38"></a>
<a name="line-39"></a>
<a name="line-40"></a> <span class='hs-comment'>-------------------------</span>
<a name="line-41"></a> <span class='hs-comment'>--[ Main Window Setup ]--</span>
<a name="line-42"></a> <span class='hs-comment'>-------------------------</span>
<a name="line-43"></a>
<a name="line-44"></a>
<a name="line-45"></a><a name="createMyGUI"></a><span class='hs-comment'>-- |Set up the GUI. This only creates the permanent widgets.</span>
<a name="line-46"></a><span class='hs-definition'>createMyGUI</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IO</span> <span class='hs-conid'>MyGUI</span>
<a name="line-47"></a><span class='hs-definition'>createMyGUI</span> <span class='hs-keyglyph'>=</span> <span class='hs-keyword'>do</span>
<a name="line-48"></a>
<a name="line-49"></a> <span class='hs-keyword'>let</span> <span class='hs-varid'>settings'</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkFMSettings</span> <span class='hs-conid'>False</span> <span class='hs-conid'>True</span> <span class='hs-num'>24</span>
<a name="line-50"></a> <span class='hs-varid'>settings</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>newTVarIO</span> <span class='hs-varid'>settings'</span>
<a name="line-51"></a> <span class='hs-varid'>operationBuffer</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>newTVarIO</span> <span class='hs-conid'>None</span>
<a name="line-52"></a>
<a name="line-53"></a> <span class='hs-varid'>builder</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderNew</span>
<a name="line-54"></a> <span class='hs-varid'>builderAddFromFile</span> <span class='hs-varid'>builder</span> <span class='hs-varop'>=&lt;&lt;</span> <span class='hs-varid'>getDataFileName</span> <span class='hs-str'>"data/Gtk/builder.xml"</span>
<a name="line-55"></a>
<a name="line-56"></a> <span class='hs-comment'>-- get the pre-defined gui widgets</span>
<a name="line-57"></a> <span class='hs-varid'>rootWin</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToWindow</span>
<a name="line-58"></a> <span class='hs-str'>"rootWin"</span>
<a name="line-59"></a> <span class='hs-varid'>menubarFileQuit</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToImageMenuItem</span>
<a name="line-60"></a> <span class='hs-str'>"menubarFileQuit"</span>
<a name="line-61"></a> <span class='hs-varid'>menubarHelpAbout</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToImageMenuItem</span>
<a name="line-62"></a> <span class='hs-str'>"menubarHelpAbout"</span>
<a name="line-63"></a> <span class='hs-varid'>statusBar</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToStatusbar</span>
<a name="line-64"></a> <span class='hs-str'>"statusBar"</span>
<a name="line-65"></a> <span class='hs-varid'>clearStatusBar</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToButton</span>
<a name="line-66"></a> <span class='hs-str'>"clearStatusBar"</span>
<a name="line-67"></a> <span class='hs-varid'>fpropGrid</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToGrid</span>
<a name="line-68"></a> <span class='hs-str'>"fpropGrid"</span>
<a name="line-69"></a> <span class='hs-varid'>fpropFnEntry</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToEntry</span>
<a name="line-70"></a> <span class='hs-str'>"fpropFnEntry"</span>
<a name="line-71"></a> <span class='hs-varid'>fpropLocEntry</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToEntry</span>
<a name="line-72"></a> <span class='hs-str'>"fpropLocEntry"</span>
<a name="line-73"></a> <span class='hs-varid'>fpropTsEntry</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToEntry</span>
<a name="line-74"></a> <span class='hs-str'>"fpropTsEntry"</span>
<a name="line-75"></a> <span class='hs-varid'>fpropModEntry</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToEntry</span>
<a name="line-76"></a> <span class='hs-str'>"fpropModEntry"</span>
<a name="line-77"></a> <span class='hs-varid'>fpropAcEntry</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToEntry</span>
<a name="line-78"></a> <span class='hs-str'>"fpropAcEntry"</span>
<a name="line-79"></a> <span class='hs-varid'>fpropFTEntry</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToEntry</span>
<a name="line-80"></a> <span class='hs-str'>"fpropFTEntry"</span>
<a name="line-81"></a> <span class='hs-varid'>fpropPermEntry</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToEntry</span>
<a name="line-82"></a> <span class='hs-str'>"fpropPermEntry"</span>
<a name="line-83"></a> <span class='hs-varid'>fpropLDEntry</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToEntry</span>
<a name="line-84"></a> <span class='hs-str'>"fpropLDEntry"</span>
<a name="line-85"></a> <span class='hs-varid'>notebook</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>builderGetObject</span> <span class='hs-varid'>builder</span> <span class='hs-varid'>castToNotebook</span>
<a name="line-86"></a> <span class='hs-str'>"notebook"</span>
<a name="line-87"></a>
<a name="line-88"></a> <span class='hs-comment'>-- construct the gui object</span>
<a name="line-89"></a> <span class='hs-keyword'>let</span> <span class='hs-varid'>menubar</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkMenuBar</span> <span class='hs-layout'>{</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>}</span>
<a name="line-90"></a> <span class='hs-keyword'>let</span> <span class='hs-varid'>fprop</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkFilePropertyGrid</span> <span class='hs-layout'>{</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>}</span>
<a name="line-91"></a> <span class='hs-keyword'>let</span> <span class='hs-varid'>mygui</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>MkMyGUI</span> <span class='hs-layout'>{</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>}</span>
<a name="line-92"></a>
<a name="line-93"></a> <span class='hs-comment'>-- sets the default icon</span>
<a name="line-94"></a> <span class='hs-keyword'>_</span> <span class='hs-keyglyph'>&lt;-</span> <span class='hs-varid'>windowSetDefaultIconFromFile</span>
<a name="line-95"></a> <span class='hs-varop'>=&lt;&lt;</span> <span class='hs-varid'>getDataFileName</span> <span class='hs-str'>"data/Gtk/icons/hsfm.png"</span>
<a name="line-96"></a>
<a name="line-97"></a> <span class='hs-varid'>return</span> <span class='hs-varid'>mygui</span>
</pre></body>
</html>