Example #1
0
    def _create_command_dialog(self,
                               enabled_var=False,
                               name_var="",
                               command_var=""):
        dialog = gtk.Dialog(_("New Command"), None, gtk.DIALOG_MODAL,
                            (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                             gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
        table = gtk.Table(3, 2)

        label = gtk.Label(_("Enabled:"))
        table.attach(label, 0, 1, 0, 1)
        enabled = gtk.CheckButton()
        enabled.set_active(enabled_var)
        table.attach(enabled, 1, 2, 0, 1)

        label = gtk.Label(_("Name:"))
        table.attach(label, 0, 1, 1, 2)
        name = gtk.Entry()
        name.set_text(name_var)
        table.attach(name, 1, 2, 1, 2)

        label = gtk.Label(_("Command:"))
        table.attach(label, 0, 1, 2, 3)
        command = gtk.Entry()
        command.set_text(command_var)
        table.attach(command, 1, 2, 2, 3)

        dialog.vbox.pack_start(table)
        dialog.show_all()
        return (dialog, enabled, name, command)
    def configure(self, widget, data=None):
        ui = {}
        dbox = Gtk.Dialog(_("Terminator themes"), None, Gtk.DialogFlags.MODAL)

        headers = {"Accept": "application/vnd.github.v3.raw"}
        response = requests.get(self.base_url, headers=headers)

        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return

        self.themes_from_repo = response.json()["themes"]
        self.profiles = self.terminal.config.list_profiles()

        main_container = Gtk.HBox(spacing=5)
        main_container.pack_start(self._create_themes_grid(ui), True, True,
                                  0)  #Left column
        main_container.pack_start(self._create_settings_grid(ui), True, True,
                                  0)  #Right column

        dbox.vbox.pack_start(main_container, True, True, 0)

        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()

        if res == Gtk.ResponseType.ACCEPT:
            self.terminal.config.save()

        del (self.dbox)
        dbox.destroy()

        return
Example #3
0
    def on_button_press(self, widget, event):

        if event.button != 3:
            return

        result = self.treeview.get_path_at_pos(int(event.x), int(event.y))
        inside = False
        path, col, x, y = None, None, None, None

        if result != None:
            inside = True
            path, col, x, y = result
            self.treeview.get_selection().select_path(path)

        menu = Gtk.Menu()

        if inside:
            item = Gtk.MenuItem.new_with_mnemonic(_('_Delete Command'))
            menu.append(item)
            item.connect('activate', self.delete_command, path)

        item = Gtk.MenuItem.new_with_mnemonic(_('_New Command'))
        menu.append(item)
        item.connect('activate', self.add_command)
        menu.show_all()
        menu.popup_at_pointer(event)
Example #4
0
    def make_headerbar(self, ui):
        
        header = Gtk.HeaderBar()
        header.props.show_close_button = True
       # header.set_subtitle(self.selected_theme_label)
        button_install = Gtk.Button(_("Install"))
        button_uninstall = Gtk.Button(_("Remove"))
        button_install.set_sensitive(False)
        button_uninstall.set_sensitive(False)
        button_uninstall.connect("clicked", self.on_uninstall, ui) 
        button_install.connect("clicked", self.on_install, ui) 

        ui["button_install"] = button_install
        ui["button_uninstall"] = button_uninstall

        header.pack_end(button_install)
        header.pack_end(button_uninstall)

        stack = Gtk.Stack()
        stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT)
        stack.set_transition_duration(500)
        stack.set_hhomogeneous(True)    

        stack_switcher = Gtk.StackSwitcher()
        stack_switcher.set_stack(stack)

        stackBox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
        stackBox.set_homogeneous(False)
        stackBox.pack_start(stack_switcher, True, False, 0)

        header.set_custom_title(stackBox)
        
        ui["header"] = header
        ui["stack"] = stack
        return header
Example #5
0
    def configure(self, widget, data=None):
        ui = {}
        dbox = Gtk.Dialog(_("Terminator themes"), None, Gtk.DIALOG_MODAL)

        self.profiles_from_repo = []
        response = requests.get(self.base_url)

        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return

        for repo in response.json():
            self.profiles_from_repo.append(repo['name'])

        self.profiles = self.terminal.config.list_profiles()

        main_container = Gtk.HBox(spacing=5)
        main_container.pack_start(self._create_themes_list(ui), True, True)
        main_container.pack_start(self._create_settings_grid(ui), True, True,
                                  0)
        dbox.vbox.pack_start(main_container, True, True)

        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()

        if res == Gtk.RESPONSE_ACCEPT:
            self.terminal.config.save()
        del (self.dbox)
        dbox.destroy()

        return
Example #6
0
    def notify(self, _vte, terminal):
        """Notify that a terminal did something"""
        show_notify = False

        # Don't notify if the user is already looking at this terminal.
        if terminal.vte.has_focus():
            return True

        note = Notify.Notification.new(
            _('Terminator'),
            _('Activity in: %s') % terminal.get_window_title(), 'terminator')

        this_time = time.mktime(time.gmtime())
        if not terminal in self.last_notifies:
            show_notify = True
        else:
            last_time = self.last_notifies[terminal]
            if this_time - last_time > hush_period:
                show_notify = True

        if show_notify == True:
            note.show()
            self.last_notifies[terminal] = this_time

        return True
Example #7
0
 def on_new(self, button, data):
     (dialog, enabled, name, command) = self._create_command_dialog()
     res = dialog.run()
     item = {}
     if res == Gtk.ResponseType.ACCEPT:
         item['enabled'] = enabled.get_active()
         item['name'] = name.get_text()
         item['command'] = command.get_text()
         if item['name'] == '' or item['command'] == '':
             err = Gtk.MessageDialog(
                 dialog, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
                 Gtk.ButtonsType.CLOSE,
                 _("You need to define a name and command"))
             err.run()
             err.destroy()
         else:
             # we have a new command
             store = data['treeview'].get_model()
             iter = store.get_iter_first()
             name_exist = False
             while iter != None:
                 if store.get_value(iter, CC_COL_NAME) == item['name']:
                     name_exist = True
                     break
                 iter = store.iter_next(iter)
             if not name_exist:
                 store.append(
                     (item['enabled'], item['name'], item['command']))
             else:
                 gerr(_("Name *%s* already exist") % item['name'])
     dialog.destroy()
Example #8
0
    def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
      dialog = Gtk.Dialog(
                        _("New Command"),
                        None,
                        Gtk.DialogFlags.MODAL,
                        (
                          Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                          Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT
                        )
                      )
      table = Gtk.Table(3, 2)

      label = Gtk.Label(label=_("Enabled:"))
      table.attach(label, 0, 1, 0, 1)
      enabled = Gtk.CheckButton()
      enabled.set_active(enabled_var)
      table.attach(enabled, 1, 2, 0, 1)

      label = Gtk.Label(label=_("Name:"))
      table.attach(label, 0, 1, 1, 2)
      name = Gtk.Entry()
      name.set_text(name_var)
      table.attach(name, 1, 2, 1, 2)
      
      label = Gtk.Label(label=_("Command:"))
      table.attach(label, 0, 1, 2, 3)
      command = Gtk.Entry()
      command.set_text(command_var)
      table.attach(command, 1, 2, 2, 3)

      dialog.vbox.pack_start(table, True, True, 0)
      dialog.show_all()
      return (dialog,enabled,name,command)
Example #9
0
    def _create_command_dialog(self, enabled_var = False, name_var = "", command_var = ""):
      dialog = gtk.Dialog(
                        _("New Command"),
                        None,
                        gtk.DIALOG_MODAL,
                        (
                          gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT,
                          gtk.STOCK_OK, gtk.RESPONSE_ACCEPT
                        )
                      )
      table = gtk.Table(3, 2)

      label = gtk.Label(_("Enabled:"))
      table.attach(label, 0, 1, 0, 1)
      enabled = gtk.CheckButton()
      enabled.set_active(enabled_var)
      table.attach(enabled, 1, 2, 0, 1)

      label = gtk.Label(_("Name:"))
      table.attach(label, 0, 1, 1, 2)
      name = gtk.Entry()
      name.set_text(name_var)
      table.attach(name, 1, 2, 1, 2)
      
      label = gtk.Label(_("Command:"))
      table.attach(label, 0, 1, 2, 3)
      command = gtk.Entry()
      command.set_text(command_var)
      table.attach(command, 1, 2, 2, 3)

      dialog.vbox.pack_start(table)
      dialog.show_all()
      return (dialog,enabled,name,command)
 def on_new(self, button, data):
     (dialog, name, command) = self._create_command_dialog()
     res = dialog.run()
     item = {}
     if res == gtk.RESPONSE_ACCEPT:
         item['name'] = name.get_text()
         item['command'] = command.get_text()
         if item['name'] == '' or item['command'] == '':
             err = gtk.MessageDialog(
                 dialog, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
                 gtk.BUTTONS_CLOSE,
                 _("You need to define a name and command"))
             err.run()
             err.destroy()
         else:
             # we have a new command
             store = data['treeview'].get_model()
             iter = store.get_iter_first()
             name_exist = False
             while iter != None:
                 if store.get_value(iter, CC_COL_NAME) == item['name']:
                     name_exist = True
                     break
                 iter = store.iter_next(iter)
             if not name_exist:
                 store.append((item['name'], item['command']))
             else:
                 self._err(_("Name *%s* already exist") % item['name'])
     dialog.destroy()
Example #11
0
 def on_new(self, button, data):
   (dialog,enabled,name,command) = self._create_command_dialog()
   res = dialog.run()
   item = {}
   if res == Gtk.ResponseType.ACCEPT:
     item['enabled'] = enabled.get_active()
     item['name'] = name.get_text()
     item['command'] = command.get_text()
     if item['name'] == '' or item['command'] == '':
       err = Gtk.MessageDialog(dialog,
                               Gtk.DialogFlags.MODAL,
                               Gtk.MessageType.ERROR,
                               Gtk.ButtonsType.CLOSE,
                               _("You need to define a name and command")
                             )
       err.run()
       err.destroy()
     else:
       # we have a new command
       store = data['treeview'].get_model()
       iter = store.get_iter_first()
       name_exist = False
       while iter != None:
         if store.get_value(iter,CC_COL_NAME) == item['name']:
           name_exist = True
           break
         iter = store.iter_next(iter)
       if not name_exist:
         store.append((item['enabled'], item['name'], item['command']))
       else:
         self._err(_("Name *%s* already exist") % item['name'])
   dialog.destroy()
Example #12
0
    def _create_command_dialog(self,
                               enabled_var=False,
                               name_var="",
                               command_var=""):
        dialog = Gtk.Dialog(_("New Command"), None, Gtk.DialogFlags.MODAL,
                            (Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                             Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT))
        table = Gtk.Table(3, 2)

        label = Gtk.Label(label=_("Enabled:"))
        table.attach(label, 0, 1, 0, 1)
        enabled = Gtk.CheckButton()
        enabled.set_active(enabled_var)
        table.attach(enabled, 1, 2, 0, 1)

        label = Gtk.Label(label=_("Name:"))
        table.attach(label, 0, 1, 1, 2)
        name = Gtk.Entry()
        name.set_text(name_var)
        table.attach(name, 1, 2, 1, 2)

        label = Gtk.Label(label=_("Command:"))
        table.attach(label, 0, 1, 2, 3)
        command = Gtk.Entry()
        command.set_text(command_var)
        table.attach(command, 1, 2, 2, 3)

        dialog.vbox.pack_start(table, True, True, 0)
        dialog.show_all()
        return (dialog, enabled, name, command)
Example #13
0
    def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        submenus = {}
        item = Gtk.MenuItem.new_with_mnemonic(_('_SSH Connect'))
        menuitems.append(item)

        submenu = Gtk.Menu()
        item.set_submenu(submenu)

        menuitem = Gtk.MenuItem.new_with_mnemonic(_('_SSH Config'))
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = Gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = Gtk.IconTheme.get_default()
        self.cmd_list.sort(key = lambda x:x['last_time'],reverse=True)
        count = 0
        for ssh_conf in self.cmd_list :
          ssh_key = ssh_conf['user'] + '@' + ssh_conf['ip']
          menuitem = Gtk.MenuItem(ssh_key)
          menuitem.connect("activate", self.new_connect_tab0, ssh_conf)
          submenu.append(menuitem)

          count = count + 1
          if count >= 10:
            break

        self.terminal = terminal
Example #14
0
    def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        item = gtk.MenuItem(_('_Custom Commands'))
        menuitems.append(item)

        submenu = gtk.Menu()
        item.set_submenu(submenu)

        menuitem = gtk.ImageMenuItem(_('_Preferences'))
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = gtk.icon_theme_get_default()
        for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ] :
          if not command['enabled']:
            continue
          exe = command['command'].split(' ')[0]
          iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN)
          if iconinfo:
            image = gtk.Image()
            image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
            menuitem = gtk.ImageMenuItem(command['name'])
            menuitem.set_image(image)
          else:
            menuitem = gtk.MenuItem(command["name"])
          terminals = terminal.terminator.get_target_terms(terminal)
          menuitem.connect("activate", self._execute, {'terminals' : terminals, 'command' : command['command'] })
          submenu.append(menuitem)
