From ad98343da1467653dacc811a9e52b7da2282c200 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Sat, 19 Oct 2019 19:57:53 +0200 Subject: Initial commit --- src/Gtk/Widgets.icl | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Gtk/Widgets.icl (limited to 'src/Gtk/Widgets.icl') diff --git a/src/Gtk/Widgets.icl b/src/Gtk/Widgets.icl new file mode 100644 index 0000000..dfeb901 --- /dev/null +++ b/src/Gtk/Widgets.icl @@ -0,0 +1,41 @@ +implementation module Gtk.Widgets + +import StdEnv +import StdMaybe + +import Control.Monad +import Control.Monad.Identity +import Control.Monad.State +import System._Pointer + +import qualified Gtk.Internal as I +import Gtk.State + +:: GtkWidget :== Int +:: GtkWindow :== Int + +instance gtkWidget GtkWidget +where + gtkWidget w = w + gtkPtr w = w + +instance gtkWidget GtkWindow +where + gtkWidget w = w + gtkPtr w = w + +newPopup :: !String !(Maybe (Int,Int)) -> State GtkState GtkWindow +newPopup title size = new_window_or_popup True title size + +newWindow :: !String !(Maybe (Int,Int)) -> State GtkState GtkWindow +newWindow title size = new_window_or_popup False title size + +new_window_or_popup :: !Bool !String !(Maybe (Int,Int)) -> State GtkState GtkWindow +new_window_or_popup is_popup title size = + toStateR ('I'.gtk_window_new is_popup) >>= \window -> + toState ('I'.gtk_window_set_title window title) >>| + (case size of + Nothing -> pure () + Just (h,v) -> toState ('I'.gtk_widget_set_size_request window h v)) >>| + toState ('I'.gtk_widget_show_all window) >>| + pure window -- cgit v1.2.3