Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell
diff options
context:
space:
mode:
authorEduardo Silva <edsiper@tuto.(none)>2007-01-07 17:23:53 (GMT)
committer Eduardo Silva <edsiper@tuto.(none)>2007-01-07 17:23:53 (GMT)
commitaad2893f62ca67312bf57d2c5468c5fc24c60f06 (patch)
treec304ea90cce37c18bf24d2cc2288e365d9bf054a /shell
parentf50d9f5f9a972f7149c4a57f225e00d7e48834c6 (diff)
[devconsole] - Starting like a dbus service, just open it one time
Diffstat (limited to 'shell')
-rwxr-xr-xshell/console/console.py36
1 files changed, 32 insertions, 4 deletions
diff --git a/shell/console/console.py b/shell/console/console.py
index e1366e3..c05e4bd 100755
--- a/shell/console/console.py
+++ b/shell/console/console.py
@@ -16,13 +16,23 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import sys, os
+import dbus
+import dbus.service
+import os
+import sys
import gtk
+import gobject
sys.path.append(os.path.dirname(__file__) + '/lib')
sys.path.append(os.path.dirname(__file__) + '/interface')
+DBUS_BUS = 'org.freedesktop.DBus'
+DBUS_PATH = '/org/freedesktop/DBus'
+
+CONSOLE_BUS = 'org.laptop.Sugar.DeveloperConsole'
+CONSOLE_PATH = '/org/laptop/Sugar/DeveloperConsole'
+CONSOLE_IFACE = 'org.laptop.Sugar.DeveloperConsole'
+
class Console:
def __init__(self):
@@ -95,6 +105,24 @@ class Console:
self.mini_fixed.show_all()
return True
+# We're using a DBUS-Service to avoid open devconsole more than one time
+class Init_Service(dbus.service.Object):
-CS = Console()
-gtk.main()
+ def __init__(self, bus, object_path=CONSOLE_PATH):
+ dbus.service.Object.__init__(self, bus, object_path)
+ CS = Console()
+
+bus = dbus.SessionBus()
+obj = bus.get_object(DBUS_BUS, DBUS_PATH)
+
+dbus_iface = dbus.Interface(obj, DBUS_BUS)
+services = dbus_iface.ListNames()
+
+# A temporal way to check if the service is running
+if not CONSOLE_BUS in services:
+ name = dbus.service.BusName(CONSOLE_BUS, bus)
+ obj = Init_Service(name)
+ gtk.main()
+else:
+ sys.exit(1)
+ \ No newline at end of file