Esempio n. 1
0
 def __init__(self, portinghacks=None):
     self.profiles = None
     self.selected_profile = None
     self.dirty = False
     self.portinghacks = portinghacks
     self.imagedir = 'external/commotion_mesh_applet/'
     self.mesh_status = MeshStatus(self.portinghacks, imagedir=self.imagedir)
     self.commotion = WindowsCommotionCore(
             profiledir="".join([core.get_own_path('/profiles/'), "/"]),
             #TODO: are these even needed?
             olsrdpath=core.olsrd_exe_path,
             olsrdconf=core.olsrd_conf_path
             )
     if not is_ui_test_mode(): core.refresh_net_list()
     self.profiles = self.read_profiles()
     self.init_ui()
Esempio n. 2
0
 def __init__(self, portinghacks=None):
     self.profiles = None
     self.selected_profile = None
     self.dirty = False
     self.portinghacks = portinghacks
     self.imagedir = 'external/commotion_mesh_applet/'
     self.mesh_status = MeshStatus(self.portinghacks,
                                   imagedir=self.imagedir)
     self.commotion = WindowsCommotionCore(
         profiledir="".join([core.get_own_path('/profiles/'), "/"]),
         #TODO: are these even needed?
         olsrdpath=core.olsrd_exe_path,
         olsrdconf=core.olsrd_conf_path)
     if not is_ui_test_mode(): core.refresh_net_list()
     self.profiles = self.read_profiles()
     self.init_ui()
Esempio n. 3
0
    def init_ui(self):
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_size_request (750, 700)
        window.set_resizable(True)  
        window.connect("destroy", self.close_application)
        window.set_title("Commotion Wireless for Windows (prototype 1)")
        window.set_border_width(0)

        box1 = gtk.VBox(False, 0)
        window.add(box1)
        box1.show()

        box2 = gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()

        notebook = gtk.Notebook()
        notebook.set_tab_pos(gtk.POS_TOP)
        notebook.show_all()
        self.show_tabs = True
        self.show_border = True

        def add_page(notebook, title, image, page):
            label = gtk.Label(title)
            vbox = gtk.VBox(False, 0)
            vbox.set_size_request(60, 60)
            image.set_size_request(46, 46)
            vbox.pack_start(image, False, True, 0)
            vbox.pack_start(label, False, True, 0)
            label.show()
            vbox.show()
            notebook.append_page(page, vbox)

        self.textview = gtk.TextView()
        self.textview.set_sensitive(False)
        self.textbuffer = self.textview.get_buffer()
        self.textview.show()

        hbox = gtk.HBox(False, 10)
        
        # FIXME replace with TreeView: http://www.pygtk.org/pygtk2tutorial/ch-TreeViewWidget.html
        clist = gtk.CList(2)
        for k,v in self.profiles.iteritems():
            clist.append(["@" if v["available"] else "", k])
        clist.set_column_width(0, 10)
        clist.set_column_width(1, 190)
        clist.set_shadow_type(gtk.SHADOW_OUT)
        clist.connect("select_row", self.profile_selection_made)
        clist.show()
        hbox.pack_start(clist, expand=False, fill=False, padding=0)
        hbox.show()

        def get_profile_editor_controls():
            def add_item(b, l, t):
                l.set_alignment(0, 0)
                b.pack_start(l, expand=False, fill=False, padding=0)
                b.pack_start(t, expand=False, fill=False, padding=0)

            vbox = gtk.VBox(False, 10)

            label = gtk.Label("Mesh Netword Name (SSID):")
            self.tbSSID = gtk.Entry()
            self.tbSSID.connect("changed", self.changed)
            add_item(vbox, label, self.tbSSID)

            label = gtk.Label("BSSID:")
            self.tbBSSID = gtk.Entry()
            self.tbBSSID.connect("changed", self.changed)
            add_item(vbox, label, self.tbBSSID)

            label = gtk.Label("Channel:")
            self.tbChannel = gtk.Entry()
            self.tbChannel.connect("changed", self.changed)
            add_item(vbox, label, self.tbChannel)

            label = gtk.Label("IP:")
            self.tbIP = gtk.Entry()
            self.tbIP.connect("changed", self.changed)
            add_item(vbox, label, self.tbIP)

            label = gtk.Label("IPGenerate:")
            self.cbIPGenerate = gtk.CheckButton()
            self.cbIPGenerate.connect("toggled", self.changed)
            add_item(vbox, label, self.cbIPGenerate)

            label = gtk.Label("Netmask:")
            self.tbNetmask = gtk.Entry()
            self.tbNetmask.connect("changed", self.changed)
            add_item(vbox, label, self.tbNetmask)

            label = gtk.Label("DNS:")
            self.tbDNS = gtk.Entry()
            self.tbDNS.connect("changed", self.changed)
            add_item(vbox, label, self.tbDNS)
            
            hbox = gtk.HBox(False, 10)
            self.save_button = gtk.Button("Save Profile")
            self.save_button.set_sensitive(False)
            self.save_button.connect("clicked", self.save_profile_clicked)
            hbox.pack_start(self.save_button)

            self.undo_changes_button = gtk.Button("Undo Changes")
            self.undo_changes_button.set_sensitive(False)
            self.undo_changes_button.connect("clicked", self.undo_changes_clicked)
            hbox.pack_start(self.undo_changes_button)

            vbox.pack_end(hbox, expand=False, fill=False, padding=0)

            vbox.show_all()
            
            # load first profile        
            clist.select_row(0, 0)

            return vbox

        vbox_profile_controls = get_profile_editor_controls()
        hbox.pack_start(vbox_profile_controls, expand=True, fill=True, padding=10)
        hbox.show()

        TAB_IMAGE_WIDTH = 40
        TAB_IMAGE_HEIGHT = 40

        pixbuf = gtk.gdk.pixbuf_new_from_file(
                core.get_own_path(os.path.join('images', 'tabProfiles.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT, gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()
        
        add_page(notebook, "Profiles", image, hbox)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
                core.get_own_path(os.path.join('images', 'tabLog.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT, gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()

        """
        vbox = gtk.VBox(False, 10)
        vbox.pack_start(self.textview, True, True, 0)
        button = gtk.Button("show jsoninfo")
        button.connect("clicked", self.show_jsoninfo)
        vbox.pack_start(button, True, True, 0)
        button.show()
        vbox.show()
        add_page(notebook, "Logs", image, vbox)
        """
        add_page(notebook, "Logs", image, self.textview)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
                core.get_own_path(os.path.join('images', 'tabStatus.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT, gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()
        label = gtk.Label("Status goes here...")
        label.show()
        add_page(notebook, "Status", image, label)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
                core.get_own_path(os.path.join('images', 'tabHelp.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT, gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()

        vbox = gtk.VBox(False, 10)

        logo_pixbuf = gtk.gdk.pixbuf_new_from_file(
                core.get_own_path(os.path.join('images', 'commotion_logo.png')))
        logo = gtk.image_new_from_pixbuf(logo_pixbuf)
        logo.show()
        vbox.pack_start(logo)

        blurb = gtk.Label("Commotion is an open-source communication tool that uses mobile phones, computers, and other wireless devices to create decentralized mesh networks.")
        blurb.set_line_wrap(True)
        blurb.show()
        vbox.pack_start(blurb)

        link = gtk.LinkButton("https://commotionwireless.net/", "commotionwireless.net") 
        link.show()
        vbox.pack_start(link)

        vbox.show()
            
        add_page(notebook, "About", image, vbox)

        vbox = gtk.VBox(False, 10)

        box2.pack_start(notebook)

        string = "\n"
        self.textbuffer.set_text(string)

        hbox = gtk.HButtonBox()
        box2.pack_start(hbox, False, False, 0)
        hbox.show()

        vbox = gtk.VBox()
        vbox.show()
        hbox.pack_start(vbox, expand=False, fill=False, padding=0)

        # check button to start up commotion
        check = gtk.ToggleButton(strings.TOGGLE_TEXT_START)
        vbox.pack_start(check, expand=False, fill=False, padding=0)
        check.connect("toggled", self.toggle_start, self.textview)
        check.set_active(False)
        check.show()

        separator = gtk.HSeparator()
        box1.pack_start(separator, False, True, 0)
        separator.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, False, True, 0)
        box2.show()
        
        button = gtk.Button("show mesh status")
        button.connect("clicked", self.show_mesh_status)
        box2.pack_start(button, True, True, 0)
        button.show()
        
        button = gtk.Button("show jsoninfo")
        button.connect("clicked", self.show_jsoninfo)
        box2.pack_start(button, True, True, 0)
        button.show()

        button = gtk.Button("quit winmesh")
        button.connect("clicked", self.close_application)
        box2.pack_start(button, True, True, 0)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()
        button.show()

        window.show()
Esempio n. 4
0
    def init_ui(self):
        window = gtk.Window(gtk.WINDOW_TOPLEVEL)
        window.set_size_request(750, 700)
        window.set_resizable(True)
        window.connect("destroy", self.close_application)
        window.set_title("Commotion Wireless for Windows (prototype 1)")
        window.set_border_width(0)

        box1 = gtk.VBox(False, 0)
        window.add(box1)
        box1.show()

        box2 = gtk.VBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, True, True, 0)
        box2.show()

        notebook = gtk.Notebook()
        notebook.set_tab_pos(gtk.POS_TOP)
        notebook.show_all()
        self.show_tabs = True
        self.show_border = True

        def add_page(notebook, title, image, page):
            label = gtk.Label(title)
            vbox = gtk.VBox(False, 0)
            vbox.set_size_request(60, 60)
            image.set_size_request(46, 46)
            vbox.pack_start(image, False, True, 0)
            vbox.pack_start(label, False, True, 0)
            label.show()
            vbox.show()
            notebook.append_page(page, vbox)

        self.textview = gtk.TextView()
        self.textview.set_sensitive(False)
        self.textbuffer = self.textview.get_buffer()
        self.textview.show()

        hbox = gtk.HBox(False, 10)

        # FIXME replace with TreeView: http://www.pygtk.org/pygtk2tutorial/ch-TreeViewWidget.html
        clist = gtk.CList(2)
        for k, v in self.profiles.iteritems():
            clist.append(["@" if v["available"] else "", k])
        clist.set_column_width(0, 10)
        clist.set_column_width(1, 190)
        clist.set_shadow_type(gtk.SHADOW_OUT)
        clist.connect("select_row", self.profile_selection_made)
        clist.show()
        hbox.pack_start(clist, expand=False, fill=False, padding=0)
        hbox.show()

        def get_profile_editor_controls():
            def add_item(b, l, t):
                l.set_alignment(0, 0)
                b.pack_start(l, expand=False, fill=False, padding=0)
                b.pack_start(t, expand=False, fill=False, padding=0)

            vbox = gtk.VBox(False, 10)

            label = gtk.Label("Mesh Netword Name (SSID):")
            self.tbSSID = gtk.Entry()
            self.tbSSID.connect("changed", self.changed)
            add_item(vbox, label, self.tbSSID)

            label = gtk.Label("BSSID:")
            self.tbBSSID = gtk.Entry()
            self.tbBSSID.connect("changed", self.changed)
            add_item(vbox, label, self.tbBSSID)

            label = gtk.Label("Channel:")
            self.tbChannel = gtk.Entry()
            self.tbChannel.connect("changed", self.changed)
            add_item(vbox, label, self.tbChannel)

            label = gtk.Label("IP:")
            self.tbIP = gtk.Entry()
            self.tbIP.connect("changed", self.changed)
            add_item(vbox, label, self.tbIP)

            label = gtk.Label("IPGenerate:")
            self.cbIPGenerate = gtk.CheckButton()
            self.cbIPGenerate.connect("toggled", self.changed)
            add_item(vbox, label, self.cbIPGenerate)

            label = gtk.Label("Netmask:")
            self.tbNetmask = gtk.Entry()
            self.tbNetmask.connect("changed", self.changed)
            add_item(vbox, label, self.tbNetmask)

            label = gtk.Label("DNS:")
            self.tbDNS = gtk.Entry()
            self.tbDNS.connect("changed", self.changed)
            add_item(vbox, label, self.tbDNS)

            hbox = gtk.HBox(False, 10)
            self.save_button = gtk.Button("Save Profile")
            self.save_button.set_sensitive(False)
            self.save_button.connect("clicked", self.save_profile_clicked)
            hbox.pack_start(self.save_button)

            self.undo_changes_button = gtk.Button("Undo Changes")
            self.undo_changes_button.set_sensitive(False)
            self.undo_changes_button.connect("clicked",
                                             self.undo_changes_clicked)
            hbox.pack_start(self.undo_changes_button)

            vbox.pack_end(hbox, expand=False, fill=False, padding=0)

            vbox.show_all()

            # load first profile
            clist.select_row(0, 0)

            return vbox

        vbox_profile_controls = get_profile_editor_controls()
        hbox.pack_start(vbox_profile_controls,
                        expand=True,
                        fill=True,
                        padding=10)
        hbox.show()

        TAB_IMAGE_WIDTH = 40
        TAB_IMAGE_HEIGHT = 40

        pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'tabProfiles.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()

        add_page(notebook, "Profiles", image, hbox)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'tabLog.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()
        """
        vbox = gtk.VBox(False, 10)
        vbox.pack_start(self.textview, True, True, 0)
        button = gtk.Button("show jsoninfo")
        button.connect("clicked", self.show_jsoninfo)
        vbox.pack_start(button, True, True, 0)
        button.show()
        vbox.show()
        add_page(notebook, "Logs", image, vbox)
        """
        add_page(notebook, "Logs", image, self.textview)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'tabStatus.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()
        label = gtk.Label("Status goes here...")
        label.show()
        add_page(notebook, "Status", image, label)

        pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'tabHelp.png')))
        pixbuf = pixbuf.scale_simple(TAB_IMAGE_WIDTH, TAB_IMAGE_HEIGHT,
                                     gtk.gdk.INTERP_BILINEAR)
        image = gtk.image_new_from_pixbuf(pixbuf)
        image.show()

        vbox = gtk.VBox(False, 10)

        logo_pixbuf = gtk.gdk.pixbuf_new_from_file(
            core.get_own_path(os.path.join('images', 'commotion_logo.png')))
        logo = gtk.image_new_from_pixbuf(logo_pixbuf)
        logo.show()
        vbox.pack_start(logo)

        blurb = gtk.Label(
            "Commotion is an open-source communication tool that uses mobile phones, computers, and other wireless devices to create decentralized mesh networks."
        )
        blurb.set_line_wrap(True)
        blurb.show()
        vbox.pack_start(blurb)

        link = gtk.LinkButton("https://commotionwireless.net/",
                              "commotionwireless.net")
        link.show()
        vbox.pack_start(link)

        vbox.show()

        add_page(notebook, "About", image, vbox)

        vbox = gtk.VBox(False, 10)

        box2.pack_start(notebook)

        string = "\n"
        self.textbuffer.set_text(string)

        hbox = gtk.HButtonBox()
        box2.pack_start(hbox, False, False, 0)
        hbox.show()

        vbox = gtk.VBox()
        vbox.show()
        hbox.pack_start(vbox, expand=False, fill=False, padding=0)

        # check button to start up commotion
        check = gtk.ToggleButton(strings.TOGGLE_TEXT_START)
        vbox.pack_start(check, expand=False, fill=False, padding=0)
        check.connect("toggled", self.toggle_start, self.textview)
        check.set_active(False)
        check.show()

        separator = gtk.HSeparator()
        box1.pack_start(separator, False, True, 0)
        separator.show()

        box2 = gtk.HBox(False, 10)
        box2.set_border_width(10)
        box1.pack_start(box2, False, True, 0)
        box2.show()

        button = gtk.Button("show mesh status")
        button.connect("clicked", self.show_mesh_status)
        box2.pack_start(button, True, True, 0)
        button.show()

        button = gtk.Button("show jsoninfo")
        button.connect("clicked", self.show_jsoninfo)
        box2.pack_start(button, True, True, 0)
        button.show()

        button = gtk.Button("quit winmesh")
        button.connect("clicked", self.close_application)
        box2.pack_start(button, True, True, 0)
        button.set_flags(gtk.CAN_DEFAULT)
        button.grab_default()
        button.show()

        window.show()