Ejemplo n.º 1
0
    def __init__(self, gui):
        super(MenuPage, self).__init__("menu", gui)
        self.size_request = (300,300)
        # CREATE BUTTONS
        objButton = create_menuButton("static/ikoner/map.png","Objekt")
        setButton = create_menuButton("static/ikoner/cog.png","Inställningar")
        conButton = create_menuButton("static/ikoner/book_addresses.png","Kontakter")
        misButton = create_menuButton("static/ikoner/book.png","Uppdrag")
        jonasButton = create_menuButton("static/ikoner/JonasInGlases.png","Jonas")
        objButton.connect("clicked", self.gui.switch_page, "object")
        misButton.connect("clicked", self.gui.switch_page, "mission")
        setButton.connect("clicked", self.gui.switch_page, "settings")
        conButton.connect("clicked", self.gui.switch_page, "contact")
        jonasButton.connect("clicked", self.hille_e_tjock)

        vMenuBox = gtk.VBox(False,0)
        vMenuBox.pack_start(objButton, False, True, padding=2)
        vMenuBox.pack_start(misButton, False, True, padding=2)
        vMenuBox.pack_start(conButton, False, True, padding=2)
        vMenuBox.pack_start(setButton, False, True, padding=2)
        vMenuBox.pack_start(jonasButton, False, True, padding=2)
        self.pack_start(vMenuBox, False, False, padding=0)

        self.show()
        vMenuBox.show()
        rpc.register("add_poi", self.add_poi)
Ejemplo n.º 2
0
    def __init__(self, gui):
        #super(ContactPage, self).__init__("contact", gui, width="full")
        super(ContactPage, self).__init__("contact", gui, width="full")
        self.contacts = {}
        self.size_request = (300,300)
        self.vbox1 = gtk.VBox()
        self.combo = gtk.combo_box_new_text()

        #self.combo innehåller alla kontakter som finns i self.contacts {(user,ip)} 
        
        backButton = create_menuButton("static/ikoner/arrow_left.png", "Tillbaka")
        newButton = create_menuButton("static/ikoner/phone.png", "Ring")
        videoButton = create_menuButton("static/ikoner/JonasInGlases.png", "Video")
        backButton.connect("clicked", self.gui.switch_page, "menu")
        videoButton.connect("clicked", self.videoCall)
        newButton.connect("clicked", self.voiceCall)
        label = gtk.Label("Välj Kontakt:")


        self.vbox1.pack_start(label, False, True, padding=2)
        self.vbox1.pack_start(self.combo,False,False,10)

        self.vbox1.pack_start(newButton, False, True, padding=2)
        self.vbox1.pack_start(videoButton, False, True, padding=2)
        self.vbox1.pack_start(backButton, False, True, padding=2)
        self.pack_start(self.vbox1,False,True,0)


        self.show_all()
        rpc.register("add_contactlist", self.add_contactlist)
Ejemplo n.º 3
0
 def __init__(self, map):
     gtk.DrawingArea.__init__(self)
     
     # Variabler
     self._map = map
     self._pos = {"x":0, "y":0}
     self._origin_position = None
     self._cols = 0
     self._rows = 0
     self._gps_data = None
     self._movement_from = {"x": 0, "y":0}
     self._allow_movement = False
     self._last_movement_timestamp = 0.0
     self._zoom_level = 1
     self._is_dirty = True
     self._last_tiles = None
     self._last_focus_pixel = 0,0
     self._focus_pixel = 0,0
     
     rpc.register("update_map", self.force_draw)
     # queue_draw() ärvs från klassen gtk.DrawingArea
     map.set_redraw_function(self.queue_draw)
   
     self.connect("expose_event", self.handle_expose_event)
     self.connect("button_press_event", self.handle_button_press_event)
     self.connect("button_release_event", self.handle_button_release_event)
     self.connect("motion_notify_event", self.handle_motion_notify_event)
     self.set_events(gtk.gdk.BUTTON_PRESS_MASK |
                     gtk.gdk.BUTTON_RELEASE_MASK |
                     gtk.gdk.EXPOSURE_MASK |
                     gtk.gdk.LEAVE_NOTIFY_MASK |
                     gtk.gdk.POINTER_MOTION_MASK |
                     gtk.gdk.POINTER_MOTION_HINT_MASK)
Ejemplo n.º 4
0
    def __init__(self, coordinate, path, is_self=False):
        self.set_coordinate(coordinate)
        #call set_coordinate to update self pos
        #if self=true makes u update the object position
        if is_self:
            rpc.register("ping_with_coordinates", self.make_dict)

#        if len(path) == 1:
        self.set_path_to_picture(path)
Ejemplo n.º 5
0
Archivo: gui.py Proyecto: dreamwave/rad
    def create_login_view(self):
        def dbcheck_press_callback(self, widget, data=None):   
            session = get_session()
            create_tables()        
            session.bind
            session.query(User).all()
            user = unicode(userText.get_text())
            pw = unicode(passText.get_text())
            login = str(packet.Packet("login", username=user, password=pw))
            print rpc.send("qos", "add_packet", packet=login)

        def access(bol):
            if bol:
                statusLabel.set_label("Access granted")
            if not bol:
                statusLabel.set_label("Access denied")

        hboxOUT  = gtk.HBox(homogeneous=False, spacing=1)
        vbox1 = gtk.VBox(homogeneous=False, spacing=1)
        hbox1 = gtk.HBox(homogeneous=False, spacing=1)
        hbox2 = gtk.HBox(homogeneous=False, spacing=1)
        userText = gtk.Entry(max=0)
        userLabel = gtk.Label("Användare")
        passText = gtk.Entry(max=0)
        passLabel = gtk.Label("Lösenord")
        okButton = gtk.Button("Login")
        okButton.set_size_request(70, 50)
        okButton.connect("clicked", dbcheck_press_callback, None)
        statusLabel = gtk.Label("No status")

        vbox1.pack_start(hbox1, expand=False, fill=False, padding=1)
        vbox1.pack_start(hbox2, expand=False, fill=False, padding=1)
        vbox1.pack_start(okButton, expand=False, fill=False, padding=1)
        hbox1.pack_start(userText, expand=False, fill=False, padding=1)
        hbox1.pack_start(userLabel, expand=False, fill=False, padding=1)
        hbox2.pack_start(passText, expand=False, fill=False, padding=1)
        hbox2.pack_start(passLabel, expand=False, fill=False, padding=1)
        vbox1.pack_start(statusLabel, expand=False, fill=False, padding=1)
        hboxOUT.pack_start(vbox1, expand=True, fill=False, padding=1)
        
        userText.show()
        userLabel.show()
        passText.show()
        passLabel.show()
        okButton.show()
        statusLabel.show()
        hbox1.show()
        hbox2.show()
        vbox1.show()
        hboxOUT.show()
        #Skapar rpc
        rpc.register("access", access)
        
        return hboxOUT
Ejemplo n.º 6
0
    def __init__(self, map):
        # Initierar hildon (GUI-biblioteket för N810)
        hildon.Program.__init__(self)

        # Sparar handdatorns karta.
        self._map = map

        # Skapar programmets fönster
        self.window = hildon.Window()
        # Någon storlek så att PyGTK inte klagar
        self.window.set_size_request(200, 200)
        # Funktion som körs när prorammet ska stängas av
        self.window.connect("destroy", self.menu_exit)
        self.add_window(self.window)

        self._pages = {}
        self._pages["menu"] = MenuPage(self)
        self._pages["mission"] = MissionPage(self)
        self._pages["settings"] = SettingsPage(self)
        self._pages["contact"] = ContactPage(self)
        self._pages["addMission"] = AddMissionPage(self)
        self._pages["removeMission"] = RemoveMissionPage(self)
        self._pages["object"] = ObjectPage(self)
        self._pages["addObject"] = AddObjectPage(self)
        self._pages["showObject"] = ShowObjectPage(self)
        self._pages["showMission"] = ShowMissionPage(self)

        # Möjliggör fullscreen-läge
        self.window.connect("key-press-event", self.on_key_press)
        self.window.connect("window-state-event", self.on_window_state_change)
        # Programmet är inte i fullscreen-läge från början.
        self.window_in_fullscreen = False
        


        self.view = gtk.Notebook()
        self.view.set_show_tabs(False)
        self.view.set_show_border(False)
        self.view.insert_page(self.create_map_view())
        self.view.insert_page(self.create_settings_view())
        #self.view.insert_page(self.create_login_view())

        # Lägger in vyn i fönstret
        self.window.add(self.view)

        # Skapar menyn
        self.window.set_menu(self.create_menu())
        
        rpc.register("access", self.access)
        #Visar login-dialog
        self.show_login()
        
        rpc.register("require_login", self.require_login)
Ejemplo n.º 7
0
    print "innan rpc access"
    #rpc.send("main", "access", bol=login_boolean)
    gobject.timeout_add(0, rpc.send, "main", "access", {"bol":login_boolean})
network_listeners["login_response"] = login_response
 
def parseBoolean(login):
    return login == "True"
 
def alarm_response(pack):
    print "Hille du e king på alarm_response"
    connection.timestamp = time.time()
network_listeners["alarm_response"] = alarm_response

def contact_response(pack):
    #rpc.send("main", "add_contactlist", pack = str(pack))
    gobject.timeout_add(0, rpc.send, "main", "add_contactlist", {"pack":str(pack)})
    connection.timestamp = time.time()
network_listeners["contact_resp"] = contact_response

def poi_response(pack):
    connection.timestamp = time.time()
    print "Hille du e king på poi_response"
    #rpc.send("main", "add_poi", pack=str(pack))
    gobject.timeout_add(0, rpc.send, "main", "add_poi", {"pack":str(pack)})
network_listeners["poi_response"] = poi_response
    
rpc.register("add_packet", connection.add_packet)
threading.Thread(target=connection.reconnect).start()
gtk.gdk.threads_init()
gtk.main()
Ejemplo n.º 8
0
    def create_login_view(self):
        def dbcheck_press_callback(button, widget, data=None):   
            #Detta behövs inte här, men kanske inte fungerar på andra stället
            #session = get_session()
            #create_tables()        
            #session.bind
            #session.query(User).all()
            self.user = unicode(userText.get_text())
            self.pw = unicode(passText.get_text())
            self.unit_name = unicode(self.combo.get_active_text())
            login = str(packet.Packet("login", username=self.user, password=self.pw, unitname=self.unit_name))
            #print rpc.send("qos", "add_packet", packet=login)
            gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet":login})

        hboxOUT  = gtk.HBox(homogeneous=False, spacing=1)
        vbox1 = gtk.VBox(homogeneous=False, spacing=1)
        hbox1 = gtk.HBox(homogeneous=False, spacing=1)
        hbox2 = gtk.HBox(homogeneous=False, spacing=1)
        self.combo = gtk.combo_box_new_text()
        
        session = get_session()
        
        ambulans = UnitType(u"Ambulans1", "static/ikoner/ambulans.png")

        self.combo.append_text(("Ingen unit"))
        self.combo.set_active(0)

        for unit in session.query(Unit).order_by(Unit.name):
            self.combo.append_text(unit.name)
            print "Det du har är: ", unit.name
 
        userText = gtk.Entry(max=0)
        userLabel = gtk.Label("Användare")
        passText = gtk.Entry(max=0)
        passLabel = gtk.Label("Lösenord")
        okButton = gtk.Button("Login")
        okButton.set_size_request(70, 50)
        okButton.connect("clicked", dbcheck_press_callback, None)
        statusLabel = gtk.Label("No status")
        unittypeLabel = gtk.Label("Context")
        
        vbox1.pack_start(hbox1, expand=False, fill=False, padding=1)
        vbox1.pack_start(hbox2, expand=False, fill=False, padding=1)
        vbox1.pack_start(okButton, expand=False, fill=False, padding=1)
        hbox1.pack_start(userText, expand=False, fill=False, padding=1)
        hbox1.pack_start(userLabel, expand=False, fill=False, padding=1)
        hbox2.pack_start(passText, expand=False, fill=False, padding=1)
        hbox2.pack_start(passLabel, expand=False, fill=False, padding=1)
        vbox1.pack_start(statusLabel, expand=False, fill=False, padding=1)
        vbox1.pack_start(unittypeLabel, expand=False, fill=False, padding=1)
        vbox1.pack_start(self.combo, expand=False, fill=False, padding=1)
        hboxOUT.pack_start(vbox1, expand=True, fill=False, padding=1)
        
        userText.show()
        userLabel.show()
        unittypeLabel.show()
        passText.show()
        passLabel.show()
        okButton.show()
        statusLabel.show()
        hbox1.show()
        hbox2.show()
        vbox1.show()
        hboxOUT.show()
        self.combo.show()
        #Skapar rpc

        def receive_updates(val):
            print "recv yeah %s" %val
        
        def access(bol):
            print "körde första!"
            if bol:
                statusLabel.set_label("Access granted")
                unit = self.combo.get_active_text()
                #Kollar om user redan finns
                insession = True
                for users in session.query(User):
                    if users.type:
                        users.type.is_self = False
                    if users.name == self.user:
                        insession = False
                        current_user = users
                        break
                    else:
                        insession = True
                if insession:
                    print "Skapar användare"
                    current_user = User(self.user,self.pw)
                    session.add(current_user)
                    session.commit()
                #ändrar users unit
                for units in session.query(Unit).filter_by(name=unit):
                    current_user.type = units
                    current_user.type.is_self = True
                    session.commit()
                # begär uppdateringar från servern
                status = {}
                status["POI"] = dict([(p.unique_id, p.changed.strftime("%s")) \
                        for p in session.query(POI).all()])
                print status
                p = str(packet.Packet("request_updates", status=status))
                gobject.timeout_add(0, rpc.send, "qos", "add_packet", {"packet": p})
            else:
                statusLabel.set_label("Access denied")
       
        rpc.register("access", access)
        return hboxOUT
Ejemplo n.º 9
0
    def __init__(self, gui):
        super(AddMissionPage, self).__init__("addMission", gui, homogeneous=False,
                spacing=0)
        self.size_request = (300,300)
        self.unit = None

            
        hbox1 = gtk.HBox()
        vbox1 = gtk.VBox()
        self.vbox2 = gtk.VBox()
        nameLabel = gtk.Label("Namn:")
        self.nameEntry = gtk.Entry()
        infoLabel = gtk.Label("Info:")
        self.infoEntry = gtk.Entry()
        poiLabel = gtk.Label("POI:")
        self.poiEntry = gtk.Entry()
        poiButton = gtk.Button("Lägg Till")
        self.combo = gtk.Combo()
        self.poiList = []
        self.combo.set_popdown_strings(self.poiList)
        self.poiEntry.set_text("Välj en POI")

        self.infoView = gtk.TextView(buffer=None)
        self.infoView.set_wrap_mode(gtk.WRAP_WORD)
        infoLabel2 = gtk.Label("Info:")
        self.infoView.set_size_request(300,200)

        vbox1.set_size_request(300,300)
        vbox1.pack_start(nameLabel, False, False,0)
        vbox1.pack_start(self.nameEntry, False, False,0)
        vbox1.pack_start(infoLabel, False, False,0)
        vbox1.pack_start(self.infoEntry, False, False,0)
        vbox1.pack_start(poiLabel, False, False,0)
        vbox1.pack_start(self.poiEntry, False, False,0)
        vbox1.pack_start(poiButton, False, False,0)
        vbox1.pack_start(self.combo,False,False,10)
        #vbox1.pack_start(okButton, False, False,0)
        
        
        saveButton = create_menuButton("static/ikoner/disk.png","Spara")
        saveButton.connect("clicked", self.save, None)
        backButton = create_menuButton("static/ikoner/arrow_undo.png","Avbryt")
        self.showDetails = create_menuButton("static/ikoner/resultset_first.png","Visa Detaljer")
        self.hideDetails = create_menuButton("static/ikoner/resultset_last.png","G�m Detaljer")
        backButton.connect("clicked", self.gui.switch_page, "mission")
        #okButton.connect("clicked", dbupdate_press_callback, None)
        poiButton.connect("clicked", self.add_poi, None)
        self.showDetails.connect("clicked", self.details, "show")
        self.hideDetails.connect("clicked", self.details, "hide")
        
        hbox2 = gtk.HBox()
        hbox2.pack_start(backButton, True, True, padding=2)
        hbox2.pack_start(saveButton, True, True, padding=2)
        vbox1.pack_start(hbox2,False,False,2)
        vbox1.pack_start(self.showDetails,False,False,2)
        vbox1.pack_start(self.hideDetails,False,False,2)
        self.vbox2.pack_start(infoLabel2,False,False,0)
        self.vbox2.pack_start(self.infoView,False,False,0)
        
        hbox1.pack_start(vbox1, False, False, 2)
        hbox1.pack_start(self.vbox2, False, False, 2)
        self.pack_start(hbox1,False,False,0)

        self.show_all()
        self.vbox2.hide()
        self.hideDetails.hide()
        rpc.register("add_mission", self.add_mission)