Permalink
Browse files

replace gconf2 settings with a yaml config

  • Loading branch information...
1 parent bca45b2 commit 46444ab7d3635bb69e3dcd183f14c8a8056be345 @themactep committed Jun 28, 2011
Showing with 48 additions and 2 deletions.
  1. +46 −0 lib/grumblr/config.rb
  2. +2 −2 lib/grumblr/core.rb
View
@@ -0,0 +1,46 @@
+require 'yaml'
+
+module Grumblr
+ class Config
+
+ def initialize
+ prepare_directory
+ end
+
+ def conf
+ @@conf ||= YAML::load(open(config_file))
+ rescue
+ @@conf ||= {}
+ end
+
+ def get(name)
+ conf[name.to_s]
+ end
+
+ def set(name, value)
+ conf[name.to_s] = value
+ end
+
+ def save
+ File.open(config_file, 'w') { |f| f.write conf.to_yaml }
+ end
+
+ def destroy
+ @@conf = {}
+ $app.quit
+ end
+
+ def config_file
+ File.join(config_directory, 'settings.yml')
+ end
+
+ def config_directory
+ @config_directory ||= File.expand_path(File.join('~', '.config', 'grumblr'))
+ end
+
+ def prepare_directory
+ return if File.directory?(config_directory)
+ FileUtils.mkdir_p(config_directory)
+ end
+ end
+end
View
@@ -1,5 +1,5 @@
-require 'ppds/config'
require 'ppds/tumblr'
+require 'grumblr/config'
require 'grumblr/ui'
require 'gtk2'
@@ -11,7 +11,7 @@ class Core
def initialize
$app = self
- $cfg = Ppds::Config.new 'grumblr'
+ $cfg = Grumblr::Config.new
$gui = Grumblr::UI.new
$gui.show_all

0 comments on commit 46444ab

Please sign in to comment.