From 189494c47acad1938b2b9c2e2cc5269c2b4d1ad8 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sun, 13 Feb 2011 01:25:43 +0000 Subject: moved turtle-specific code out of collaboration plugin --- diff --git a/extra/collaborationplugin.py b/extra/collaborationplugin.py index 28ff700..75b2d2a 100644 --- a/extra/collaborationplugin.py +++ b/extra/collaborationplugin.py @@ -39,7 +39,6 @@ from collaboration import telepathyclient from collaboration.tubeconn import TubeConnection import traceback from TurtleArt.tacollaboration import Collaboration -from TurtleArt.taconstants import DEFAULT_TURTLE_COLORS CONNECTION_INTERFACE_ACTIVITY_PROPERTIES = \ 'org.laptop.Telepathy.ActivityProperties' @@ -157,19 +156,13 @@ class CollaborationPlugin(Plugin): raise RuntimeError("Invalid server address") self._nick = self._collaboration_config_values.get("nick") + # Tell the parent activity that the nick may have changed + self._activity.nick_changed(self._nick) + self._colors = self._collaboration_config_values.get("colors") + # Tell the parent activity that the colors may have changed + self._activity.color_changed(self._colors) - # Reskin turtle with collaboration colors - default_turtle = self._activity.tw.turtles.get_turtle( - self._activity.tw.default_turtle_name) - try: - default_turtle.colors = self._colors.split(',') - except: - default_turtle.colors = DEFAULT_TURTLE_COLORS - default_turtle.custom_shapes = True # Force regeneration of shapes - default_turtle.reset_shapes() - default_turtle.show() - self._activities = {} self._buddies = {} diff --git a/turtleart.py b/turtleart.py index 10820d3..9aeaed7 100755 --- a/turtleart.py +++ b/turtleart.py @@ -45,7 +45,7 @@ sys.argv[1:] = [] # Execution of import gst cannot see '--help' or '-h' from gettext import gettext as _ -from TurtleArt.taconstants import OVERLAY_LAYER +from TurtleArt.taconstants import OVERLAY_LAYER, DEFAULT_TURTLE_COLORS from TurtleArt.tautils import data_to_string, data_from_string, get_save_name from TurtleArt.tawindow import TurtleArtWindow from TurtleArt.taexporthtml import save_html @@ -545,5 +545,20 @@ class TurtleMain(): """ Callback for destroy event. """ gtk.main_quit() + def nick_changed(self, nick): + pass + + def color_changed(self, colors): + """ Reskin turtle with collaboration colors """ + turtle = self.tw.turtles.get_turtle(self.tw.default_turtle_name) + try: + turtle.colors = colors.split(',') + except: + turtle.colors = DEFAULT_TURTLE_COLORS + turtle.custom_shapes = True # Force regeneration of shapes + turtle.reset_shapes() + turtle.show() + + if __name__ == "__main__": TurtleMain() -- cgit v0.9.1