Logo Search packages:      
Sourcecode: zim version File versions  Download package

def zim::gui::MainWindow::__init__ (   self,
  ui,
  fullscreen = False,
  geometry = None 
)

Constructor

Definition at line 1116 of file __init__.py.

01116                                                              :
            '''Constructor'''
            gtk.Window.__init__(self)
            self._fullscreen = False
            self.ui = ui

            ui.connect_after('open-notebook', self.do_open_notebook)
            ui.connect('open-page', self.do_open_page)
            ui.connect('close-page', self.do_close_page)
            ui.connect('preferences-changed', self.do_preferences_changed)

            self._sidepane_autoclose = False
            self._switch_focus_accelgroup = None

            # Catching this signal prevents the window to actually be destroyed
            # when the user tries to close it. The action for close should either
            # hide or destroy the window.
            def do_delete_event(*a):
                  logger.debug('Action: close (delete-event)')
                  ui.close()
                  return True # Do not destroy - let close() handle it
            self.connect('delete-event', do_delete_event)

            vbox = gtk.VBox()
            self.add(vbox)

            # setup menubar and toolbar
            self.add_accel_group(ui.uimanager.get_accel_group())
            self.menubar = ui.uimanager.get_widget('/menubar')
            self.toolbar = ui.uimanager.get_widget('/toolbar')
            self.toolbar.connect('popup-context-menu', self.do_toolbar_popup)
            vbox.pack_start(self.menubar, False)
            vbox.pack_start(self.toolbar, False)

            # split window in side pane and editor
            self.hpane = gtk.HPaned()
            self.hpane.set_position(175)
            vbox.add(self.hpane)
            self.sidepane = gtk.VBox(spacing=5)
            self.hpane.add1(self.sidepane)

            self.sidepane.connect('key-press-event',
                  lambda o, event: event.keyval == KEYVAL_ESC
                        and self.toggle_sidepane())


            self.pageindex = PageIndex(ui)
            self.sidepane.add(self.pageindex)

            vbox2 = gtk.VBox()
            self.hpane.add2(vbox2)

            self.pathbar = None
            self.pathbar_box = gtk.HBox() # FIXME other class for this ?
            self.pathbar_box.set_border_width(3)
            vbox2.pack_start(self.pathbar_box, False)

            self.pageview = PageView(ui)
            self.pageview.view.connect(
                  'toggle-overwrite', self.do_textview_toggle_overwrite)
            vbox2.add(self.pageview)

            # create statusbar
            hbox = gtk.HBox(spacing=0)
            vbox.pack_start(hbox, False, True, False)

            self.statusbar = gtk.Statusbar()
            #~ self.statusbar.set_has_resize_grip(False)
            self.statusbar.push(0, '<page>')
            hbox.add(self.statusbar)

            def update_statusbar(*a):
                  page = self.pageview.get_page()
                  if not page:
                        return
                  label = page.name
                  # TODO if page is read-only
                  if page.modified:
                        label += '*'
                  if self.ui.readonly or page.readonly:
                        label += ' ['+_('readonly')+']' # T: page status in statusbar
                  self.statusbar.pop(0)
                  self.statusbar.push(0, label)

            self.pageview.connect('modified-changed', update_statusbar)
            self.ui.connect_after('open-page', update_statusbar)
            self.ui.connect_after('save-page', update_statusbar)
            self.ui.connect_after('readonly-changed', update_statusbar)

            def statusbar_element(string, size):
                  frame = gtk.Frame()
                  frame.set_shadow_type(gtk.SHADOW_IN)
                  self.statusbar.pack_end(frame, False)
                  label = gtk.Label(string)
                  label.set_size_request(size, 10)
                  label.set_alignment(0.1, 0.5)
                  frame.add(label)
                  return label

            # specify statusbar elements right-to-left
            self.statusbar_style_label = statusbar_element('<style>', 100)
            self.statusbar_insert_label = statusbar_element('INS', 60)

            # and build the widget for backlinks
            self.statusbar_backlinks_button = \
                  BackLinksMenuButton(self.ui, status_bar_style=True)
            frame = gtk.Frame()
            frame.set_shadow_type(gtk.SHADOW_IN)
            self.statusbar.pack_end(frame, False)
            frame.add(self.statusbar_backlinks_button)

            # add a second statusbar widget - somehow the corner grip
            # does not render properly after the pack_end for the first one
            #~ statusbar2 = gtk.Statusbar()
            #~ statusbar2.set_size_request(25, 10)
            #~ hbox.pack_end(statusbar2, False)

            self.do_preferences_changed()

            self._geometry_set = False
            self._set_fullscreen = False
            if geometry:
                  try:
                        self.parse_geometry(geometry)
                        self._geometry_set = True
                  except:
                        logger.exception('Parsing geometry string failed:')
            elif fullscreen:
                  self._set_fullscreen = True

      def do_window_state_event(self, event):


Generated by  Doxygen 1.6.0   Back to index