Skip to content

Re-export all widgets from AGS.Widget #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/AGS/Utils/Exec.purs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ module AGS.Utils.Exec

import Prelude

import AGS.Widget (Widget)
import Data.Array.NonEmpty (NonEmptyArray, toArray)
import Effect (Effect)
import Effect.Aff (Aff)
import Gio.Subprocess (Subprocess, forceSubprocessExit) as Gio.Subprocess
import Gtk.Widget (Widget)
import Prim.Row (class Union)
import Promise (Promise)
import Promise.Aff (toAffE)
Expand Down
97 changes: 53 additions & 44 deletions src/AGS/Widget.purs
Original file line number Diff line number Diff line change
@@ -1,50 +1,59 @@
module AGS.Widget
module AGS.Widget (module Exports) where

import AGS.Binding (Binding, SelfOrBinding, bindProp) as Exports
import AGS.Widget.Box (BoxProps, box) as Exports
import AGS.Widget.Button (ButtonProps, button, buttonImpl) as Exports
import AGS.Widget.CenterBox (CenterBoxProps, centerBox) as Exports
import AGS.Widget.CircularProgress (CircularProgressProps, circularProgress) as Exports
import AGS.Widget.Entry (EntryProps, entry) as Exports
import AGS.Widget.EventBox (EventBoxProps, eventBox) as Exports
import AGS.Widget.Icon (IconProps, icon) as Exports
import AGS.Widget.Internal
( AGSWidgetProps
, AnyF
, Any
, AnyF
, grabFocus
, mkAny
, unsafeSetProperty
, grabFocus
, withInterval
, module AGS.Binding
, module Gtk.Widget
) where

import Prelude

import AGS.Binding (SelfOrBinding)
import Data.Exists (Exists, mkExists)
import Effect (Effect)
import Effect.Uncurried (EffectFn1)
import Gtk.Widget (GtkWidgetProps, Widget)
import Type.Row (type (+))

type AGSWidgetProps r =
GtkWidgetProps
+
( setup ∷ EffectFn1 Widget Unit
, className ∷ SelfOrBinding String
, classNames ∷ Array String
, css ∷ String
, hpack ∷ String {- TODO make it a proper type -}
, vpack ∷ String {- TODO make it a proper type -}
, cursor ∷ String {- TODO make it a proper type -}
, attribute ∷ Any
| r
)

newtype AnyF a = AnyF a

type Any = Exists AnyF

mkAny ∷ ∀ a. a → Any
mkAny = mkExists <<< AnyF

-- * Methods

foreign import unsafeSetProperty ∷ ∀ a. String → a → Widget → Effect Unit

foreign import grabFocus ∷ Widget → Effect Unit

foreign import withInterval ∷ Int → Effect Unit → Widget → Effect Unit
) as Exports
import AGS.Widget.Label (LabelProps, label) as Exports
import AGS.Widget.Menu (MenuProps, menu) as Exports
import AGS.Widget.Menu.Item (MenuItem, MenuItemProps, menuItem, menuItemImpl) as Exports
import AGS.Widget.Overlay (OverlayProps, overlay) as Exports
import AGS.Widget.ProgressBar (ProgressBarProps, progressBar) as Exports
import AGS.Widget.Revealer
( GtkRevealerTransitionType
, RevealerProps
, revealer
, transitions
) as Exports
import AGS.Widget.Scrollable (ScrollableProps, scrollable) as Exports
import AGS.Widget.Slider
( Mark
, MarkPosition
, SliderProps
, markPositionBottom
, markPositionLeft
, markPositionRight
, markPositionTop
, slider
) as Exports
import AGS.Widget.Stack (StackProps, stack) as Exports
import AGS.Widget.Window (Window, WindowProps, window) as Exports
import Effect.Uncurried
( EffectFn1
, EffectFn2
, EffectFn3
, EffectFn4
, mkEffectFn1
, mkEffectFn2
, mkEffectFn3
, mkEffectFn4
, runEffectFn1
, runEffectFn2
, runEffectFn3
, runEffectFn4
) as Exports
import Untagged.Union (UndefinedOr, asOneOf) as Exports

4 changes: 3 additions & 1 deletion src/AGS/Widget/Box.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ module AGS.Widget.Box
, box
) where

import AGS.Widget (AGSWidgetProps, SelfOrBinding, Widget)
import AGS.Binding (SelfOrBinding)
import AGS.Widget.Internal (AGSWidgetProps)
import Gtk.Box (GtkBoxProps)
import Gtk.Container (GtkContainerProps)
import Gtk.Orientable (GtkOrientableProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
4 changes: 3 additions & 1 deletion src/AGS/Widget/Button.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ module AGS.Widget.Button where

import Prelude

import AGS.Widget (AGSWidgetProps, SelfOrBinding, Widget)
import AGS.Binding (SelfOrBinding)
import AGS.Widget.Internal (AGSWidgetProps)
import Effect (Effect)
import Gtk.Button (GtkButtonProps)
import Gtk.Container (GtkContainerProps)
import Gtk.Widget (Widget)
import Prim.Row (class Union)
import Type.Row (type (+))
import Unsafe.Coerce (unsafeCoerce)
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/CenterBox.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module AGS.Widget.CenterBox
, centerBox
) where

import AGS.Widget (SelfOrBinding, Widget)
import AGS.Binding (SelfOrBinding)
import AGS.Widget.Box (BoxProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Unsafe.Coerce (unsafeCoerce)
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/CircularProgress.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module AGS.Widget.CircularProgress
, circularProgress
) where

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Gtk.Container (GtkContainerProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Entry.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ module AGS.Widget.Entry

import Prelude

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Effect.Uncurried (EffectFn1)
import Gtk.Entry (GtkEntryProps)
import Gtk.Widget (Widget)
import Prim.Row (class Union)
import Type.Row (type (+))
import Unsafe.Coerce (unsafeCoerce)
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/EventBox.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ module AGS.Widget.EventBox

import Prelude

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Effect (Effect)
import Gtk.Container (GtkContainerProps)
import Gtk.Widget (Widget)
import Prim.Row (class Union)
import Type.Row (type (+))
import Unsafe.Coerce (unsafeCoerce)
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Icon.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ module AGS.Widget.Icon
, icon
) where

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Gtk.Image (GtkImageProps)
import Gtk.Misc (GtkMiscProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
File renamed without changes.
48 changes: 48 additions & 0 deletions src/AGS/Widget/Internal.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module AGS.Widget.Internal
( AGSWidgetProps
, AnyF
, Any
, mkAny
, unsafeSetProperty
, grabFocus
, withInterval
) where

import Prelude

import AGS.Binding (SelfOrBinding)
import Data.Exists (Exists, mkExists)
import Effect (Effect)
import Effect.Uncurried (EffectFn1)
import Gtk.Widget (GtkWidgetProps, Widget)
import Type.Row (type (+))

type AGSWidgetProps r =
GtkWidgetProps
+
( setup ∷ EffectFn1 Widget Unit
, className ∷ SelfOrBinding String
, classNames ∷ Array String
, css ∷ String
, hpack ∷ String {- TODO make it a proper type -}
, vpack ∷ String {- TODO make it a proper type -}
, cursor ∷ String {- TODO make it a proper type -}
, attribute ∷ Any
| r
)

newtype AnyF a = AnyF a

type Any = Exists AnyF

mkAny ∷ ∀ a. a → Any
mkAny = mkExists <<< AnyF

-- * Methods

foreign import unsafeSetProperty ∷ ∀ a. String → a → Widget → Effect Unit

foreign import grabFocus ∷ Widget → Effect Unit

foreign import withInterval ∷ Int → Effect Unit → Widget → Effect Unit

3 changes: 2 additions & 1 deletion src/AGS/Widget/Label.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ module AGS.Widget.Label
, label
) where

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Gtk.Label (GtkLabelProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Menu.purs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ module AGS.Widget.Menu

import AGS.Widget.Menu.Item

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Effect (Effect)
import Effect.Uncurried (EffectFn1)
import Gtk.Container (GtkContainerProps)
import Gtk.Menu (GtkMenuProps)
import Gtk.MenuShell (GtkMenuShellProps)
import Gtk.ScrollType (GtkScrollType)
import Gtk.Widget (Widget)
import Prelude (Unit, (<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Menu/Item.purs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module AGS.Widget.Menu.Item where

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Effect (Effect)
import Gtk.Actionable (GtkActionableProps)
import Gtk.Activatable (GtkActivatableProps)
import Gtk.Container (GtkContainerProps)
import Gtk.MenuItem (GtkMenuItemProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Overlay.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module AGS.Widget.Overlay
, overlay
) where

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/ProgressBar.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ module AGS.Widget.ProgressBar
, progressBar
) where

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Gtk.Orientable (GtkOrientableProps)
import Gtk.ProgressBar (GtkProgressBarProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Revealer.purs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ module AGS.Widget.Revealer
, module Gtk.RevealerTransition
) where

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Control.Category ((<<<))
import Gtk.Container (GtkContainerProps)
import Gtk.Revealer (GtkRevealerProps)
import Gtk.RevealerTransition (GtkRevealerTransitionType, transitions)
import Gtk.Widget (Widget)
import Prim.Row (class Union)
import Type.Row (type (+))
import Unsafe.Coerce (unsafeCoerce)
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Scrollable.purs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ module AGS.Widget.Scrollable

import Prelude

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Gtk.Container (GtkContainerProps)
import Gtk.ScrolledWindow (GtkScrolledWindowProps)
import Gtk.Widget (Widget)
import Prim.Row (class Union)
import Type.Row (type (+))
import Unsafe.Coerce (unsafeCoerce)
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Slider.purs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ module AGS.Widget.Slider

import Prelude

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Data.Maybe (Maybe, maybe)
import Effect (Effect)
import Effect.Uncurried (mkEffectFn1)
import Gtk.Orientable (GtkOrientableProps)
import Gtk.Range (GtkRangeProps)
import Gtk.Scale (GtkScaleProps)
import Gtk.Widget (Widget)
import Prim.Row (class Union)
import Record.Unsafe as RU
import Type.Row (type (+))
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Stack.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ module AGS.Widget.Stack
, stack
) where

import AGS.Widget (AGSWidgetProps, Widget)
import AGS.Widget.Internal (AGSWidgetProps)
import Foreign.Object (Object)
import Gtk.Container (GtkContainerProps)
import Gtk.Stack (GtkStackProps)
import Gtk.Widget (Widget)
import Prelude ((<<<))
import Prim.Row (class Union)
import Type.Row (type (+))
Expand Down
3 changes: 2 additions & 1 deletion src/AGS/Widget/Window.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ module AGS.Widget.Window (WindowProps, Window, window) where

import Prelude

import AGS.Widget (SelfOrBinding, Widget)
import AGS.Binding (SelfOrBinding)
import AGS.Widget.Window.Anchor as Anchor
import AGS.Widget.Window.Exclusivity as Exclusivity
import AGS.Widget.Window.Layer as WindowLayer
import Effect (Effect)
import Gtk.Widget (Widget)
import Prim.Row (class Union)
import Unsafe.Coerce (unsafeCoerce)

Expand Down
3 changes: 2 additions & 1 deletion src/Gtk/Button.purs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Gtk.Button where

import AGS.Widget (SelfOrBinding, Widget)
import AGS.Binding (SelfOrBinding)
import Gtk.Widget (Widget)

-- https://gjs-docs.gnome.org/gtk30~3.0/gtk.button
-- Inherited: GObject.Object (1), Gtk.Widget (69), Gtk.Container (4)
Expand Down
Loading