2
# -*- coding: utf-8 -*-
4
# Copyright 2010 Duane Hinnen, Kenny Meyer, Marcos Vanetta
6
# This program is free software: you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License version 3, as published
8
# by the Free Software Foundation.
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranties of
12
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
13
# PURPOSE. See the GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License along
16
# with this program. If not, see <http://www.gnu.org/licenses/>.
20
# This file contains the menus, buttons, and right clicks
24
import clicompanionlib.tabs
27
class FileMenu(object):
29
def the_menu(self, actions, notebook, liststore):
31
root_menu = gtk.MenuItem(_("File"))
32
root_menu.set_submenu(menu)
35
root_menu2 = gtk.MenuItem(_("Help"))
36
root_menu2.set_submenu(menu2)
39
## Make 'Run' menu entry
40
menu_item1 = gtk.MenuItem(_("Run Command"))
41
menu.append(menu_item1)
42
menu_item1.connect("activate", actions.run_command, notebook, liststore)
45
## Make 'Add' file menu entry
46
menu_item2 = gtk.MenuItem(_("Add Command"))
47
menu.append(menu_item2)
48
menu_item2.connect("activate", actions.add_command, liststore)
51
## Make 'Remove' file menu entry
52
menu_item2 = gtk.MenuItem(_("Remove Command"))
53
menu.append(menu_item2)
54
menu_item2.connect("activate", actions.remove_command, liststore)
57
## Make 'Add Tab' file menu entry
58
tabs = clicompanionlib.tabs.Tabs()
59
menu_item4 = gtk.MenuItem(_("Add Tab"))
60
menu.append(menu_item4)
61
menu_item4.connect("activate", tabs.add_tab, notebook)
64
## Make 'Quit' file menu entry
65
menu_item3 = gtk.MenuItem(_("Quit"))
66
menu.append(menu_item3)
67
menu_item3.connect("activate", actions.delete_event)
72
## Make 'About' file menu entry
73
menu_item11 = gtk.MenuItem(_("About"))
74
menu2.append(menu_item11)
75
menu_item11.connect("activate", actions.about_event)
79
## Make 'Help' file menu entry
80
menu_item22 = gtk.MenuItem(_("Help"))
81
menu2.append(menu_item22)
82
menu_item22.connect("activate", actions.help_event)
86
menu_bar = gtk.MenuBar()
88
menu_bar.append (root_menu) ##Menu bar(file)
89
menu_bar.append (root_menu2) ##Menu bar(help)
90
#menu_bar.show() ##show File Menu # Menu Bar
97
def buttons(self, actions, spacing, layout, notebook, liststore):
98
#button box at bottom of main window
100
bbox = gtk.HButtonBox()
101
bbox.set_border_width(5)
104
# Set the appearance of the Button Box
105
bbox.set_layout(layout)
106
bbox.set_spacing(spacing)
108
buttonRun = gtk.Button(_("Run"))
110
buttonRun.connect("clicked", actions.run_command, notebook, liststore)
111
buttonRun.set_tooltip_text(_("Click to run a highlighted command"))
113
buttonAdd = gtk.Button(stock=gtk.STOCK_ADD)
115
buttonAdd.connect("clicked", actions.add_command, liststore)
116
buttonAdd.set_tooltip_text(_("Click to add a command to your command list"))
118
buttonEdit = gtk.Button("Edit")
120
buttonEdit.connect("clicked", actions.edit_command, liststore)
121
buttonEdit.set_tooltip_text(_("Click to edit a command in your command list"))
123
buttonDelete = gtk.Button(stock=gtk.STOCK_DELETE)
124
bbox.add(buttonDelete)
125
buttonDelete.connect("clicked", actions.remove_command, liststore)
126
buttonDelete.set_tooltip_text(_("Click to delete a command in your command list"))
128
buttonHelp = gtk.Button(stock=gtk.STOCK_HELP)
130
buttonHelp.connect("clicked", actions.man_page, notebook)
131
buttonHelp.set_tooltip_text(_("Click to get help with a command in your command list"))
133
buttonCancel = gtk.Button(stock=gtk.STOCK_QUIT)
134
bbox.add(buttonCancel)
135
buttonCancel.connect("clicked", actions.delete_event)
136
buttonCancel.set_tooltip_text(_("Click to quit CLI Companion"))
141
#right-click popup menu for the Liststore(command list)
142
def right_click(self, widget, event, actions, treeview, notebook, liststore):
143
if event.button == 3:
147
pthinfo = treeview.get_path_at_pos(x, y)
148
if pthinfo is not None:
149
path, col, cellx, celly = pthinfo
150
treeview.grab_focus()
151
treeview.set_cursor( path, col, 0)
153
# right-click popup menu Apply(run)
154
popupMenu = gtk.Menu()
155
menuPopup1 = gtk.ImageMenuItem (gtk.STOCK_APPLY)
156
popupMenu.add(menuPopup1)
157
menuPopup1.connect("activate", actions.run_command, notebook, liststore)
158
# right-click popup menu Edit
159
menuPopup2 = gtk.ImageMenuItem (gtk.STOCK_EDIT)
160
popupMenu.add(menuPopup2)
161
menuPopup2.connect("activate", actions.edit_command, liststore)
162
# right-click popup menu Delete
163
menuPopup3 = gtk.ImageMenuItem (gtk.STOCK_DELETE)
164
popupMenu.add(menuPopup3)
165
menuPopup3.connect("activate", actions.remove_command, liststore)
166
# right-click popup menu Help
167
menuPopup4 = gtk.ImageMenuItem (gtk.STOCK_HELP)
168
popupMenu.add(menuPopup4)
169
menuPopup4.connect("activate", actions.man_page, notebook)
172
popupMenu.popup( None, None, None, event.button, time)