From cf8252abf24fa76c0a6eba362f66b1f1f3358fa3 Mon Sep 17 00:00:00 2001 From: Camil Staps Date: Tue, 29 Oct 2019 17:29:09 +0100 Subject: Add general instance tune w GtkSizeRequest | gtkWidget w, remove size parameter on windows and popups --- src/Gtk/Widgets.icl | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/Gtk/Widgets.icl') diff --git a/src/Gtk/Widgets.icl b/src/Gtk/Widgets.icl index 9500b5f..b59006e 100644 --- a/src/Gtk/Widgets.icl +++ b/src/Gtk/Widgets.icl @@ -534,22 +534,26 @@ where toState (gtk_widget_add_accelerator w "activate" ag (gdk_keyval_from_name key) (toInt mask) 1) >>| pure widget +instance tune w GtkSizeRequest | gtkWidget w +where + tune (GtkSizeRequest (width,height)) widget = + let (GtkWidget w) = gtkWidget widget in + toState (gtk_widget_set_size_request w width height) >>| + pure widget + instance gtkWidget GtkWindow where gtkWidget (GtkWindow w) = GtkWidget w instance gtkContainer GtkWindow where gtkContainer (GtkWindow w) = GtkContainer w instance gtkWindow GtkWindow where gtkWindow w = w -newPopup :: !(Maybe (Int,Int)) -> GtkM GtkWindow -newPopup size = new_window_or_popup True size +newPopup :: -> GtkM GtkWindow +newPopup = new_window_or_popup True -newWindow :: !(Maybe (Int,Int)) -> GtkM GtkWindow -newWindow size = new_window_or_popup False size +newWindow :: GtkM GtkWindow +newWindow = new_window_or_popup False -new_window_or_popup :: !Bool !(Maybe (Int,Int)) -> GtkM GtkWindow -new_window_or_popup is_popup size = +new_window_or_popup :: !Bool -> GtkM GtkWindow +new_window_or_popup is_popup = toStateR (gtk_window_new is_popup) >>= \w -> - (case size of - Nothing -> pure () - Just (h,v) -> toState (gtk_widget_set_size_request w h v)) >>| show (GtkWindow w) instance tune w GtkTitle | gtkWindow w -- cgit v1.2.3