Example #15
0
class TerminalShot(plugin.MenuItem):
    """Add custom commands to the terminal menu"""
    capabilities = ['terminal_menu']
    dialog_action = Gtk.FileChooserAction.SAVE
    dialog_buttons = (_("_Cancel"), Gtk.ResponseType.CANCEL, _("_Save"),
                      Gtk.ResponseType.OK)

    def __init__(self):
        plugin.MenuItem.__init__(self)

    def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        item = Gtk.MenuItem.new_with_mnemonic(_('Terminal _screenshot'))
        item.connect("activate", self.terminalshot, terminal)
        menuitems.append(item)

    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)
        filename = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
        path = "~/Screenshots/"
        path += filename
        path += ".png"
        orig_pixbuf.savev(path, 'png', [], [])
Example #16
0
    def configure(self, widget, data = None):
        ui = {}
        dbox = Gtk.Dialog( _("Terminator themes"), None, Gtk.DialogFlags.MODAL)
        
        headers = { "Accept": "application/vnd.github.v3.raw" }
        response = requests.get(self.base_url, headers=headers)

        if response.status_code != 200:
            gerr(_("Failed to get list of available themes"))
            return
        
        self.themes_from_repo = response.json()["themes"]
        self.profiles = self.terminal.config.list_profiles()

        main_container = Gtk.HBox(spacing=7)
        main_container.pack_start(self._create_themes_list(ui), True, True, 0)
        main_container.pack_start(self._create_settings_grid(ui), True, True, 0)
        dbox.vbox.pack_start(main_container, True, True, 0)

        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()

        if res == Gtk.ResponseType.ACCEPT:
            self.terminal.config.save()

        del(self.dbox)
        dbox.destroy()
        return
