[beryl-commits] r2216 - trunk/beryl-settings-2

quinn at server.beryl-project.org quinn at server.beryl-project.org
Mon Jan 1 14:12:33 CET 2007


Author: quinn
Date: 2007-01-01 13:12:33 +0000 (Mon, 01 Jan 2007)
New Revision: 2216

Modified:
   trunk/beryl-settings-2/main.py
Log:
can now set contents of all widgets based on settings


Modified: trunk/beryl-settings-2/main.py
===================================================================
--- trunk/beryl-settings-2/main.py	2007-01-01 12:34:52 UTC (rev 2215)
+++ trunk/beryl-settings-2/main.py	2007-01-01 13:12:33 UTC (rev 2216)
@@ -36,6 +36,8 @@
 	global AllowUpdate
 	AllowUpdate=False
 	SetPluginsEnabled()
+	for s in AllSettings:
+		SetWidgetsForSetting(s[0])
 	AllowUpdate=True
 
 
@@ -53,7 +55,6 @@
 				ee.remove(pld[4].Name)
 				Aps.Value=ee
 		UpdateBindingsList(hideshowall.props.active)
-		print Aps.Value
 
 def CatClicked(wid,event,CatInfo):
 	for s in AllCats:
@@ -101,6 +102,43 @@
 			[("Bottom Left Corner","BottomLeft"), ("Bottom Edge","Bottom"), ("Bottom Right Corner","BottomRight")]
 			]
 
+def SetWidgetsForSetting(setting):
+	#find setting in AllSettings
+	this=None
+	for set in AllSettings:
+		if set[0].Name==setting.Name and set[0].Plugin.Name==setting.Plugin.Name:
+			this=set
+	if (this == None):
+		return
+	set=this[0]
+	if (set.Type=='Bool'):
+		this[1][0].props.active=set.Value
+	elif (set.Type=='Int' or set.Type=='Float'):
+		this[1][0].set_value(set.Value)
+	elif (set.Type=='String' and len(set.Restrictions)==0):
+		this[1][0].set_text(set.Value)
+	elif (set.Type=='String'):
+		for m in range(0,len(set.Restrictions)):
+			if (set.Restrictions[m]==set.Value):
+				this[1][0].set_active(m)
+	elif (set.Type=='Color'):
+		this[1][0].set_color(gdk.Color(set.Value[0],set.Value[1],set.Value[2]))
+		this[1][0].set_alpha(set.Value[3])
+	elif (set.Type=='Binding' and set.Restrictions[2]):
+		this[1][0].props.active=set.Value[2]
+	elif (set.Type=='List of String'):
+		if (len(set.Restrictions)):
+			for n in this[1][0]:
+				if (set.Value.__contains__(n[1])):
+					n[0].props.active=True
+				else:
+					n[0].props.active=False
+		else:
+			this[1][1].clear()
+			for n in set.Value:
+				Iter=this[1][1].append()
+				this[1][1].set(Iter,0,n)
+
 def UpdateBindingsList(ShowHidden):
 	global GenStore
 	GenStore.clear()
@@ -235,21 +273,21 @@
 	global AllSettings
 	resbut=gtk.Button()
 	resbut.props.image=gtk.image_new_from_stock(gtk.STOCK_CLEAR,gtk.ICON_SIZE_BUTTON)
-	SetWid=()
+	SetWid=[]
 	if (setting.Type == 'Bool'):
 		foo=gtk.HBox(False,8)
 		foo.pack_start(resbut,False,False)
 		bar=gtk.CheckButton(setting.ShortDesc)
 		foo.pack_start(bar,True,True)
 		bar.props.xalign=0
-		SetWid=(bar)
+		SetWid=[bar]
 	elif (setting.Type == 'Binding' and setting.Restrictions[2]):
 		foo=gtk.HBox(False,8)
 		foo.pack_start(resbut,False,False)
 		bar=gtk.CheckButton("%s on system bell"%setting.ShortDesc)
 		foo.pack_start(bar,True,True)
 		bar.props.xalign=0
-		SetWid=(bar)
+		SetWid=[bar]
 	elif (setting.Type == 'List of String'):
 		if (setting.Name=='active_plugins'):
 			return False
@@ -267,28 +305,32 @@
 			checkCont=gtk.Table()
 			for m in setting.Restrictions:
 				ss=gtk.CheckButton(m)
-				checkies=checkies+[ss]
+				checkies=checkies+[(ss,m)]
 				checkCont.attach(ss,col,col+1,row,row+1)
 				col=col+1
 				if (col>3):
 					col=0
 					row=row+1
 			bar.pack_start(checkCont,True,True)
-			SetWid=(checkies)
+			SetWid=[checkies]
 		else:
 			foo=gtk.Frame(setting.ShortDesc)
 			bar=gtk.HBox(False,8)
 			bar.props.border_width=4
 			foo.add(bar)
 			bil=gtk.ListStore(gobject.TYPE_STRING)
+			foob=gtk.Frame()
 			baz=gtk.TreeView(bil)
-			baz.insert_column_with_attributes(0,"Value",gtk.CellRendererText(),text=0)
+			foob.add(baz)
+			ren=gtk.CellRendererText()
+			ren.props.editable=True
+			baz.insert_column_with_attributes(0,"Value",ren,text=0)
 			baz.props.headers_visible=False
 			baz.props.height_request=100
 			fib=gtk.VBox()
 			fib.pack_start(resbut,False,False)
 			bar.pack_start(fib,False,False)
-			bar.pack_start(baz,True,True)
+			bar.pack_start(foob,True,True)
 			tab=gtk.Table(homogeneous=True)
 			up=gtk.Button()
 			up.props.image=gtk.image_new_from_stock(gtk.STOCK_GO_UP,gtk.ICON_SIZE_BUTTON)
@@ -306,7 +348,7 @@
 			tab.attach(add,1,2,0,1)
 			tab.attach(delete,1,2,2,3)
 			bar.pack_start(tab,False,False)
-			SetWid=(baz,bil)
+			SetWid=[baz,bil]
 	elif (setting.Type == 'String'):
 		foo=gtk.HBox(False,8)
 		foo.pack_start(resbut,False,False)
@@ -319,7 +361,7 @@
 			bar=gtk.Entry()
 			bar.props.width_chars=40
 		foo.pack_end(bar,False,False)
-		SetWid=(bar)
+		SetWid=[bar]
 	elif (setting.Type == 'Int' or setting.Type=='Float'):
 		foo=gtk.Frame(setting.ShortDesc)
 		baz=gtk.HBox(False,8)
@@ -341,14 +383,15 @@
 			bat=gtk.SpinButton(Adj,1,1)
 		baz.pack_start(bar,True,True)
 		baz.pack_start(bat,False,False)
-		SetWid=(bar,bat)
+		SetWid=[bar,bat]
 	elif (setting.Type == 'Color'):
 		foo=gtk.HBox(False,8)
 		foo.pack_start(resbut,False,False)
 		foo.pack_start(gtk.Label(setting.ShortDesc),False,False)
 		bar=gtk.ColorButton()
+		bar.props.use_alpha=True
 		foo.pack_end(bar,False,False)
-		SetWid=(bar)
+		SetWid=[bar]
 	else:
 		return False
 	wid.pack_start(foo,False,False)




More information about the commits mailing list