summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornatural <natural>2007-01-10 21:23:34 +0000
committernatural <natural>2007-01-10 21:23:34 +0000
commit46a6aae6b909db116e0bd69764adce069c4e0275 (patch)
tree04560971bfe7511113a0629c3e78f6f472f3d09d
parentc61b941817107402d535b8cc6304e002ac4cc0e4 (diff)
downloadkberylsettings-46a6aae6b909db116e0bd69764adce069c4e0275.tar.gz
kberylsettings-46a6aae6b909db116e0bd69764adce069c4e0275.tar.bz2
Support for profile set.
-rw-r--r--kberylsettings/aboutpage.py2
-rw-r--r--kberylsettings/main.py55
2 files changed, 26 insertions, 31 deletions
diff --git a/kberylsettings/aboutpage.py b/kberylsettings/aboutpage.py
index f7db1ec..75e057d 100644
--- a/kberylsettings/aboutpage.py
+++ b/kberylsettings/aboutpage.py
@@ -83,7 +83,7 @@ class AboutPage(Frame):
self.pluginHREF % (plugin.Name, plugin.ShortDesc),
plugin.LongDesc)
rows.append(row)
- rows = [self.contentCell % (i18n(a), b) for a, b in rows]
+ rows = [self.contentCell % (i18n(str(a)), b) for a, b in rows]
rows = [self.contentRow % row for row in rows]
extra = '<div>%s</div>' % i18n(self.contextExtra)
return self.contentContainer % (str.join('', rows), extra)
diff --git a/kberylsettings/main.py b/kberylsettings/main.py
index f6fe2f3..95036d5 100644
--- a/kberylsettings/main.py
+++ b/kberylsettings/main.py
@@ -10,7 +10,6 @@ from sys import argv
from kdecore import KApplication, KCmdLineArgs, KIcon, KGlobal, KWin, i18n, locate
from kdeui import KMainWindow, KStdGuiItem, KLineEdit, KSystemTray, KTipDialog, \
KKeyDialog
-from kio import KDirWatch
from kfile import KFileDialog
from qt import Qt, QWidget, QHBoxLayout, QLabel, QImage
@@ -31,7 +30,8 @@ class KBerylSettings(KMainWindow):
iconSize = KIcon.SizeMedium
startDir = '::kberylsettings'
berylDir = expanduser('~/.beryl/')
-
+ defaultProfileName = '<beryl default>'
+
def __init__(self):
KMainWindow.__init__(self)
self.buildWidgets()
@@ -141,6 +141,7 @@ class KBerylSettings(KMainWindow):
actions.readShortcutSettings('shortcuts', self.config())
## done after initial emit to prevent spurious context update
connect(self, Signals.berylContextChanged, self.onContextChanged)
+ self.updateProfileMenus()
self.tipDialog(force=False)
def config(self, group=None):
@@ -197,38 +198,29 @@ class KBerylSettings(KMainWindow):
"""
try:
- profileMap = self.profileMap
- except (AttributeError, ):
- profileMap = self.profileMap = {}
- try:
- watcher = self.watcher
+ pop = self.profilePop
except (AttributeError, ):
- watcher = self.watcher = KDirWatch(self)
- self.connect(watcher, Signals.fileChanged, self.updatedFile)
- self.connect(watcher, Signals.fileCreated, self.newFile)
-
- berylDir = self.berylDir
- profFormat = 'settings%s.Profile'
- maybeProfiles = [profFormat % i for i in range(1, 6)]
-
- pop = Popup(self)
- for name in maybeProfiles:
- popid = pop.insertItem(name)
- path = berylDir + name
- index = hash(path)
- profileMap[index] = path
+ self.profileMap = {}
+ pop = self.profilePop = Popup(self)
+ return pop
+
+ def updateProfileMenus(self):
+ context = self.context
+ profileMap = self.profileMap
+ defName = self.defaultProfileName
+ current = self.context.Profile
+ pop = self.profilePop
+ pop.clear()
+ profiles = [(defName, ''), ] + [(p, p) for p in context.Profiles]
+
+ for label, name in profiles:
+ popid = pop.insertItem(label)
+ index = hash(name)
+ profileMap[index] = name
pop.setItemParameter(popid, index)
- pop.setItemEnabled(popid, exists(path))
+ pop.setItemChecked(popid, name==current)
pop.connectItem(popid, self.onProfileSelect)
- watcher.addFile(path)
- return pop
-
- def updatedFile(self, path):
- print '### updated file path:', path
- def newFile(self, path):
- print '### new file path:', path
-
def viewMenu(self):
""" creates a new View menu
@@ -390,6 +382,9 @@ class KBerylSettings(KMainWindow):
@return None
"""
self.context.Profile = self.profileMap[itemId]
+ self.context.Write()
+ #self.context = context = Context()
+ self.updateProfileMenus()
self.emit(Signals.berylContextChanged, (self.context, ))
def onSelectPlugins(self):