Пример #1
0
    def _construct_logwindow(self):

        def cb_logwindow_hideshow(window, action):
            action.set_active(window.get_property('visible'))

        # logwindow is hidden by default. See _construct_uimanager if
        # you want to change this default
        logwindow = logwin.LogWindow()
        logwindow.set_transient_for(self)
        logwindow.set_destroy_with_parent(True)
        logwindow.hide()

        # logwindow specific
        def cb_toggle_logwindow(action, logwindow):
            if action.get_active() is True: logwindow.show()
            else: logwindow.hide()

        t = gtk.ToggleAction('ToggleLogwindow', 'Show Logwindow', None, None)
        t.connect("toggled", cb_toggle_logwindow, logwindow)
        uihelper.get_action_group(self.uimanager, 'Application').add_action(t)

        logwindow.connect('hide', cb_logwindow_hideshow, t)
        logwindow.connect('show', cb_logwindow_hideshow, t)
        
        return logwindow
Пример #2
0
    def _refresh_windowlist(self):      

        # We are going to recreate the actiongroup 'WindowList'.
        # To avoid adding this actiongroup multiple times, we need
        # to remove it first.
        if self._windowlist_merge_id is not None:
            ag = uihelper.get_action_group(self.uimanager, "DynamicWindowList")
            self.uimanager.remove_action_group(ag)
            self.uimanager.remove_ui(self._windowlist_merge_id)
            
        # Create action groups list from windowlist.
        # The corresponding ui string is created as well.
        ui = ""
        ag =  gtk.ActionGroup('DynamicWindowList')
        for window in self._windows:            
            title = window.get_title() or "noname"
            logger.debug("Window title is %s" % title)
            action = gtk.Action(id(window), title, None, None)
            action.connect('activate', self._cb_subwindow_present, window)
            ag.add_action(action)
            ui+="<menuitem action='%s'/>\n" % id(window)
        self.uimanager.insert_action_group(ag,0)

        # Wrap UI description.
        ui="""
        <ui>
          <menubar name='MainMenu'>
            <menu action='ViewMenu'>
            %s
            </menu>
          </menubar>
        </ui>
        """ % ui
                       
        self._windowlist_merge_id = self.uimanager.add_ui_from_string(ui)                      
Пример #3
0
    def set_up_visibility_toggle(self, widget, action_name, description, accel=None):

        def toggle_visibility(action, widget):
            if action.get_active() is True:
                widget.show()
            else:
                widget.hide()

        def on_hide_or_show(widget, action):
            action.set_active(widget.get_property('visible'))

        t = gtk.ToggleAction(action_name, description, None, None)
        t.connect("toggled", toggle_visibility, widget)
        uihelper.get_action_group(self.uimanager, 'Application').add_action_with_accel(t, accel)

        widget.connect('hide', on_hide_or_show, t)
        widget.connect('show', on_hide_or_show, t)
Пример #4
0
    def _construct_toolbox(self):

        window = tools.Toolbox(None)
        window.set_transient_for(self)
        window.set_destroy_with_parent(True)
        window.hide()

        def cb_toggle_window(action, window):
            if action.get_active() is True: window.show()
            else: window.hide()        
        t = gtk.ToggleAction('ToggleToolbox', 'Show Toolbox', None, None)
        t.connect("toggled", cb_toggle_window, window)
        uihelper.get_action_group(self.uimanager, 'Application').add_action(t)

        def on_window_visibility_toggled(window, action):
            action.set_active(window.get_property('visible'))
        window.connect('hide', on_window_visibility_toggled, t)
        window.connect('show', on_window_visibility_toggled, t)

        def on_notify_project(sender, project, toolwin):
            toolwin.set_project(project)
        globals.app.sig_connect('notify::project', on_notify_project, window)
        
        return window
Пример #5
0
    def _refresh_recentfiles(self):
       
        # remove last recent files
        if self._recentfiles_merge_id is not None:
            ag = uihelper.get_action_group(self.uimanager, "DynamicRecentFiles")
            self.uimanager.remove_action_group(ag)
            self.uimanager.remove_ui(self._recentfiles_merge_id)

        # Create action group list from list of recent files.
        # The corresponding ui string is created as well.
        ui = ""
        n = 1
        ag = gtk.ActionGroup('DynamicRecentFiles')
        for file in globals.app.recent_files:
            key = 'recent_files_%d' % n
            label = os.path.basename(file)
            action = gtk.Action(key, label, None, None)
            action.connect('activate',
                           (lambda sender, filename: globals.app.load_project(filename)),
                           file)

            # the most recent file can be retrieved using <control><alt>r
            if n == 1:
                ag.add_action_with_accel(action, '<control><alt>r')
            else:
                ag.add_action(action)
            
            ui+="<menuitem action='%s'/>\n" % key
            n += 1
            
        self.uimanager.insert_action_group(ag, 0)

        # Wrap UI description.
        ui="""
        <ui>
          <menubar name='MainMenu'>
            <menu action='FileMenu'>
              <menu action='RecentFilesMenu'>
                <placeholder name='RecentFilesList'>
                  %s
                </placeholder>
               </menu>
             </menu>
          </menubar>
        </ui>
        """ % ui
            
        self._recentfiles_merge_id = self.uimanager.add_ui_from_string(ui)