GTK: make file/edit menus useful
This commit is contained in:
parent
137956df42
commit
e160f340ec
@ -32,6 +32,15 @@
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="menubarFileExecute">
|
||||
<property name="label">gtk-execute</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem" id="separatormenuitem1">
|
||||
<property name="visible">True</property>
|
||||
@ -62,7 +71,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="menubarFileCut">
|
||||
<object class="GtkImageMenuItem" id="menubarEditCut">
|
||||
<property name="label">gtk-cut</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@ -71,7 +80,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="menubarFileCopy">
|
||||
<object class="GtkImageMenuItem" id="menubarEditCopy">
|
||||
<property name="label">gtk-copy</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@ -80,7 +89,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="menubarFilePaste">
|
||||
<object class="GtkImageMenuItem" id="menubarEditPaste">
|
||||
<property name="label">gtk-paste</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
@ -89,7 +98,7 @@
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="menubarFileDelete">
|
||||
<object class="GtkImageMenuItem" id="menubarEditDelete">
|
||||
<property name="label">gtk-delete</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
|
@ -151,14 +151,16 @@ startMainWindow startdir = do
|
||||
"menubarFileQuit"
|
||||
menubarFileOpen <- builderGetObject builder castToImageMenuItem
|
||||
"menubarFileOpen"
|
||||
menubarFileCut <- builderGetObject builder castToImageMenuItem
|
||||
"menubarFileCut"
|
||||
menubarFileCopy <- builderGetObject builder castToImageMenuItem
|
||||
"menubarFileCopy"
|
||||
menubarFilePaste <- builderGetObject builder castToImageMenuItem
|
||||
"menubarFilePaste"
|
||||
menubarFileDelete <- builderGetObject builder castToImageMenuItem
|
||||
"menubarFileDelete"
|
||||
menubarFileExecute <- builderGetObject builder castToImageMenuItem
|
||||
"menubarFileExecute"
|
||||
menubarEditCut <- builderGetObject builder castToImageMenuItem
|
||||
"menubarEditCut"
|
||||
menubarEditCopy <- builderGetObject builder castToImageMenuItem
|
||||
"menubarEditCopy"
|
||||
menubarEditPaste <- builderGetObject builder castToImageMenuItem
|
||||
"menubarEditPaste"
|
||||
menubarEditDelete <- builderGetObject builder castToImageMenuItem
|
||||
"menubarEditDelete"
|
||||
menubarHelpAbout <- builderGetObject builder castToImageMenuItem
|
||||
"menubarHelpAbout"
|
||||
urlBar <- builderGetObject builder castToEntry
|
||||
|
@ -79,7 +79,6 @@ setCallbacks mygui myview = do
|
||||
"Delete" <- fmap glibToString eventKeyName
|
||||
liftIO $ withRow mygui myview del
|
||||
_ <- treeView mygui `on` rowActivated $ (\_ _ -> withRow mygui myview open)
|
||||
_ <- menubarFileQuit mygui `on` menuItemActivated $ mainQuit
|
||||
_ <- urlBar mygui `on` entryActivated $ urlGoTo mygui myview
|
||||
_ <- treeView mygui `on` keyPressEvent $ tryEvent $ do
|
||||
[Control] <- eventModifier
|
||||
@ -93,6 +92,24 @@ setCallbacks mygui myview = do
|
||||
[Control] <- eventModifier
|
||||
"v" <- fmap glibToString eventKeyName
|
||||
liftIO $ operationFinal mygui myview
|
||||
|
||||
-- menubar-file
|
||||
_ <- menubarFileQuit mygui `on` menuItemActivated $ mainQuit
|
||||
_ <- menubarFileOpen mygui `on` menuItemActivated $
|
||||
liftIO $ withRow mygui myview open
|
||||
_ <- menubarFileExecute mygui `on` menuItemActivated $
|
||||
liftIO $ withRow mygui myview execute
|
||||
|
||||
-- menubar-edit
|
||||
_ <- menubarEditCopy mygui `on` menuItemActivated $
|
||||
liftIO $ withRow mygui myview copyInit
|
||||
_ <- menubarEditPaste mygui `on` menuItemActivated $
|
||||
liftIO $ operationFinal mygui myview
|
||||
_ <- menubarEditDelete mygui `on` menuItemActivated $
|
||||
liftIO $ withRow mygui myview del
|
||||
_ <- menubarEditCut mygui `on` menuItemActivated $
|
||||
liftIO $ withRow mygui myview moveInit
|
||||
|
||||
return ()
|
||||
|
||||
|
||||
@ -118,6 +135,12 @@ open row mygui myview = withErrorDialog $
|
||||
void $ openFile r
|
||||
|
||||
|
||||
-- |Execute a given file.
|
||||
execute :: Row -> MyGUI -> MyView -> IO ()
|
||||
execute row mygui myview = withErrorDialog $
|
||||
void $ executeFile row []
|
||||
|
||||
|
||||
-- |Supposed to be used with 'withRow'. Deletes a file or directory.
|
||||
del :: Row -> MyGUI -> MyView -> IO ()
|
||||
del row mygui myview = withErrorDialog $ do
|
||||
|
@ -28,10 +28,11 @@ data MyGUI = MkMyGUI {
|
||||
rootWin :: Window
|
||||
, menubarFileQuit :: ImageMenuItem
|
||||
, menubarFileOpen :: ImageMenuItem
|
||||
, menubarFileCut :: ImageMenuItem
|
||||
, menubarFileCopy :: ImageMenuItem
|
||||
, menubarFilePaste :: ImageMenuItem
|
||||
, menubarFileDelete :: ImageMenuItem
|
||||
, menubarFileExecute :: ImageMenuItem
|
||||
, menubarEditCut :: ImageMenuItem
|
||||
, menubarEditCopy :: ImageMenuItem
|
||||
, menubarEditPaste :: ImageMenuItem
|
||||
, menubarEditDelete :: ImageMenuItem
|
||||
, menubarHelpAbout :: ImageMenuItem
|
||||
, urlBar :: Entry
|
||||
, statusBar :: Statusbar
|
||||
|
Loading…
Reference in New Issue
Block a user