openshot.code team mailing list archive
-
openshot.code team
-
Mailing list archive
-
Message #00014
[Branch ~openshot.code/openshot/main] Rev 509: Applied a patch from Emil to fix bug #767229, Color settings show default colors when re-edit tit...
------------------------------------------------------------
revno: 509
committer: Andy Finch <we.rocked.in79@xxxxxxxxx>
branch nick: openshot
timestamp: Thu 2011-08-18 23:08:34 +0100
message:
Applied a patch from Emil to fix bug #767229, Color settings show default colors when re-edit titles.
modified:
openshot/windows/Titles.py
--
lp:openshot
https://code.launchpad.net/~openshot.code/openshot/main
Your team OpenShot Code is subscribed to branch lp:openshot.
To unsubscribe from this branch go to https://code.launchpad.net/~openshot.code/openshot/main/+edit-subscription
=== modified file 'openshot/windows/Titles.py'
--- openshot/windows/Titles.py 2011-08-16 20:46:41 +0000
+++ openshot/windows/Titles.py 2011-08-18 22:08:34 +0000
@@ -106,6 +106,10 @@
else:
self.filename = self.file
self.load_svg_template(self.file)
+
+ self.update_font_color_button()
+ self.update_background_color_button()
+
#set edit button states
self.btnEditText.set_sensitive(True)
self.btnFont.set_sensitive(True)
@@ -151,6 +155,10 @@
#load the template doc to read xml
self.load_svg_template(self.template_name)
+
+ self.update_font_color_button()
+ self.update_background_color_button()
+
#set the new filename
(fileBaseName, fileExtension)=os.path.splitext(self.template_name)
self.filename = self.filename + fileExtension
@@ -350,16 +358,16 @@
s = self.rect_node[0].attributes["style"].value
ar = s.split(";")
fill = self.find_in_list(ar, "fill:")
- if fill:
+ if fill == None:
+ ar.append("fill:" + color)
+ else:
ar[fill] = "fill:" + color
- else:
- ar.append("fill:" + color)
opacity = self.find_in_list(ar, "opacity:")
- if opacity:
+ if opacity == None:
+ ar.append("opacity:" + str(self.bg_color_alpha))
+ else:
ar[opacity] = "opacity:" + str(self.bg_color_alpha)
- else:
- ar.append("opacity:" + str(self.bg_color_alpha))
#rejoin the modifed parts
t = ";"
@@ -439,16 +447,16 @@
#split the text node so we can access each part
ar = s.split(";")
fill = self.find_in_list(ar, "fill:")
- if fill:
+ if fill == None:
+ ar.append("fill:" + self.font_color_code)
+ else:
ar[fill] = "fill:" + self.font_color_code
- else:
- ar.append("fill:" + self.font_color_code)
opacity = self.find_in_list(ar, "opacity:")
- if opacity:
+ if opacity == None:
+ ar.append("opacity:" + str(self.font_color_alpha))
+ else:
ar[opacity] = "opacity:" + str(self.font_color_alpha)
- else:
- ar.append("opacity:" + str(self.font_color_alpha))
t = ";"
text_child.setAttribute("style", t.join(ar))
@@ -462,10 +470,10 @@
#split the text node so we can access each part
ar = s.split(";")
fill = self.find_in_list(ar, "fill:")
- if fill:
+ if fill == None:
+ ar.append("fill:" + self.font_color_code)
+ else:
ar[fill] = "fill:" + self.font_color_code
- else:
- ar.append("fill:" + self.font_color_code)
t = ";"
tspan_child.setAttribute("style", t.join(ar))
@@ -536,6 +544,97 @@
#set the style element
self.set_font_color()
+
+ def update_font_color_button(self):
+ """Updates the color shown on the font color button"""
+
+ # Loop through each TEXT element
+ for node in self.text_node:
+
+ # Get the value in the style attribute
+ s = node.attributes["style"].value
+
+ # split the node so we can access each part
+ ar = s.split(";")
+ color = self.find_in_list(ar, "fill:")
+
+ try:
+ # Parse the result
+ txt = ar[color]
+ color = gtk.gdk.color_parse(txt[5:])
+ except:
+ # If the color was in an invalid format, try the next text element
+ continue
+
+ opacity = self.find_in_list(ar, "opacity:")
+
+ try:
+ # Parse the result
+ txt = ar[opacity]
+ opacity = float(txt[8:])
+ except:
+ pass
+
+ # Default the font color to white if non-existing
+ if color == None:
+ color = gtk.gdk.color_parse("#FFFFFF")
+
+ # Default the opacity to fully visible if non-existing
+ if opacity == None:
+ opacity = 1.0
+
+ # Set the color value of the button
+ self.btnFontColor.set_color(color)
+
+ # Convert the opacity into the gtk alpha value
+ alpha = int(opacity * 65535.0)
+ # Set the alpha value of the button
+ self.btnFontColor.set_alpha(alpha)
+
+ def update_background_color_button(self):
+ """Updates the color shown on the background color button"""
+
+ if self.rect_node:
+
+ # All backgrounds should be the first (index 0) rect tag in the svg
+ s = self.rect_node[0].attributes["style"].value
+
+ # split the node so we can access each part
+ ar = s.split(";")
+
+ color = self.find_in_list(ar, "fill:")
+
+ try:
+ # Parse the result
+ txt = ar[color]
+ color = gtk.gdk.color_parse(txt[5:])
+ except ValueError:
+ pass
+
+ opacity = self.find_in_list(ar, "opacity:")
+
+ try:
+ # Parse the result
+ txt = ar[opacity]
+ opacity = float(txt[8:])
+ except ValueError:
+ pass
+
+ # Default the background color to black if non-existing
+ if color == None:
+ color = gtk.gdk.color_parse("#000000")
+
+ # Default opacity to fully visible if non-existing
+ if opacity == None:
+ opacity = 1.0
+
+ # Set the color value of the button
+ self.btnBackgroundColor.set_color(color)
+
+ # Convert the opacity into the gtk alpha value
+ alpha = int(opacity * 65535.0)
+ # Set the alpha value of the button
+ self.btnBackgroundColor.set_alpha(alpha)
def on_btnFont_clicked(self, widget):