Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions src/Termonad/App.hs
Original file line number Diff line number Diff line change
Expand Up @@ -478,13 +478,13 @@ setupTermonad tmConfig app win builder = do
void $ onSimpleActionActivate enlargeFontAction $ \_ ->
modifyFontSizeForAllTerms (modFontSize 1) mvarTMState
actionMapAddAction app enlargeFontAction
applicationSetAccelsForAction app "app.enlargefont" ["<Ctrl>plus"]
applicationSetAccelsForAction app "app.enlargefont" ["<Ctrl>KP_Add"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops! this doesn't belong to this draft PR...


reduceFontAction <- simpleActionNew "reducefont" Nothing
void $ onSimpleActionActivate reduceFontAction $ \_ ->
modifyFontSizeForAllTerms (modFontSize (-1)) mvarTMState
actionMapAddAction app reduceFontAction
applicationSetAccelsForAction app "app.reducefont" ["<Ctrl>minus"]
applicationSetAccelsForAction app "app.reducefont" ["<Ctrl>KP_Subtract"]

findAction <- simpleActionNew "find" Nothing
void $ onSimpleActionActivate findAction $ \_ -> doFind mvarTMState
Expand Down
21 changes: 20 additions & 1 deletion src/Termonad/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import GI.Gtk
, notebookGetNthPage
, notebookGetNPages
)
import qualified GI.Gtk as Gtk
import Data.GI.Base.GObject
import GI.Pango (FontDescription)
import GI.Vte (Terminal, CursorBlinkMode(..))
import Text.Pretty.Simple (pPrint)
Expand Down Expand Up @@ -66,7 +68,7 @@ data TMNotebookTab = TMNotebookTab
{ tmNotebookTabTermContainer :: !ScrolledWindow
-- ^ The 'ScrolledWindow' holding the VTE 'Terminal'.
, tmNotebookTabTerm :: !TMTerm
-- ^ The 'Terminal' insidie the 'ScrolledWindow'.
-- ^ The 'Terminal' inside the 'ScrolledWindow'.
, tmNotebookTabLabel :: !Label
-- ^ The 'Label' holding the title of the 'Terminal' in the 'Notebook' tab.
}
Expand Down Expand Up @@ -530,6 +532,23 @@ data TMStateInvariantErr
| TabsDoNotMatch TabsDoNotMatch
deriving Show

printWidgetTree :: Gtk.IsWidget a => a -> IO ()
printWidgetTree widget_ = do
widget <- Gtk.toWidget widget_
go "" widget
where
go :: Text -> Gtk.Widget -> IO ()
go indent w = do
type_ <- gtypeFromInstance w
name <- Gtk.gtypeName type_
let ptr = Gtk.managedForeignPtr . Gtk.toManagedPtr $ w
putStrLn $ indent <> pack name <> " " <> pack (show ptr)
maybeContainer <- Gtk.castTo Gtk.Container w
for_ maybeContainer $ \container -> do
children <- Gtk.containerGetChildren container
for_ children $ \child -> do
go (" " <> indent) child
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I implemented this function in order to help me debug my implementation, but the now-debugged code is not using it anywhere, so I should probably remove it.

Copy link
Owner

@cdepillabout cdepillabout Jan 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really nice. I've wanted something like this before, so I opened an issue on haskell-gi to see if it could potentially be included in gi-gtk: haskell-gi/haskell-gi#374

I don't think it makes sense to only have this in the Termonad codebase, since it seems widely helpful.

Although, if this type of function is not accepted upstream, let's move it to the Termonad.Gtk module, since there are already a few other helper functions in there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have now moved printWidgetTree to Termonad.Gtk, let's remove when/if it is accepted upstream.


-- | Gather up the invariants for 'TMState' and return them as a list.
--
-- If no invariants have been violated, then this function should return an
Expand Down