about summary refs log tree commit diff
path: root/overrides/gajim
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2013-05-25 09:52:27 +0200
committeraszlig <aszlig@redmoonstudios.org>2013-05-25 10:29:24 +0200
commit28a49801c8bcaa4a4092e12496aa0c6a3b015467 (patch)
treecde9463b38a41557f303f4cdebf009cc6af1172c /overrides/gajim
parenta304a5f19a0362894ee171cd9fa5a95b5213b683 (diff)
Move over from TKabber to Gajim.
This not only patches the desired configuration into Gajim itself but also
enforces a specific GTK+ theme to be used for Gajim only. The main reason for
that is to mimic the look of my previos TKabber theme and configuration.

For the gory details, have a look at the patch. Basically we just use the config
from the nix store as a default configuration file and only add changed lines to
the configuration in the home directory. That way we can still play around with
options while not killing our base configuration. If we want to make something
permanent, we can just move it into the nix config.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Diffstat (limited to 'overrides/gajim')
-rw-r--r--overrides/gajim/config.patch80
1 files changed, 80 insertions, 0 deletions
diff --git a/overrides/gajim/config.patch b/overrides/gajim/config.patch
new file mode 100644
index 00000000..ef40284f
--- /dev/null
+++ b/overrides/gajim/config.patch
@@ -0,0 +1,80 @@
+diff --git a/src/common/optparser.py b/src/common/optparser.py
+index f84b18a..0078317 100644
+--- a/src/common/optparser.py
++++ b/src/common/optparser.py
+@@ -30,6 +30,7 @@ import os
+ import sys
+ import locale
+ import re
++from itertools import chain
+ from time import time
+ from common import gajim
+ from common import helpers
+@@ -46,19 +47,25 @@ class OptionsParser:
+ 
+     def read(self):
+         try:
+-            fd = open(self.__filename)
++            cfg = nixfd = open("@nix_config@", 'r')
+         except Exception:
+             if os.path.exists(self.__filename):
+                 #we talk about a file
+                 print _('Error: cannot open %s for reading') % self.__filename
+             return False
+ 
++        try:
++            fd = open(self.__filename)
++            cfg = chain(cfg, fd)
++        except Exception:
++            fd = None
++
+         new_version = gajim.config.get('version')
+         new_version = new_version.split('-', 1)[0]
+         seen = set()
+         regex = re.compile(r"(?P<optname>[^.]+)(?:(?:\.(?P<key>.+))?\.(?P<subname>[^.]+))?\s=\s(?P<value>.*)")
+ 
+-        for line in fd:
++        for line in cfg:
+             try:
+                 line = line.decode('utf-8')
+             except UnicodeDecodeError:
+@@ -79,10 +86,13 @@ class OptionsParser:
+         self.update_config(old_version, new_version)
+         self.old_values = {} # clean mem
+ 
+-        fd.close()
++        if fd is not None:
++            fd.close()
++
++        nixfd.close()
+         return True
+ 
+-    def write_line(self, fd, opt, parents, value):
++    def write_line(self, (fd, nixcfg), opt, parents, value):
+         if value is None:
+             return
+         value = value[1]
+@@ -102,17 +112,21 @@ class OptionsParser:
+                     p = p.encode('utf-8')
+                 s += p + '.'
+         s += opt
+-        fd.write(s + ' = ' + value + '\n')
++        line = s + ' = ' + value + '\n'
++        if not nixcfg.startswith(line) and not ('\n' + line) in nixcfg:
++            fd.write(line)
+ 
+     def write(self):
+         (base_dir, filename) = os.path.split(self.__filename)
+         self.__tempfile = os.path.join(base_dir, '.' + filename)
++
+         try:
++            nixcfg = open("@nix_config@", 'r').read()
+             f = open(self.__tempfile, 'w')
+         except IOError, e:
+             return str(e)
+         try:
+-            gajim.config.foreach(self.write_line, f)
++            gajim.config.foreach(self.write_line, (f, nixcfg))
+         except IOError, e:
+             return str(e)
+         f.flush()