[pygi] Update to latest version of the pygi-convert.sh script



commit a90298cc9e6c0f336f887a71d80b1efd07ec2811
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date:   Sun Apr 18 10:44:35 2010 -0400

    Update to latest version of the pygi-convert.sh script

 pygi-convert.sh |  193 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 137 insertions(+), 56 deletions(-)
---
diff --git a/pygi-convert.sh b/pygi-convert.sh
index 3be59e7..10b3de5 100644
--- a/pygi-convert.sh
+++ b/pygi-convert.sh
@@ -1,71 +1,152 @@
 #!/bin/sh
 
-for f in $@; do
-    sed -i "
-    s/import gconf/import GConf/g
-    s/gconf\./GConf\./g
-    s/GConf\.client_get_default/GConf.Client.get_default/g
+FILES_TO_CONVERT="$(find sugar-pygi -iname \*.py) $(find sugar-toolkit-pygi -iname \*.py) sugar-pygi/bin/sugar-session"
 
-    s/import gtk/import Gtk/g
-    s/gtk\./Gtk\./g
-    s/Gtk.SIZE_GROUP_/Gtk.SizeGroupMode./g
-    s/Gtk.POLICY_/Gtk.PolicyType./g
-    s/Gtk.STATE_/Gtk.StateType./g
-    s/Gtk.TARGET_/Gtk.TargetFlags./g
-    s/Gtk.SHADOW_NONE/Gtk.ShadowType.NONE/g
-    s/Gtk.ICON_SIZE_/Gtk.IconSize./g
-    s/Gtk.IMAGE_/Gtk.ImageType./g
+for f in $FILES_TO_CONVERT; do
+    perl -i -0 \
+    -pe "s/import gconf\n/from gi.repository import GConf\n/g;" \
+    -pe "s/gconf\./GConf\./g;" \
+    -pe "s/GConf\.client_get_default/GConf.Client.get_default/g;" \
+    -pe "s/GConf\.CLIENT_/GConf.ClientPreloadType./g;" \
+    -pe "s/gconf_client.notify_add\('\/desktop\/sugar\/collaboration\/publish_gadget',/return;gconf_client.notify_add\('\/desktop\/sugar\/collaboration\/publish_gadget',/g;" \
+\
+    -pe "s/import gtk\n/from gi.repository import Gtk\n/g;" \
+    -pe "s/gtk\./Gtk\./g;" \
+    -pe "s/Gtk.SIZE_GROUP_/Gtk.SizeGroupMode./g;" \
+    -pe "s/Gtk.POLICY_/Gtk.PolicyType./g;" \
+    -pe "s/Gtk.STATE_/Gtk.StateType./g;" \
+    -pe "s/Gtk.TARGET_/Gtk.TargetFlags./g;" \
+    -pe "s/Gtk.SHADOW_NONE/Gtk.ShadowType.NONE/g;" \
+    -pe "s/Gtk.ICON_SIZE_/Gtk.IconSize./g;" \
+    -pe "s/Gtk.IMAGE_/Gtk.ImageType./g;" \
+    -pe "s/Gtk.SELECTION_/Gtk.SelectionMode./g;" \
+    -pe "s/Gtk.CELL_RENDERER_MODE_/Gtk.CellRendererMode./g;" \
+    -pe "s/Gtk.TREE_VIEW_COLUMN_/Gtk.TreeViewColumnSizing./g;" \
+    -pe "s/Gtk.CORNER_/Gtk.CornerType./g;" \
+    -pe "s/Gtk.settings_get_default/Gtk.Settings.get_default/g;" \
+    -pe "s/Gtk.icon_theme_get_default/Gtk.IconTheme.get_default/g;" \
+    -pe "s/.window.set_type_hint/.set_type_hint/g;" \
+    -pe "s/self.drag_source_unset\(\)/Gtk.drag_source_unset\(self\)/g;" \
+    -pe "s/self.drag_dest_unset\(\)/Gtk.drag_dest_unset\(self\)/g;" \
+    -pe "s/Gtk.ListStore\(([^\)]*)\)/Gtk.ListStore.newv\(\[\1\]\)/g;" \
+    -pe "s/self._model.filter_new\(\)/Gtk.TreeModelFilter.new\(self._model, None\)/g;" \
+    -pe "#s/Gtk.ScrolledWindow\(\)/Gtk.ScrolledWindow\(None, None\)/g;" \
+    -pe "#s/Gtk.Window.__init__\(self\)/Gtk.Window.__init__\(Gtk.WindowType.TOPLEVEL\)/g;" \
+    -pe "#s/\.child/.get_child\(\)/g;" \
+\
+    -pe "s/column.pack_start\(([^,\)]*)\)/column.pack_start\(\1, True\)/g;" \
+    -pe "s/pack_start\(([^,\)]*)\)/pack_start\(\1, True, True, 0\)/g;" \
+    -pe "s/pack_start\(([^,]*), fill=([^,\)]*)\)/pack_start\(\1, True, \2, 0\)/g;" \
+    -pe "s/pack_start\(([^,]*), expand=([^,\)]*)\)/pack_start\(\1, \2, True, 0\)/g;" \
+    -pe "s/pack_start\(([^,]*),(\s*)padding=([A-Za-z0-9._]*)\)/pack_start\(\1,\2True, True,\2\3\)/g;" \
+    -pe "#s/Gtk.HBox\(\)/Gtk.HBox\(False, 0\)/g;" \
+    -pe "#s/Gtk.VBox\(\)/Gtk.VBox\(False, 0\)/g;" \
+    -pe "s/Gtk.Label\(([^,\)]+)\)/Gtk.Label\(label=\1\)/g;" \
+    -pe "s/Gtk.AccelLabel\(([^,\)]+)\)/Gtk.AccelLabel\(label=\1\)/g;" \
+    -pe "s/len\(self._content.get_children\(\)\) > 0/self._content.get_children\(\)/g;" \
+    -pe "s/len\(self.menu.get_children\(\)\) > 0/self.menu.get_children\(\)/g;" \
+\
+    -pe "s/Gtk\..*\.__init__/gobject.GObject.__init__/g;" \
+\
+    -pe "s/Gtk.gdk\./Gdk\./g;" \
+    -pe "s/Gdk.screen_width/Gdk.Screen.width/g;" \
+    -pe "s/Gdk.screen_height/Gdk.Screen.height/g;" \
+    -pe "s/Gdk.screen_get_default/Gdk.Screen.get_default/g;" \
+    -pe "s/Gdk.WINDOW_TYPE_HINT_/Gdk.WindowTypeHint./g;" \
+    -pe "s/Gdk\.Rectangle/Gdk.rectangle_new/g;" \
+    -pe "s/Gdk.BUTTON_PRESS_MASK/Gdk.EventMask.BUTTON_PRESS_MASK/g;" \
+    -pe "s/Gdk.POINTER_MOTION_HINT_MASK/Gdk.EventMask.POINTER_MOTION_HINT_MASK/g;" \
+    -pe "s/Gdk.VISIBILITY_NOTIFY_MASK/Gdk.EventMask.VISIBILITY_NOTIFY_MASK/g;" \
+    -pe "s/Gdk.Color\(/Gdk.color_new\(/g;" \
+    -pe "s/Gdk.BUTTON_PRESS/Gdk.EventType.BUTTON_PRESS/g;" \
+\
+    -pe "s/import pango\n/from gi.repository import Pango\n/g;" \
+    -pe "s/pango\./Pango\./g;" \
+    -pe "s/Pango\.FontDescription/Pango\.Font\.description_from_string/g;" \
+    -pe "s/Pango.ELLIPSIZE_/Pango.EllipsizeMode./g;" \
+\
+    -pe "s/import hippo\n/from gi.repository import Hippo\n/g;" \
+    -pe "s/hippo\./Hippo\./g;" \
+    -pe "s/Hippo\..*\.__init__/gobject.GObject.__init__/g;" \
+    -pe "#s/insert_sorted\(([^,\)]*), ([^,\)]*), ([^,\)]*)\)/insert_sorted\(\1, \2, \3, None\)/g;" \
+    -pe "s/self\._box\.insert_sorted/#self\._box\.insert_sorted/g;" \
+    -pe "s/self._box.append\(([^,\)]*)\)/self._box.append\(\1, 0\)/g;" \
+    -pe "s/self._box.sort\(([^,\)]*)\)/self._box.sort\(\1, None\)/g;" \
+\
+    -pe "s/import wnck\n/from gi.repository import Wnck\n/g;" \
+    -pe "s/wnck\./Wnck\./g;" \
+    -pe "s/Wnck.screen_get_default/Wnck.Screen.get_default/g;" \
+    -pe "s/Wnck.WINDOW_/Wnck.WindowType./g;" \
+\
+    -pe "s/from sugar import _sugarext\n/from gi.repository import SugarExt\n/g;" \
+    -pe "s/_sugarext\.ICON_ENTRY_/SugarExt.SexyIconEntryPosition./g;" \
+    -pe "s/_sugarext\.IconEntry/SugarExt.SexyIconEntry/g;" \
+    -pe "s/_sugarext\.SMClientXSMP/SugarExt.GsmClientXSMP/g;" \
+    -pe "s/_sugarext\.VolumeAlsa/SugarExt.AcmeVolumeAlsa/g;" \
+    -pe "s/_sugarext\./SugarExt\./g;" \
+\
+    -pe "s/import gtksourceview2\n/from gi.repository import GtkSource\n/g;" \
+\
+    -pe "#s/import cairo\n/from gi.repository import cairo\n/g;" \
+\
+    -pe "s/SugarExt.xsmp_init\(\)/'mec'/g;" \
+    -pe "s/SugarExt.xsmp_run\(\)/#SugarExt.xsmp_run\(\)/g;" \
+    -pe "s/SugarExt.session_create_global\(\)/None #SugarExt.session_create_global\(\)/g;" \
+    -pe "s/self.session.start\(\)/return #self.session.start\(\)/g;" \
+\
+    -pe "s/self._box.sort\(self._layout.compare_activities, None\)/pass #self._box.sort(self._layout.compare_activities, None)/g;" \
+    -pe "s/attach_points = info.get_attach_points/has_attach_points_, attach_points = info.get_attach_points/g;" \
+    -pe "s/attach_points\[0\]\[0\]/attach_points\[0\].x/g;" \
+    -pe "s/attach_points\[0\]\[1\]/attach_points\[0\].y/g;" \
+    -pe "s/has_attach_points_/return 0,0;has_attach_points_/g;" \
+    -pe "s/gobject.GObject.__init__\(self, self._model_filter\)/gobject.GObject.__init__\(self, model=self._model_filter\)/g;" \
+    -pe "s/self._model_filter.set_visible_func/return;self._model_filter.set_visible_func/g;" \
+    -pe "s/buddies_column.set_cell_data_func/return;buddies_column.set_cell_data_func/g;" \
+    -pe "s/ column.set_cell_data_func/# column.set_cell_data_func/g;" \
+    -pe "s/Hippo\.cairo_surface_from_gdk_pixbuf/SugarExt\.cairo_surface_from_pixbuf/g;" \
+    $f
+done
 
-    s/Gtk.settings_get_default/Gtk.Settings.get_default/g
-    s/Gtk.icon_theme_get_default/Gtk.IconTheme.get_default/g
-    s/.window.set_type_hint/.set_type_hint/g
-    s/self.drag_source_unset()/Gtk.drag_source_unset(self)/g
-    s/self.drag_dest_unset()/Gtk.drag_dest_unset(self)/g
-    s/Gtk.ScrolledWindow()/Gtk.ScrolledWindow(None, None)/g
-    s/\.child/.get_child()/g
+NEED_GOBJECT=`grep -R -l gobject\. $FILES_TO_CONVERT | xargs grep -nL import\ gobject`
+for f in $NEED_GOBJECT; do
+    sed -i "/import Gdk/ i\import gobject" $f
+done
 
-    s/pack_start(\([^,]*\))/pack_start(\1, expand=True, fill=True, padding=0)/g
-    s/pack_start(\([^,]*\), fill=\([^,]*\))/pack_start(\1, expand=True, fill=\2, padding=0)/g
-    s/pack_start(\([^,]*\), expand=\([^,]*\))/pack_start(\1, expand=\2, fill=True, padding=0)/g
-    s/Gtk.HBox()/Gtk.HBox(homogeneous=False, spacing=0)/g
-    s/Gtk.VBox()/Gtk.VBox(homogeneous=False, spacing=0)/g
-    s/Gtk.Label()/Gtk.Label('')/g
+NEED_GOBJECT=`grep -R -l gobject\. $FILES_TO_CONVERT | xargs grep -nL import\ gobject`
+for f in $NEED_GOBJECT; do
+    sed -i "/import Gtk/ i\import gobject" $f
+done
 
-    s/Gtk\..*\.__init__/gobject.GObject.__init__/g
+NEED_GOBJECT=`grep -R -l gobject\. $FILES_TO_CONVERT | xargs grep -nL import\ gobject`
+for f in $NEED_GOBJECT; do
+    sed -i "/import Hippo/ i\import gobject" $f
+done
 
-    s/Gtk.gdk\./Gdk\./g
-    s/Gdk.screen_width/Gdk.Screen.width/g
-    s/Gdk.screen_height/Gdk.Screen.height/g
-    s/Gdk.screen_get_default/Gdk.Screen.get_default/g
-    s/Gdk.WINDOW_TYPE_HINT_/Gdk.WindowTypeHint./g
-    s/Gdk\.Rectangle/Gdk.rectangle_new/g
-    s/Gdk.BUTTON_PRESS_MASK/Gdk.EventMask.BUTTON_PRESS_MASK/g
-    s/Gdk.POINTER_MOTION_HINT_MASK/Gdk.EventMask.POINTER_MOTION_HINT_MASK/g
+NEED_GDK=`grep -R -l Gdk\. $FILES_TO_CONVERT | xargs grep -nL import\ Gdk`
+for f in $NEED_GDK; do
+    sed -i "/import Gtk/ i\from gi.repository import Gdk" $f
+done
 
