示例#1
0
    def __init__(self, renderer, textview, **kwargs):
        super(InputArea, self).__init__(**kwargs)

        self.__renderer = renderer
        self.__textview = textview

        # Whether the user manually changed the password mode - if so, take it off auto
        self.__override_password_mode = False
        # Whether we're modifying password mode programatically
        self.__doing_auto_password_mode = False

        close = gtk.Button()
        close.set_focus_on_click(False)
        close.set_relief(gtk.RELIEF_NONE)
        img = gtk.Image()
        img.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_SMALL_TOOLBAR)
        close.add(img)
        close.connect('clicked', lambda b: self.__do_close())
        self.pack_start(close, expand=False)
        self.__input = gtk.Entry()
        self.__input.connect("key-press-event",
                             lambda i, e: self.__on_input_keypress(e))
        hbox = gtk.HBox()
        hbox.pack_start(self.__input, expand=True)
        self.__send = gtk.Button('_Send', gtk.STOCK_OK)
        self.__send.set_focus_on_click(False)
        self.__send.connect("clicked", lambda b: self.__do_send())
        hbox.pack_start(self.__send, expand=False)
        self.__password_button = gtk.CheckButton(label=_('_Password mode'))
        self.__password_button.connect('toggled', self.__on_password_toggled)
        self.__password_button.set_focus_on_click(False)
        hbox.pack_start(hotwidgets.Align(self.__password_button,
                                         padding_left=8),
                        expand=False)
        self.pack_start(hotwidgets.Align(hbox, xscale=0.75), expand=True)
示例#2
0
 def __add_checkbutton(self, name, prefname, function, vbox):
     prefs = Preferences.getInstance()
     checkbutton = gtk.CheckButton(name)
     checkbutton.set_property('active',
                              prefs.get_pref(prefname, default=True))
     checkbutton.connect('toggled', function)
     vbox.pack_start(hotwidgets.Align(checkbutton, padding_left=12),
                     expand=False)
示例#3
0
    def __init__(self,
                 cwd=None,
                 cmd=None,
                 title='',
                 ptyfd=None,
                 initbuf=None,
                 autoclose=False):
        super(VteTerminal, self).__init__()
        self.__ui_string = """
<ui>
  <menubar name='Menubar'>
    <menu action='EditMenu'>
      <placeholder name='EditMenuAdditions'>
        <menuitem action='Copy'/>
        <menuitem action='Paste'/>
      </placeholder>
    </menu>
    <!-- <menu action='ControlMenu'>
      <menuitem action='SplitWindow'/>
    </menu> -->
  </menubar>
</ui>"""

        self.__title = title
        self.__header = gtk.HBox()
        self.__msg = gtk.Label('')
        self.__pid = None
        self.__exited = False
        self.__autoclose = autoclose
        self.__header.pack_start(hotwidgets.Align(self.__msg, xalign=1.0),
                                 expand=False)
        self.__msg.set_property('xalign', 1.0)

        self.pack_start(self.__header, expand=False)

        prefs = Preferences.getInstance()
        prefs.monitor_prefs('term.', self.__on_pref_changed)

        termargs = {}
        if isinstance(cmd, basestring):
            termargs['cmd'] = ['/bin/sh', '-c', cmd]
        else:
            termargs['cmd'] = cmd
        if ptyfd is not None:
            termargs['ptyfd'] = ptyfd
        if initbuf is not None:
            termargs['initbuf'] = initbuf
        _logger.debug("creating term, cmd=%r", termargs['cmd'])
        self.__term = term = VteTerminalWidget(cwd=cwd, **termargs)
        self.__action_group = term.get_action_group()
        self.pack_start(self.__term, expand=True)
        self.__term.connect('child-exited', self.__on_child_exited)
        self.__term.connect('fork-child', self.__on_fork_child)
        self.__term.get_vte().connect('key-press-event', self.__on_keypress)

        self.__sync_prefs()
