Handle the case where there is no child text node. (GtkBuilderConverter):
2008-01-25 Johan Dahlin <johan@gnome.org> * gtk/gtk-builder-convert (GtkBuilderConverter._convert_adjustment): Handle the case where there is no child text node. (GtkBuilderConverter): Allow xml comments in most places. svn path=/trunk/; revision=19405
This commit is contained in:

committed by
Johan Dahlin

parent
3f3425d19c
commit
4c08143831
@ -1,3 +1,10 @@
|
|||||||
|
2008-01-25 Johan Dahlin <johan@gnome.org>
|
||||||
|
|
||||||
|
* gtk/gtk-builder-convert
|
||||||
|
(GtkBuilderConverter._convert_adjustment): Handle the case where
|
||||||
|
there is no child text node.
|
||||||
|
(GtkBuilderConverter): Allow xml comments in most places.
|
||||||
|
|
||||||
2008-01-25 Johan Dahlin <johan@gnome.org>
|
2008-01-25 Johan Dahlin <johan@gnome.org>
|
||||||
|
|
||||||
* gtk/gtk-builder-convert
|
* gtk/gtk-builder-convert
|
||||||
|
@ -58,7 +58,7 @@ def get_child_nodes(node):
|
|||||||
assert node.tagName == 'object'
|
assert node.tagName == 'object'
|
||||||
nodes = []
|
nodes = []
|
||||||
for child in node.childNodes:
|
for child in node.childNodes:
|
||||||
if child.nodeType == Node.TEXT_NODE:
|
if child.nodeType != Node.ELEMENT_NODE:
|
||||||
continue
|
continue
|
||||||
if child.tagName != 'child':
|
if child.tagName != 'child':
|
||||||
continue
|
continue
|
||||||
@ -69,7 +69,7 @@ def get_properties(node):
|
|||||||
assert node.tagName == 'object'
|
assert node.tagName == 'object'
|
||||||
properties = {}
|
properties = {}
|
||||||
for child in node.childNodes:
|
for child in node.childNodes:
|
||||||
if child.nodeType == Node.TEXT_NODE:
|
if child.nodeType != Node.ELEMENT_NODE:
|
||||||
continue
|
continue
|
||||||
if child.tagName != 'property':
|
if child.tagName != 'property':
|
||||||
continue
|
continue
|
||||||
@ -86,7 +86,7 @@ def get_property_node(node, property_name):
|
|||||||
assert node.tagName == 'object'
|
assert node.tagName == 'object'
|
||||||
properties = {}
|
properties = {}
|
||||||
for child in node.childNodes:
|
for child in node.childNodes:
|
||||||
if child.nodeType == Node.TEXT_NODE:
|
if child.nodeType != Node.ELEMENT_NODE:
|
||||||
continue
|
continue
|
||||||
if child.tagName != 'property':
|
if child.tagName != 'property':
|
||||||
continue
|
continue
|
||||||
@ -97,7 +97,7 @@ def get_signal_nodes(node):
|
|||||||
assert node.tagName == 'object'
|
assert node.tagName == 'object'
|
||||||
signals = []
|
signals = []
|
||||||
for child in node.childNodes:
|
for child in node.childNodes:
|
||||||
if child.nodeType == Node.TEXT_NODE:
|
if child.nodeType != Node.ELEMENT_NODE:
|
||||||
continue
|
continue
|
||||||
if child.tagName == 'signal':
|
if child.tagName == 'signal':
|
||||||
signals.append(child)
|
signals.append(child)
|
||||||
@ -107,8 +107,9 @@ def get_property_nodes(node):
|
|||||||
assert node.tagName == 'object'
|
assert node.tagName == 'object'
|
||||||
properties = []
|
properties = []
|
||||||
for child in node.childNodes:
|
for child in node.childNodes:
|
||||||
if child.nodeType == Node.TEXT_NODE:
|
if child.nodeType != Node.ELEMENT_NODE:
|
||||||
continue
|
continue
|
||||||
|
# FIXME: handle comments
|
||||||
if child.tagName == 'property':
|
if child.tagName == 'property':
|
||||||
properties.append(child)
|
properties.append(child)
|
||||||
return properties
|
return properties
|
||||||
@ -117,7 +118,7 @@ def get_accelerator_nodes(node):
|
|||||||
assert node.tagName == 'object'
|
assert node.tagName == 'object'
|
||||||
accelerators = []
|
accelerators = []
|
||||||
for child in node.childNodes:
|
for child in node.childNodes:
|
||||||
if child.nodeType == Node.TEXT_NODE:
|
if child.nodeType != Node.ELEMENT_NODE:
|
||||||
continue
|
continue
|
||||||
if child.tagName == 'accelerator':
|
if child.tagName == 'accelerator':
|
||||||
accelerators.append(child)
|
accelerators.append(child)
|
||||||
@ -127,7 +128,7 @@ def get_object_node(child_node):
|
|||||||
assert child_node.tagName == 'child', child_node
|
assert child_node.tagName == 'child', child_node
|
||||||
nodes = []
|
nodes = []
|
||||||
for node in child_node.childNodes:
|
for node in child_node.childNodes:
|
||||||
if node.nodeType == Node.TEXT_NODE:
|
if node.nodeType != Node.ELEMENT_NODE:
|
||||||
continue
|
continue
|
||||||
if node.tagName == 'object':
|
if node.tagName == 'object':
|
||||||
nodes.append(node)
|
nodes.append(node)
|
||||||
@ -500,7 +501,7 @@ class GtkBuilderConverter(object):
|
|||||||
|
|
||||||
# 2) Get dialogs action-widgets tag, create if not found
|
# 2) Get dialogs action-widgets tag, create if not found
|
||||||
for child in dialog.childNodes:
|
for child in dialog.childNodes:
|
||||||
if child.nodeType == Node.TEXT_NODE:
|
if child.nodeType != Node.ELEMENT_NODE:
|
||||||
continue
|
continue
|
||||||
if child.tagName == 'action-widgets':
|
if child.tagName == 'action-widgets':
|
||||||
actions = child
|
actions = child
|
||||||
@ -516,16 +517,22 @@ class GtkBuilderConverter(object):
|
|||||||
actions.appendChild(action)
|
actions.appendChild(action)
|
||||||
|
|
||||||
def _convert_adjustment(self, prop):
|
def _convert_adjustment(self, prop):
|
||||||
data = prop.childNodes[0].data
|
properties = {}
|
||||||
value, lower, upper, step, page, page_size = data.split(' ')
|
if prop.childNodes:
|
||||||
|
data = prop.childNodes[0].data
|
||||||
|
value, lower, upper, step, page, page_size = data.split(' ')
|
||||||
|
properties.update(value=value,
|
||||||
|
lower=lower,
|
||||||
|
upper=upper,
|
||||||
|
step_increment=step,
|
||||||
|
page_increment=page,
|
||||||
|
page_size=page_size)
|
||||||
|
else:
|
||||||
|
prop.appendChild(self._dom.createTextNode(""))
|
||||||
|
|
||||||
adj = self._create_root_object("GtkAdjustment",
|
adj = self._create_root_object("GtkAdjustment",
|
||||||
template='adjustment',
|
template='adjustment',
|
||||||
properties=dict(value=value,
|
properties=properties)
|
||||||
lower=lower,
|
|
||||||
upper=upper,
|
|
||||||
step_increment=step,
|
|
||||||
page_increment=page,
|
|
||||||
page_size=page_size))
|
|
||||||
prop.childNodes[0].data = adj.getAttribute('id')
|
prop.childNodes[0].data = adj.getAttribute('id')
|
||||||
|
|
||||||
def _convert_combobox_items(self, node, prop):
|
def _convert_combobox_items(self, node, prop):
|
||||||
|
Reference in New Issue
Block a user