11
2- from gi .repository import GLib
32from gi .repository import GObject
43from gi .repository import Gtk
54from gi .repository import GtkSource
65
7- from meld .conf import _ , ui_file
8- from meld .ui .listselector import FilteredListSelector
6+ from meld .conf import _
7+ from meld .ui .listselector import FilteredListSelector , with_template_file
98
109
10+ @with_template_file ('encoding-selector.ui' )
1111class EncodingSelector (FilteredListSelector , Gtk .Grid ):
1212 # The subclassing here is weird; the Selector must directly
1313 # subclass Gtk.Grid, or the template building explodes.
@@ -33,18 +33,18 @@ def get_value_label(self, enc):
3333 name = enc .get_name (), charset = enc .get_charset ())
3434
3535
36- template = open (ui_file ('encoding-selector.ui' ), 'rb' ).read ()
37- template_bytes = GLib .Bytes .new (template )
38- EncodingSelector .set_template (template_bytes )
39-
40-
4136# SourceLangSelector was intially based on gedit's
4237# GeditHighlightModeSelector
4338# Copyright (C) 2013 - Ignacio Casal Quinteiro
4439# Python translation and adaptations
4540# Copyright (C) 2015, 2017 Kai Willadsen <kai.willadsen@gmail.com>
4641
4742
43+ # TODO: When there's proper pygobject support for widget templates,
44+ # make both selectors here use a generic UI file. We can't do this
45+ # currently due to subclassing issues.
46+
47+ @with_template_file ('language-selector.ui' )
4848class SourceLangSelector (FilteredListSelector , Gtk .Grid ):
4949 # The subclassing here is weird; the Selector must directly
5050 # subclass Gtk.Grid, or the template building explodes.
@@ -72,11 +72,3 @@ def get_value_label(self, lang):
7272 if not lang :
7373 return _ ("Plain Text" )
7474 return lang .get_name ()
75-
76-
77- # TODO: When there's proper pygobject support for widget templates,
78- # make both selectors here use a generic UI file. We can't do this
79- # currently due to subclassing issues.
80- template = open (ui_file ('language-selector.ui' ), 'rb' ).read ()
81- template_bytes = GLib .Bytes .new (template )
82- SourceLangSelector .set_template (template_bytes )
0 commit comments