示例#4
0
    def __init__(self):
        super(PrefsWindow,
              self).__init__(title=_('Preferences'),
                             parent=None,
                             flags=gtk.DIALOG_DESTROY_WITH_PARENT,
                             buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_ACCEPT))

        prefs = Preferences.getInstance()

        self.connect('response', lambda *args: self.hide())
        self.connect('delete-event', self.hide_on_delete)

        self.set_has_separator(False)
        self.set_border_width(5)

        self.__vbox = gtk.VBox()
        self.vbox.add(self.__vbox)
        self.vbox.set_spacing(2)
        self.__notebook = gtk.Notebook()
        self.__vbox.add(self.__notebook)

        self.__general_tab = gtk.VBox()
        self.__notebook.append_page(self.__general_tab)
        self.__notebook.set_tab_label_text(self.__general_tab, _('General'))

        vbox = gtk.VBox()
        vbox.set_border_width(12)
        vbox.set_spacing(6)
        self.__general_tab.pack_start(vbox, expand=False)
        label = gtk.Label()
        label.set_markup('<b>%s</b>' % (_('Interface'), ))
        label.set_alignment(0.0, 0.0)
        vbox.pack_start(hotwidgets.Align(label), expand=False)
        menuaccess = gtk.CheckButton(_('Disable menu access keys'))
        menuaccess.set_property(
            'active', not prefs.get_pref('ui.menuaccels', default=True))
        menuaccess.connect('toggled', self.__on_menuaccess_toggled)
        vbox.pack_start(hotwidgets.Align(menuaccess, padding_left=12),
                        expand=False)
        readline = self.__readline = gtk.CheckButton(
            _('Enable Unix "Readline" keys (Ctrl-A, Alt-F, Ctrl-K, etc.)'))
        readline.set_property('active',
                              prefs.get_pref('ui.emacs', default=False))
        readline.connect('toggled', self.__on_readline_toggled)
        vbox.pack_start(hotwidgets.Align(readline, padding_left=12),
                        expand=False)
        self.__sync_emacs_sensitive()

        label = gtk.Label()
        label.set_markup('<b>%s</b>' % (_('System'), ))
        label.set_alignment(0.0, 0.0)
        vbox.pack_start(hotwidgets.Align(label), expand=False)
        hbox = gtk.HBox()
        vbox.pack_start(hotwidgets.Align(hbox, padding_left=12), expand=False)
        ed_label = gtk.Label(_('Editor: '))
        hbox.pack_start(ed_label, expand=False)
        self.__ed_combo = PrefEditorCombo()
        hbox.pack_start(self.__ed_combo, expand=False)

        self.__term_tab = gtk.VBox()
        self.__notebook.append_page(self.__term_tab)
        self.__notebook.set_tab_label_text(self.__term_tab, _('Terminal'))

        vbox = gtk.VBox()
        vbox.set_border_width(12)
        vbox.set_spacing(6)
        label = gtk.Label()
        label.set_markup('<b>%s</b>' % (_('Interface'), ))
        label.set_alignment(0.0, 0.0)
        vbox.pack_start(label, expand=False)
        self.__term_tab.pack_start(vbox, expand=False)

        hbox = gtk.HBox()
        vbox.pack_start(hotwidgets.Align(hbox, padding_left=12), expand=False)
        sg = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)
        fg_label = gtk.Label(_('Foreground Color: '))
        sg.add_widget(fg_label)
        hbox.pack_start(fg_label, expand=False)
        fg_color = self.__fg_color = gtk.ColorButton(
            gtk.gdk.color_parse(
                prefs.get_pref('term.foreground', default='#000')))
        hbox.pack_start(fg_color, expand=False)
        fg_color.connect('color-set', self.__on_fg_bg_changed)

        hbox = gtk.HBox()
        vbox.pack_start(hotwidgets.Align(hbox, padding_left=12), expand=False)
        bg_label = gtk.Label(_('Background Color: '))
        sg.add_widget(bg_label)
        hbox.pack_start(bg_label, expand=False)
        bg_color = self.__bg_color = gtk.ColorButton(
            gtk.gdk.color_parse(
                prefs.get_pref('term.background', default='#FFF')))
        hbox.pack_start(bg_color, expand=False)
        bg_color.connect('color-set', self.__on_fg_bg_changed)

        self.__folders_tab = gtk.VBox()
        self.__notebook.append_page(self.__folders_tab)
        self.__notebook.set_tab_label_text(self.__folders_tab, _('Folders'))

        vbox = gtk.VBox()
        vbox.set_border_width(12)
        vbox.set_spacing(6)
        label = gtk.Label()
        label.set_markup('<b>%s</b>' % (_('Default view'), ))
        label.set_alignment(0.0, 0.0)
        vbox.pack_start(label, expand=False)
        self.__folders_tab.pack_start(vbox, expand=False)
        self.__add_checkbutton(
            _('Sort folders before files'),
            'hotwire.ui.render.File.general.foldersbeforefiles',
            self.__on_folders_before_files_toggled, vbox)

        vbox = gtk.VBox()
        vbox.set_border_width(12)
        vbox.set_spacing(6)
        label = gtk.Label()
        label.set_markup('<b>%s</b>' % (_('List columns'), ))
        label.set_alignment(0.0, 0.0)
        vbox.pack_start(label, expand=False)
        self.__folders_tab.pack_start(vbox, expand=False)

        self.__add_checkbutton(_('Size'),
                               'hotwire.ui.render.File.columns.size',
                               self.__on_list_size_toggled, vbox)
        self.__add_checkbutton(_('Last modified'),
                               'hotwire.ui.render.File.columns.last_modified',
                               self.__on_list_lastmodified_toggled, vbox)
        self.__add_checkbutton(_('Owner'),
                               'hotwire.ui.render.File.columns.owner',
                               self.__on_list_owner_toggled, vbox)
        self.__add_checkbutton(_('Group'),
                               'hotwire.ui.render.File.columns.group',
                               self.__on_list_group_toggled, vbox)
        self.__add_checkbutton(_('Permissions'),
                               'hotwire.ui.render.File.columns.permissions',
                               self.__on_list_permissions_toggled, vbox)
        self.__add_checkbutton(_('File type'),
                               'hotwire.ui.render.File.columns.mime',
                               self.__on_list_filetype_toggled, vbox)