Example #17
0
    def __init__(self):
        """Class initialiser"""
        GObject.GObject.__init__(self)

        self.config = Config()

        self.get_style_context().add_class("terminator-terminal-searchbar")

        # Search text
        self.entry = Gtk.Entry()
        self.entry.set_activates_default(True)
        self.entry.show()
        self.entry.connect('activate', self.do_search)
        self.entry.connect('key-press-event', self.search_keypress)

        # Label
        label = Gtk.Label(label=_('Search:'))
        label.show()

        # Close Button
        close = Gtk.Button()
        close.set_relief(Gtk.ReliefStyle.NONE)
        close.set_focus_on_click(False)
        icon = Gtk.Image()
        icon.set_from_stock(Gtk.STOCK_CLOSE, Gtk.IconSize.MENU)
        close.add(icon)
        close.set_name('terminator-search-close-button')
        if hasattr(close, 'set_tooltip_text'):
            close.set_tooltip_text(_('Close Search bar'))
        close.connect('clicked', self.end_search)
        close.show_all()

        # Next Button
        self.next = Gtk.Button(label=_('Next'))
        self.next.show()
        self.next.set_sensitive(False)
        self.next.connect('clicked', self.next_search)

        # Previous Button
        self.prev = Gtk.Button(label=_('Prev'))
        self.prev.show()
        self.prev.set_sensitive(False)
        self.prev.connect('clicked', self.prev_search)

        # Wrap checkbox
        self.wrap = Gtk.CheckButton(label=_('Wrap'))
        self.wrap.show()
        self.wrap.set_sensitive(True)
        self.wrap.connect('toggled', self.wrap_toggled)

        self.pack_start(label, False, True, 0)
        self.pack_start(self.entry, True, True, 0)
        self.pack_start(self.prev, False, False, 0)
        self.pack_start(self.next, False, False, 0)
        self.pack_start(self.wrap, False, False, 0)
        self.pack_end(close, False, False, 0)

        self.hide()
        self.set_no_show_all(True)
 def callback(self, menuitems, menu, terminal):
     """Add our menu items to the menu"""
     if not self.watches.has_key(terminal):
         item = gtk.MenuItem(_('Watch for activity'))
         item.connect("activate", self.watch, terminal)
     else:
         item = gtk.MenuItem(_('Stop watching for activity'))
         item.connect("activate", self.unwatch, terminal)
     menuitems.append(item)
Example #19
0
 def callback(self, menuitems, menu, terminal):
     """Add our menu items to the menu"""
     if not self.watches.has_key(terminal):
         item = gtk.MenuItem(_('Watch for activity'))
         item.connect("activate", self.watch, terminal)
     else:
         item = gtk.MenuItem(_('Stop watching for activity'))
         item.connect("activate", self.unwatch, terminal)
     menuitems.append(item)
Example #20
0
    def __init__(self, parent, key, pattern, action_store, title='TreeView'):

        Gtk.Dialog.__init__(self, title, parent, Gtk.DialogFlags.MODAL,
                            (_("Ok"), Gtk.ResponseType.OK, _("Cancel"),
                             Gtk.ResponseType.CANCEL))

        self.set_transient_for(parent)

        if action_store != None:
            self.action_store = self.copy_action_store(action_store)
        else:
            store_factory = StoreFactory()
            self.action_store = store_factory.create_action_store({})

        self.treeview = Gtk.TreeView(self.action_store)
        self.treeview.set_grid_lines(Gtk.TreeViewGridLines.BOTH)
        self.treeview.connect('button-press-event', self.on_button_press)

        renderer = MyCellRendererText()
        renderer.set_property("editable", True)
        renderer.set_property("placeholder-text", "<Command>")
        renderer.connect('edited', self.on_edited, self.M_COL_COMMAND)
        column = Gtk.TreeViewColumn(_("Command"),
                                    renderer,
                                    text=self.M_COL_COMMAND)
        column.set_property('resizable', True)
        column.set_sort_column_id(self.M_COL_COMMAND)
        column.set_min_width(200)
        self.treeview.append_column(column)

        renderer = Gtk.CellRendererToggle()
        renderer.connect('toggled', self.on_toggled, self.M_COL_IN_TERMINAL)
        column = Gtk.TreeViewColumn(_("In Terminal"),
                                    renderer,
                                    active=self.M_COL_IN_TERMINAL)
        self.treeview.append_column(column)

        renderer = Gtk.CellRendererToggle()
        renderer.connect('toggled', self.on_toggled, self.M_COL_USE_SHELL)
        column = Gtk.TreeViewColumn(_("Use Shell"),
                                    renderer,
                                    active=self.M_COL_USE_SHELL)
        self.treeview.append_column(column)

        upper_label = Gtk.Label('Actions for %s (%s)' % (pattern, key))

        scrolled_window = Gtk.ScrolledWindow()
        scrolled_window.set_policy(Gtk.PolicyType.NEVER,
                                   Gtk.PolicyType.AUTOMATIC)
        scrolled_window.add(self.treeview)
        scrolled_window.set_min_content_height(200)

        self.vbox.pack_start(upper_label, False, False, 0)
        self.vbox.pack_start(scrolled_window, False, False, 0)

        self.show_all()
Example #21
0
 def callback(self, menuitems, menu, terminal):
     """ Add save menu item to the menu"""
     vte_terminal = terminal.get_vte()
     if vte_terminal not in self.loggers:
         item = Gtk.MenuItem.new_with_mnemonic(_('Start logging'))
         item.connect("activate", self.start, terminal)
     else:
         item = Gtk.MenuItem.new_with_mnemonic(_('Stop logging'))
         item.connect("activate", self.stop, terminal)
     menuitems.append(item)
