diff options
author | Marco Pesenti Gritti <mpg@redhat.com> | 2006-06-14 19:01:17 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <mpg@redhat.com> | 2006-06-14 19:01:17 (GMT) |
commit | 3ea146e17c8f1679d58fbc38b06734851673d9f9 (patch) | |
tree | e751a03808e0c4bd7ac26b50a74b05e81d5ec481 /sugar | |
parent | 4a7aac0e01127d8b7c8d84170980df3c5988d556 (diff) |
Initial start page implementation
Diffstat (limited to 'sugar')
-rw-r--r-- | sugar/presence/Buddy.py | 1 | ||||
-rw-r--r-- | sugar/shell/StartPage.py | 80 | ||||
-rwxr-xr-x | sugar/shell/shell.py | 9 | ||||
-rwxr-xr-x | sugar/sugar | 9 |
4 files changed, 91 insertions, 8 deletions
diff --git a/sugar/presence/Buddy.py b/sugar/presence/Buddy.py index 9d94b9d..cc6be57 100644 --- a/sugar/presence/Buddy.py +++ b/sugar/presence/Buddy.py @@ -79,6 +79,7 @@ class Buddy(gobject.GObject): # A buddy isn't valid until its official presence # service has been found and resolved self._valid = True + print 'Requesting buddy icon %s' % self._nick_name self._request_buddy_icon(service) return True diff --git a/sugar/shell/StartPage.py b/sugar/shell/StartPage.py new file mode 100644 index 0000000..1c87ee5 --- /dev/null +++ b/sugar/shell/StartPage.py @@ -0,0 +1,80 @@ +import pygtk +pygtk.require('2.0') +import gtk +import dbus + +import google + +class ActivitiesModel(gtk.ListStore): + def __init__(self): + gtk.ListStore.__init__(self, str, str) + + def add_web_page(self, title, address): + self.append([ title, address ]) + +class ActivitiesView(gtk.TreeView): + def __init__(self, model): + gtk.TreeView.__init__(self, model) + + self.set_headers_visible(False) + + column = gtk.TreeViewColumn('') + self.append_column(column) + + cell = gtk.CellRendererText() + column.pack_start(cell, True) + column.add_attribute(cell, 'text', 0) + + self.connect('row-activated', self._row_activated_cb) + + def _row_activated_cb(self, treeview, path, column): + bus = dbus.SessionBus() + proxy_obj = bus.get_object('com.redhat.Sugar.Browser', '/com/redhat/Sugar/Browser') + browser_shell = dbus.Interface(proxy_obj, 'com.redhat.Sugar.BrowserShell') + + model = self.get_model() + address = model.get_value(model.get_iter(path), 1) + browser_shell.open_browser(address) + +class StartPage(gtk.HBox): + def __init__(self): + gtk.HBox.__init__(self) + + vbox = gtk.VBox() + + search_box = gtk.HBox(False, 6) + search_box.set_border_width(24) + + self._search_entry = gtk.Entry() + search_box.pack_start(self._search_entry) + self._search_entry.show() + + search_button = gtk.Button("Search") + search_button.connect('clicked', self._search_button_clicked_cb) + search_box.pack_start(search_button, False) + search_button.show() + + vbox.pack_start(search_box, False, True) + search_box.show() + + exp_space = gtk.Label('') + vbox.pack_start(exp_space) + exp_space.show() + + self.pack_start(vbox) + vbox.show() + + self._activities_model = ActivitiesModel() + + activities = ActivitiesView(self._activities_model) + self.pack_start(activities) + activities.show() + + def _search_button_clicked_cb(self, button): + self.search(self._search_entry.get_text()) + + def search(self, text): + google.LICENSE_KEY = '1As9KaJQFHIJ1L0W5EZPl6vBOFvh/Vaf' + data = google.doGoogleSearch(text) + for result in data.results: + self._activities_model.add_web_page(result.title, result.URL) diff --git a/sugar/shell/shell.py b/sugar/shell/shell.py index aaf1569..12a3396 100755 --- a/sugar/shell/shell.py +++ b/sugar/shell/shell.py @@ -10,6 +10,7 @@ import pango import sugar.util from sugar.shell.PresenceWindow import PresenceWindow from sugar.shell.Owner import ShellOwner +from sugar.shell.StartPage import StartPage class ActivityHost(dbus.service.Object): @@ -226,10 +227,10 @@ class ActivityContainer(dbus.service.Object): self.window.set_geometry_hints(min_width = 640, max_width = 640, min_height = 480, max_height = 480) self.notebook = gtk.Notebook() - #tab_label = gtk.Label("My Laptop") - #empty_label = gtk.Label("This activity could launch other activities / be a help page") - #empty_label.show() - #self.notebook.append_page(empty_label, tab_label) + tab_label = gtk.Label("Everyone") + tab_page = StartPage() + self.notebook.append_page(tab_page, tab_label) + tab_page.show() self.notebook.show() self.notebook.connect("switch-page", self.notebook_tab_changed) diff --git a/sugar/sugar b/sugar/sugar index f634089..f90ed4c 100755 --- a/sugar/sugar +++ b/sugar/sugar @@ -7,7 +7,8 @@ import pygtk pygtk.require('2.0') import gobject -def append_to_python_path(path): +def add_to_python_path(path): + sys.path.insert(0, path) if os.environ.has_key('PYTHONPATH'): os.environ['PYTHONPATH'] += ':' + path else: @@ -59,13 +60,13 @@ if os.path.isfile(os.path.join(curdir, '__uninstalled__.py')): print 'Running sugar from current directory...' else: print 'Running sugar from ' + basedir + ' ...' - sys.path.insert(0, basedir) - append_to_python_path(basedir) + add_to_python_path(basedir) + add_to_python_path(os.path.join(basedir, 'cut-n-paste')) console = True else: print 'Running the installed sugar...' -append_to_python_path(os.path.expanduser('~/.sugar/activities')) +add_to_python_path(os.path.expanduser('~/.sugar/activities')) if console: os.environ['SUGAR_USE_CONSOLE'] = 'yes' |