示例#5
0
    def __init__(self, context, pipeline, odisp, overview_mode=True, **args):
        super(CommandExecutionHeader, self).__init__(**args)
        self.__context = context
        self.__pipeline = pipeline
        self.__overview_mode = overview_mode
        self.__primary_complete = False
        self.__complete_unseen = False
        self.__last_view_time = None
        self.__visible = True
        self.__prev_pipeline_state = None
        self.__cancelled = False
        self.__undone = False
        self.__exception = False
        self.__mouse_hovering = False
        
        self.__throbber_pixbuf_done = PixbufCache.getInstance().get('throbber-done.gif', size=None)
        self.__throbber_pixbuf_ani = PixbufCache.getInstance().get('throbber.gif', size=None, animation=True)
        
        self.__tooltips = gtk.Tooltips()

        self.__pipeline.connect("state-changed", self.__on_pipeline_state_change)   
        self.__pipeline.connect("metadata", self.__on_pipeline_metadata)
        
        self.__main_hbox = gtk.HBox()
        self.pack_start(self.__main_hbox, expand=True)
        self.__cmdstatus_vbox = gtk.VBox()
        self.__main_hbox.pack_start(self.__cmdstatus_vbox, expand=True)
        
        self.__titlebox_ebox = gtk.EventBox()
        self.__titlebox_ebox.set_visible_window(False)
        if overview_mode:
            self.__titlebox_ebox.add_events(gtk.gdk.BUTTON_PRESS_MASK
                                            & gtk.gdk.ENTER_NOTIFY_MASK
                                            & gtk.gdk.LEAVE_NOTIFY_MASK)
            self.__titlebox_ebox.connect("enter_notify_event", self.__on_enter) 
            self.__titlebox_ebox.connect("leave_notify_event", self.__on_leave) 
        self.__titlebox_ebox.connect("button-press-event", lambda eb, e: self.__on_button_press(e))

        self.__titlebox = gtk.HBox()
        self.__titlebox_ebox.add(self.__titlebox)
        self.__cmdstatus_vbox.pack_start(hotwidgets.Align(self.__titlebox_ebox), expand=False)
        self.__pipeline_str = self.__pipeline.__str__()
        self.__title = gtk.Label()
        self.__title.set_alignment(0, 0.5)
        #self.__title.set_selectable(True)        
        self.__title.set_ellipsize(True)
        self.__state_image = gtk.Image()
        self.__titlebox.pack_start(self.__state_image, expand=False)
        self.__titlebox.pack_start(hotwidgets.Align(self.__title, padding_left=4), expand=True)
        self.__statusbox = gtk.HBox()
        self.__cmdstatus_vbox.pack_start(self.__statusbox, expand=False)
        self.__status_left = gtk.Label()
        self.__status_right = gtk.Label()
        self.__statusbox.pack_start(hotwidgets.Align(self.__status_left, padding_left=4), expand=False)
        self.__action = hotwidgets.Link()
        self.__action.connect("clicked", self.__on_action)
        self.__statusbox.pack_start(hotwidgets.Align(self.__action), expand=False)          
        self.__statusbox.pack_start(hotwidgets.Align(self.__status_right), expand=False)        
        
        self.__undoable = self.__pipeline.get_undoable() and (not self.__pipeline.get_idempotent())

        status_cmds = list(pipeline.get_status_commands())
        self.__pipeline_status_visible = False
        if status_cmds:
            self.__cmd_statuses = gtk.HBox(spacing=8)
            show_cmd_name = len(status_cmds) > 1
            for cmdname in status_cmds:
                self.__cmd_statuses.pack_start(CommandStatusDisplay(show_cmd_name and cmdname or None), expand=True)
            self.__statusbox.pack_start(hotwidgets.Align(self.__cmd_statuses), expand=False)
        else:
            self.__cmd_statuses = None
            self.__cmd_status_show_cmd = False

        self.__objects = odisp
        self.__objects.connect("primary-complete", self.__on_primary_complete)        
        self.__objects.connect("changed", lambda o: self.__update_titlebox())

        self.__exception_box = gtk.HBox()
        self.__exception_link = hotwidgets.Link()
        self.__exception_link.set_alignment(0.0, 0.5)
        self.__exception_link.set_ellipsize(True)
        self.__exception_link.connect('clicked', self.__on_exception_clicked)
        self.__exception_box.pack_start(self.__exception_link, expand=True)        
        self.__cmdstatus_vbox.pack_start(hotwidgets.Align(self.__exception_box, padding_left=4), expand=False)
        if overview_mode:
            self.__cmdstatus_vbox.pack_start(gtk.HSeparator(), expand=False)
            self.__otype_expander = None
        else:
            self.__otype_expander = gtk.Expander('')
            self.__otype_expander.unset_flags(gtk.CAN_FOCUS);
            self.__otype_expander.set_use_markup(True)
            self.__otype_expander.connect('notify::expanded', self.__on_otype_expander_toggled)
            self.__main_hbox.pack_start(self.__otype_expander, expand=False)