Exemple #1
0
 def __init__(self):
     self.region = region = get_obj('timezone_region')
     self.cities = cities = get_obj('timezone_cities')
     pref_button = get_obj('pref_button')
     
     for name in tz_regions:
         region.append(name, name)
     region.connect('changed', self.region_handler, cities)
     cities.connect('changed', self.cities_handler)
     gst.bind('timezone-region', region, 'active')
     gst.bind('timezone-cities', cities, 'active')
     
     self.colorpicker = get_obj('colorselection')
     gst.bind_with_convert('track-color', self.colorpicker, 'current-color',
         lambda x: Gdk.Color(*x), lambda x: (x.red, x.green, x.blue))
     self.colorpicker.connect('color-changed', self.track_color_changed)
     
     pref_button.connect('clicked', self.preferences_dialog,
         get_obj('preferences'), region, cities, self.colorpicker)
     
     self.radios = {}
     for option in ['system', 'lookup', 'custom']:
         option += '-timezone'
         radio = get_obj(option)
         radio.set_name(option)
         gst.bind(option, radio, 'active')
         self.radios[option] = radio
         radio.connect('clicked', self.radio_handler)
     gst.bind('custom-timezone', get_obj('custom_timezone_combos'),
              'sensitive')
     
     gst.bind('use-dark-theme', Gtk.Settings.get_default(),
              'gtk-application-prefer-dark-theme')
     
     map_source_menu()
Exemple #2
0
def map_source_menu():
    """Load the predefined map sources into a menu the user can use."""
    radio_group = []
    map_menu = get_obj('map_source_menu')
    last_source = gst.get_string('map-source-id')
    gst.bind_with_convert('map-source-id', map_view, 'map-source',
        MAP_SOURCES.get, lambda x: x.get_id())
    menu_item_clicked = (lambda item, mapid: item.get_active() and
        map_view.set_map_source(MAP_SOURCES[mapid]))
    
    for i, source_id in enumerate(sorted(MAP_SOURCES.keys())):
        source = MAP_SOURCES[source_id]
        menu_item = Gtk.RadioMenuItem.new_with_label(radio_group,
                                                     source.get_name())
        radio_group.append(menu_item)
        if last_source == source_id:
            menu_item.set_active(True)
        menu_item.connect('activate', menu_item_clicked, source_id)
        map_menu.attach(menu_item, 0, 1, i, i+1)
    map_menu.show_all()
Exemple #3
0
def map_source_menu():
    """Load the predefined map sources into a menu the user can use."""
    radio_group = []
    map_menu = get_obj('map_source_menu')
    last_source = gst.get_string('map-source-id')
    gst.bind_with_convert('map-source-id', map_view, 'map-source',
        MAP_SOURCES.get, lambda x: x.get_id())
    menu_item_clicked = (lambda item, mapid: item.get_active() and
        map_view.set_map_source(MAP_SOURCES[mapid]))
    
    for i, source_id in enumerate(sorted(MAP_SOURCES.keys())):
        source = MAP_SOURCES[source_id]
        menu_item = Gtk.RadioMenuItem.new_with_label(radio_group,
                                                     source.get_name())
        radio_group.append(menu_item)
        if last_source == source_id:
            menu_item.set_active(True)
        menu_item.connect('activate', menu_item_clicked, source_id)
        map_menu.attach(menu_item, 0, 1, i, i+1)
    map_menu.show_all()