[meld] build_helpers: Update icon theme on install



commit 1ddf7009243f7f057b1708653c0a2fcc8510c3a8
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sun May 18 08:37:54 2014 +1000

    build_helpers: Update icon theme on install
    
    This commit also introduces MeldDistribution as a semi-sane way of
    passing the --no-update-icon-cache flag through to the install process.

 meld/build_helpers.py |   18 ++++++++++++++++++
 setup.py              |    3 ++-
 2 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/meld/build_helpers.py b/meld/build_helpers.py
index d0440dd..036676c 100644
--- a/meld/build_helpers.py
+++ b/meld/build_helpers.py
@@ -23,6 +23,7 @@ from __future__ import print_function
 import distutils.cmd
 import distutils.command.build
 import distutils.command.install_data
+import distutils.dist
 import distutils.dir_util
 import glob
 import os.path
@@ -54,6 +55,16 @@ distutils.command.build.build.sub_commands.extend([
 ])
 
 
+class MeldDistribution(distutils.dist.Distribution):
+    global_options = distutils.dist.Distribution.global_options + [
+        ("no-update-icon-cache", None, "Don't run gtk-update-icon-cache"),
+    ]
+
+    def __init__(self, *args, **kwargs):
+        self.no_update_icon_cache = False
+        distutils.dist.Distribution.__init__(self, *args, **kwargs)
+
+
 class build_data(distutils.cmd.Command):
 
     gschemas = [
@@ -317,6 +328,13 @@ class install_data(distutils.command.install_data.install_data):
 
     def run(self):
         distutils.command.install_data.install_data.run(self)
+
+        if not self.distribution.no_update_icon_cache:
+            # TODO: Generalise to non-hicolor icon themes
+            info("running gtk-update-icon-cache")
+            icon_path = os.path.join(self.install_dir, "share/icons/hicolor")
+            self.spawn(["gtk-update-icon-cache", "-q", "-t", icon_path])
+
         if not self.no_compile_schemas:
             gschema_path = build_data.gschemas[0][0]
             gschema_install = os.path.join(self.install_dir, gschema_path)
diff --git a/setup.py b/setup.py
index 4ae82c3..593a5ec 100644
--- a/setup.py
+++ b/setup.py
@@ -59,5 +59,6 @@ setup(
         "build_icons": meld.build_helpers.build_icons,
         "build_data": meld.build_helpers.build_data,
         "install_data": meld.build_helpers.install_data,
-    }
+    },
+    distclass=meld.build_helpers.MeldDistribution,
 )


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