Example #22
0
 def callback(self, menuitems, menu, terminal):
     """Add our menu items to the menu"""
     if not self.watches.has_key(terminal):
         item = gtk.MenuItem(_("Watch for silence"))
         item.connect("activate", self.watch, terminal)
     else:
         item = gtk.MenuItem(_("Stop watching for silence"))
         item.connect("activate", self.unwatch, terminal)
     menuitems.append(item)
     dbg('Menu items appended')
 def callback(self, menuitems, menu, terminal):
     """Add our menu items to the menu"""
     if not self.watches.has_key(terminal):
         item = gtk.MenuItem(_("Watch for silence"))
         item.connect("activate", self.watch, terminal)
     else:
         item = gtk.MenuItem(_("Stop watching for silence"))
         item.connect("activate", self.unwatch, terminal)
     menuitems.append(item)
     dbg('Menu items appended')
Example #24
0
 def callback(self, menuitems, menu, terminal):
     """ Add save menu item to the menu"""
     vte_terminal = terminal.get_vte()
     if not self.loggers.has_key(vte_terminal):
         item = gtk.MenuItem(_('Start Logger'))
         item.connect("activate", self.start_logger, terminal)
     else:
         item = gtk.MenuItem(_('Stop Logger'))
         item.connect("activate", self.stop_logger, terminal)
         item.set_has_tooltip(True)
         item.set_tooltip_text("Saving at '" + self.loggers[vte_terminal]["filepath"] + "'")
     menuitems.append(item)
Example #25
0
 def callback(self, menuitems, menu, terminal):
     """ Add save menu item to the menu"""
     vte_terminal = terminal.get_vte()
     if not self.loggers.has_key(vte_terminal):
         item = gtk.MenuItem(_('Start Logger'))
         item.connect("activate", self.start_logger, terminal)
     else:
         item = gtk.MenuItem(_('Stop Logger'))
         item.connect("activate", self.stop_logger, terminal)
         item.set_has_tooltip(True)
         item.set_tooltip_text("Saving at '" + self.loggers[vte_terminal]["filepath"] + "'")
     menuitems.append(item)
Example #26
0
    def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        submenus = {}
        item = Gtk.MenuItem.new_with_mnemonic(_('_Custom Commands'))
        menuitems.append(item)

        submenu = Gtk.Menu()
        item.set_submenu(submenu)

        menuitem = Gtk.MenuItem.new_with_mnemonic(_('_Preferences'))
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = Gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = Gtk.IconTheme.get_default()
        for command in [
                self.cmd_list[key] for key in sorted(self.cmd_list.keys())
        ]:
            if not command['enabled']:
                continue
            exe = command['command'].split(' ')[0]
            iconinfo = theme.choose_icon([exe], Gtk.IconSize.MENU,
                                         Gtk.IconLookupFlags.USE_BUILTIN)
            leaf_name = command['name'].split('/')[-1]
            branch_names = command['name'].split('/')[:-1]
            target_submenu = submenu
            parent_submenu = submenu
            for idx in range(len(branch_names)):
                lookup_name = '/'.join(branch_names[0:idx + 1])
                target_submenu = submenus.get(lookup_name, None)
                if not target_submenu:
                    item = Gtk.MenuItem(label=_(branch_names[idx]))
                    parent_submenu.append(item)
                    target_submenu = Gtk.Menu()
                    item.set_submenu(target_submenu)
                    submenus[lookup_name] = target_submenu
                parent_submenu = target_submenu
            if iconinfo:
                image = Gtk.Image()
                image.set_from_icon_name(exe, Gtk.IconSize.MENU)
                menuitem = Gtk.ImageMenuItem(label=leaf_name)
                menuitem.set_image(image)
            else:
                menuitem = Gtk.MenuItem(label=leaf_name)
            terminals = terminal.terminator.get_target_terms(terminal)
            menuitem.connect("activate", self._execute, {
                'terminals': terminals,
                'command': command['command']
            })
            target_submenu.append(menuitem)
Example #27
0
 def on_delete_event(self, window, event, data=None):
     """Handle a window close request"""
     maker = Factory()
     if maker.isinstance(self.get_child(), 'Terminal'):
         if self.get_property('term_zoomed') == True:
             return self.confirm_close(window, _('window'))
         else:
             dbg('Window::on_delete_event: Only one child, closing is fine')
             return False
     elif maker.isinstance(self.get_child(), 'Container'):
         return self.confirm_close(window, _('window'))
     else:
         dbg('unknown child: %s' % self.get_child())
Example #28
0
 def callback(self, menuitems, menu, terminal):
     """ Add save menu item to the menu"""
     vte_terminal = terminal.get_vte()
     if vte_terminal not in self.loggers:
         item = Gtk.MenuItem.new_with_mnemonic(_('Start _Logger'))
         item.connect('activate', self.start_logger, terminal)
     else:
         item = Gtk.MenuItem.new_with_mnemonic(_('Stop _Logger'))
         item.connect('activate', self.stop_logger, terminal)
         item.set_has_tooltip(True)
         item.set_tooltip_text("Saving at '" +
                               self.loggers[vte_terminal]["filepath"] + "'")
     menuitems.append(item)
Example #29
0
    def check_times(self, terminal):
        """Check if this terminal has gone silent"""
        time_now = time.mktime(time.gmtime())
        if not self.last_activities.has_key(terminal):
            dbg('Terminal %s has no last activity' % terminal)
            return True

        dbg('seconds since last activity: %f (%s)' % (time_now - self.last_activities[terminal], terminal))
        if time_now - self.last_activities[terminal] >= inactive_period:
            del(self.last_activities[terminal])
            note = Notify.Notification.new(_('Terminator'), _('Silence in: %s') % 
                                         terminal.get_window_title(), 'terminator')
            note.show()

        return True
Example #30
0
    def check_times(self, terminal):
        """Check if this terminal has gone silent"""
        time_now = time.mktime(time.gmtime())
        if terminal not in self.last_activities:
            dbg('Terminal %s has no last activity' % terminal)
            return True

        dbg('seconds since last activity: %f (%s)' % (time_now - self.last_activities[terminal], terminal))
        if time_now - self.last_activities[terminal] >= inactive_period:
            del(self.last_activities[terminal])
            note = Notify.Notification.new(_('Terminator'), _('Silence in: %s') % 
                                         terminal.get_window_title(), 'terminator')
            note.show()

        return True
    def on_install(self, button, data):
        treeview = data['treeview']
        selection = treeview.get_selection()
        (store, iter) = selection.get_selected()
        target = store[iter][0]
        widget = self.terminal.get_vte()
        treeview.set_enable_tree_lines(False)

        if not iter:
            return

        headers = {"Accept": "application/vnd.github.v3.raw"}
        response = requests.get(self.base_url + '/' + target + '.config',
                                headers=headers)

        if response.status_code != 200:
            gerr(_("Failed to download selected theme"))
            return

        # Creates a new profile and overwrites the default colors for the new theme
        self.terminal.config.add_profile(target)
        target_data = self.make_dictionary(response.content)
        for k, v in target_data.items():
            if k != 'background_image':
                self.config_base.set_item(k, v[1:-1], target)

        self.terminal.force_set_profile(widget, target)
        self.terminal.config.save()

        # "Remove" button available again
        self.liststore.set_value(iter, 1, False)
        self.on_selection_changed(selection, data)
        treeview.set_enable_tree_lines(True)
