Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 29a6c962ac
Fetching contributors…

Cannot retrieve contributors at this time

file 103 lines (84 sloc) 4.222 kb
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
#!/usr/bin/env python
#
# menu.py
#
# Copyright 2009 Matthew Brush <mbrush@leftclick.ca>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
import sys
import gtk

class ContextMenu(gtk.Menu):
    window_visible = True
    def __init__(self, window):
        gtk.Menu.__init__(self)
        self._window = window
        #self._tray = traywidget
        
        self.accel_group = gtk.AccelGroup()
        
        self._menuItemNewTerminal = gtk.ImageMenuItem(gtk.STOCK_OPEN, self.accel_group)
        self.append(self._menuItemNewTerminal)
        self._menuItemNewTerminal.get_children()[0].set_label('Open Terminal')
        self._menuItemNewTerminal.connect('activate', self._window.on_new_terminal_clicked)

        self._menuSep1 = gtk.MenuItem()
        self.append(self._menuSep1)
        
        self._menuItemNewTab = gtk.ImageMenuItem(gtk.STOCK_NEW, self.accel_group)
        self.append(self._menuItemNewTab)
        self._menuItemNewTab.get_children()[0].set_label('New Tab')
        self._menuItemNewTab.connect('activate', self._window.on_new_tab_clicked)
        
        self._menuCloseTab = gtk.ImageMenuItem(gtk.STOCK_CLOSE, self.accel_group)
        self.append(self._menuCloseTab)
        self._menuCloseTab.get_children()[0].set_label('Close Tab')
        self._menuCloseTab.connect('activate', self._window.on_close_tab_clicked)
        
        #self._menuSep2 = gtk.MenuItem()
        #self.append(self._menuSep2)
        
        self._menuNextTab = gtk.ImageMenuItem(gtk.STOCK_GO_FORWARD, self.accel_group)
        self.append(self._menuNextTab)
        self._menuNextTab.get_children()[0].set_label('Next Tab')
        self._menuNextTab.connect('activate', self._window.on_next_tab_clicked)

        self._menuPreviousTab = gtk.ImageMenuItem(gtk.STOCK_GO_BACK, self.accel_group)
        self.append(self._menuPreviousTab)
        self._menuPreviousTab.get_children()[0].set_label('Previous Tab')
        self._menuPreviousTab.connect('activate', self._window.on_previous_tab_clicked)

        self._menuSep3 = gtk.MenuItem()
        self.append(self._menuSep3)

        self._menuCopy = gtk.ImageMenuItem(gtk.STOCK_COPY, self.accel_group)
        self.append(self._menuCopy)
        #self._menuCopy.connect('activate', self.on_copy_clicked)

        self._menuPaste = gtk.ImageMenuItem(gtk.STOCK_PASTE, self.accel_group)
        self.append(self._menuPaste)
        #self._menuPaste.connect('activate', self.on_paste_clicked)
        
        self._menuSep4 = gtk.MenuItem()
        self.append(self._menuSep4)

        self._menuShowHide = gtk.MenuItem("Show/Hide")
        self.append(self._menuShowHide)
        self._menuShowHide.connect('activate', self.on_show_hide_clicked)
        
        self._menuSep5 = gtk.MenuItem()
        self.append(self._menuSep5)

        self._menuItemQuit = gtk.ImageMenuItem(gtk.STOCK_QUIT, self.accel_group)
        self.append(self._menuItemQuit)
        self._menuItemQuit.connect('activate', self._window.on_quit_clicked)

        self.show_all()
        
    def on_show_hide_clicked(self,widget):
        self.toggle_window()

    # toggle whether the window is visible or not
    def toggle_window(self):
        print "Toggling window"
        if self.window_visible == True:
            self.window_visible = False
            self._window.hide()
        else:
            self.window_visible = True
            self._window.show()
        self._window.set_keep_below(True)
Something went wrong with that request. Please try again.