gitso

gitso Commit Details


Date:2008-05-10 15:25:27 (16 years 7 months ago)
Author:gerberad
Branch:master
Commit:bfa292c2b2057abdc4fb325a3b90dc483cbde075
Parents: 5d97ad6614a4af22b45a6db35dc0e576e2eed562
Message:Moved Menu to UIManager

Changes:

File differences

gitso/trunk/gitso.py
2626
2727
2828
29
2930
3031
3132
......
5556
5657
5758
58
59
5960
6061
6162
......
6970
7071
7172
72
73
7374
7475
7576
......
127128
128129
129130
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147131
148
149
150
151
152
153
154
132
155133
156134
157135
......
166144
167145
168146
169
170
171
172
173
174
175
176
177
178
179
180
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
181190
182191
183192
......
196205
197206
198207
199
200
201
202
208
209
210
211
203212
204213
205214
......
211220
212221
213222
214
223
215224
216225
217226
......
220229
221230
222231
223
224
232
233
225234
226
227235
228
236
229237
230238
231239
232240
233
241
234242
235243
236244
237
245
238246
239247
240248
241249
242250
243
251
244252
245253
246254
import signal
import webbrowser
class Connect:
# Make sure the URLs are clickable
self.connectButton.set_sensitive(False)
self.stopButton.set_sensitive(True)
self.statusLabel.set_text(self.statusLabelText[1])
self.returnPID = os.spawnlp(os.P_NOWAIT, 'x11vnc', 'x11vnc', "-connect %s" % self.GetSupportEntry.get_text())
self.returnPID = os.spawnlp(os.P_NOWAIT, 'x11vnc', 'x11vnc', " --connect %s -rawfb console" % self.GetSupportEntry.get_text())
else:
self.connectButton.set_sensitive(False)
self.stopButton.set_sensitive(True)
license = open('aboutlicense.txt', 'r')
aboutDialog = gtk.AboutDialog()
aboutDialog.set_name("Gitso")
aboutDialog.set_version("0.499-svn")
aboutDialog.set_version("0.1.1")
aboutDialog.set_authors(["Derek Buranen", "Aaron Gerber"])
aboutDialog.set_license(license.read())
aboutDialog.set_website('http://code.google.com/p/gitso')
self.killPID(self)
gtk.main_quit()
def get_main_menu(self, window):
accel_group = gtk.AccelGroup()
# This function initializes the item factory.
# Param 1: The type of menu - can be MenuBar, Menu,
# or OptionMenu.
# Param 2: The path of the menu.
# Param 3: A reference to an AccelGroup. The item factory sets up
# the accelerator table while generating menus.
item_factory = gtk.ItemFactory(gtk.MenuBar, "<main>", accel_group)
# This method generates the menu items. Pass to the item factory
# the list of menu items
item_factory.create_items(self.menu_items)
# Attach the new accelerator group to the window.
window.add_accel_group(accel_group)
# need to keep a reference to item_factory to prevent its destruction
self.item_factory = item_factory
# Finally, return the actual menu bar created by the item factory.
return item_factory.get_widget("<main>")
# Run Loop: Initilize program
# Run Loop: Initilize program
def __init__(self):
#initializing various variables
self.returnPID = 0
self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
self.menu_items = (
('/_File', None, None, 0, '<Branch>' ),
('/File/Connect', None, self.connectSupport, 0, '<StockItem>', gtk.STOCK_CONNECT),
('/File/_Quit', '<control>Q', self.destroy, 0, '<StockItem>', gtk.STOCK_QUIT),
('/_Edit/_Copy', None, self.setClipboard, 0, '<StockItem>',gtk.STOCK_COPY),
('/_Edit/_Paste', None, self.getClipboard, 0, '<StockItem>',gtk.STOCK_PASTE),
('/_Help', None, None, 0, '<Branch>'),
('/Help/_About', None, self.showAbout, 0, '<StockItem>',gtk.STOCK_ABOUT),
)
self.MenuBar = self.get_main_menu(self.window)
ui = '''<ui>
<menubar name="MenuBar">
<menu action="File">
<menuitem action="Quit"/>
</menu>
<menu action="Edit">
<menuitem action="Copy"/>
<menuitem action="Paste"/>
</menu>
<menu action="Help">
<menuitem action="About"/>
</menu>
</menubar>
</ui>'''
# Create a UIManager instance
GitsoUIManager = gtk.UIManager()
# Add the accelerator group to the toplevel window
AccelGroup = GitsoUIManager.get_accel_group()
self.window.add_accel_group(AccelGroup)
# Create an ActionGroup
self.ActionGroup = gtk.ActionGroup('GitsoUIManager')
# Create actions
self.ActionGroup.add_actions([('Quit', gtk.STOCK_QUIT, '_Quit', None, 'Quit the Program', self.destroy),
('File', None, '_File'),
('Copy', gtk.STOCK_COPY, '_Copy', None, 'Copy IP Address', self.setClipboard),
('Paste', gtk.STOCK_PASTE, '_Paste', None, 'Copy IP Address', self.getClipboard),
('Edit', None, '_Edit'),
('About', gtk.STOCK_ABOUT, '_About', None, 'About Gitso', self.showAbout),
('Help', None, '_Help')])
self.ActionGroup.get_action('Quit').set_property('short-label', '_Quit')
# Add the ActionGroup to the GitsoUIManager
GitsoUIManager.insert_action_group(self.ActionGroup, 0)
# Add a UI description
GitsoUIManager.add_ui_from_string(ui)
# Create a MenuBar
menubar = GitsoUIManager.get_widget('/MenuBar')
# Initialize IP Textbox
self.GetSupportEntry = gtk.Entry(50)
self.GetSupportRadio.show()
#### ToDo :: Connect Button -- Default ##########
#self.button.grab_default()
####################################
# Initialize Connect Button Bar
#### ToDo :: Connect Button -- Default ##########
#self.button.grab_default()
####################################
# Initialize Connect Button Bar
self.connectButton = gtk.Button("OK", gtk.STOCK_CONNECT)
self.connectButton.connect("clicked", self.connectSupport)
self.connectButton.show()
self.statusLabel.show()
# Initialize Boxes
# Initialize Boxes
self.mainVBox = gtk.VBox(False, 0)
self.interfaceVBox = gtk.VBox(False, 0)
self.menuHBox = gtk.HBox(False, 0)
self.buttonHBox = gtk.HBox(False, 0)
# VBox MenuBar
self.menuHBox.pack_start(self.MenuBar, True, True, 0)
# VBox MenuBar
self.menuHBox.pack_start(menubar, True, True, 0)
self.mainVBox.pack_start(self.menuHBox, False, False, 0)
self.MenuBar.show()
# VBox cell 1
# VBox cell 1
self.getSupportHBox.pack_start(self.GetSupportRadio, True, True, 8)
self.getSupportHBox.pack_start(self.GetSupportEntry, True, True, 8)
self.interfaceVBox.pack_start(self.getSupportHBox, True, True, 4)
# VBox cell 2
# VBox cell 2
self.giveSupportHBox.pack_start(self.GiveSupportRadio, True, True, 8)
self.interfaceVBox.pack_start(self.giveSupportHBox, True, True, 0)
# VBox cell 3
# VBox cell 3
self.buttonHBox.pack_start(self.statusLabel, False, False, 8)
self.buttonHBox.pack_end(self.stopButton, False, False, 8)
self.buttonHBox.pack_end(self.connectButton, False, False, 8)
self.interfaceVBox.pack_start(self.buttonHBox, False, False, 0)
# Show main window and initialize focus
# Show main window and initialize focus
self.GetSupportEntry.grab_focus()
self.mainVBox.pack_end(self.interfaceVBox, False, False, 8)

Archive Download the corresponding diff file

Branches

Number of commits:
Page rendered in 0.06035s using 13 queries.