Esempio n. 1
0
    def on_edit_trip(self, btn):
        tr = self.trip_list.get_selected()
        if tr is None:
            return True

        dlg = AddTripRouteDialog(None)
        dlg.content.set_route(self._route())
        dlg.content.fill(tr)
        dlg.show_all()

        resp = dlg.run()
        if resp == Gtk.ResponseType.ACCEPT:
            # edit a trip route
            tr.name = dlg.content.get_name()
            tr.calendar = dlg.content.get_calendar()
            tr.headsign = dlg.content.get_headsign()
            tr.direction = dlg.content.get_direction()
            tr.path = dlg.content.get_path()

            tr._stops = []
            for s in dlg.content.get_stops():
                tr.add_stop(s)

            self.trip_list.update_trip_route(tr)

        dlg.destroy()

        return True
Esempio n. 2
0
    def on_add_trip_clicked(self, toolbutton, user_data = None):
        # create the trip (temporarily)
        try: route = Route.routes[0]
        except Exception, e: route = None

        try: calendar = Calendar.calendars[0]
        except Exception, e: calendar = None

        trip = libsubte.TripRoute('', route, calendar, '', 0, None)

        win = AddTripRouteDialog(self._gui(), trip)
        win.show_all()

        dlg = win.content

        handler = self.connect('on-stop-selected', dlg.on_stop_selected)
        libsubte.Stop.activate_stop_hook = dlg.on_stop_selected

        resp = win.run()
        self.disconnect('on-stop-selected', handler)
        libsubte.Stop.activate_stop_hook = None

        if resp == Gtk.ResponseType.ACCEPT:
            name = dlg.get_name()
            route = dlg.get_route()
            calendar = dlg.get_calendar()
            headsign = dlg.get_headsign()
            direction = dlg.get_direction()
            path = dlg.get_path()

            if route != trip.route and route != None:
                if trip.route:
                    trip.route.remove_trip_route(trip)
                route.add_trip_route(trip)

            trip.name = name
            trip.route = route
            trip.calendar = calendar
            trip.headsign = headsign
            trip.direction = direction
            trip.path = path

            self.add_trip(trip)
        else:
            trip.destroy()

        win.destroy()

        return True
Esempio n. 3
0
    def on_add_trip(self, btn):
        dlg = AddTripRouteDialog(None)
        dlg.content.set_route(self._route())
        dlg.show_all()

        resp = dlg.run()
        if resp == Gtk.ResponseType.ACCEPT:
            # create a new trip route
            tr = libsubte.TripRoute(dlg.content.get_name(),
                                    self._route(),
                                    dlg.content.get_calendar(),
                                    dlg.content.get_headsign(),
                                    dlg.content.get_direction(),
                                    dlg.content.get_path())
            for s in dlg.content.get_stops():
                tr.add_stop(s)
            
            self.trip_list.add_trip_route(tr)
            

        dlg.destroy()

        return True