gitso

gitso Commit Details


Date:2008-06-15 14:42:46 (16 years 6 months ago)
Author:gerberad
Branch:master
Commit:e506a00f454a8f20e368937a72356a08db5a7f1a
Parents: 86d75b3beace7f20e391a5d4c523dd60fef88e75
Message:More file structure changes.

Changes:

File differences

gitso/trunk/Gitso.py
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
"""
Gisto - Gitso is to support others
Gitso is a utility to facilitate the connection of VNC
@author: Aaron Gerber ('gerberad')
@author: Derek Buranen ('burner') <derek@buranen.info>
@copyright: 2007-2008
"""
import pygtk
pygtk.require('2.0')
import gtk, os, signal, webbrowser, sys
class Connect(object):
"""
??????
@author: Derek Buranen
@author: Aaron Gerber
"""
#TODO: Test Try using the pretty python decorator instead of calling the class. Not sure GTK will support this but worth a try
## @gtk.about_dialog_set_url_hook ##
def openURL(func, url):
"""
Makes sure the URLs are clickable
@author: Derek Buranen
@author: Aaron Gerber
"""
webbrowser.open_new(url)
gtk.about_dialog_set_url_hook(openURL)
# Callback: radioToggle
# : EVENT - Radio buttons toggled
def radioToggle(self, widget, data=None):
"""
Toggles Radio Buttons
@author: Derek Buranen
@author: Aaron Gerber
"""
value = (data, ("OFF", "ON")[widget.get_active()])
if value[0] == "_Get Help":
if value[1] == "ON":
self.GetSupportEntry.set_sensitive(True)
self.GetSupportEntry.grab_focus()
elif value[0] == "Give _Support":
if value[1] == "ON":
self.GetSupportEntry.set_sensitive(False)
# Callback: connectSupport
# : EVENT - Connect button was pressed
def connectSupport(self, widget, data=None):
"""
???
@author: Derek Buranen
@author: Aaron Gerber
"""
if self.GetSupportRadio.get_active() == True:
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())
else:
self.connectButton.set_sensitive(False)
self.stopButton.set_sensitive(True)
self.statusLabel.set_text(self.statusLabelText[1])
self.returnPID = os.spawnlp(os.P_NOWAIT, 'vncviewer', 'vncviewer', '-listen')
# Callback: showAbout
# : EVENT - About Gitso selected
def showAbout(self, widget, data=None):
"""
Display About Dialog
@author: Derek Buranen
@author: Aaron Gerber
"""
license = open(os.path.join(sys.path[0], '..', 'share', 'doc', 'gitso', 'copyright'), 'r')
aboutDialog = gtk.AboutDialog()
aboutDialog.set_name("Gitso")
aboutDialog.set_version("0.4")
aboutDialog.set_authors(["Derek Buranen", "Aaron Gerber"])
aboutDialog.set_license(license.read())
aboutDialog.set_website('http://gitso.googlecode.com')
aboutDialog.set_copyright("2007-2008 Derek Buranen, Aaron Gerber")
aboutDialog.set_comments("Gitso Is To Support Others")
license.close()
aboutDialog.run()
aboutDialog.destroy()
# Callback: getClipboard
# : EVENT - Paste menu item selected
def getClipboard(self, menu, data=None):
"""
Paste clipboard text in Support Entry Field
@author: Derek Buranen
@author: Aaron Gerber
"""
self.GetSupportEntry.set_text(self.clipboard.wait_for_text())
return
# Callback: getClipboard
# : EVENT - Copy menu item selected
def setClipboard(self, menu, data=None):
"""
Set the value of the clipboard
@author: Derek Buranen
@author: Aaron Gerber
"""
self.clipboard.set_text(self.GetSupportEntry.get_text())
return
# Callback: killPID
# : EVENT - Stop is pressed or Applications ends
def killPID(self, data=None):
"""
Kill VNC instance
@author: Derek Buranen
@author: Aaron Gerber
"""
if self.returnPID != 0:
self.connectButton.set_sensitive(True)
self.stopButton.set_sensitive(False)
os.kill(self.returnPID, signal.SIGKILL)
self.statusLabel.set_text(self.statusLabelText[0])
self.returnPID = 0
return
# Callback: deleteEvent
# : EVENT - "Close" option is selected - title bar or button
#TODO: Add "Close" button
#TODO: "quit" prompt dialog
#TODO: Close VNC connection
def deleteEvent(self, widget, event, data=None):
"""
Close Window
If you return FALSE in the "deleteEvent" signal handler,
GTK will emit the "destroy" signal. Returning TRUE means
you don't want the window to be destroyed.
This is useful for popping up 'are you sure you want to quit?' dialog
@author: Derek Buranen
@author: Aaron Gerber
"""
print "Close Window"
return False
# Callback: destroy
# : EVENT - Gtk_widget_destroy() is called on the window, or return FALSE in "deleteEvent"
def destroy(self, widget, data=None):
"""
Quit Application
@author: Derek Buranen
@author: Aaron Gerber
"""
print "Quit Application"
self.killPID(self)
gtk.main_quit()
# Run Loop: Initilize program
def __init__(self):
"""
Setup Application Dialog
@author: Derek Buranen
@author: Aaron Gerber
"""
#initializing various variables
self.returnPID = 0
self.statusLabelText = ('Status: Idle', 'Status: Started')
# create a new window
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title("Gitso")
self.window.connect("delete_event", self.deleteEvent)
self.window.connect("destroy", self.destroy)
self.window.set_border_width(0)
self.window.set_icon_from_file(os.path.join(sys.path[0], '..', 'share', 'gitso', 'gitso.svg'))
self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
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.GetSupportEntry.set_text("IP address")
self.GetSupportEntry.show()
# Initialize Radio Buttons.
self.GiveSupportRadio = gtk.RadioButton(None, "Give _Support", use_underline=True)
self.GetSupportRadio = gtk.RadioButton(self.GiveSupportRadio, "_Get Help", use_underline=True)
self.GiveSupportRadio.connect("toggled", self.radioToggle, "Give _Support")
self.GetSupportRadio.connect("toggled", self.radioToggle, "_Get Help")
self.GetSupportRadio.set_active(True)
self.GiveSupportRadio.show()
self.GetSupportRadio.show()
#TODO: Connect Button -- Default
#### 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.stopButton = gtk.Button("Stop", gtk.STOCK_STOP)
self.stopButton.connect("clicked", self.killPID)
self.stopButton.set_sensitive(False)
self.stopButton.show()
self.statusLabel = gtk.Label(self.statusLabelText[0])
self.statusLabel.show()
# Initialize Boxes
self.mainVBox = gtk.VBox(False, 0)
self.interfaceVBox = gtk.VBox(False, 0)
self.menuHBox = gtk.HBox(False, 0)
self.getSupportHBox = gtk.HBox(False, 0)
self.giveSupportHBox = gtk.HBox(False, 0)
self.buttonHBox = gtk.HBox(False, 0)
# VBox MenuBar
self.menuHBox.pack_start(menubar, True, True, 0)
self.mainVBox.pack_start(self.menuHBox, False, False, 0)
# 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
self.giveSupportHBox.pack_start(self.GiveSupportRadio, True, True, 8)
self.interfaceVBox.pack_start(self.giveSupportHBox, True, True, 0)
# 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
self.GetSupportEntry.grab_focus()
self.mainVBox.pack_end(self.interfaceVBox, False, False, 8)
self.mainVBox.show()
self.interfaceVBox.show()
self.menuHBox.show()
self.getSupportHBox.show()
self.giveSupportHBox.show()
self.buttonHBox.show()
self.window.add(self.mainVBox)
self.window.set_position(gtk.WIN_POS_CENTER)
self.window.show()
# Run Loop: Main run loop
def main(self):
gtk.main()

Archive Download the corresponding diff file

Branches

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