diff options
author | Ariel Calzada <ariel@activitycentral.com> | 2012-01-24 16:50:22 (GMT) |
---|---|---|
committer | Ariel Calzada <ariel@activitycentral.com> | 2012-01-24 16:50:22 (GMT) |
commit | 9e3ff0dd128534b9925f4e9d9579c5d98e802ae6 (patch) | |
tree | 878108b90705b1b841206b731e7273c57b2e64f9 | |
parent | 6611a697892cb3fbad0c5fc7396ec865823c7999 (diff) |
Added viewer and i18n strings
-rw-r--r-- | i18n.py | 2 | ||||
-rw-r--r-- | utilities.py | 6 | ||||
-rw-r--r-- | viewer.py | 150 | ||||
-rwxr-xr-x | vncviewer | bin | 0 -> 622744 bytes | |||
-rwxr-xr-x | x11vnc | bin | 0 -> 1402876 bytes |
5 files changed, 157 insertions, 1 deletions
@@ -15,6 +15,8 @@ from gettext import gettext as _ # UI Buttons START = _('Start') STOP = _('Stop') +CONNECT = _('Connect') +DISCONNECT = _('Disconnect') # Process IPS = _('IPs') diff --git a/utilities.py b/utilities.py index 1953a3d..5ac8ad2 100644 --- a/utilities.py +++ b/utilities.py @@ -107,7 +107,11 @@ class Utilities(): os.system("kill -9 " + pid) def startProgram(self, programName, args=[]): - cmd = [programName] + fname = "/usr/bin/" + programName + if not os.path.isfile(fname): + fname = programName + + cmd = [fname] if len(args) > 0: for arg in args: diff --git a/viewer.py b/viewer.py new file mode 100644 index 0000000..874dfe0 --- /dev/null +++ b/viewer.py @@ -0,0 +1,150 @@ +import gtk +import pango + +from utilities import Utilities +import i18n + +class ViewerProcess(): + """Viewer process component + """ + + # utilities + _utilities = None + + # process details + _programName = "vncviewer" + _args = [] + + def __init__(self): + """Constructor + """ + self._utilities = Utilities() + + def getStatus(self): + """get current status of the vnc process + """ + st = self._utilities.checkProgramStatus(self._programName) + + return st[0] + + def changeStatus(self): + """change current status of the vnc proces + """ + if self.getStatus(): + self._utilities.endProgram(self._programName) + else: + self._utilities.startProgram(self._programName,self._args) + + def getProcessInfo(self): + return self._utilities.getNetworkProcessInfo(self._programName) + + +class ViewerUI(): + """Viewer UI component for Classroom Kit Activity + """ + # Constants + _greenColor = '#00E500' + _redColor = '#FF0000' + + # UI elements + _box = None + _button = None + _label = None + _toolbar = None + _boxAlign = None + + # activity, process + _activity = None + _process = None + + def __init__(self, activity, process): + """Constructor + """ + self._activity = activity + self._process = process + + def loadUI(self): + """Create and show UI + """ + # Box + self._box = gtk.VBox() + + # Label + self._label = gtk.Label() + + # Button + self._button = gtk.Button() + self._button.set_size_request(200, 50) + self._button.connect("clicked", self.buttonClicked) + + # Add button to box + self._box.pack_start(self._button) + + # Add label to box + self._box.pack_start(self._label, padding=20) + + # Box Align (xalign, yalign, xscale, yscale) + self._boxAlign = gtk.Alignment(0.5, 0.5, 0, 0) + self._boxAlign.add(self._box) + + # Set canvas with box alignment + self._activity.set_canvas(self._boxAlign) + + def setButtonBG(self, color): + """Change button bg color + """ + self._button.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse(color)) + + def setButtonLabel(self, txt): + """Change button label + """ + self._button.set_label(txt) + + def buttonClicked(self, widget, data=None): + """Button clicked event handler + """ + self._process.changeStatus() + self.showStatus() + + def setLabelTXT(self, txt): + """Change label text + """ + self._label.set_label(txt) + + def showStatus(self): + """Show VNC status + """ + state = self._process.getStatus() + + if not state: + self.setButtonBG(self._greenColor) + self.setButtonLabel(i18n.CONNECT) + self.setLabelTXT("") + else: + self.setButtonBG(self._redColor) + self.setButtonLabel(i18n.DISCONNECT) + self.setLabelTXT(self._process.getProcessInfo()) + +class Viewer(): + """Viewer component for Classroom Kit Activity + """ + _activity = None + _process = None + _ui = None + + def __init__(self,activity): + """Constructor + """ + self._activity = activity + self._process = ViewerProcess() + self._ui = ViewerUI(self._activity, self._process) + + def loadUI(self): + """Load UI + """ + self._ui.loadUI() + + def showStatus(self): + """Show Viewer status + """ + self._ui.showStatus() diff --git a/vncviewer b/vncviewer Binary files differBinary files differnew file mode 100755 index 0000000..bcbc643 --- /dev/null +++ b/vncviewer |