Example #32
0
    def update_button(self):
        """Update the state of our close button"""
        if not self.config['close_button_on_tab']:
            if self.button:
                self.button.remove(self.icon)
                self.remove(self.button)
                del self.button
                del self.icon
                self.button = None
                self.icon = None
            return

        if not self.button:
            self.button = Gtk.Button()
        if not self.icon:
            self.icon = Gio.ThemedIcon.new_with_default_fallbacks("window-close-symbolic")
            self.icon = Gtk.Image.new_from_gicon(self.icon, Gtk.IconSize.MENU)

        self.button.set_focus_on_click(False)
        self.button.set_relief(Gtk.ReliefStyle.NONE)
#        style = Gtk.RcStyle()  # FIXME FOR GTK3 how to do it there? actually do we really want to override the theme?
#        style.xthickness = 0
#        style.ythickness = 0
#        self.button.modify_style(style)
        self.button.add(self.icon)
        self.button.connect('clicked', self.on_close)
        self.button.set_name('terminator-tab-close-button')
        if hasattr(self.button, 'set_tooltip_text'):
            self.button.set_tooltip_text(_('Close Tab'))
        self.pack_start(self.button, False, False, 0)
        self.show_all()
Example #33
0
    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)

        savedialog = Gtk.FileChooserDialog(title=_("Save image"),
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_transient_for(_widget.get_toplevel())
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)

        pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
                                          orig_pixbuf.get_height() / 2,
                                          GdkPixbuf.InterpType.BILINEAR)
        image = Gtk.Image.new_from_pixbuf(pixbuf)
        savedialog.set_preview_widget(image)

        savedialog.show_all()
        response = savedialog.run()
        path = None
        if response == Gtk.ResponseType.OK:
            path = os.path.join(savedialog.get_current_folder(),
                                savedialog.get_filename())
            orig_pixbuf.savev(path, 'png', [], [])

        savedialog.destroy()
Example #34
0
 def callback(self, menuitems, menu, terminal):
     """ Add dump-to-file command to the terminal menu """
     vte_terminal = terminal.get_vte()
     if not self.dumpers.has_key(vte_terminal):
         item = gtk.MenuItem(_('Dump terminal to file'))
         item.connect("activate", self.dump_console, terminal)
     menuitems.append(item)
Example #35
0
    def _create_main_action_button(self, ui, label, action):
        btn = Gtk.Button(_(label.capitalize()))
        btn.connect("clicked", action, ui) 
        btn.set_sensitive(False)
        ui['button_' + label] = btn

        return btn
    def configure(self, widget, data = None):
        ui = {}
        dbox = Gtk.Dialog( _("Terminator themes (local)"), None, Gtk.DialogFlags.MODAL)

        local_file = open(self.base_url, 'r')
        self.themes_from_repo = json.loads(local_file.read())["themes"]
        local_file.close()

        self.profiles = self.terminal.config.list_profiles()

        main_container = Gtk.HBox(spacing=5)
        main_container.pack_start(self._create_themes_grid(ui), True, True, 0) #Left column
        main_container.pack_start(self._create_settings_grid(ui), True, True, 0) #Right column
       
        dbox.vbox.pack_start(main_container, True, True, 0)
        
        self.dbox = dbox
        dbox.show_all()
        res = dbox.run()

        if res == Gtk.ResponseType.ACCEPT:
            self.terminal.config.save()

        del(self.dbox)
        dbox.destroy()

        return
Example #37
0
    def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        item = gtk.MenuItem(_('Custom Commands'))
        menuitems.append(item)

        submenu = gtk.Menu()
        item.set_submenu(submenu)

        menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = gtk.IconTheme()
        for command in self.cmd_list:
            if not command['enabled']:
                continue
            exe = command['command'].split(' ')[0]
            iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU,
                                         gtk.ICON_LOOKUP_USE_BUILTIN)
            if iconinfo:
                image = gtk.Image()
                image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
                menuitem = gtk.ImageMenuItem(command['name'])
                menuitem.set_image(image)
            else:
                menuitem = gtk.MenuItem(command["name"])
            menuitem.connect("activate", self._execute, {
                'terminal': terminal,
                'command': command['command']
            })
            submenu.append(menuitem)
Example #38
0
    def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        item = Gtk.MenuItem(_('Custom Commands'))
        menuitems.append(item)

        submenu = Gtk.Menu()
        item.set_submenu(submenu)

        menuitem = Gtk.ImageMenuItem(Gtk.STOCK_PREFERENCES)
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = Gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = Gtk.IconTheme()
        for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ] :
          if not command['enabled']:
            continue
          exe = command['command'].split(' ')[0]
          iconinfo = theme.choose_icon([exe], Gtk.IconSize.MENU, Gtk.IconLookupFlags.USE_BUILTIN)
          if iconinfo:
            image = Gtk.Image()
            image.set_from_icon_name(exe, Gtk.IconSize.MENU)
            menuitem = Gtk.ImageMenuItem(command['name'])
            menuitem.set_image(image)
          else:
            menuitem = Gtk.MenuItem(command["name"])
          terminals = terminal.terminator.get_target_terms(terminal)
          menuitem.connect("activate", self._execute, {'terminals' : terminals, 'command' : command['command'] })
          submenu.append(menuitem)
Example #39
0
    def start_logger(self, _widget, Terminal):
        """ Handle menu item callback by saving text to a file"""
        savedialog = gtk.FileChooserDialog(title=_("Save Log File As"),
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)
        savedialog.show_all()
        response = savedialog.run()
        if response == gtk.RESPONSE_OK:
            try:
                logfile = os.path.join(savedialog.get_current_folder(),
                                       savedialog.get_filename())
                fd = open(logfile, 'w+')
                # Save log file path, 
                # associated file descriptor, signal handler id
                # and last saved col,row positions respectively.
                vte_terminal = Terminal.get_vte()
                (col, row) = vte_terminal.get_cursor_position()

                self.loggers[vte_terminal] = {"filepath":logfile,
                                              "handler_id":0, "fd":fd,
                                              "col":col, "row":row}
                # Add contents-changed callback
                self.loggers[vte_terminal]["handler_id"] = vte_terminal.connect('contents-changed', self.save)
            except:
                e = sys.exc_info()[1]
                error = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR,
                                          gtk.BUTTONS_OK, e.strerror)
                error.run()
                error.destroy()
        savedialog.destroy()
Example #40
0
    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)

        savedialog = gtk.FileChooserDialog(title=_("Save image"),
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)

        pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2, 
                                     orig_pixbuf.get_height() / 2,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        savedialog.set_preview_widget(image)

        savedialog.show_all()
        response = savedialog.run()
        path = None
        if response == gtk.RESPONSE_OK:
            path = os.path.join(savedialog.get_current_folder(),
                                savedialog.get_filename())
            orig_pixbuf.save(path, 'png')

        savedialog.destroy()
Example #41
0
    def start_logger(self, _widget, Terminal):
        """ Handle menu item callback by saving text to a file"""
        savedialog = Gtk.FileChooserDialog(title=_("Save Log File As"),
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)
        savedialog.show_all()
        response = savedialog.run()
        if response == Gtk.ResponseType.OK:
            try:
                logfile = os.path.join(savedialog.get_current_folder(),
                                       savedialog.get_filename())
                fd = open(logfile, 'w+')
                # Save log file path, 
                # associated file descriptor, signal handler id
                # and last saved col,row positions respectively.
                vte_terminal = Terminal.get_vte()
                (col, row) = vte_terminal.get_cursor_position()

                self.loggers[vte_terminal] = {"filepath":logfile,
                                              "handler_id":0, "fd":fd,
                                              "col":col, "row":row}
                # Add contents-changed callback
                self.loggers[vte_terminal]["handler_id"] = vte_terminal.connect('contents-changed', self.save)
            except:
                e = sys.exc_info()[1]
                error = Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.ERROR,
                                          Gtk.ButtonsType.OK, e.strerror)
                error.run()
                error.destroy()
        savedialog.destroy()
Example #42
0
 def callback(self, menuitems, menu, terminal):
     """ Add dump-to-file command to the terminal menu """
     vte_terminal = terminal.get_vte()
     if not self.dumpers.has_key(vte_terminal):
         item = gtk.MenuItem(_('Dump terminal to file'))
         item.connect("activate", self.dump_console, terminal)
     menuitems.append(item)
    def on_install(self, button, data):
        treeview = data['treeview']
        selection = treeview.get_selection()
        (store, iter) = selection.get_selected()
        target = store[iter][0]
        widget = self.terminal.get_vte()
        treeview.set_enable_tree_lines(False)
        
        if not iter:
            return

    
        headers = { "Accept": "application/vnd.github.v3.raw" }
        response = requests.get(self.base_url+ '/' + target + '.config', headers=headers)
       
        if response.status_code != 200:
            gerr(_("Failed to download selected theme"))
            return

        # Creates a new profile and overwrites the default colors for the new theme
        self.terminal.config.add_profile(target) 
        target_data = self.make_dictionary(response.content)
        for k, v in target_data.items():
            if k != 'background_image':
                 self.config_base.set_item(k, v[1:-1], target)

        self.terminal.force_set_profile(widget, target)
        self.terminal.config.save()

        # "Remove" button available again
        self.liststore.set_value(iter, 1, False)
        self.on_selection_changed(selection, data)
        treeview.set_enable_tree_lines(True)
    def _create_main_action_button(self, ui, label, action):
        btn = Gtk.Button(_(label.capitalize()))
        btn.connect("clicked", action, ui)
        btn.set_sensitive(False)
        ui['button_' + label] = btn

        return btn
Example #45
0
    def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        item = gtk.MenuItem(_('Custom Commands'))
        menuitems.append(item)

        submenu = gtk.Menu()
        item.set_submenu(submenu)

        menuitem = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = gtk.IconTheme()
        for command in self.cmd_list:
          if not command['enabled']:
            continue
          exe = command['command'].split(' ')[0]
          iconinfo = theme.choose_icon([exe], gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN)
          if iconinfo:
            image = gtk.Image()
            image.set_from_icon_name(exe, gtk.ICON_SIZE_MENU)
            menuitem = gtk.ImageMenuItem(command['name'])
            menuitem.set_image(image)
          else:
            menuitem = gtk.MenuItem(command["name"])
          menuitem.connect("activate", self._execute, {'terminal' : terminal, 'command' : command['command'] })
          submenu.append(menuitem)
Example #46
0
    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)

        savedialog = Gtk.FileChooserDialog(title=_("Save image"),
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_transient_for(_widget.get_toplevel())
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)

        pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2, 
                                     orig_pixbuf.get_height() / 2,
                                     GdkPixbuf.InterpType.BILINEAR)
        image = Gtk.Image.new_from_pixbuf(pixbuf)
        savedialog.set_preview_widget(image)

        savedialog.show_all()
        response = savedialog.run()
        path = None
        if response == Gtk.ResponseType.OK:
            path = os.path.join(savedialog.get_current_folder(),
                                savedialog.get_filename())
            orig_pixbuf.savev(path, 'png', [], [])

        savedialog.destroy()
