From f4952d5f8f15079afae19d237bffb12448623ed1 Mon Sep 17 00:00:00 2001 From: "Paul W. Frields" Date: Sun, 30 Aug 2009 19:55:47 -0400 Subject: Support initial warning dialog - Use /apps/PulseCaster/skip_warning to toggle - Reserve /apps/PulseCaster/vorbisq for later use --- pulsecaster/gconf.py | 37 ------------------------------------- pulsecaster/gconfig.py | 44 ++++++++++++++++++++++++++++++++++++++++++++ pulsecaster/ui.py | 19 ++++++++++++++++++- 3 files changed, 62 insertions(+), 38 deletions(-) delete mode 100644 pulsecaster/gconf.py create mode 100644 pulsecaster/gconfig.py (limited to 'pulsecaster') diff --git a/pulsecaster/gconf.py b/pulsecaster/gconf.py deleted file mode 100644 index 7a85c93..0000000 --- a/pulsecaster/gconf.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/python -# -# Copyright (C) 2009 Paul W. Frields -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# -# Author: Paul W. Frields - - -import gconf -from config import * - -class PulseCasterGconf: - def __init__(self): - self.dirbase = '/apps/' + NAME - self.client = gconf.client_get_default() - self.warn = self.client.get_without_default(self.dirbase + '/warn') - if type(self.warn) is None: - self.warn = True - self.client.set_value(self.dirbase + '/warn', False) - self.vorbisq = self.client.get_without_default(self.dirbase + '/vorbisq') - if type(self.vorbisq) is None: - self.vorbisq = 4 - self.client.set_value(self.dirbase + '/vorbisq', self.vorbisq) - diff --git a/pulsecaster/gconfig.py b/pulsecaster/gconfig.py new file mode 100644 index 0000000..d956d42 --- /dev/null +++ b/pulsecaster/gconfig.py @@ -0,0 +1,44 @@ +#!/usr/bin/python +# +# Copyright (C) 2009 Paul W. Frields +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# +# Author: Paul W. Frields + + +import gconf +from config import * + +class PulseCasterGconf: + def __init__(self): + self.dirbase = '/apps/' + NAME + self.client = gconf.client_get_default() + if self.client.dir_exists(self.dirbase) is False: + self.client.add_dir(self.dirbase, gconf.CLIENT_PRELOAD_NONE) + + self.skip_warn = self.client.get_bool(self.dirbase + '/skip_warning') + if self.skip_warn is None or type(self.skip_warn) is not bool: + self.skip_warn = False + + self.vorbisq = self.client.get(self.dirbase + '/vorbisq') + if type(self.vorbisq) is not int: + self.vorbisq = 4 + self.client.set_int(self.dirbase + '/vorbisq', self.vorbisq) + + def change_warn(self, val): + if type(val) is not bool: + raise ValueError, "requires bool value" + self.client.set_bool(self.dirbase + '/skip_warning', val) diff --git a/pulsecaster/ui.py b/pulsecaster/ui.py index 596f9b2..c2c8d7f 100644 --- a/pulsecaster/ui.py +++ b/pulsecaster/ui.py @@ -20,6 +20,7 @@ from config import * +import gconfig from pulseaudio.PulseObj import PulseObj import gtk import gtk.glade @@ -44,6 +45,13 @@ class PulseCasterUI: def __init__(self): self.xml = gtk.glade.XML(fname) self.logo = gtk.gdk.pixbuf_new_from_file(logofile) + self.gconfig = gconfig.PulseCasterGconf() + + self.warning = self.xml.get_widget('warning') + self.dismiss = self.xml.get_widget('dismiss_warning') + self.swckbox = self.xml.get_widget('skip_warn_checkbox') + self.swckbox.set_active(int(self.gconfig.skip_warn)) + self.dismiss.connect('clicked', self.hideWarn) # Main dialog basics self.main = self.xml.get_widget('main_dialog') @@ -126,6 +134,11 @@ class PulseCasterUI: self.combo_vbox.reorder_child(self.subject_vox, 1) self.combo_vbox.show_all() + if self.gconfig.skip_warn is False: + self.warning.show() + else: + self.hideWarn() + def on_record(self, *args): # Get filename # Check whether filename exists, if so, overwrite? y/n @@ -181,6 +194,11 @@ class PulseCasterUI: pass gtk.main_quit() + def hideWarn(self, *args): + self.gconfig.change_warn(self.swckbox.get_active()) + self.warning.hide() + self.main.show() + def showAbout(self, *args): self.about.show() @@ -217,5 +235,4 @@ class PulseCasterListener: if __name__ == '__main__': pulseCaster = PulseCasterUI() - pulseCaster.main.show_all() gtk.main() -- cgit