linuxcnc/lib/python/multifilebuilder.py
Lubomir Rintel a63ec765cb all: update FSF address in GPL 2.0 notices
If you write to 59 Temple Place you're unlikely to get a response.
Let's realign the address with a more up-to-date one from [1].

  [1] https://www.gnu.org/licenses/old-licenses/gpl-2.0.txt

This is purely a cosmetic change, doesn't affect the meaning of the
license. Done to make rpmlint happy.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2017-09-15 13:06:22 +02:00

53 lines
1.8 KiB
Python

# -*- python -*-
# Copyright (C) 2014 Jeff Epler <jepler@unpythonic.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import gtk
__all__ = ['MultiFileBuilder']
class MultiFileBuilder:
def __init__(self):
self.builders = []
self.domain = None
def set_translation_domain(self, domain):
self.domain = domain
def connect_signals(self, obj):
for b in self.builders: b.connect_signals(obj)
def add_from_file(self, fn):
builder = gtk.Builder()
if self.domain is not None: builder.set_translation_domain(self.domain)
self.builders.append(builder)
builder.add_from_file(fn)
def add_from_string(self, strg):
builder = gtk.Builder()
if self.domain is not None: builder.set_translation_domain(self.domain)
self.builders.append(builder)
builder.add_from_string(strg)
def get_object(self, obj):
objects = [builder.get_object(obj) for builder in self.builders]
objects = [o for o in objects if o]
if not objects: return None
if len(objects) > 1: raise ValueError, """Use of object with duplicate ID -> '%s'"""% obj
return objects[0]