[gtk+] Add target version handling to gtk-builder-convert
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add target version handling to gtk-builder-convert
- Date: Wed, 12 Jan 2011 21:49:33 +0000 (UTC)
commit b6464b6c0a467226057e21d7f35e8afa50321422
Author: Christian Persch <chpe gnome org>
Date: Wed Jan 12 19:02:20 2011 +0100
Add target version handling to gtk-builder-convert
When converting to gtk3, replace GtkComboBoxEntry with GtkComboxBox
has-entry=True, and remove the has-separator property from GtkDialogs.
Bug #639327.
docs/reference/gtk/gtk-builder-convert.xml | 11 ++++++++++
gtk/gtk-builder-convert | 31 ++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/gtk/gtk-builder-convert.xml b/docs/reference/gtk/gtk-builder-convert.xml
index aa98d5d..002a73e 100644
--- a/docs/reference/gtk/gtk-builder-convert.xml
+++ b/docs/reference/gtk/gtk-builder-convert.xml
@@ -14,6 +14,7 @@
<cmdsynopsis>
<command>gtk-builder-convert</command>
<arg choice="opt">--skip-windows</arg>
+<arg choice="opt">--target-version <replaceable>version</replaceable></arg>
<arg choice="opt">--root <replaceable>name</replaceable></arg>
<arg choice="req">input</arg>
<arg choice="req">output</arg>
@@ -38,6 +39,16 @@ its output the file specified as the second argument.
<listitem><para>Convert everything but GtkWindow subclasses.</para></listitem>
</varlistentry>
<varlistentry>
+ <term>--target-version</term>
+ <term>-t</term>
+ <listitem>
+ <para>
+ Some widgets and properties are different between GTK+ versions 2.0 and
+ 3.0, so this option allows to set the desired GTK+ target version.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term>--root</term>
<term>-r</term>
<listitem><para>Convert only the widget named <replaceable>name</replaceable>
diff --git a/gtk/gtk-builder-convert b/gtk/gtk-builder-convert
index 4cae240..ed815a5 100755
--- a/gtk/gtk-builder-convert
+++ b/gtk/gtk-builder-convert
@@ -146,8 +146,9 @@ def copy_properties(node, props, prop_dict):
class GtkBuilderConverter(object):
- def __init__(self, skip_windows, root):
+ def __init__(self, skip_windows, target_version, root):
self.skip_windows = skip_windows
+ self.target_version = target_version
self.root = root
self.root_objects = []
self.objects = {}
@@ -295,6 +296,25 @@ class GtkBuilderConverter(object):
self._convert_menu(node, popup=True)
elif klass in WINDOWS and self.skip_windows:
self._remove_window(node)
+
+ if self.target_version == "3.0":
+ if klass == "GtkComboBoxEntry":
+ node.setAttribute("class","GtkComboBox")
+ prop = self._dom.createElement("property")
+ prop.setAttribute("name", "has-entry")
+ prop.appendChild(self._dom.createTextNode("True"))
+ node.appendChild(prop)
+ elif klass == "GtkDialog":
+ for child in node.childNodes:
+ if child.nodeType != Node.ELEMENT_NODE:
+ continue
+ if child.tagName != 'property':
+ continue
+ if (child.getAttribute("name") not in ("has-separator", "has_separator")):
+ continue;
+ node.removeChild(child)
+ break
+
self._default_widget_converter(node)
def _default_widget_converter(self, node):
@@ -732,7 +752,10 @@ def usage():
def main(args):
try:
opts, args = getopt.getopt(args[1:], "hwr:",
- ["help", "skip-windows", "root="])
+ ["help",
+ "skip-windows",
+ "target-version=",
+ "root="])
except getopt.GetoptError:
usage()
return 2
@@ -746,6 +769,7 @@ def main(args):
skip_windows = False
split = False
root = None
+ target_version = "3.0"
for o, a in opts:
if o in ("-h", "--help"):
usage()
@@ -754,8 +778,11 @@ def main(args):
root = a
elif o in ("-w", "--skip-windows"):
skip_windows = True
+ elif o in ("-t", "--target-version"):
+ target_version = a
conv = GtkBuilderConverter(skip_windows=skip_windows,
+ target_version=target_version,
root=root)
conv.parse_file(input_filename)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]