Example #47
0
    def terminalshot(self, _widget, terminal):
        """Handle the taking, prompting and saving of a terminalshot"""
        # Grab a pixbuf of the terminal
        orig_pixbuf = widget_pixbuf(terminal)

        savedialog = gtk.FileChooserDialog(title=_("Save image"),
                                           action=self.dialog_action,
                                           buttons=self.dialog_buttons)
        savedialog.set_do_overwrite_confirmation(True)
        savedialog.set_local_only(True)

        pixbuf = orig_pixbuf.scale_simple(orig_pixbuf.get_width() / 2,
                                          orig_pixbuf.get_height() / 2,
                                          gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        savedialog.set_preview_widget(image)

        savedialog.show_all()
        response = savedialog.run()
        path = None
        if response == gtk.RESPONSE_OK:
            path = os.path.join(savedialog.get_current_folder(),
                                savedialog.get_filename())
            orig_pixbuf.save(path, 'png')

        savedialog.destroy()
Example #48
0
    def on_edit(self, button, data):
      treeview = data['treeview']
      selection = treeview.get_selection()
      (store, iter) = selection.get_selected()
      
      if not iter:
        return
       
      (dialog,enabled,name,command) = self._create_command_dialog(
                                                enabled_var = store.get_value(iter, CC_COL_ENABLED),
                                                name_var = store.get_value(iter, CC_COL_NAME),
                                                command_var = store.get_value(iter, CC_COL_COMMAND)
                                                                  )
      res = dialog.run()
      item = {}
      if res == Gtk.ResponseType.ACCEPT:
        item['enabled'] = enabled.get_active()
        item['name'] = name.get_text()
        item['command'] = command.get_text()
        if item['name'] == '' or item['command'] == '':
          err = Gtk.MessageDialog(dialog,
                                  Gtk.DialogFlags.MODAL,
                                  Gtk.MessageType.ERROR,
                                  Gtk.ButtonsType.CLOSE,
                                  _("You need to define a name and command")
                                )
          err.run()
          err.destroy()
        else:
          tmpiter = store.get_iter_first()
          name_exist = False
          while tmpiter != None:
            if store.get_path(tmpiter) != store.get_path(iter) and store.get_value(tmpiter,CC_COL_NAME) == item['name']:
              name_exist = True
              break
            tmpiter = store.iter_next(tmpiter)
          if not name_exist:
            store.set(iter,
                      CC_COL_ENABLED,item['enabled'],
                      CC_COL_NAME, item['name'],
                      CC_COL_COMMAND, item['command']
                      )
          else:
            self._err(_("Name *%s* already exist") % item['name'])

      dialog.destroy()
Example #49
0
    def callback(self, menuitems, menu, terminal):
        """Add our menu items to the menu"""
        submenus = {}
        item = Gtk.MenuItem.new_with_mnemonic(_('_Custom Commands'))
        menuitems.append(item)

        submenu = Gtk.Menu()
        item.set_submenu(submenu)

        menuitem = Gtk.MenuItem.new_with_mnemonic(_('_Preferences'))
        menuitem.connect("activate", self.configure)
        submenu.append(menuitem)

        menuitem = Gtk.SeparatorMenuItem()
        submenu.append(menuitem)

        theme = Gtk.IconTheme.get_default()
        for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ] :
          if not command['enabled']:
            continue
          exe = command['command'].split(' ')[0]
          iconinfo = theme.choose_icon([exe], Gtk.IconSize.MENU, Gtk.IconLookupFlags.USE_BUILTIN)
          leaf_name = command['name'].split('/')[-1]
          branch_names = command['name'].split('/')[:-1]
          target_submenu = submenu
          parent_submenu = submenu
          for idx in range(len(branch_names)):
            lookup_name = '/'.join(branch_names[0:idx+1])
            target_submenu = submenus.get(lookup_name, None)
            if not target_submenu:
              item = Gtk.MenuItem(_(branch_names[idx]))
              parent_submenu.append(item)
              target_submenu = Gtk.Menu()
              item.set_submenu(target_submenu)
              submenus[lookup_name] = target_submenu
            parent_submenu = target_submenu
          if iconinfo:
            image = Gtk.Image()
            image.set_from_icon_name(exe, Gtk.IconSize.MENU)
            menuitem = Gtk.ImageMenuItem(leaf_name)
            menuitem.set_image(image)
          else:
            menuitem = Gtk.MenuItem(leaf_name)
          terminals = terminal.terminator.get_target_terms(terminal)
          menuitem.connect("activate", self._execute, {'terminals' : terminals, 'command' : command['command'] })
          target_submenu.append(menuitem)
 def createMainItems(self):
     """
     Create the 'Layout Manager' menu item, together with the sub menu
     for saved layouts.
     """
     mainItem = gtk.MenuItem(_(LAYOUTMANAGER_DISPLAY_NAME))
     submenu = gtk.Menu()
     mainItem.set_submenu(submenu)
     return mainItem, submenu
Example #51
0
 def callback(self, menuitems, menu, terminal):
     """Add our menu item to the menu"""
     item = gtk.CheckMenuItem(_("Watch for _silence"))
     item.set_active(self.watches.has_key(terminal))
     if item.get_active():
         item.connect("activate", self.unwatch, terminal)
     else:
         item.connect("activate", self.watch, terminal)
     menuitems.append(item)
     dbg('Menu items appended')
Example #52
0
 def callback(self, menuitems, menu, terminal):
     """Add our menu item to the menu"""
     item = Gtk.CheckMenuItem.new_with_mnemonic(_('Watch for _activity'))
     item.set_active(self.watches.has_key(terminal))
     if item.get_active():
         item.connect("activate", self.unwatch, terminal)
     else:
         item.connect("activate", self.watch, terminal)
     menuitems.append(item)
     dbg('Menu item appended')
Example #53
0
 def tryAddLayoutMenuItem(self, name, terminal, menu):
     (isLayout, shortname) = self.tryGetLayoutShortName(name)
     if isLayout:
         layoutItem = gtk.MenuItem(_(shortname))
         layoutItem.connect(EVENT_ACTIVATE, self.loadCallback, terminal)
         menu.append(layoutItem)
         return True
     else:
         dbg("ignoring [%s] : %s" % (name, shortname))
         return False               
 def callback(self, menuitems, menu, terminal):
     '''called by terminator on context menu open'''
     item = gtk.MenuItem(_(self.pluginConfig[SETTING_MENU_MAIN]))
     submenu = gtk.Menu()
     exportItem = gtk.MenuItem(_(self.pluginConfig[SETTING_MENU_EXPORT]))
     exportItem.connect("activate", self.doExport, terminal)
     submenu.append(exportItem)
     if terminal in self.loggingTerminals:
         logItem = gtk.MenuItem(_(self.pluginConfig[SETTING_MENU_STOP_LOG]))
         logItem.connect("activate", self.doStopLog, terminal)
         submenu.append(logItem)
     else:
         logItem = gtk.MenuItem(_(self.pluginConfig[SETTING_MENU_START_LOG]))
         logItem.connect("activate", self.doLog, terminal)
         submenu.append(logItem)
         logItem = gtk.MenuItem(_(self.pluginConfig[SETTING_MENU_EXPORT_LOG]))
         logItem.connect("activate", self.doExportLog, terminal)
         submenu.append(logItem)
     item.set_submenu(submenu)
     menuitems.append(item)
Example #55
0
    def callback(self, menuitems, menu, terminal):
        """ Add save menu item to log 'content'the menu"""
        vte_terminal = terminal.get_vte()

        change_color_item = gtk.MenuItem(_('Change color'))
        change_color_item.connect("activate", self.change_color, terminal)
        change_color_item.set_has_tooltip(True)
        change_color_item.set_tooltip_text("Change titlebar color of this terminal")

        menuitems.append(change_color_item)

        # sub menu

        pick_color_menu = gtk.Menu()

        counter = 1
        for color in self.color_set:
            if color.get('name'):
                suffix = color['name']
            else:
                suffix = str(counter)
            color_item = gtk.MenuItem(_('Color') + ' ' + suffix)
            color_item.connect("activate", self.pick_color, terminal, counter - 1)
            color_item.set_has_tooltip(True)
            color_item.set_tooltip_text("Set this color for current terminal")

            accel_group = gtk.AccelGroup()


            color_item.add_accelerator("activate", accel_group,
                                       ord(str(counter)), gtk.gdk.CONTROL_MASK | gtk.gdk.SHIFT_MASK, gtk.ACCEL_VISIBLE)


            pick_color_menu.append(color_item)
            counter += 1


        item = gtk.MenuItem(_('Pick color'))
        item.set_submenu(pick_color_menu)
        menuitems.append(item)
Example #56
0
    def notify(self, _vte, terminal):
        """Notify that a terminal did something"""
        show_notify = False

        # Don't notify if the user is already looking at this terminal.
        if terminal.vte.has_focus():
            return True

        note = Notify.Notification.new(_('Terminator'), _('Activity in: %s') % 
                                  terminal.get_window_title(), 'terminator')

        this_time = time.mktime(time.gmtime())
        if not self.last_notifies.has_key(terminal):
            show_notify = True
        else:
            last_time = self.last_notifies[terminal]
            if this_time - last_time > hush_period:
                show_notify = True

        if show_notify == True:
            note.show()
            self.last_notifies[terminal] = this_time

        return True
 def tryAddLayoutMenuItem(self, name, terminal, menu):
     """
     Checks if given file is a layout and add a context menu item if so.
     @param name: The file name of the possible layout.
     @param terminal: The terminal this context menu item belongs to.
     @param menu: Full gtk menu instance; not used here.
     """
     isLayout, shortname = self.tryGetLayoutShortName(name)
     if isLayout:
         layoutItem = gtk.MenuItem(_(shortname))
         layoutItem.connect(EVENT_ACTIVATE, self.loadCallback, terminal)
         menu.append(layoutItem)
         return True
     else:
         dbg("ignoring [%s] : %s" % (name, shortname))
         return False
Example #58
0
 def callback(self, menuitems, menu, terminal):
     """Add our menu items to the menu"""
     item = gtk.MenuItem(_('Terminal screenshot'))
     item.connect("activate", self.terminalshot, terminal)
     menuitems.append(item)
import gtk
import gobject
import pyglet # for playing sounds
import terminatorlib.plugin as plugin
from terminatorlib.translation import _
from terminatorlib.util import err, dbg
from terminatorlib.version import APP_NAME

try:
    import pynotify
    # Every plugin you want Terminator to load *must* be listed in 'AVAILABLE'
    # This is inside this try so we only make the plugin available if pynotify
    #  is present on this computer.
    AVAILABLE = ['ActivityWatch', 'InactivityWatch']
except ImportError:
    err(_('ActivityWatch plugin unavailable: please install python-notify'))

class ActivityWatch(plugin.MenuItem):
    """Add custom commands to the terminal menu"""
    capabilities = ['terminal_menu']
    watches = None
    last_notifies = None
    timers = None
    

    def __init__(self):
        plugin.MenuItem.__init__(self)
        if not self.watches:
            self.watches = {}
        if not self.last_notifies:
            self.last_notifies = {}
Example #60
0
    def configure(self, widget, data = None):
      ui = {}
      dbox = Gtk.Dialog(
                      _("Custom Commands Configuration"),
                      None,
                      Gtk.DialogFlags.MODAL,
                      (
                        Gtk.STOCK_CANCEL, Gtk.ResponseType.REJECT,
                        Gtk.STOCK_OK, Gtk.ResponseType.ACCEPT
                      )
                    )

      icon_theme = Gtk.IconTheme()
      try:
        icon = icon_theme.load_icon('terminator-custom-commands', 48, 0)
      except (NameError, GObject.GError):
        dbg('Unable to load 48px Terminator preferences icon')
        icon = dbox.render_icon(Gtk.STOCK_DIALOG_INFO, Gtk.IconSize.BUTTON)
      dbox.set_icon(icon)

      store = Gtk.ListStore(bool, str, str)

      for command in [ self.cmd_list[key] for key in sorted(self.cmd_list.keys()) ]:
        store.append([command['enabled'], command['name'], command['command']])
 
      treeview = Gtk.TreeView(store)
      #treeview.connect("cursor-changed", self.on_cursor_changed, ui)
      selection = treeview.get_selection()
      selection.set_mode(Gtk.SelectionMode.SINGLE)
      selection.connect("changed", self.on_selection_changed, ui)
      ui['treeview'] = treeview

      renderer = Gtk.CellRendererToggle()
      renderer.connect('toggled', self.on_toggled, ui)
      column = Gtk.TreeViewColumn("Enabled", renderer, active=CC_COL_ENABLED)
      treeview.append_column(column)

      renderer = Gtk.CellRendererText()
      column = Gtk.TreeViewColumn("Name", renderer, text=CC_COL_NAME)
      treeview.append_column(column)

      renderer = Gtk.CellRendererText()
      column = Gtk.TreeViewColumn("Command", renderer, text=CC_COL_COMMAND)
      treeview.append_column(column)

      scroll_window = Gtk.ScrolledWindow()
      scroll_window.set_size_request(500, 250)
      scroll_window.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
      scroll_window.add_with_viewport(treeview)

      hbox = Gtk.HBox()
      hbox.pack_start(scroll_window, True, True)
      dbox.vbox.pack_start(hbox, True, True, 0)

      button_box = Gtk.VBox()

      button = Gtk.Button(stock=Gtk.STOCK_GOTO_TOP)
      button_box.pack_start(button, False, True)
      button.connect("clicked", self.on_goto_top, ui) 
      button.set_sensitive(False)
      ui['button_top'] = button

      button = Gtk.Button(stock=Gtk.STOCK_GO_UP)
      button_box.pack_start(button, False, True)
      button.connect("clicked", self.on_go_up, ui)
      button.set_sensitive(False)
      ui['button_up'] = button

      button = Gtk.Button(stock=Gtk.STOCK_GO_DOWN)
      button_box.pack_start(button, False, True)
      button.connect("clicked", self.on_go_down, ui) 
      button.set_sensitive(False)
      ui['button_down'] = button

      button = Gtk.Button(stock=Gtk.STOCK_GOTO_LAST)
      button_box.pack_start(button, False, True)
      button.connect("clicked", self.on_goto_last, ui) 
      button.set_sensitive(False)
      ui['button_last'] = button

      button = Gtk.Button(stock=Gtk.STOCK_NEW)
      button_box.pack_start(button, False, True)
      button.connect("clicked", self.on_new, ui) 
      ui['button_new'] = button

      button = Gtk.Button(stock=Gtk.STOCK_EDIT)
      button_box.pack_start(button, False, True)
      button.set_sensitive(False)
      button.connect("clicked", self.on_edit, ui) 
      ui['button_edit'] = button

      button = Gtk.Button(stock=Gtk.STOCK_DELETE)
      button_box.pack_start(button, False, True)
      button.connect("clicked", self.on_delete, ui) 
      button.set_sensitive(False)
      ui['button_delete'] = button



      hbox.pack_start(button_box, False, True)
      dbox.show_all()
      res = dbox.run()
      if res == Gtk.ResponseType.ACCEPT:
        self.update_cmd_list(store)
        self._save_config()
      dbox.destroy()
      return