diff options
author | Camil Staps | 2020-01-27 08:17:47 +0100 |
---|---|---|
committer | Camil Staps | 2020-01-27 08:17:47 +0100 |
commit | 9618e5bb7a189af1ee9bc5bda0588face013b2f1 (patch) | |
tree | a02d08f438ded10ffbd2457b13de6f1e30192f1d | |
parent | Add GtkTreeViewColumnSizing for TreeView columns (diff) |
Add support for populate-popup signal
-rw-r--r-- | src/Gtk/Signal.dcl | 5 | ||||
-rw-r--r-- | src/Gtk/Signal.icl | 22 | ||||
-rw-r--r-- | src/Gtk/Widgets.dcl | 3 | ||||
-rw-r--r-- | src/Gtk/Widgets.icl | 1 |
4 files changed, 26 insertions, 5 deletions
diff --git a/src/Gtk/Signal.dcl b/src/Gtk/Signal.dcl index 85a780c..d377f09 100644 --- a/src/Gtk/Signal.dcl +++ b/src/Gtk/Signal.dcl @@ -10,7 +10,7 @@ from Gdk.Events import :: GdkEvent from Gtk.State import :: GtkM, :: GtkState from Gtk.Tune import class tune from Gtk.Types import :: GtkPropagate, :: GtkTimeout -from Gtk.Widgets import class gtkWidget +from Gtk.Widgets import class gtkWidget, :: GtkMenu /** * If more handlers are defined outside this module (and hence outside the @@ -33,6 +33,7 @@ where | DestroyHandler !(GtkM ()) | KeyPressHandler !(GdkEvent -> GtkM GtkPropagate) | NextMatchHandler !(GtkM ()) + | PopulatePopupHandler !(GtkMenu -> GtkM ()) | PreviousMatchHandler !(GtkM ()) | SearchChangedHandler !(GtkM ()) | StopSearchHandler !(GtkM ()) @@ -45,6 +46,7 @@ instance signalHandler GSignalHandler */ :: SignalHandlerInternal = SHI_Void !(GtkM ()) + | SHI_Pointer_Void !(Pointer -> GtkM ()) | SHI_Pointer_Bool !(Pointer -> GtkM Bool) | SHI_Int_Int_Bool !(Int Int -> GtkM Bool) | SHI_Int_Int_Pointer_Pointer_Bool !(Int Int Pointer Pointer -> GtkM Bool) @@ -88,6 +90,7 @@ retrieveState :: GtkM GtkState // The functions below are only exported because they need a foreign export entry point: handleSignal_void :: !Pointer !Int -> Int +handleSignal_pointer_void :: !Pointer !Pointer !Int -> Int handleSignal_pointer_bool :: !Pointer !Pointer !Int -> Int handleSignal_int_int_bool :: !Pointer !Int !Int !Int -> Int handleSignal_int_int_pointer_pointer_bool :: !Pointer !Int !Int !Pointer !Pointer !Int -> Int diff --git a/src/Gtk/Signal.icl b/src/Gtk/Signal.icl index be019b5..fd86293 100644 --- a/src/Gtk/Signal.icl +++ b/src/Gtk/Signal.icl @@ -23,6 +23,7 @@ where DestroyHandler _ -> "destroy" KeyPressHandler _ -> "key-press-event" NextMatchHandler _ -> "next-match" + PopulatePopupHandler _ -> "populate-popup" PreviousMatchHandler _ -> "previous-match" SearchChangedHandler _ -> "search-changed" StopSearchHandler _ -> "stop-search" @@ -34,6 +35,7 @@ where DestroyHandler f -> SHI_Void f KeyPressHandler f -> SHI_Pointer_Bool \ev -> toBool <$> f (GdkEvent ev) NextMatchHandler f -> SHI_Void f + PopulatePopupHandler f -> SHI_Pointer_Void \m -> f (gtkCast m) PreviousMatchHandler f -> SHI_Void f SearchChangedHandler f -> SHI_Void f StopSearchHandler f -> SHI_Void f @@ -55,22 +57,27 @@ installSignalHandler handler widget = where callback handler = case handler of SHI_Void _ -> callback_void - SHI_Int_Int_Bool _ -> callback_int_int_bool + SHI_Pointer_Void _ -> callback_pointer_void SHI_Pointer_Bool _ -> callback_pointer_bool + SHI_Int_Int_Bool _ -> callback_int_int_bool SHI_Int_Int_Pointer_Pointer_Bool _ -> callback_int_int_pointer_pointer_bool callback_void :: Pointer callback_void = code { pushLc handleSignal_void } - callback_int_int_bool :: Pointer - callback_int_int_bool = code { - pushLc handleSignal_int_int_bool + callback_pointer_void :: Pointer + callback_pointer_void = code { + pushLc handleSignal_pointer_void } callback_pointer_bool :: Pointer callback_pointer_bool = code { pushLc handleSignal_pointer_bool } + callback_int_int_bool :: Pointer + callback_int_int_bool = code { + pushLc handleSignal_int_int_bool + } callback_int_int_pointer_pointer_bool :: Pointer callback_int_int_pointer_pointer_bool = code { pushLc handleSignal_int_int_pointer_pointer_bool @@ -141,6 +148,13 @@ handleSignal_void _ id = handleSignal id \h -> case h of -> Just (toInt <$> f) -> Nothing +foreign export handleSignal_pointer_void +handleSignal_pointer_void :: !Pointer !Pointer !Int -> Int +handleSignal_pointer_void _ p id = handleSignal id \h -> case h of + SHI_Pointer_Void f + -> Just (toInt <$> f p) + -> Nothing + foreign export handleSignal_pointer_bool handleSignal_pointer_bool :: !Pointer !Pointer !Int -> Int handleSignal_pointer_bool _ p id = handleSignal id \h -> case h of diff --git a/src/Gtk/Widgets.dcl b/src/Gtk/Widgets.dcl index 2857045..13fbef4 100644 --- a/src/Gtk/Widgets.dcl +++ b/src/Gtk/Widgets.dcl @@ -32,6 +32,8 @@ from Gtk.Types import :: GtkSizeRequest, :: GtkSortable, :: GtkSpacing, :: GtkStylePriority, :: GtkText, :: GtkTitle, :: GtkTreeViewColumnSizing, :: GtkWrapMode +class gtkCast w :: !Pointer -> w + /** * A `GtkAccelGroup` is needed for a `GtkAccelerator`. 'Accelerator' is Gtk's * term for what most people call shortcuts, i.e. `Ctrl`-`S`, etc. @@ -229,6 +231,7 @@ swapItems :: !Int !Int !GtkListStore -> GtkM Bool */ :: GtkMenu (=: GtkMenu Pointer) instance gtkWidget GtkMenu +instance gtkCast GtkMenu newMenu :: GtkM GtkMenu diff --git a/src/Gtk/Widgets.icl b/src/Gtk/Widgets.icl index 34d0065..6b0e77c 100644 --- a/src/Gtk/Widgets.icl +++ b/src/Gtk/Widgets.icl @@ -311,6 +311,7 @@ swapItems a b (GtkListStore s) = :: GtkMenu =: GtkMenu Pointer instance gtkWidget GtkMenu where gtkWidget (GtkMenu m) = GtkWidget m +instance gtkCast GtkMenu where gtkCast p = GtkMenu p newMenu :: GtkM GtkMenu newMenu = |