Ejemplo n.º 1
0
 def __init__(self, filename, root, watch):
     self.filename = filename
     self.progress = get_obj('progressbar')
     self.clock    = clock()
     self.append   = None
     self.tracks   = {}
     self.polygons = set()
     
     self.parser = XMLSimpleParser(root, watch)
     self.parser.parse(filename, self.element_start, self.element_end)
     
     empty_trackfile_label.hide()
     
     points.update(self.tracks)
     keys = self.tracks.keys()
     self.alpha = min(keys)
     self.omega = max(keys)
     self.latitude = self.tracks[self.alpha].lat
     self.longitude = self.tracks[self.alpha].lon
     
     # TODO find some kind of parent widget that can group these together
     # to make it easier to get them and insert them into places.
     builder = Builder('trackfile')
     self.colorpicker = builder.get_object('colorpicker')
     self.trash = builder.get_object('unload')
     self.label = builder.get_object('trackfile_label')
     
     self.label.set_text(basename(filename))
     self.colorpicker.set_title(basename(filename))
     self.colorpicker.connect('color-set', track_color_changed, self.polygons)
     self.trash.connect('clicked', self.destroy)
     
     get_obj('trackfiles_view').attach_next_to(
         builder.get_object('trackfile_settings'), None, BOTTOM, 1, 1)
     
     self.gst = GSettings('trackfile', basename(filename))
     
     if self.gst.get_string('start-timezone') is '':
         # Then this is the first time this file has been loaded
         # and we should honor the user-selected global default
         # track color instead of using the schema-defined default
         self.gst.set_value('track-color', gst.get_value('track-color'))
     
     self.gst.set_string('start-timezone', self.lookup_geoname())
     self.gst.bind_with_convert('track-color', self.colorpicker, 'color',
         lambda x: Gdk.Color(*x), lambda x: (x.red, x.green, x.blue))
     self.colorpicker.emit('color-set')
Ejemplo n.º 2
0
 def __init__(self, camera_id, make, model):
     """Generate Gtk widgets and bind their properties to GSettings."""
     self.photos = set()
     
     empty_camera_label.hide()
     
     builder = Builder('camera')
     builder.get_object('camera_label').set_text(model)
     
     # GtkScale allows the user to correct the camera's clock.
     offset = builder.get_object('offset')
     offset.connect('value-changed', self.offset_handler)
     offset.connect('format-value', display_offset,
         _('Add %dm, %ds to clock.'),
         _('Subtract %dm, %ds from clock.'))
     
     # These two ComboBoxTexts are used for choosing the timezone manually.
     # They're hidden to reduce clutter when not needed.
     tz_region = builder.get_object('timezone_region')
     tz_cities = builder.get_object('timezone_cities')
     for name in tz_regions:
         tz_region.append(name, name)
     tz_region.connect('changed', self.region_handler, tz_cities)
     tz_cities.connect('changed', self.cities_handler)
     
     # TODO we're gonna need some on screen help to explain what it even
     # means to select the method of determining the timezone.
     # Back when this was radio button in a preferences window we had more
     # room for verbosity, but this combobox is *so terse* that I don't
     # really expect anybody to understand it at all.
     timezone = builder.get_object('timezone_method')
     timezone.connect('changed', self.method_handler, tz_region, tz_cities)
     
     # Push all the widgets into the UI
     get_obj('cameras_view').attach_next_to(
         builder.get_object('camera_settings'), None, BOTTOM, 1, 1)
     
     self.offset    = offset
     self.tz_method = timezone
     self.tz_region = tz_region
     self.tz_cities = tz_cities
     self.camera_id = camera_id
     self.make      = make
     self.model     = model
     
     self.gst = GSettings('camera', camera_id)
     
     self.gst.set_string('make', make)
     self.gst.set_string('model', model)
     
     self.gst.bind('offset', offset.get_adjustment(), 'value')
     self.gst.bind('timezone-method', timezone, 'active-id')
     self.gst.bind('timezone-region', tz_region, 'active')
     self.gst.bind('timezone-cities', tz_cities, 'active')