Commit 764ea6af authored by Fabián Orccón's avatar Fabián Orccón Committed by Alexandru Băluț

widgets: Remove usage of deprecated Gdk.Color and unused types in ColorWidget

parent 817d885a
......@@ -188,10 +188,10 @@ class PreferencesDialog(Loggable):
def addColorPreference(cls, attrname, label, description, section=None, value_type=int):
def addColorPreference(cls, attrname, label, description, section=None):
"""Adds a user preference for a color."""
cls._add_preference(attrname, label, description, section,
widgets.ColorWidget, value_type=value_type)
def addFontPreference(cls, attrname, label, description, section=None):
......@@ -446,9 +446,7 @@ class PreferencesDialog(Loggable):
# convert the value of the widget to whatever type it is currently
if value is not None:
value = type(value)(real_widget.getWidgetValue())
value = real_widget.getWidgetValue()
setattr(self.settings, attrname, value)
# adjust controls as appropriate
......@@ -555,42 +555,18 @@ class PathWidget(Gtk.FileChooserButton, DynamicWidget):
class ColorWidget(Gtk.ColorButton, DynamicWidget):
def __init__(self, value_type=str, default=None):
def __init__(self, default=None):
DynamicWidget.__init__(self, default)
self.value_type = value_type
def connectValueChanged(self, callback, *args):
self.connect("color-set", callback, *args)
def setWidgetValue(self, value):
type_ = type(value)
alpha = 0xFFFF
if type_ is str:
color = Gdk.Color(value)
elif (type_ is int) or (type_ is int):
red, green, blue, alpha = unpack_color(value)
color = Gdk.Color(red, green, blue)
elif type_ is Gdk.Color:
color = value
raise TypeError("%r is not something we can convert to a color" %
def getWidgetValue(self):
color = self.get_color()
alpha = self.get_alpha()
if self.value_type is int:
return pack_color_32(,,, alpha)
if self.value_type is int:
return pack_color_64(,,, alpha)
elif self.value_type is Gdk.Color:
return color
return color.to_string()
return self.get_rgba()
class FontWidget(Gtk.FontButton, DynamicWidget):
......@@ -16,6 +16,7 @@
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
# Boston, MA 02110-1301, USA.
from gi.repository import Gdk
from gi.repository import Gst
from pitivi.utils.widgets import ChoiceWidget
......@@ -41,7 +42,7 @@ class TestWidgets(common.TestCase):
("banana", "banana"),
("apple", "apple"),
("pear", "pear")),)),
(ColorWidget, 0x336699FF, (int,)),
(ColorWidget, Gdk.RGBA(0.5, 0.5, 0.3, 0.8), ()),
(FontWidget, "Sans 9", ()))
for widget_class, default, args in widgets:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment