2
# -*- coding: utf-8 -*-
4
# Copyright 2010 Duane Hinnen, Kenny Meyer, Marcos Vanetta
6
# This file contains the menus, buttons, and right clicks
11
class FileMenu(object):
12
def the_menu(self, cli):
14
root_menu = gtk.MenuItem(_("File"))
15
root_menu.set_submenu(menu)
18
root_menu2 = gtk.MenuItem(_("Help"))
19
root_menu2.set_submenu(menu2)
22
## Make 'Run' menu entry
23
menu_item1 = gtk.MenuItem(_("Run Command"))
24
menu.append(menu_item1)
25
menu_item1.connect("activate", cli.run_command)
28
## Make 'Add' file menu entry
29
menu_item2 = gtk.MenuItem(_("Add Command"))
30
menu.append(menu_item2)
31
menu_item2.connect("activate", cli.add_command)
34
## Make 'Remove' file menu entry
35
menu_item2 = gtk.MenuItem(_("Remove Command"))
36
menu.append(menu_item2)
37
menu_item2.connect("activate", cli.remove_command)
40
## Make 'Quit' file menu entry
41
menu_item3 = gtk.MenuItem(_("Quit"))
42
menu.append(menu_item3)
43
menu_item3.connect("activate", cli.delete_event)
47
## Make 'Add Tab' file menu entry
48
menu_item4 = gtk.MenuItem(_("Add Tab"))
49
menu.append(menu_item4)
50
menu_item4.connect("activate", cli.add_tab)
55
## Make 'About' file menu entry
56
menu_item11 = gtk.MenuItem(_("About"))
57
menu2.append(menu_item11)
58
menu_item11.connect("activate", cli.about_event)
62
## Make 'Help' file menu entry
63
menu_item22 = gtk.MenuItem(_("Help"))
64
menu2.append(menu_item22)
65
menu_item22.connect("activate", cli.help_event)
69
menu_bar = gtk.MenuBar()
71
menu_bar.append (root_menu) ##Menu bar(file)
72
menu_bar.append (root_menu2) ##Menu bar(help)
73
#menu_bar.show() ##show File Menu # Menu Bar
80
def buttons(self, cli, spacing, layout):
81
#button box at bottom of main window
83
bbox = gtk.HButtonBox()
84
bbox.set_border_width(5)
87
# Set the appearance of the Button Box
88
bbox.set_layout(layout)
89
bbox.set_spacing(spacing)
91
buttonRun = gtk.Button(_("Run"))
93
buttonRun.connect("clicked", cli.run_command)
94
buttonRun.set_tooltip_text("Click to run a highlighted command")
96
buttonAdd = gtk.Button(stock=gtk.STOCK_ADD)
98
buttonAdd.connect("clicked", cli.add_command)
99
buttonAdd.set_tooltip_text("Click to add a command to your command list")
101
buttonEdit = gtk.Button("Edit")
103
buttonEdit.connect("clicked", cli.edit_command)
104
buttonEdit.set_tooltip_text("Click to edit a command in your command list")
106
buttonDelete = gtk.Button(stock=gtk.STOCK_DELETE)
107
bbox.add(buttonDelete)
108
buttonDelete.connect("clicked", cli.remove_command)
109
buttonDelete.set_tooltip_text("Click to delete a command in your command list")
111
buttonHelp = gtk.Button(stock=gtk.STOCK_HELP)
113
buttonHelp.connect("clicked", cli.man_page)
114
buttonHelp.set_tooltip_text("Click to get help with a command in your command list")
116
buttonCancel = gtk.Button(stock=gtk.STOCK_QUIT)
117
bbox.add(buttonCancel)
118
buttonCancel.connect("clicked", cli.delete_event)
119
buttonCancel.set_tooltip_text("Click to quit CLI Companion")
124
#right-click popup menu for the Liststore(command list)
125
def right_click(self, treeview, event, cli):
126
if event.button == 3:
130
pthinfo = treeview.get_path_at_pos(x, y)
131
if pthinfo is not None:
132
path, col, cellx, celly = pthinfo
133
treeview.grab_focus()
134
treeview.set_cursor( path, col, 0)
136
# right-click popup menu Apply(run)
137
popupMenu = gtk.Menu()
138
menuPopup1 = gtk.ImageMenuItem (gtk.STOCK_APPLY)
139
popupMenu.add(menuPopup1)
140
menuPopup1.connect("activate", cli.run_command)
141
# right-click popup menu Edit
142
menuPopup2 = gtk.ImageMenuItem (gtk.STOCK_EDIT)
143
popupMenu.add(menuPopup2)
144
menuPopup2.connect("activate", cli.edit_command)
145
# right-click popup menu Delete
146
menuPopup3 = gtk.ImageMenuItem (gtk.STOCK_DELETE)
147
popupMenu.add(menuPopup3)
148
menuPopup3.connect("activate", cli.remove_command)
149
# right-click popup menu Help
150
menuPopup4 = gtk.ImageMenuItem (gtk.STOCK_HELP)
151
popupMenu.add(menuPopup4)
152
menuPopup4.connect("activate", cli.man_page)
155
popupMenu.popup( None, None, None, event.button, time)