# Path: meld/ui/bufferselectors.py
# class EncodingSelector(FilteredListSelector, Gtk.Grid):
#     # The subclassing here is weird; the Selector must directly
#     # subclass Gtk.Grid, or the template building explodes.
# 
#     __gtype_name__ = 'EncodingSelector'
# 
#     __gsignals__ = {
#         'encoding-selected': (
#             GObject.SignalFlags.RUN_FIRST | GObject.SignalFlags.ACTION,
#             None, (GtkSource.Encoding,)),
#     }
# 
#     # These exist solely to make subclassing easier.
#     value_accessor = 'get_charset'
#     change_signal_name = 'encoding-selected'
# 
#     entry = Gtk.Template.Child('entry')
#     treeview = Gtk.Template.Child('treeview')
# 
#     def populate_model(self):
#         for enc in GtkSource.Encoding.get_all():
#             self.liststore.append((self.get_value_label(enc), enc))
# 
#     def get_value_label(self, enc):
#         return _('{name} ({charset})').format(
#             name=enc.get_name(), charset=enc.get_charset())
# 
# class SourceLangSelector(FilteredListSelector, Gtk.Grid):
# 
#     __gtype_name__ = "SourceLangSelector"
# 
#     __gsignals__ = {
#         'language-selected': (
#             GObject.SignalFlags.RUN_FIRST | GObject.SignalFlags.ACTION,
#             None, (GtkSource.Language,)),
#     }
# 
#     # These exist solely to make subclassing easier.
#     value_accessor = 'get_id'
#     change_signal_name = 'language-selected'
# 
#     entry = Gtk.Template.Child('entry')
#     treeview = Gtk.Template.Child('treeview')
# 
#     def populate_model(self):
#         self.liststore.append((_("Plain Text"), None))
#         manager = GtkSource.LanguageManager.get_default()
#         for lang_id in manager.get_language_ids():
#             lang = manager.get_language(lang_id)
#             self.liststore.append((lang.get_name(), lang))
# 
#     def get_value_label(self, lang):
#         if not lang:
#             return _("Plain Text")
#         return lang.get_name()


from gi.repository import GObject, Gtk, GtkSource, Pango
from meld.conf import _
from meld.ui.bufferselectors import EncodingSelector, SourceLangSelector
        selector.connect('encoding-selected', change_encoding)
        selector.connect('map', set_initial_encoding)

        pop = Gtk.Popover()
        pop.set_position(Gtk.PositionType.TOP)
        pop.add(selector)

        button = MeldStatusMenuButton()
        self.bind_property(
            'source-encoding', button, 'label',
            GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE,
            lambda binding, enc: selector.get_value_label(enc))
        button.set_popover(pop)
        button.show()

        return button

    def construct_highlighting_selector(self):
        def change_language(selector, lang):
            # TODO: Our other GObject properties are expected to be
            # updated through a bound state from our parent. This is
            # the only place where we assign to them instead of
            # emitting a signal, and it makes the class logic as a
            # whole kind of confusing.
            self.props.source_language = lang
            pop.hide()

        def set_initial_language(selector):
            selector.select_value(self.props.source_language)


# Path: meld/ui/bufferselectors.py
# class EncodingSelector(FilteredListSelector, Gtk.Grid):
#     # The subclassing here is weird; the Selector must directly
#     # subclass Gtk.Grid, or the template building explodes.
# 
#     __gtype_name__ = 'EncodingSelector'
# 
#     __gsignals__ = {
#         'encoding-selected': (
#             GObject.SignalFlags.RUN_FIRST | GObject.SignalFlags.ACTION,
#             None, (GtkSource.Encoding,)),
#     }
# 
#     # These exist solely to make subclassing easier.
#     value_accessor = 'get_charset'
#     change_signal_name = 'encoding-selected'
# 
#     entry = Gtk.Template.Child('entry')
#     treeview = Gtk.Template.Child('treeview')
# 
#     def populate_model(self):
#         for enc in GtkSource.Encoding.get_all():
#             self.liststore.append((self.get_value_label(enc), enc))
# 
#     def get_value_label(self, enc):
#         return _('{name} ({charset})').format(
#             name=enc.get_name(), charset=enc.get_charset())
# 
# class SourceLangSelector(FilteredListSelector, Gtk.Grid):
# 
#     __gtype_name__ = "SourceLangSelector"
# 
#     __gsignals__ = {
#         'language-selected': (
#             GObject.SignalFlags.RUN_FIRST | GObject.SignalFlags.ACTION,
#             None, (GtkSource.Language,)),
#     }
# 
#     # These exist solely to make subclassing easier.
#     value_accessor = 'get_id'
#     change_signal_name = 'language-selected'
# 
#     entry = Gtk.Template.Child('entry')
#     treeview = Gtk.Template.Child('treeview')
# 
#     def populate_model(self):
#         self.liststore.append((_("Plain Text"), None))
#         manager = GtkSource.LanguageManager.get_default()
#         for lang_id in manager.get_language_ids():
#             lang = manager.get_language(lang_id)
#             self.liststore.append((lang.get_name(), lang))
# 
#     def get_value_label(self, lang):
#         if not lang:
#             return _("Plain Text")
#         return lang.get_name()


# Path: meld/ui/statusbar.py
from gi.repository import GObject, Gtk, GtkSource, Pango
from meld.conf import _
from meld.ui.bufferselectors import EncodingSelector, SourceLangSelector

        selector.connect('encoding-selected', change_encoding)
        selector.connect('map', set_initial_encoding)

        pop = Gtk.Popover()
        pop.set_position(Gtk.PositionType.TOP)
        pop.add(selector)

        button = MeldStatusMenuButton()
        self.bind_property(
            'source-encoding', button, 'label',
            GObject.BindingFlags.DEFAULT | GObject.BindingFlags.SYNC_CREATE,
            lambda binding, enc: selector.get_value_label(enc))
        button.set_popover(pop)
        button.show()

        return button

    def construct_highlighting_selector(self):
        def change_language(selector, lang):
            # TODO: Our other GObject properties are expected to be
            # updated through a bound state from our parent. This is
            # the only place where we assign to them instead of
            # emitting a signal, and it makes the class logic as a
            # whole kind of confusing.
            self.props.source_language = lang
            pop.hide()

        def set_initial_language(selector):
            selector.select_value(self.props.source_language)


        selector = SourceLangSelector()