2006-04-19 19:32:26 +02:00
|
|
|
#!/usr/bin/python
|
2006-04-21 20:02:54 +02:00
|
|
|
# -*- tab-width: 4; indent-tabs-mode: t -*-
|
2006-04-19 19:32:26 +02:00
|
|
|
|
|
|
|
import string
|
|
|
|
|
2006-04-21 19:32:03 +02:00
|
|
|
import gc
|
2006-04-19 19:32:26 +02:00
|
|
|
import dbus
|
|
|
|
import dbus.service
|
|
|
|
import dbus.glib
|
|
|
|
import gobject
|
|
|
|
import pygtk
|
|
|
|
pygtk.require('2.0')
|
|
|
|
import gtk,sys
|
|
|
|
|
2006-04-21 22:08:36 +02:00
|
|
|
import activity
|
2006-04-21 02:37:03 +02:00
|
|
|
|
|
|
|
def my_exit():
|
2006-04-21 20:02:54 +02:00
|
|
|
sys.exit(0)
|
2006-04-21 02:37:03 +02:00
|
|
|
|
|
|
|
def deferred_exit():
|
2006-04-21 20:02:54 +02:00
|
|
|
gobject.timeout_add(0, my_exit)
|
2006-04-21 02:37:03 +02:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
2006-04-21 22:08:36 +02:00
|
|
|
class ExampleActivity(activity.Activity):
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
def __init__(self, name):
|
|
|
|
self.name = name
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
def entry_changed(self, entry):
|
|
|
|
self.activity_set_tab_text(entry.get_text())
|
|
|
|
|
|
|
|
def activity_on_connected_to_shell(self):
|
|
|
|
print "act %d: in activity_on_connected_to_shell"%self.activity_get_id()
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
self.activity_set_tab_text(self.name)
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
plug = self.activity_get_gtk_plug()
|
|
|
|
self.entry = gtk.Entry()
|
|
|
|
self.entry.set_text(self.name)
|
|
|
|
self.entry.connect("changed", self.entry_changed)
|
|
|
|
plug.add(self.entry)
|
|
|
|
plug.show_all()
|
2006-04-21 19:32:03 +02:00
|
|
|
|
2006-04-26 18:25:40 +02:00
|
|
|
icon_theme = gtk.icon_theme_get_default()
|
|
|
|
pixbuf = icon_theme.load_icon("gnome-dev-cdrom", gtk.ICON_SIZE_MENU, gtk.ICON_LOOKUP_USE_BUILTIN)
|
|
|
|
self.activity_set_icon(pixbuf)
|
|
|
|
self.activity_show_icon(True)
|
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
def activity_on_disconnected_from_shell(self):
|
|
|
|
print "act %d: in activity_on_disconnected_from_shell"%self.activity_get_id()
|
|
|
|
print "act %d: Shell disappeared..."%self.activity_get_id()
|
2006-04-21 19:32:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
gc.collect()
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
def activity_on_close_from_user(self):
|
|
|
|
print "act %d: in activity_on_close_from_user"%self.activity_get_id()
|
|
|
|
self.activity_shutdown()
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
def activity_on_lost_focus(self):
|
|
|
|
print "act %d: in activity_on_lost_focus"%self.activity_get_id()
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
def activity_on_got_focus(self):
|
|
|
|
print "act %d: in activity_on_got_focus"%self.activity_get_id()
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-21 20:02:54 +02:00
|
|
|
def __del__(self):
|
|
|
|
print "in __del__ for ExampleActivity"
|
2006-04-21 19:32:03 +02:00
|
|
|
|
2006-04-21 02:37:03 +02:00
|
|
|
|
2006-04-19 19:32:26 +02:00
|
|
|
if len(sys.argv) != 2:
|
2006-04-21 20:02:54 +02:00
|
|
|
print "usage: example-activity.py <name_of_activity>"
|
|
|
|
sys.exit(1)
|
2006-04-19 19:32:26 +02:00
|
|
|
|
2006-04-21 19:32:03 +02:00
|
|
|
gc.set_debug(gc.DEBUG_LEAK)
|
|
|
|
|
2006-04-21 02:37:03 +02:00
|
|
|
example_activity = ExampleActivity(sys.argv[1])
|
|
|
|
example_activity.activity_connect_to_shell()
|
2006-04-21 19:32:03 +02:00
|
|
|
example_activity = None
|
2006-04-19 19:32:26 +02:00
|
|
|
|
|
|
|
gtk.main()
|
|
|
|
|
|
|
|
|