File: dir_open.py

package info (click to toggle)
terminator 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,916 kB
  • sloc: python: 11,390; sh: 26; makefile: 15
file content (31 lines) | stat: -rw-r--r-- 895 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from gi.repository import Gtk

from terminatorlib.translation import _
import terminatorlib.plugin as plugin

AVAILABLE = ['CurrDirOpen']


class CurrDirOpen(plugin.MenuItem):
    capabilities = ['terminal_menu']
    config = None

    def __init__(self):
        self.cwd = ""
        self.terminal = None

    def _on_menu_item_add_tag_activate(self, menu_item_add_tag):
        self.terminal.open_url("file://" + self.cwd)

    def callback(self, menuitems, menu, terminal):
        self.cwd = terminal.get_cwd()
        self.terminal = terminal

        menuitem = Gtk.ImageMenuItem(_('Open current directory'))
        image = Gtk.Image()
        image.set_from_icon_name('folder', Gtk.IconSize.MENU)
        menuitem.set_image(image)
        menuitem.set_always_show_image(True)
        menuitem.connect("activate", self._on_menu_item_add_tag_activate)

        menuitems.append(menuitem)