gitso

gitso Commit Details


Date:2008-05-10 15:44:32 (16 years 7 months ago)
Author:xburnerx
Branch:master
Commit:2c0496cd67d405cf16a6bfc2f35ba96690ae9547
Parents: 7f06a98b75e6d443521a6ba19ae41de32637e857
Message:moving to package

Changes:

File differences

gitso/trunk/gitso
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
#!/usr/bin/env python
# Copyright (c) 2007
# Aaron Gerber ('gerberad')
# Derek Buranen ('bur[n]er') <xburnerx@gmail.com>
#
# 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, 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 pygtk
pygtk.require('2.0')
import gtk
import os
import signal
import webbrowser
class Connect:
# Make sure the URLs are clickable
def openURL(func, url):
webbrowser.open_new(url)
gtk.about_dialog_set_url_hook(openURL)
# Callback: radioToggle
# : EVENT - Radio buttons toggled
def radioToggle(self, widget, data=None):
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):
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 -rawfb console" % 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):
license = open('aboutlicense.txt', 'r')
aboutDialog = gtk.AboutDialog()
aboutDialog.set_name("Gitso")
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')
aboutDialog.set_copyright("2007 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):
self.GetSupportEntry.set_text(self.clipboard.wait_for_text())
return
# Callback: getClipboard
# : EVENT - Copy menu item selected
def setClipboard(self, menu, data=None):
self.clipboard.set_text(self.GetSupportEntry.get_text())
return
# Callback: killPID
# : EVENT - Stop is pressed or Applications ends
def killPID(self, data=None):
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" promt dialog
# : TODO - Close VNC connection
def deleteEvent(self, widget, event, data=None):
# 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
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):
print "Quit Application"
self.killPID(self)
gtk.main_quit()
# Run Loop: Initilize program
def __init__(self):
#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.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 ##########
#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.show()
# Run Loop: Main run loop
def main(self):
gtk.main()
# If the program is run directly or passed as an argument to the python
# interpreter then create a "Connect" instance and show it
if __name__ == "__main__":
hello = Connect()
hello.main()

Archive Download the corresponding diff file

Branches

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