I've received help from #gtk+ on irc.gimp.org that has got me unstuck with this 
knowledge:

+ I must compile the schema to create a cache file. This cache file is what 
gsettings uses.
+ I can include a cache file in my source distribution as it is platform 
independent. So, I only need to compile once per release, and no users will 
need to do the compile step.
+ This page answers my exact question:
How can I install a Gsettings Schema without root privileges?

+ Once I have my compiled schema, I can use it (in my specific case) as:
  

  """ this seems to work, when the plugin is not installed as root."""
  schema_dir = os.path.join(self.plugin_info.get_module_dir(), "gutenberg")
  schema_source = Gio.SettingsSchemaSource.new_from_directory(
    schema_dir,
    Gio.SettingsSchemaSource.get_default(),
    False,
  )
  schema = schema_source.lookup('org.gnome.rhythmbox.plugins.gutenberg', False)
  self.settings = Gio.Settings.new_full(schema, None, None)
  self.settings.set_boolean('my-bool-setting', False)


^ I imagine there is a nicer way than this - but I wanted to share this method 
with any other hackers.

cheers,
Richard



________________________________
 From: Richard Henwood <rjhenw...@yahoo.co.uk>
To: desktop-devel-list <desktop-devel-list@gnome.org> 
Sent: Tuesday, 11 November 2014, 13:29
Subject: gio settings schema
 


Hi All,

I'm writing a plugin in python for Rhythmbox. I want to use GSettings to record 
the state of the plugin.

I feel like I should be able to do something like:

  if source.lookup("org.gnome.rhythmbox.plugins.gutenberg", True):
    print ("got settings.")
  else:
    print("seems like settings are missing. Creating new ones.")
    self.settings =
 Gio.Settings.new("org.gnome.rhythmbox.plugins.gutenberg")


... but I can't - and it seems [1] I need to create a schema manually, as root, 
by copying a file into /usr/share/glib-2.0/schemas/

This feels weird to me: I can install my plug-in as a user, but I can't create 
a GSetting (that I think my plugin should be using for good hygiene). I imagine 
I've missed something - and I'd appreciate guidance back to the path.

best regards,
Richard

 
1. Using GSettings with Python/PyGObject

  
             
Using GSettings with Python/PyGObject
Example Python program using GSettings with PyGObject in GNOME 3.  
View on www.micahcarrick.com Preview by Yahoo  
  

_______________________________________________
desktop-devel-list mailing list
desktop-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/desktop-devel-list
_______________________________________________
desktop-devel-list mailing list
desktop-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/desktop-devel-list

Reply via email to