summaryrefslogtreecommitdiff
path: root/src/Gtk/Widgets
diff options
context:
space:
mode:
authorCamil Staps2019-11-01 18:41:10 +0100
committerCamil Staps2019-11-01 18:41:10 +0100
commit0497dfb79211aa1e64304fa446d230c41ca73daa (patch)
treecc29910a32b81db4430aff1a74172174039e9c25 /src/Gtk/Widgets
parentRemove dependency on supporting C code (diff)
Cleanup and add documentation
Diffstat (limited to 'src/Gtk/Widgets')
-rw-r--r--src/Gtk/Widgets/Sheet.dcl13
-rw-r--r--src/Gtk/Widgets/Sheet/Signal.dcl7
-rw-r--r--src/Gtk/Widgets/Sheet/Signal.icl6
3 files changed, 24 insertions, 2 deletions
diff --git a/src/Gtk/Widgets/Sheet.dcl b/src/Gtk/Widgets/Sheet.dcl
index 2541242..0f365d2 100644
--- a/src/Gtk/Widgets/Sheet.dcl
+++ b/src/Gtk/Widgets/Sheet.dcl
@@ -4,6 +4,8 @@ definition module Gtk.Widgets.Sheet
* This module provides support for GtkSheet; a spreadsheet widget. See
* https://fpaquet.github.io/gtksheet/ for more details and installation
* instructions. Use the 'Gtk with GtkSheet' environment.
+ *
+ * Note that the C library is slightly buggy.
*/
from StdMaybe import :: Maybe
@@ -26,8 +28,19 @@ instance gtkWidget GtkSheet
instance gtkContainer GtkSheet
newSheet :: !Int !Int !String -> GtkM GtkSheet
+
+/**
+ * Freezing a sheet means that the GUI will not be updated; all model updates
+ * are collected and the GUI is updated in a single step when the sheet is
+ * unfrozen. This is a wrapper function which freezes the sheet, executes the
+ * monad, and then unfreezes the sheet again.
+ */
whileFrozen :: !(GtkM a) !GtkSheet -> GtkM a
+/**
+ * Make sure the sheet has the given width and height by adding or deleting
+ * rows and columns.
+ */
ensureDimensions :: !Int !Int !GtkSheet -> GtkM GtkSheet
setColumnTitle :: !Int !String !GtkSheet -> GtkM GtkSheet
diff --git a/src/Gtk/Widgets/Sheet/Signal.dcl b/src/Gtk/Widgets/Sheet/Signal.dcl
index 5708651..9084b4d 100644
--- a/src/Gtk/Widgets/Sheet/Signal.dcl
+++ b/src/Gtk/Widgets/Sheet/Signal.dcl
@@ -4,11 +4,16 @@ from StdMaybe import :: Maybe
from Gtk.Signal import class signalHandler, :: SignalHandlerInternal
from Gtk.State import :: GtkM
+from Gtk.Tune import class tune
+from Gtk.Types import :: GtkPropagate
+from Gtk.Widgets import class gtkWidget
:: GtkSheetSignalHandler
= DeactivateHandler !(Int Int -> GtkM Bool)
- | EnterPressedHandler !(GtkM Bool)
+ | EnterPressedHandler !(GtkM GtkPropagate)
| SheetActivateHandler !(Int Int -> GtkM ())
| TraverseHandler !((Maybe (Int,Int)) (Int,Int) -> GtkM (Maybe (Int, Int)))
instance signalHandler GtkSheetSignalHandler
+
+instance tune w GtkSheetSignalHandler | gtkWidget w
diff --git a/src/Gtk/Widgets/Sheet/Signal.icl b/src/Gtk/Widgets/Sheet/Signal.icl
index 6de4209..d08f4dd 100644
--- a/src/Gtk/Widgets/Sheet/Signal.icl
+++ b/src/Gtk/Widgets/Sheet/Signal.icl
@@ -18,7 +18,7 @@ where
TraverseHandler _ -> "traverse"
signalHandler handler = case handler of
DeactivateHandler f -> SHI_Int_Int_Bool f
- EnterPressedHandler f -> SHI_Pointer_Bool \_ -> not <$> f
+ EnterPressedHandler f -> SHI_Pointer_Bool \_ -> (\p -> p=:StopPropagation) <$> f
SheetActivateHandler f -> SHI_Int_Int_Bool \r c -> f r c >>| pure True
TraverseHandler f -> SHI_Int_Int_Pointer_Pointer_Bool \oldrow oldcol newrowp newcolp ->
let newrow = readInt4S newrowp 0; newcol = readInt4S newcolp 0 in
@@ -35,3 +35,7 @@ where
appWorld (forceEval (writeInt4 newrowp 0 row)) >>|
appWorld (forceEval (writeInt4 newcolp 0 col)) >>|
pure True)
+
+instance tune w GtkSheetSignalHandler | gtkWidget w
+where
+ tune handler widget = installSignalHandler handler widget