/usr/share/pyshared/pida/ui/window.py is in pida 0.5.1-6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 | import gtk
from kiwi.ui.dialogs import save, open as opendlg, info, error, yesno#, get_input
from pida.ui.uimanager import PidaUIManager
from pida.ui.paneds import PidaPaned
from pida.core.environment import get_uidef_path, get_pixmap_path
from pida.core.actions import accelerator_group
# locale
from pida.core.locale import Locale
locale = Locale('pida')
_ = locale.gettext
class Window(gtk.Window):
def __init__(self, boss, *args, **kw):
self._boss = boss
gtk.Window.__init__(self, *args, **kw)
self.set_icon_from_file(get_pixmap_path('pida-icon.png'))
self.add_accel_group(accelerator_group)
self.connect('delete-event', self._on_delete_event)
self.create_all()
def _on_delete_event(self, window, event):
return self._boss.stop()
def create_all(self):
pass
# Dialogs
def save_dlg(self, *args, **kw):
return save(parent = self, *args, **kw)
def open_dlg(self, *args, **kw):
return opendlg(parent = self, *args, **kw)
def info_dlg(self, *args, **kw):
return info(parent = self, *args, **kw)
def error_dlg(self, *args, **kw):
return error(parent = self, *args, **kw)
def yesno_dlg(self, *args, **kw):
return yesno(parent = self, *args, **kw) == gtk.RESPONSE_YES
def error_list_dlg(self, msg, errs):
return self.error_dlg('%s\n\n* %s' % (msg, '\n\n* '.join(errs)))
def input_dlg(self, *args, **kw):
return get_input(parent=self, *args, **kw)
class PidaWindow(Window):
"""Main PIDA Window"""
def create_all(self):
self.set_title(_('PIDA Loves You!'))
self._fix_paneds()
self._create_ui()
self.resize(800, 600)
def start(self):
self._start_ui()
def _create_ui(self):
self._uim = PidaUIManager()
self.main_box = gtk.VBox()
self.top_box = gtk.VBox()
self.bottom_box = gtk.VBox()
self._create_statusbar()
self.main_box.pack_start(self.top_box, expand=False)
self.main_box.pack_start(self._paned)
self.main_box.pack_start(self.bottom_box, expand=False)
self.main_box.pack_start(self._status_holder, expand=False)
self.add(self.main_box)
def _create_statusbar(self):
self._statusbar = gtk.HBox()
self._status_holder = gtk.Statusbar()
# OMG
frame = self._status_holder.get_children()[0]
frame.remove(frame.get_children()[0])
frame.add(self._statusbar)
def _start_ui(self):
self._menubar = self._uim.get_menubar()
self._toolbar = self._uim.get_toolbar()
self._toolbar.set_style(gtk.TOOLBAR_ICONS)
self.top_box.pack_start(self._menubar, expand=False)
self.top_box.pack_start(self._toolbar, expand=False)
self.top_box.show_all()
self.main_box.show_all()
self._statusbar.show_all()
def _fix_paneds(self):
self._paned = PidaPaned()
# Action group API
def add_action_group(self, actiongroup):
self._uim.add_action_group(actiongroup)
def add_uidef(self, filename):
try:
uifile = get_uidef_path(filename)
return self._uim.add_ui_from_file(uifile)
except Exception, e:
self._boss.log.debug('unable to get %s resource: %s' %
(filename, e))
def remove_action_group(self, actiongroup):
self._uim.remove_action_group(actiongroup)
def remove_uidef(self, ui_merge_id):
if ui_merge_id is not None:
self._uim.remove_ui(ui_merge_id)
# View API
def add_view(self, bookname, view, removable=True, present=False):
self._paned.add_view(bookname, view, removable, present)
def remove_view(self, view):
self._paned.remove_view(view)
def detach_view(self, view, size):
self._paned.detach_view(view, size)
def present_view(self, view):
self._paned.present_view(view)
def present_paned(self, bookname):
self._paned.present_paned(bookname)
def switch_next_view(self, bookname):
self._paned.switch_next_pane(bookname)
def switch_prev_view(self, bookname):
self._paned.switch_prev_pane(bookname)
def get_statusbar(self):
return self._statusbar
# UI hiding API
def set_toolbar_visibility(self, visibility):
if visibility:
self._toolbar.show_all()
else:
self._toolbar.hide_all()
def set_menubar_visibility(self, visibility):
if visibility:
self._menubar.show_all()
else:
self._menubar.hide_all()
def set_statusbar_visibility(self, visibility):
if visibility:
self._statusbar.show_all()
else:
self._statusbar.hide_all()
|