From 9e3ff0dd128534b9925f4e9d9579c5d98e802ae6 Mon Sep 17 00:00:00 2001 From: Ariel Calzada Date: Tue, 24 Jan 2012 16:50:22 +0000 Subject: Added viewer and i18n strings --- diff --git a/i18n.py b/i18n.py index b438938..8f9e96a 100644 --- a/i18n.py +++ b/i18n.py @@ -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 new file mode 100755 index 0000000..bcbc643 --- /dev/null +++ b/vncviewer Binary files differ diff --git a/x11vnc b/x11vnc new file mode 100755 index 0000000..f37061a --- /dev/null +++ b/x11vnc Binary files differ -- cgit v0.9.1