Beispiel #1
0
	def add_from_file(self, filename):
		""" Builds UI from file """
		log.debug("Loading glade file %s", filename)
		if len(self.conditions) == 0 and not IS_WINDOWS and get_locale_dir() is None:
			# There is no need to do any magic in this case; Just use
			# Gtk.Builder directly
			Gtk.Builder.add_from_file(self, filename)
		else:
			self.add_from_string(file(filename, "r").read())
Beispiel #2
0
	def add_from_file(self, filename):
		""" Builds UI from file """
		log.debug("Loading glade file %s", filename)
		if len(self.conditions) == 0 and not IS_WINDOWS and get_locale_dir() is None:
			# There is no need to do any magic in this case; Just use
			# Gtk.Builder directly
			Gtk.Builder.add_from_file(self, filename)
		else:
			self.add_from_string(file(filename, "r").read())
Beispiel #3
0
	def _build(self):
		"""
		Fun part starts here. Recursively walks through entire DOM tree,
		removes all <IF> tags replacing them with child nodes if when
		condition is met and fixes icon paths, if required.
		"""
		log.debug("Enabled conditions: %s", self.conditions)
		self._replace_icon_paths(self.xml.documentElement)
		self._find_conditions(self.xml.documentElement)
		if IS_WINDOWS or get_locale_dir() is not None:
			self._find_translatables()
		# Now this will convert parsed DOM tree back to XML and fed it
		# to Gtk.Builder XML parser.
		# God probably kills kitten every time when method is called...
		Gtk.Builder.add_from_string(self, self.xml.toxml("utf-8"))