Add import capability to SVGdraw.py
This commit is contained in:
+17
-13
@@ -1,11 +1,15 @@
|
||||
# -*- tab-width: 4; indent-tabs-mode: t -*-
|
||||
|
||||
import string
|
||||
|
||||
import gc
|
||||
import dbus
|
||||
import dbus.service
|
||||
import dbus.glib
|
||||
import gobject
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
import gtk,sys
|
||||
|
||||
|
||||
class Activity(dbus.service.Object):
|
||||
@@ -32,21 +36,21 @@ class Activity(dbus.service.Object):
|
||||
"com.redhat.Sugar.Shell.ActivityContainer")
|
||||
|
||||
self.__activity_id = self.__activity_container.add_activity("")
|
||||
self.__object_path = "/com/redhat/Sugar/Shell/Activities/%d" % self.__activity_id
|
||||
self.__object_path = "/com/redhat/Sugar/Shell/Activities/%d"%self.__activity_id
|
||||
|
||||
print "object_path = %s" % self.__object_path
|
||||
print "object_path = %s"%self.__object_path
|
||||
|
||||
self.__activity_object = dbus.Interface(self.__bus.get_object("com.redhat.Sugar.Shell", self.__object_path), \
|
||||
"com.redhat.Sugar.Shell.ActivityHost")
|
||||
self.__window_id = self.__activity_object.get_host_xembed_id()
|
||||
|
||||
print "XEMBED window_id = %d" % self.__window_id
|
||||
print "XEMBED window_id = %d"%self.__window_id
|
||||
|
||||
self.__plug = gtk.Plug(self.__window_id)
|
||||
|
||||
# Now let the Activity register a peer service so the Shell can poke it
|
||||
self.__peer_service_name = "com.redhat.Sugar.Activity%d" % self.__activity_id
|
||||
self.__peer_object_name = "/com/redhat/Sugar/Activity/%d" % self.__activity_id
|
||||
self.__peer_service_name = "com.redhat.Sugar.Activity%d"%self.__activity_id
|
||||
self.__peer_object_name = "/com/redhat/Sugar/Activity/%d"%self.__activity_id
|
||||
self.__service = dbus.service.BusName(self.__peer_service_name, bus=self.__bus)
|
||||
dbus.service.Object.__init__(self, self.__service, self.__peer_object_name)
|
||||
|
||||
@@ -82,7 +86,7 @@ class Activity(dbus.service.Object):
|
||||
pixarray = []
|
||||
pixstr = pixbuf.get_pixels();
|
||||
for c in pixstr:
|
||||
pixarray.append(c)
|
||||
pixarray.append(c)
|
||||
self.__activity_object.set_tab_icon(pixarray, \
|
||||
pixbuf.get_colorspace(), \
|
||||
pixbuf.get_has_alpha(), \
|
||||
@@ -159,16 +163,16 @@ class Activity(dbus.service.Object):
|
||||
# pure virtual methods
|
||||
|
||||
def activity_on_connected_to_shell(self):
|
||||
print "act %d: you need to override activity_on_connected_to_shell" % self.activity_get_id()
|
||||
print "act %d: you need to override activity_on_connected_to_shell"%self.activity_get_id()
|
||||
|
||||
def activity_on_disconnected_from_shell(self):
|
||||
print "act %d: you need to override activity_on_disconnected_from_shell" % self.activity_get_id()
|
||||
|
||||
print "act %d: you need to override activity_on_disconnected_from_shell"%self.activity_get_id()
|
||||
|
||||
def activity_on_close_from_user(self):
|
||||
print "act %d: you need to override activity_on_close_from_user" % self.activity_get_id()
|
||||
print "act %d: you need to override activity_on_close_from_user"%self.activity_get_id()
|
||||
|
||||
def activity_on_lost_focus(self):
|
||||
print "act %d: you need to override activity_on_lost_focus" % self.activity_get_id()
|
||||
print "act %d: you need to override activity_on_lost_focus"%self.activity_get_id()
|
||||
|
||||
def activity_on_got_focus(self):
|
||||
print "act %d: you need to override activity_on_got_focus" % self.activity_get_id()
|
||||
print "act %d: you need to override activity_on_got_focus"%self.activity_get_id()
|
||||
|
||||
+14
-10
@@ -1,9 +1,12 @@
|
||||
#!/usr/bin/python
|
||||
# -*- tab-width: 4; indent-tabs-mode: t -*-
|
||||
|
||||
import string
|
||||
|
||||
import dbus
|
||||
import dbus.service
|
||||
import dbus.glib
|
||||
import gobject
|
||||
import pygtk
|
||||
pygtk.require('2.0')
|
||||
import gtk
|
||||
@@ -24,7 +27,7 @@ class ActivityHost(dbus.service.Object):
|
||||
self.activity_id = activity_counter
|
||||
activity_counter += 1
|
||||
|
||||
self.dbus_object_name = "/com/redhat/Sugar/Shell/Activities/%d" % self.activity_id
|
||||
self.dbus_object_name = "/com/redhat/Sugar/Shell/Activities/%d"%self.activity_id
|
||||
#print "object name = %s"%self.dbus_object_name
|
||||
|
||||
dbus.service.Object.__init__(self, activity_container.service, self.dbus_object_name)
|
||||
@@ -140,7 +143,7 @@ class ActivityHost(dbus.service.Object):
|
||||
#print " data = ", data
|
||||
pixstr = ""
|
||||
for c in data:
|
||||
pixstr += chr(c)
|
||||
pixstr += chr(c)
|
||||
|
||||
pixbuf = gtk.gdk.pixbuf_new_from_data(pixstr, colorspace, has_alpha, bits_per_sample, width, height, rowstride)
|
||||
#print pixbuf
|
||||
@@ -222,11 +225,10 @@ class ActivityContainer(dbus.service.Object):
|
||||
self.window.add(self.notebook)
|
||||
|
||||
self.window.connect("destroy", lambda w: gtk.main_quit())
|
||||
self.window.show()
|
||||
|
||||
self.current_activity = None
|
||||
|
||||
def show(self):
|
||||
self.window.show()
|
||||
|
||||
def __focus_reply_cb(self):
|
||||
pass
|
||||
@@ -281,10 +283,10 @@ class ActivityContainer(dbus.service.Object):
|
||||
return activity.get_host_activity_id()
|
||||
|
||||
def __print_activities(self):
|
||||
print "__print_activities: %d activities registered" % len(self.activities)
|
||||
print "__print_activities: %d activities registered"%len(self.activities)
|
||||
i = 0
|
||||
for owner, activity in self.activities:
|
||||
print " %d: owner=%s activity_object_name=%s" % (i, owner, activity.dbus_object_name)
|
||||
print " %d: owner=%s activity_object_name=%s"%(i, owner, activity.dbus_object_name)
|
||||
i += 1
|
||||
|
||||
|
||||
@@ -293,9 +295,11 @@ def main():
|
||||
service = dbus.service.BusName("com.redhat.Sugar.Shell", bus=session_bus)
|
||||
|
||||
activityContainer = ActivityContainer(service, session_bus)
|
||||
activityContainer.show()
|
||||
|
||||
gtk.main()
|
||||
try:
|
||||
gtk.main()
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
if __name__=="__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user