diff options
Diffstat (limited to 'src/Gtk/Widgets.icl')
-rw-r--r-- | src/Gtk/Widgets.icl | 41 |
1 files changed, 41 insertions, 0 deletions
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 |