-    s/import pango/import Pango/g
-    s/pango\./Pango\./g
-    s/Pango\.FontDescription/Pango\.Font\.description_from_string/g
-    s/Pango.ELLIPSIZE_/Pango.EllipsizeMode./g
+NEED_SUGAR_EXT=`grep -R -l SugarExt\. $FILES_TO_CONVERT | xargs grep -nL import\ SugarExt`
+for f in $NEED_SUGAR_EXT; do
+    sed -i "/import cairo/ i\from gi.repository import SugarExt" $f
+done
+
+for f in sugar-pygi/src/jarabe/util/emulator.py sugar-pygi/bin/sugar-session; do
+    sed -i "/import Gdk/ a\Gdk.init_check([])" $f
+    sed -i "/import Gtk/ a\Gtk.init_check([])" $f
+done
 
-    s/import hippo/import Hippo/g
-    s/hippo\./Hippo\./g
-    s/Hippo\..*\.__init__/gobject.GObject.__init__/g
+sed -i "/Gdk.threads_init()/ i\gobject.threads_init()" sugar-pygi/bin/sugar-session
 
-    s/self._box.append(\([^,]*\))/self._box.append(\1, 0)/g
-    s/self._box.sort(\([^,]*\))/self._box.sort(\1, None)/g
+# Disable treeview stuff
+sed -i 's/class CellRendererIcon(Gtk.GenericCellRenderer):/class CellRendererIcon(Gtk.CellRenderer):/g' sugar-toolkit-pygi/src/sugar/graphics/icon.py
 
-    s/import gio/import Gio/g
-    s/gio\./Gio\./g
+#sed -i '/def get_icon_state(base_name, perc, step=5):/ i\"""' sugar-toolkit-pygi/src/sugar/graphics/icon.py
 
-    s/import wnck/import Wnck/g
-    s/wnck\./Wnck\./g
-    s/Wnck.screen_get_default/Wnck.Screen.get_default/g
-    " $f
-done
+#sed -i 's/from sugar.graphics.icon import Icon, CellRendererIcon/from sugar.graphics.icon import Icon/g' sugar-pygi/src/jarabe/desktop/activitieslist.py
 
-echo 'Add "import Gdk" to'
-rgrep -l Gdk\. $(find . -iname \*.py) | xargs grep -nL import\ Gdk
+#sed -i '/class CellRendererFavorite(CellRendererIcon):/ i\"""' sugar-pygi/src/jarabe/desktop/activitieslist.py
+#sed -i '/def get_icon_state(base_name, perc, step=5):/ i\"""' sugar-toolkit-pygi/src/sugar/graphics/icon.py
 
-echo 'Add "import gobject" to'
-rgrep -l gobject\. $(find . -iname \*.py) | xargs grep -nL import\ gobject
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]