From cfb428a70e34cb4abb036d454edacd21e0e16aec Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Thu, 28 Jul 2016 21:14:31 +0200 Subject: [PATCH] Dump glade --- CG2.cabal | 2 +- GUI/Gtk.hs | 69 +++++---- GUI/{gtk2.glade => gtk2.xml} | 271 ++++++++++++++++++----------------- 3 files changed, 174 insertions(+), 168 deletions(-) rename GUI/{gtk2.glade => gtk2.xml} (89%) diff --git a/CG2.cabal b/CG2.cabal index 9ea0ba4..e5c3c7c 100644 --- a/CG2.cabal +++ b/CG2.cabal @@ -86,7 +86,7 @@ executable Gtk diagrams-contrib >= 1.3.0.0, directory >=1.2, filepath >= 1.3.0.2, - glade >=0.12, + glib >=0.13, gtk >=0.12, safe >= 0.3.8, transformers >=0.4 diff --git a/GUI/Gtk.hs b/GUI/Gtk.hs index 5cfb5c4..4d9fea6 100644 --- a/GUI/Gtk.hs +++ b/GUI/Gtk.hs @@ -14,10 +14,11 @@ import Diagrams.Backend.Cairo.Internal import Graphics.Diagram.Core (DiagProp(..)) import Graphics.Diagram.Gtk import Graphics.UI.Gtk -import Graphics.UI.Gtk.Glade +import Graphics.UI.Gtk.Builder import MyPrelude import System.Directory import System.FilePath.Posix +import System.Glib.UTFString import Text.Read @@ -77,42 +78,38 @@ data MyGUI = MkMyGUI { } --- |The glade file to load the UI from. -gladeFile :: FilePath -gladeFile = "GUI/gtk2.glade" - - -- |Loads the glade file and creates the MyGUI object. makeMyGladeGUI :: IO MyGUI makeMyGladeGUI = do -- load glade file - Just xml <- xmlNew gladeFile + builder <- builderNew + builderAddFromFile builder "GUI/gtk2.xml" MkMyGUI - <$> xmlGetWidget xml castToWindow "window1" - <*> xmlGetWidget xml castToWindow "window2" - <*> xmlGetWidget xml castToButton "drawButton" - <*> xmlGetWidget xml castToButton "saveButton" - <*> xmlGetWidget xml castToButton "quitButton" - <*> xmlGetWidget xml castToFileChooserButton "filechooserButton" - <*> xmlGetWidget xml castToDrawingArea "drawingarea" - <*> xmlGetWidget xml castToDrawingArea "treedrawingarea" - <*> xmlGetWidget xml castToHScale "hscale" - <*> xmlGetWidget xml castToEntry "xlD" - <*> xmlGetWidget xml castToEntry "xuD" - <*> xmlGetWidget xml castToEntry "ylD" - <*> xmlGetWidget xml castToEntry "yuD" - <*> xmlGetWidget xml castToAboutDialog "aboutdialog" - <*> xmlGetWidget xml castToComboBox "comboalgo" - <*> xmlGetWidget xml castToCheckButton "gridcheckbutton" - <*> xmlGetWidget xml castToCheckButton "coordcheckbutton" - <*> xmlGetWidget xml castToEntry "path" - <*> xmlGetWidget xml castToBox "vbox7" - <*> xmlGetWidget xml castToBox "vbox10" - <*> xmlGetWidget xml castToEntry "rxMin" - <*> xmlGetWidget xml castToEntry "rxMax" - <*> xmlGetWidget xml castToEntry "ryMin" - <*> xmlGetWidget xml castToEntry "ryMax" + <$> builderGetObject builder castToWindow "window1" + <*> builderGetObject builder castToWindow "window2" + <*> builderGetObject builder castToButton "drawButton" + <*> builderGetObject builder castToButton "saveButton" + <*> builderGetObject builder castToButton "quitButton" + <*> builderGetObject builder castToFileChooserButton "filechooserButton" + <*> builderGetObject builder castToDrawingArea "drawingarea" + <*> builderGetObject builder castToDrawingArea "treedrawingarea" + <*> builderGetObject builder castToHScale "hscale" + <*> builderGetObject builder castToEntry "xlD" + <*> builderGetObject builder castToEntry "xuD" + <*> builderGetObject builder castToEntry "ylD" + <*> builderGetObject builder castToEntry "yuD" + <*> builderGetObject builder castToAboutDialog "aboutdialog" + <*> builderGetObject builder castToComboBox "comboalgo" + <*> builderGetObject builder castToCheckButton "gridcheckbutton" + <*> builderGetObject builder castToCheckButton "coordcheckbutton" + <*> builderGetObject builder castToEntry "path" + <*> builderGetObject builder castToBox "vbox7" + <*> builderGetObject builder castToBox "vbox10" + <*> builderGetObject builder castToEntry "rxMin" + <*> builderGetObject builder castToEntry "rxMax" + <*> builderGetObject builder castToEntry "ryMin" + <*> builderGetObject builder castToEntry "ryMax" -- |Main entry point for the GTK GUI routines. @@ -158,23 +155,23 @@ makeGUI startFile = do -- hotkeys _ <- rootWin mygui `on` keyPressEvent $ tryEvent $ do [Control] <- eventModifier - "q" <- eventKeyName + "q" <- fmap glibToString eventKeyName liftIO mainQuit _ <- treeWin mygui `on` keyPressEvent $ tryEvent $ do [Control] <- eventModifier - "q" <- eventKeyName + "q" <- fmap glibToString eventKeyName liftIO (widgetHide $ treeWin mygui) _ <- rootWin mygui `on` keyPressEvent $ tryEvent $ do [Control] <- eventModifier - "s" <- eventKeyName + "s" <- fmap glibToString eventKeyName liftIO $ saveDiag mygui _ <- rootWin mygui `on` keyPressEvent $ tryEvent $ do [Control] <- eventModifier - "d" <- eventKeyName + "d" <- fmap glibToString eventKeyName liftIO $ drawDiag mygui _ <- rootWin mygui `on` keyPressEvent $ tryEvent $ do [Control] <- eventModifier - "a" <- eventKeyName + "a" <- fmap glibToString eventKeyName liftIO $ widgetShowAll (aboutDialog mygui) -- draw widgets and start main loop diff --git a/GUI/gtk2.glade b/GUI/gtk2.xml similarity index 89% rename from GUI/gtk2.glade rename to GUI/gtk2.xml index f3595f3..0fd4942 100644 --- a/GUI/gtk2.glade +++ b/GUI/gtk2.xml @@ -1,8 +1,8 @@ - - + + - + False 5 dialog @@ -353,16 +353,16 @@ Public License instead of this License. Julian Ospald <hasufell@hasufell.de> - + True False 2 - + True False end - + True True @@ -372,10 +372,16 @@ Public License instead of this License. - + - - + + + 0.10000000000000001 + 10 + 1 + 10 + + 600 750 False @@ -383,15 +389,15 @@ Public License instead of this License. mouse dialog - + True False - + True False False - + False False @@ -399,12 +405,12 @@ Public License instead of this License. - + 600 600 True False - + True True @@ -412,16 +418,16 @@ Public License instead of this License. - + True False - + Draw True True True - + True True @@ -429,12 +435,12 @@ Public License instead of this License. - + Save True True True - + True True @@ -442,19 +448,19 @@ Public License instead of this License. - + Quit True True True - + True True 2 - + False False @@ -462,10 +468,10 @@ Public License instead of this License. - + True False - + False True @@ -474,23 +480,23 @@ Public License instead of this License. - + True False - + True False - + True False - + True False X min - + True True @@ -498,7 +504,7 @@ Public License instead of this License. - + 5 True True @@ -509,14 +515,14 @@ Public License instead of this License. False True True - + True True 1 - + True True @@ -524,15 +530,15 @@ Public License instead of this License. - + True False - + True False X max - + True True @@ -540,7 +546,7 @@ Public License instead of this License. - + 5 True True @@ -551,21 +557,21 @@ Public License instead of this License. False True True - + True True 1 - + True True 1 - + True True @@ -573,19 +579,19 @@ Public License instead of this License. - + True False - + True False - + True False Y min - + True True @@ -593,7 +599,7 @@ Public License instead of this License. - + 5 True True @@ -604,14 +610,14 @@ Public License instead of this License. False True True - + True True 1 - + True True @@ -619,15 +625,15 @@ Public License instead of this License. - + True False - + True False Y max - + True True @@ -635,7 +641,7 @@ Public License instead of this License. - + 5 True True @@ -646,21 +652,21 @@ Public License instead of this License. False True True - + True True 1 - + True True 1 - + True True @@ -668,15 +674,15 @@ Public License instead of this License. - + True False - + True False point thickness - + True True @@ -684,20 +690,21 @@ Public License instead of this License. - + True True - 2 0.10000000000000001 10 0.5 0.5 0 + adjustment1 + 999999999999999 1 left - + True True 1 - + True True @@ -705,15 +712,15 @@ Public License instead of this License. - + True False - + True False options - + True True @@ -721,17 +728,17 @@ Public License instead of this License. - + True False - + grid True True False True - + False False @@ -739,34 +746,34 @@ Public License instead of this License. - + coord True True False True - + True True 1 - + True True 1 - + False False 3 - + False False @@ -774,10 +781,10 @@ Public License instead of this License. - + True False - + False True @@ -786,19 +793,19 @@ Public License instead of this License. - + True False - + True False - + True False QuadTree Path - + False False @@ -807,7 +814,7 @@ Public License instead of this License. - + True True @@ -815,14 +822,14 @@ Public License instead of this License. False True True - + True True 1 - + True True @@ -830,10 +837,10 @@ Public License instead of this License. - + True False - + False True @@ -841,7 +848,7 @@ Public License instead of this License. 1 - + False False @@ -849,19 +856,19 @@ Public License instead of this License. - + True False - + True False - + True False Range search - + True True @@ -870,15 +877,15 @@ Public License instead of this License. - + True False - + True False X min - + True True @@ -886,7 +893,7 @@ Public License instead of this License. - + 5 True True @@ -895,14 +902,14 @@ Public License instead of this License. False True True - + True True 1 - + True True @@ -910,15 +917,15 @@ Public License instead of this License. - + True False - + True False X max - + True True @@ -926,7 +933,7 @@ Public License instead of this License. - + 5 True True @@ -935,14 +942,14 @@ Public License instead of this License. False True True - + True True 1 - + True True @@ -950,15 +957,15 @@ Public License instead of this License. - + True False - + True False Y min - + True True @@ -966,7 +973,7 @@ Public License instead of this License. - + 5 True True @@ -975,14 +982,14 @@ Public License instead of this License. False True True - + True True 1 - + True True @@ -990,15 +997,15 @@ Public License instead of this License. - + True False - + True False Y max - + True True @@ -1006,7 +1013,7 @@ Public License instead of this License. - + 5 True True @@ -1015,21 +1022,21 @@ Public License instead of this License. False True True - + True True 1 - + True True 4 - + False False @@ -1037,17 +1044,17 @@ Public License instead of this License. - + True False - + False True 1 - + False False @@ -1055,37 +1062,39 @@ Public License instead of this License. - + True False - Show points -Show convex hull -Show polygons -Show polygons intersection -Show quad tree squares -Show kd tree squares -Polygon Triangulation - + + Show points + Show convex hull + Show polygons + Show polygons intersection + Show quad tree squares + Show kd tree squares + Polygon Triangulation + + False False 8 - + - - + + 800 500 False Tree dialog - + True False - + - - + +