Class GnomeSSHMenu::App
In: lib/gnome-sshmenu.rb  (Git)
Parent: SSHMenu::App

The GnomeSSHMenu::App class builds on SSHMenu::App to add support for gnome-terminal and tabbed windows.

Methods

Public Instance methods

Given a GnomeSSHMenu::MenuItem, constructs a command line to open a gnome-terminal window containing multiple tabs - each with an SSH connection to a host.

[Source]

# File lib/gnome-sshmenu.rb, line 99
    def build_tabbed_window_command(menu)
      command = 'gnome-terminal'
      first_host = true
      menu.items.each do |i|
        if i.host?
          if first_host
            if i.env_settings and i.env_settings.length > 0
              command = i.env_settings + command + ' --disable-factory'
            end
            if i.geometry and i.geometry.length > 0
              command += " --geometry=#{i.geometry}"
            end
          end
          if i.profile and i.profile.length > 0
            command += ' --tab-with-profile=' + shell_quote(i.profile)
          else
            command += " --tab-with-profile=Default"
          end
          command += ' --title=' + shell_quote(i.title)
          ssh_cmnd = "#{ssh_command(i)} #{i.sshparams_noenv}"
          command += ' -e ' + shell_quote("sh -c #{shell_quote(ssh_cmnd)}")
          first_host = false
        end
      end
      return command + ' &'
    end

Given a GnomeSSHMenu::HostItem, constructs a command line to open a gnome-terminal window containing an SSH connection to the host.

[Source]

# File lib/gnome-sshmenu.rb, line 69
    def build_window_command(host)
      command = 'gnome-terminal'
      if host.env_settings and host.env_settings.length > 0
        command = host.env_settings + command + ' --disable-factory'
      end
      if host.geometry and host.geometry.length > 0
        command += " --geometry=#{host.geometry}"
      end
      if host.profile and host.profile.length > 0
        command += ' --window-with-profile=' + shell_quote(host.profile)
      end
      command += ' --title=' + shell_quote(host.title)
      ssh_cmnd = "#{ssh_command(host)} #{host.sshparams_noenv}"
      command += ' -e ' + shell_quote("sh -c #{shell_quote(ssh_cmnd)}")
      return command + ' &';
    end

Sets default class mappings to refer to GnomeSSHMenu dialog classes.

[Source]

# File lib/gnome-sshmenu.rb, line 57
    def inject_defaults
      mapper.inject(
        'app.dialog.prefs' => GnomeSSHMenu::PrefsDialog,
        'app.dialog.host'  => GnomeSSHMenu::HostDialog,
        'app.dialog.menu'  => GnomeSSHMenu::MenuDialog
      )
      super
    end

Helper routine for SSHMenu::App#show_hosts_menu. Adds the ‘Open all as tabs’ menu item if the option is enabled.

[Source]

# File lib/gnome-sshmenu.rb, line 129
    def menu_add_menu_options(mif, parents, item)
      return unless item.has_children?
      need_sep = super(mif, parents, item)
      if @config.menus_open_tabs?
        mif.create_item(
          item_path(parents, item) + '/Open all as tabs', "<Item>"
        ) { open_tabs(item) }
        need_sep = true
      end
      return need_sep
    end

Called when the user selects ‘Open all as tabs’ from a sub menu. Calls build_tabbed_window_command to open a multi-tabbed terminal window.

[Source]

# File lib/gnome-sshmenu.rb, line 89
    def open_tabs(menu)
      return unless menu.items.length > 0
      add_key
      system(build_tabbed_window_command(menu))
    end

[Validate]