Commit 72a99195 authored by Kai Willadsen's avatar Kai Willadsen

Move ui_file helper to meld.conf to avoid circular imports

We could easily get circular imports in ui.util because it imports all
glade-constructable widgets so that it can construct them.
parent f5d5b074
......@@ -49,3 +49,7 @@ def uninstalled():
data_dir = os.environ.get('XDG_DATA_DIRS', "/usr/local/share/:/usr/share/")
data_dir = ":".join((melddir, data_dir))
os.environ['XDG_DATA_DIRS'] = data_dir
def ui_file(filename):
return os.path.join(DATADIR, "ui", filename)
......@@ -14,15 +14,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from gi.repository import Gtk
import meld.conf
def ui_file(filename):
return os.path.join(meld.conf.DATADIR, "ui", filename)
# For backwards compat
ui_file = meld.conf.ui_file
class Component(object):
......
......@@ -13,8 +13,6 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from gi.repository import Gtk
import meld.conf
......@@ -23,19 +21,17 @@ import meld.conf
from meld.ui import gladesupport
def ui_file(filename):
return os.path.join(meld.conf.DATADIR, "ui", filename)
def get_widget(filename, widget):
builder = Gtk.Builder()
builder.set_translation_domain(meld.conf.__package__)
builder.add_objects_from_file(ui_file(filename), [widget])
path = meld.conf.ui_file(filename)
builder.add_objects_from_file(path, [widget])
return builder.get_object(widget)
def get_builder(filename):
builder = Gtk.Builder()
builder.set_translation_domain(meld.conf.__package__)
builder.add_from_file(ui_file(filename))
path = meld.conf.ui_file(filename)
builder.add_from_file(path)
return builder
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment