GTK: improve tab opening
When multiple folders are selected, a regular 'open' will open new tabs for each of them without changing the current view.
This commit is contained in:
parent
e72bff4180
commit
077ac81227
@ -525,15 +525,6 @@
|
|||||||
<property name="use_stock">False</property>
|
<property name="use_stock">False</property>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkImageMenuItem" id="rcFileNewTabHere">
|
|
||||||
<property name="label" translatable="yes">New Tab here</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="image">image9</property>
|
|
||||||
<property name="use_stock">False</property>
|
|
||||||
</object>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -643,11 +634,6 @@
|
|||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
<property name="stock">gtk-add</property>
|
<property name="stock">gtk-add</property>
|
||||||
</object>
|
</object>
|
||||||
<object class="GtkImage" id="image9">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">False</property>
|
|
||||||
<property name="stock">gtk-add</property>
|
|
||||||
</object>
|
|
||||||
<object class="GtkBox" id="viewBox">
|
<object class="GtkBox" id="viewBox">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
@ -229,9 +229,7 @@ setViewCallbacks mygui myview = do
|
|||||||
_ <- viewBox myview `on` keyPressEvent $ tryEvent $ do
|
_ <- viewBox myview `on` keyPressEvent $ tryEvent $ do
|
||||||
[Control] <- eventModifier
|
[Control] <- eventModifier
|
||||||
"t" <- fmap glibToString eventKeyName
|
"t" <- fmap glibToString eventKeyName
|
||||||
liftIO $ void $ do
|
liftIO $ void $ newTab' mygui myview
|
||||||
cwd <- getCurrentDir myview
|
|
||||||
newTabHere mygui cwd
|
|
||||||
_ <- viewBox myview `on` keyPressEvent $ tryEvent $ do
|
_ <- viewBox myview `on` keyPressEvent $ tryEvent $ do
|
||||||
[Control] <- eventModifier
|
[Control] <- eventModifier
|
||||||
"w" <- fmap glibToString eventKeyName
|
"w" <- fmap glibToString eventKeyName
|
||||||
@ -273,7 +271,7 @@ setViewCallbacks mygui myview = do
|
|||||||
-- if the item under the cursor is not within the current
|
-- if the item under the cursor is not within the current
|
||||||
-- selection
|
-- selection
|
||||||
(Just item) -> do
|
(Just item) -> do
|
||||||
liftIO $ newTabHere mygui item
|
liftIO $ opeInNewTab mygui item
|
||||||
return True
|
return True
|
||||||
-- no item under the cursor, pass on the signal
|
-- no item under the cursor, pass on the signal
|
||||||
Nothing -> return False
|
Nothing -> return False
|
||||||
@ -297,12 +295,7 @@ setViewCallbacks mygui myview = do
|
|||||||
_ <- (rcFileNewDir . rcmenu) myview `on` menuItemActivated $
|
_ <- (rcFileNewDir . rcmenu) myview `on` menuItemActivated $
|
||||||
liftIO $ newDir mygui myview
|
liftIO $ newDir mygui myview
|
||||||
_ <- (rcFileNewTab . rcmenu) myview `on` menuItemActivated $
|
_ <- (rcFileNewTab . rcmenu) myview `on` menuItemActivated $
|
||||||
liftIO $ do
|
liftIO $ newTab' mygui myview
|
||||||
cwd <- getCurrentDir myview
|
|
||||||
newTabHere mygui cwd
|
|
||||||
_ <- (rcFileNewTabHere . rcmenu) myview `on` menuItemActivated $
|
|
||||||
liftIO $ withItems mygui myview $ \items mygui' _ ->
|
|
||||||
forM_ items $ newTabHere mygui'
|
|
||||||
_ <- (rcFileCopy . rcmenu) myview `on` menuItemActivated $
|
_ <- (rcFileCopy . rcmenu) myview `on` menuItemActivated $
|
||||||
liftIO $ withItems mygui myview copyInit
|
liftIO $ withItems mygui myview copyInit
|
||||||
_ <- (rcFileRename . rcmenu) myview `on` menuItemActivated $
|
_ <- (rcFileRename . rcmenu) myview `on` menuItemActivated $
|
||||||
@ -355,12 +348,16 @@ closeTab mygui myview = do
|
|||||||
when (n > 1) $ void $ destroyView mygui myview
|
when (n > 1) $ void $ destroyView mygui myview
|
||||||
|
|
||||||
|
|
||||||
newTabHere :: MyGUI -> Item -> IO ()
|
newTab' :: MyGUI -> MyView -> IO ()
|
||||||
newTabHere mygui item@(DirOrSym _) =
|
newTab' mygui myview = do
|
||||||
|
cwd <- getCurrentDir myview
|
||||||
|
void $ withErrorDialog $ newTab mygui createTreeView cwd (-1)
|
||||||
|
|
||||||
|
|
||||||
|
opeInNewTab :: MyGUI -> Item -> IO ()
|
||||||
|
opeInNewTab mygui item@(DirOrSym _) =
|
||||||
void $ withErrorDialog $ newTab mygui createTreeView item (-1)
|
void $ withErrorDialog $ newTab mygui createTreeView item (-1)
|
||||||
newTabHere _ _ = return ()
|
opeInNewTab _ _ = return ()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -520,12 +517,11 @@ open [item] mygui myview = withErrorDialog $
|
|||||||
goDir True mygui myview nv
|
goDir True mygui myview nv
|
||||||
r ->
|
r ->
|
||||||
void $ openFile . path $ r
|
void $ openFile . path $ r
|
||||||
-- this throws on the first error that occurs
|
open items mygui _ = do
|
||||||
open (FileLikeList fs) _ _ = withErrorDialog $
|
let dirs = filter (fst . sdir) items
|
||||||
forM_ fs $ \f -> void $ openFile . path $ f
|
files = filter (fst . sfileLike) items
|
||||||
open _ _ _ = withErrorDialog
|
forM_ dirs (withErrorDialog . opeInNewTab mygui)
|
||||||
. throwIO $ InvalidOperation
|
forM_ files (withErrorDialog . openFile . path)
|
||||||
"Operation not supported on multiple files"
|
|
||||||
|
|
||||||
|
|
||||||
-- |Go up one directory and visualize it in the treeView.
|
-- |Go up one directory and visualize it in the treeView.
|
||||||
|
@ -108,7 +108,6 @@ data RightClickMenu = MkRightClickMenu {
|
|||||||
, rcFileNewRegFile :: !ImageMenuItem
|
, rcFileNewRegFile :: !ImageMenuItem
|
||||||
, rcFileNewDir :: !ImageMenuItem
|
, rcFileNewDir :: !ImageMenuItem
|
||||||
, rcFileNewTab :: !ImageMenuItem
|
, rcFileNewTab :: !ImageMenuItem
|
||||||
, rcFileNewTabHere :: !ImageMenuItem
|
|
||||||
, rcFileCut :: !ImageMenuItem
|
, rcFileCut :: !ImageMenuItem
|
||||||
, rcFileCopy :: !ImageMenuItem
|
, rcFileCopy :: !ImageMenuItem
|
||||||
, rcFileRename :: !ImageMenuItem
|
, rcFileRename :: !ImageMenuItem
|
||||||
|
@ -163,8 +163,6 @@ createMyView mygui iofmv = do
|
|||||||
"rcFileNewDir"
|
"rcFileNewDir"
|
||||||
rcFileNewTab <- builderGetObject builder castToImageMenuItem
|
rcFileNewTab <- builderGetObject builder castToImageMenuItem
|
||||||
"rcFileNewTab"
|
"rcFileNewTab"
|
||||||
rcFileNewTabHere <- builderGetObject builder castToImageMenuItem
|
|
||||||
"rcFileNewTabHere"
|
|
||||||
rcFileCut <- builderGetObject builder castToImageMenuItem
|
rcFileCut <- builderGetObject builder castToImageMenuItem
|
||||||
"rcFileCut"
|
"rcFileCut"
|
||||||
rcFileCopy <- builderGetObject builder castToImageMenuItem
|
rcFileCopy <- builderGetObject builder castToImageMenuItem
|
||||||
|
Loading…
Reference in New Issue
Block a user