From 3841ac9983df5e8307ad2aa2ffa89edf7aa23030 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sun, 21 May 2006 21:31:57 -0400 Subject: [PATCH] merge --- configure.ac | 3 +- sugar/browser/Makefile.am | 2 ++ sugar/browser/browser.py | 2 ++ sugar/chat/Makefile.am | 6 +++- sugar/chat/chat.py | 3 ++ sugar/chat/richtext.py | 48 +++++++++++++++++++++++-------- sugar/chat/sketchpad/SketchPad.py | 11 +++++-- sugar/env.py | 3 ++ sugar/session/session.py | 2 +- 9 files changed, 62 insertions(+), 18 deletions(-) diff --git a/configure.ac b/configure.ac index 434bd514..097cc0a5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([Sugar],[0.4],[],[sugar]) +AC_INIT([Sugar],[0.6],[],[sugar]) AC_PREREQ([2.59]) @@ -21,6 +21,7 @@ sugar/Makefile sugar/__installed__.py sugar/browser/Makefile sugar/chat/Makefile +sugar/chat/sketchpad/Makefile sugar/p2p/Makefile sugar/p2p/model/Makefile sugar/shell/Makefile diff --git a/sugar/browser/Makefile.am b/sugar/browser/Makefile.am index 4bf03d2a..7aacdd8a 100644 --- a/sugar/browser/Makefile.am +++ b/sugar/browser/Makefile.am @@ -16,4 +16,6 @@ activitydir = $(pkgdatadir)/activities activity_DATA = browser.activity EXTRA_DIST = \ + $(rc_DATA) \ + $(activity_DATA) \ $(icon_DATA) diff --git a/sugar/browser/browser.py b/sugar/browser/browser.py index cec6e096..1bc61608 100755 --- a/sugar/browser/browser.py +++ b/sugar/browser/browser.py @@ -322,6 +322,8 @@ class BrowserShell(dbus.service.Object): get_instance = staticmethod(get_instance) def __init__(self): + geckoembed.set_profile_path(sugar.env.get_user_dir()) + session_bus = dbus.SessionBus() bus_name = dbus.service.BusName('com.redhat.Sugar.Browser', bus=session_bus) object_path = '/com/redhat/Sugar/Browser' diff --git a/sugar/chat/Makefile.am b/sugar/chat/Makefile.am index 4197815e..c43ba873 100644 --- a/sugar/chat/Makefile.am +++ b/sugar/chat/Makefile.am @@ -1,3 +1,5 @@ +SUBDIRS = sketchpad + sugardir = $(pythondir)/sugar/chat sugar_PYTHON = \ __init__.py \ @@ -12,4 +14,6 @@ icon_DATA = \ activitydir = $(pkgdatadir)/activities activity_DATA = chat.activity -EXTRA_DIST = $(icon_DATA) +EXTRA_DIST = \ + $(icon_DATA) \ + $(activity_DATA) diff --git a/sugar/chat/chat.py b/sugar/chat/chat.py index d7bc85d0..95cedc3f 100755 --- a/sugar/chat/chat.py +++ b/sugar/chat/chat.py @@ -20,6 +20,7 @@ from sugar.p2p.Stream import Stream from sugar.session.LogWriter import LogWriter from sugar.chat.sketchpad.Toolbox import Toolbox from sugar.chat.sketchpad.SketchPad import SketchPad +from sugar.chat.Emoticons import Emoticons import sugar.env import richtext @@ -197,6 +198,8 @@ class Chat(activity.Activity): # FIXME self._controller.notify_activate(self) def _insert_rich_message(self, nick, msg): + msg = Emoticons.get_instance().replace(msg) + buf = self._chat_view.get_buffer() aniter = buf.get_end_iter() buf.insert(aniter, nick + ": ") diff --git a/sugar/chat/richtext.py b/sugar/chat/richtext.py index 543e431e..5aa44f7c 100644 --- a/sugar/chat/richtext.py +++ b/sugar/chat/richtext.py @@ -59,7 +59,7 @@ class RichTextView(gtk.TextView): it = self.__get_event_iter(event) if it and self.__iter_is_link(it): buf = self.get_buffer() - address_tag = buf.get_tag_table().lookup("link-address") + address_tag = buf.get_tag_table().lookup("object-id") address_end = it.copy() address_end.backward_to_tag_toggle(address_tag) @@ -81,9 +81,18 @@ class RichTextBuffer(gtk.TextBuffer): def append_link(self, title, address): it = self.get_iter_at_mark(self.get_insert()) - self.insert_with_tags_by_name(it, address, "link", "link-address") + self.insert_with_tags_by_name(it, address, "link", "object-id") self.insert_with_tags_by_name(it, title, "link") - + + def append_icon(self, name, it = None): + if not it: + it = self.get_iter_at_mark(self.get_insert()) + + self.insert_with_tags_by_name(it, name, "icon", "object-id") + icon_theme = gtk.icon_theme_get_default() + pixbuf = icon_theme.load_icon(name, 16, 0) + self.insert_pixbuf(it, pixbuf) + def apply_tag(self, tag_name): self.active_tags.append(tag_name) @@ -101,11 +110,13 @@ class RichTextBuffer(gtk.TextBuffer): self.remove_tag_by_name(tag_name, start, end) def __create_tags(self): + tag = self.create_tag("icon") + tag = self.create_tag("link") tag.set_property("underline", pango.UNDERLINE_SINGLE) tag.set_property("foreground", "#0000FF") - tag = self.create_tag("link-address") + tag = self.create_tag("object-id") tag.set_property("invisible", True) tag = self.create_tag("bold") @@ -224,6 +235,8 @@ class RichTextHandler(xml.sax.handler.ContentHandler): self.tags.append(tag) if name == "link": self.href = attrs['href'] + elif name == "icon": + self.buf.append_icon(attrs['name'], self.buf.get_end_iter()) def characters(self, data): start_it = it = self.buf.get_end_iter() @@ -235,8 +248,8 @@ class RichTextHandler(xml.sax.handler.ContentHandler): self.buf.apply_tag_by_name(tag, start_it, it) if tag == "link": self.buf.insert_with_tags_by_name(start_it, self.href, - "link", "link-address") - + "link", "object-id") + def endElement(self, name): if not self._done and self._in_richtext: if name != "richtext": @@ -258,9 +271,17 @@ class RichTextSerializer: return "font-size-" + attributes["size"] elif el_name == "link": return "link" + elif el_name == "icon": + return "icon" else: return None + def _parse_object_id(self, it): + object_id_tag = self.buf.get_tag_table().lookup("object-id") + end = it.copy() + end.forward_to_tag_toggle(object_id_tag) + return self.buf.get_text(it, end) + def serialize_tag_start(self, tag, it): name = tag.get_property("name") if name == "bold": @@ -268,12 +289,12 @@ class RichTextSerializer: elif name == "italic": return "" elif name == "link": - address_tag = self.buf.get_tag_table().lookup("link-address") - end = it.copy() - end.forward_to_tag_toggle(address_tag) - address = self.buf.get_text(it, end) + address = self._parse_object_id(it) return "" - elif name == "link-address": + elif name == "icon": + name = self._parse_object_id(it) + return "" + elif name == "object-id": return "" elif name.startswith("font-size-"): tag_name = name.replace("font-size-", "", 1) @@ -289,7 +310,9 @@ class RichTextSerializer: return "" elif name == "link": return "" - elif name == "link-address": + elif name == "icon": + return "" + elif name == "object-id": return "" elif name.startswith("font-size-"): return "" @@ -369,6 +392,7 @@ if __name__ == "__main__": test_xml += "Test two" test_xml += "Test three" test_xml += "Test link" + test_xml += "" test_xml += "" RichTextSerializer().deserialize(test_xml, rich_buf) diff --git a/sugar/chat/sketchpad/SketchPad.py b/sugar/chat/sketchpad/SketchPad.py index 150b6fbb..d19ca401 100644 --- a/sugar/chat/sketchpad/SketchPad.py +++ b/sugar/chat/sketchpad/SketchPad.py @@ -48,17 +48,22 @@ class SketchPad(gtk.DrawingArea): def add_sketch(self, sketch): self._sketches.append(sketch) + def add_point(self, event): + if self._active_sketch: + self._active_sketch.add_point(event.x, event.y) + self.window.invalidate_rect(None, False) + def __button_press_cb(self, widget, event): self._active_sketch = Sketch(self._rgb) self.add_sketch(self._active_sketch) + self.add_point(event) def __button_release_cb(self, widget, event): + self.add_point(event) self._active_sketch = None def __motion_notify_cb(self, widget, event): - if self._active_sketch: - self._active_sketch.add_point(event.x, event.y) - self.window.invalidate_rect(None, False) + self.add_point(event) def to_svg(self): """Return a string containing an SVG representation of this sketch.""" diff --git a/sugar/env.py b/sugar/env.py index 9359409b..ffea539a 100644 --- a/sugar/env.py +++ b/sugar/env.py @@ -4,6 +4,9 @@ try: from sugar.__uninstalled__ import * except ImportError: from sugar.__installed__ import * + +def get_user_dir(): + return os.path.expanduser('~/.sugar/') def get_data_file(filename): for data_dir in get_data_dirs(): diff --git a/sugar/session/session.py b/sugar/session/session.py index df0a0db4..4d57a208 100644 --- a/sugar/session/session.py +++ b/sugar/session/session.py @@ -20,7 +20,7 @@ def start(console): act_dir = os.path.join(data_dir, env.get_activities_dir()) activities_dirs.append(act_dir) - activities_dirs.append(os.path.expanduser('~/.sugar/activities')) + activities_dirs.append(os.path.join(env.get_user_dir(), 'activities')) for activities_dir in activities_dirs: if os.path.isdir(activities_dir):