43
43
#('fgcolor', 'color', _('Screen foreground color'), '#eeeeec'),
46
def __init__(self, *a):
47
@extends('MainWindow')
48
class MainWindowExtension(WindowExtension):
50
def __init__(self, plugin, window):
51
WindowExtension.__init__(self, plugin, window)
47
52
self._normal_colors = None
48
53
self._show_panes = True
49
PluginClass.__init__(self, *a)
51
def finalize_ui(self, ui):
52
self.connectto(self.ui.mainwindow.pageview.view, 'size-allocate')
53
self.connectto(self.ui.mainwindow, 'fullscreen-changed')
54
self.do_preferences_changed()
56
def do_preferences_changed(self):
54
self.preferences = plugin.preferences
56
self.connectto(plugin.preferences, 'changed', self.on_preferences_changed)
57
self.connectto(window, 'init-uistate', self.on_init_uistate)
59
self.connectto(window, 'fullscreen-changed')
60
self.connectto(window.pageview.view, 'size-allocate')
62
def on_init_uistate(self, window):
63
self.on_preferences_changed(self.plugin.preferences)
65
def on_preferences_changed(self, preferences):
57
66
# Set show menubar & Update margins
58
show_menubar = not self.preferences['hide_menubar']
59
show_toolbar = not self.preferences['hide_toolbar']
60
show_pathbar = not self.preferences['hide_pathbar']
61
show_statusbar = not self.preferences['hide_statusbar']
62
if self.ui.mainwindow.isfullscreen:
63
self.ui.mainwindow.toggle_menubar(show_menubar)
64
self.ui.mainwindow.toggle_toolbar(show_toolbar)
65
self.ui.mainwindow.toggle_statusbar(show_statusbar)
67
show_menubar = not preferences['hide_menubar']
68
show_toolbar = not preferences['hide_toolbar']
69
show_pathbar = not preferences['hide_pathbar']
70
show_statusbar = not preferences['hide_statusbar']
71
if self.window.isfullscreen:
72
self.window.toggle_menubar(show_menubar)
73
self.window.toggle_toolbar(show_toolbar)
74
self.window.toggle_statusbar(show_statusbar)
68
and self.ui.uistate['MainWindow']['pathbar_type_fullscreen'] == PATHBAR_NONE:
69
self.ui.mainwindow.set_pathbar(PATHBAR_RECENT)
77
and self.window.uistate['pathbar_type_fullscreen'] == PATHBAR_NONE:
78
self.window.set_pathbar(PATHBAR_RECENT)
70
79
elif not show_pathbar:
71
self.ui.mainwindow.set_pathbar(PATHBAR_NONE)
80
self.window.set_pathbar(PATHBAR_NONE)
73
textview = self.ui.mainwindow.pageview.view
82
textview = self.window.pageview.view
74
83
self.on_size_allocate(textview, textview.get_allocation())
76
self.ui.uistate['MainWindow']['show_menubar_fullscreen'] = show_menubar
77
self.ui.uistate['MainWindow']['show_toolbar_fullscreen'] = show_toolbar
78
self.ui.uistate['MainWindow']['show_statusbar_fullscreen'] = show_statusbar
85
self.window.uistate['show_menubar_fullscreen'] = show_menubar
86
self.window.uistate['show_toolbar_fullscreen'] = show_toolbar
87
self.window.uistate['show_statusbar_fullscreen'] = show_statusbar
81
and self.ui.uistate['MainWindow']['pathbar_type_fullscreen'] == PATHBAR_NONE:
82
self.ui.uistate['MainWindow']['pathbar_type_fullscreen'] = PATHBAR_RECENT
90
and self.window.uistate['pathbar_type_fullscreen'] == PATHBAR_NONE:
91
self.window.uistate['pathbar_type_fullscreen'] = PATHBAR_RECENT
83
92
elif not show_pathbar:
84
self.ui.uistate['MainWindow']['pathbar_type_fullscreen'] = PATHBAR_NONE
93
self.window.uistate['pathbar_type_fullscreen'] = PATHBAR_NONE
86
95
# TODO - would be nice to be able to toggle hide/show for pathbar without need to set type
87
96
# allow hiding container or seperate widget from "model"
218
226
self._set_margins(left, right, top, bottom)
220
228
def _set_margins(self, left, right, top, bottom):
221
self.ui.mainwindow.pageview.view.set_border_window_size(gtk.TEXT_WINDOW_LEFT, left)
222
self.ui.mainwindow.pageview.view.set_border_window_size(gtk.TEXT_WINDOW_RIGHT, right)
223
self.ui.mainwindow.pageview.view.set_border_window_size(gtk.TEXT_WINDOW_TOP, top)
224
self.ui.mainwindow.pageview.view.set_border_window_size(gtk.TEXT_WINDOW_BOTTOM, bottom)
229
textview = self.window.pageview.view
230
textview.set_border_window_size(gtk.TEXT_WINDOW_LEFT, left)
231
textview.set_border_window_size(gtk.TEXT_WINDOW_RIGHT, right)
232
textview.set_border_window_size(gtk.TEXT_WINDOW_TOP, top)
233
textview.set_border_window_size(gtk.TEXT_WINDOW_BOTTOM, bottom)
227
236
# show at least menubar again, set margins to zero & restore colors
228
self.ui.uistate['MainWindow']['show_menubar_fullscreen'] = True
237
self.window.uistate['show_menubar_fullscreen'] = True
229
238
self._set_margins(0, 0, 0, 0)
230
239
if self._normal_colors:
231
240
self._set_colors(self._normal_colors)
232
PluginClass.destroy(self)