コード例 #1
0
ファイル: prefs.py プロジェクト: kaio/ibus-anthy
 def variant_to_value(self, variant):
     if type(variant) != GLib.Variant:
         return variant
     type_string = variant.get_type_string()
     if type_string == 's':
         return variant.get_string()
     elif type_string == 'i':
         return variant.get_int32()
     elif type_string == 'b':
         return variant.get_boolean()
     elif type_string == 'as':
         if self.__tuple_for_variant_strv:
             return variant.dup_strv()[0]
         else:
             return variant.dup_strv()
     else:
         print >> sys.stderr, 'Unknown variant type:', type_string
         sys.abrt()
     return variant
コード例 #2
0
ファイル: prefs.py プロジェクト: julroy67/ibus-anthy
 def variant_to_value(self, variant):
     if type(variant) != GLib.Variant:
         return variant
     type_string = variant.get_type_string()
     if type_string == "s":
         return variant.get_string()
     elif type_string == "i":
         return variant.get_int32()
     elif type_string == "b":
         return variant.get_boolean()
     elif type_string == "as":
         # Use unpack() instead of dup_strv() in python.
         # In the latest pygobject3 3.3.4 or later, g_variant_dup_strv
         # returns the allocated strv but in the previous release,
         # it returned the tuple of (strv, length)
         return variant.unpack()
     else:
         self.printerr("Unknown variant type: %s" % type_string)
         sys.abrt()
     return variant
コード例 #3
0
 def variant_to_value(self, variant):
     if type(variant) != GLib.Variant:
         return variant
     type_string = variant.get_type_string()
     if type_string == 's':
         return variant.get_string()
     elif type_string == 'i':
         return variant.get_int32()
     elif type_string == 'b':
         return variant.get_boolean()
     elif type_string == 'as':
         # Use unpack() instead of dup_strv() in python.
         # In the latest pygobject3 3.3.4 or later, g_variant_dup_strv
         # returns the allocated strv but in the previous release,
         # it returned the tuple of (strv, length)
         return variant.unpack()
     else:
         self.printerr('Unknown variant type:', type_string)
         sys.abrt()
     return variant
コード例 #4
0
ファイル: prefs.py プロジェクト: julroy67/ibus-anthy
 def commit_item(self, section, key):
     if section in self.new and key in self.new[section]:
         s = "/".join([s for s in "/".join([self._prefix, section]).split("/") if s])
         v = self.new[section][key]
         if v == []:
             v = [""]
         variant = None
         if type(v) == str:
             variant = GLib.Variant.new_string(v)
         elif type(v) == int:
             variant = GLib.Variant.new_int32(v)
         elif type(v) == bool:
             variant = GLib.Variant.new_boolean(v)
         elif type(v) == list:
             variant = GLib.Variant.new_strv(v)
         if variant == None:
             self.printerr("Unknown value type: %s" % type(v))
             sys.abrt()
         if self._config != None:
             self._config.set_value(s, key, variant)
         self.modified.setdefault(section, {})[key] = v
         del (self.new[section][key])
コード例 #5
0
ファイル: prefs.py プロジェクト: kaio/ibus-anthy
 def commit_item(self, section, key):
     if section in self.new and key in self.new[section]:
         s = '/'.join(
             [s for s in '/'.join([self._prefix, section]).split('/') if s])
         v = self.new[section][key]
         if v == []:
             v = ['']
         variant = None
         if type(v) == str:
             variant = GLib.Variant.new_string(v)
         elif type(v) == int:
             variant = GLib.Variant.new_int32(v)
         elif type(v) == bool:
             variant = GLib.Variant.new_boolean(v)
         elif type(v) == list:
             variant = GLib.Variant.new_strv(v)
         if variant == None:
             print >> sys.stderr, 'Unknown value type:', type(v)
             sys.abrt()
         self._config.set_value(s, key, variant)
         self.modified.setdefault(section, {})[key] = v
         del(self.new[section][key])
コード例 #6
0
 def commit_item(self, section, key):
     if section in self.new and key in self.new[section]:
         s = '/'.join(
             [s for s in '/'.join([self._prefix, section]).split('/') if s])
         v = self.new[section][key]
         if v == []:
             v = ['']
         variant = None
         if type(v) == str:
             variant = GLib.Variant.new_string(v)
         elif type(v) == int:
             variant = GLib.Variant.new_int32(v)
         elif type(v) == bool:
             variant = GLib.Variant.new_boolean(v)
         elif type(v) == list:
             variant = GLib.Variant.new_strv(v)
         if variant == None:
             self.printerr('Unknown value type:', type(v))
             sys.abrt()
         if self._config != None:
             self._config.set_value(s, key, variant)
         self.modified.setdefault(section, {})[key] = v
         del(self.new[section][key])