2022-11-29 04:34:13 +00:00
# Python imports
2023-03-05 21:42:11 +00:00
# Lib imports
import gi
gi . require_version ( ' Gtk ' , ' 3.0 ' )
gi . require_version ( ' Gdk ' , ' 3.0 ' )
from gi . repository import Gtk
from gi . repository import Gdk
2023-12-24 19:23:24 +00:00
from gi . repository import GLib
2022-11-29 04:34:13 +00:00
# Application imports
from . mixins . ui . pane_mixin import PaneMixin
from . mixins . ui . window_mixin import WindowMixin
2023-03-05 21:42:11 +00:00
from . widgets . files_view . files_widget import FilesWidget
2022-11-29 04:34:13 +00:00
2022-12-04 08:45:26 +00:00
2023-03-05 21:42:11 +00:00
class UIMixinException ( Exception ) :
. . .
2022-12-04 08:45:26 +00:00
2022-12-05 01:43:32 +00:00
class UIMixin ( PaneMixin , WindowMixin ) :
2023-03-05 21:42:11 +00:00
# class UIMixin(PaneMixin):
def _generate_file_views ( self , session_json = None ) :
# self._wip_hybrid_approach_loading_process(session_json)
self . _current_loading_process ( session_json )
def _wip_hybrid_approach_loading_process ( self , session_json = None ) :
for session in session_json :
self . fm_controller . create_window ( )
FilesWidget ( ) . set_fm_controller ( self . fm_controller )
for session in session_json :
nickname = session [ " window " ] [ " Nickname " ]
tabs = session [ " window " ] [ " tabs " ]
isHidden = True if session [ " window " ] [ " isHidden " ] == " True " else False
2023-11-25 21:52:43 +00:00
event_system . emit ( " load_files_view_state " , ( nickname , tabs , isHidden ) )
2023-09-28 05:12:20 +00:00
def _focus_last_visible_notebook ( self , icon_grid ) :
import time
window = settings_manager . get_main_window ( )
while not window . is_visible ( ) and not window . get_realized ( ) :
2023-12-24 19:23:24 +00:00
time . sleep ( 0.2 )
2023-09-28 05:12:20 +00:00
icon_grid . event ( Gdk . Event ( ) . new ( type = Gdk . EventType . BUTTON_RELEASE ) )
2023-03-05 21:42:11 +00:00
def _current_loading_process ( self , session_json = None ) :
if session_json :
for j , value in enumerate ( session_json ) :
i = j + 1
notebook_tggl_button = self . builder . get_object ( f " tggl_notebook_ { i } " )
is_hidden = True if value [ " window " ] [ " isHidden " ] == " True " else False
tabs = value [ " window " ] [ " tabs " ]
self . fm_controller . create_window ( )
notebook_tggl_button . set_active ( True )
if tabs :
for tab in tabs :
self . create_new_tab_notebook ( None , i , tab )
else :
self . create_new_tab_notebook ( None , i , None )
if is_hidden :
self . toggle_notebook_pane ( notebook_tggl_button )
try :
if not self . is_pane4_hidden :
2023-09-28 05:12:20 +00:00
notebook = self . window4
2023-03-05 21:42:11 +00:00
elif not self . is_pane3_hidden :
2023-09-28 05:12:20 +00:00
notebook = self . window3
2023-03-05 21:42:11 +00:00
elif not self . is_pane2_hidden :
2023-09-28 05:12:20 +00:00
notebook = self . window2
2023-03-05 21:42:11 +00:00
elif not self . is_pane1_hidden :
2023-09-28 05:12:20 +00:00
notebook = self . window1
2023-03-05 21:42:11 +00:00
2023-09-28 05:12:20 +00:00
scroll_win = notebook . get_children ( ) [ - 1 ]
icon_grid = scroll_win . get_children ( ) [ 0 ]
2023-12-24 19:23:24 +00:00
GLib . Thread ( " " , self . _focus_last_visible_notebook , icon_grid )
2023-03-05 21:42:11 +00:00
except UIMixinException as e :
logger . info ( " \n : The saved session might be missing window data! : \n Location: ~/.config/solarfm/session.json \n Fix: Back it up and delete it to reset. \n " )
logger . debug ( repr ( e ) )
else :
for j in range ( 0 , 4 ) :
i = j + 1
self . fm_controller . create_window ( )
2023-11-12 06:49:16 +00:00
self . create_new_tab_notebook ( None , i , None )