gimmie r667 - in trunk: . data data/awn gimmie po



Author: orph
Date: Thu Feb  7 21:48:26 2008
New Revision: 667
URL: http://svn.gnome.org/viewvc/gimmie?rev=667&view=rev

Log:
2008-02-07  Alex Graveley  <alex beatniksoftware com>

	* data/awn/gimmie_*.desktop.in: Add .desktop templates that get
	processed by the makefile and installed into 
	
	* data/awn/Makefile.am (desktop_DATA): Install .desktop files
	representing the 4 topic plugins for Awn.

	* gimmie/gimmie_library.py:
	* gimmie/gimmie_computer.py:
	* gimmie/gimmie_applications.py:
	* gimmie/gimmie_people.py: Allow running these as the main 
	Python entry point, and assume we're running as an Awn applet
	for now.

	* gimmie/Makefile.am (gimmie_SCRIPTS): Add the Awn applet
	launchers as SCRIPTS, so they are chmod'd executable at install.

	* gimmie/gimmie_awn.py: New file provides the guts for Awn applet
	functionality.  Basically a copy of gimmie_applet.py, but altered
	to allow the TopicView subclass to be inserted in an
	AppletDialog.  Still really buggy.



Added:
   trunk/data/awn/
   trunk/data/awn/Makefile.am
   trunk/data/awn/gimmie_computer.desktop.in.in
   trunk/data/awn/gimmie_library.desktop.in.in
   trunk/data/awn/gimmie_people.desktop.in.in
   trunk/data/awn/gimmie_programs.desktop.in.in
   trunk/gimmie/gimmie_awn.py
Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/data/Makefile.am
   trunk/gimmie/Makefile.am
   trunk/gimmie/gimmie_applications.py
   trunk/gimmie/gimmie_computer.py
   trunk/gimmie/gimmie_library.py
   trunk/gimmie/gimmie_people.py
   trunk/po/POTFILES.in

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Thu Feb  7 21:48:26 2008
@@ -115,6 +115,7 @@
 AC_OUTPUT([
 Makefile
 data/Makefile
+data/awn/Makefile
 data/images/Makefile
 gimmie/Makefile
 gimmie/gimmie_globals.py

Modified: trunk/data/Makefile.am
==============================================================================
--- trunk/data/Makefile.am	(original)
+++ trunk/data/Makefile.am	Thu Feb  7 21:48:26 2008
@@ -1,5 +1,5 @@
 
-SUBDIRS = images
+SUBDIRS = awn images
 
 
 serverdir       = $(PANELAPPLET_SERVER_DIR)

Added: trunk/data/awn/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/data/awn/Makefile.am	Thu Feb  7 21:48:26 2008
@@ -0,0 +1,15 @@
+
+ INTLTOOL_DESKTOP_RULE@
+
+desktopdir = $(libdir)/awn/applets
+desktop_DATA =			\
+	gimmie_computer.desktop	\
+	gimmie_programs.desktop \
+	gimmie_library.desktop	\
+	gimmie_people.desktop
+
+%.desktop.in: %.desktop.in.in
+	sed -e "s|\ pyexecdir\@|$(pyexecdir)|g" $< > $@
+
+EXTRA_DIST = $(desktop_DATA:.desktop=.desktop.in.in)
+CLEANFILES = $(desktop_DATA) $(desktop_DATA:.desktop=.desktop.in)

Added: trunk/data/awn/gimmie_computer.desktop.in.in
==============================================================================
--- (empty file)
+++ trunk/data/awn/gimmie_computer.desktop.in.in	Thu Feb  7 21:48:26 2008
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Type=Application
+X-AWN-AppletType=Python
+X-AWN-AppletCategory=System
+Encoding=UTF-8
+Name=Gimmie Linux
+Comment=Quick access to system tasks, devices and settings
+Exec= pyexecdir@/gimmie/gimmie_computer.py
+Icon=computer

Added: trunk/data/awn/gimmie_library.desktop.in.in
==============================================================================
--- (empty file)
+++ trunk/data/awn/gimmie_library.desktop.in.in	Thu Feb  7 21:48:26 2008
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Type=Application
+X-AWN-AppletType=Python
+X-AWN-AppletCategory=System
+Encoding=UTF-8
+Name=Gimmie Library
+Comment=Quick access to downloads, attachments, and recent documents
+Exec= pyexecdir@/gimmie/gimmie_library.py
+Icon=stock_new-template

Added: trunk/data/awn/gimmie_people.desktop.in.in
==============================================================================
--- (empty file)
+++ trunk/data/awn/gimmie_people.desktop.in.in	Thu Feb  7 21:48:26 2008
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Type=Application
+X-AWN-AppletType=Python
+X-AWN-AppletCategory=System
+Encoding=UTF-8
+Name=Gimmie People
+Comment=Quick access to Email & IM contacts
+Exec= pyexecdir@/gimmie/gimmie_people.py
+Icon=stock_people

Added: trunk/data/awn/gimmie_programs.desktop.in.in
==============================================================================
--- (empty file)
+++ trunk/data/awn/gimmie_programs.desktop.in.in	Thu Feb  7 21:48:26 2008
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Type=Application
+X-AWN-AppletType=Python
+X-AWN-AppletCategory=System
+Encoding=UTF-8
+Name=Gimmie Programs
+Comment=Quick access to programs
+Exec= pyexecdir@/gimmie/gimmie_applications.py
+Icon=gnome-main-menu

Modified: trunk/gimmie/Makefile.am
==============================================================================
--- trunk/gimmie/Makefile.am	(original)
+++ trunk/gimmie/Makefile.am	Thu Feb  7 21:48:26 2008
@@ -19,6 +19,13 @@
 	chmod a+x $@
 
 gimmiedir = $(pyexecdir)/gimmie
+
+gimmie_SCRIPTS = 		\
+	gimmie_applications.py	\
+	gimmie_computer.py	\
+	gimmie_library.py	\
+	gimmie_people.py
+
 gimmie_PYTHON = 		\
 	__init__.py		\
 	\
@@ -31,10 +38,9 @@
 	\
 	gimmie.py		\
 	gimmie_applet.py	\
-	gimmie_applications.py	\
+	gimmie_awn.py		\
 	gimmie_bar.py		\
 	gimmie_base.py		\
-	gimmie_computer.py	\
 	gimmie_delicious.py	\
 	gimmie_evolution.py	\
 	gimmie_facebook.py	\
@@ -45,9 +51,7 @@
 	gimmie_gmail.py		\
 	gimmie_googleoffice.py	\
 	gimmie_gui.py		\
-	gimmie_library.py	\
 	gimmie_logout.py	\
-	gimmie_people.py	\
 	gimmie_pidgin.py	\
 	gimmie_recent.py	\
 	gimmie_running.py	\

Modified: trunk/gimmie/gimmie_applications.py
==============================================================================
--- trunk/gimmie/gimmie_applications.py	(original)
+++ trunk/gimmie/gimmie_applications.py	Thu Feb  7 21:48:26 2008
@@ -1,3 +1,4 @@
+#!/usr/bin/python
 
 import os
 import time
@@ -456,3 +457,12 @@
 
         return tools
 
+
+#
+# Avant-window-navigator applet entrypoint
+#
+
+if __name__ == "__main__":
+    # Assume we're being launched as an Awn applet
+    import gimmie_awn
+    gimmie_awn.start(ApplicationsTopic())

Added: trunk/gimmie/gimmie_awn.py
==============================================================================
--- (empty file)
+++ trunk/gimmie/gimmie_awn.py	Thu Feb  7 21:48:26 2008
@@ -0,0 +1,300 @@
+#!/usr/bin/python
+
+import os
+import sys
+from gettext import bindtextdomain, textdomain, gettext as _
+
+import awn
+import gtk
+
+### Running in panel applet mode.
+import gimmie_globals
+gimmie_globals.gimmie_is_panel_applet = lambda: True
+
+from gimmie_base import Topic
+from gimmie_util import bookmarks, icon_factory, ToolMenuButton
+from gimmie_topicwin import TopicView, TimeBar
+
+
+class TopicBox(gtk.VBox, TopicView):
+    '''
+    Panel applet menu version of topic window.
+    '''
+    def __init__(self, topic):
+        gtk.VBox.__init__(self, False, 0)
+        TopicView.__init__(self, topic)
+
+        # Contains the visual frame, giving it some space
+        self._content = self
+        self._content.set_border_width(0)
+        self._content.show()
+
+        # Toolbar
+        self._content.pack_start(self.toolbar, False, False, 0)
+
+        # Hbox containing the sidebar buttons and the toolbar/iconview
+        body = gtk.HBox(False, 12)
+        body.set_border_width(12)
+        body.show()
+        self._content.pack_start(body, True, True, 0)
+
+        # Load up the sidebar
+        self._sidebar_align = gtk.Alignment(0.5, 0.0, 0.0, 0.0)
+        self._sidebar_align.add(self.sidebar)
+        self._sidebar_align.show()
+        body.pack_start(self._sidebar_align, False, True, 0)
+
+        # Horizontal time line bar with plus/minus buttons above icon view
+        self.timebar = TimeBar()
+        self.timebar.connect("zoom-changed", lambda w, num_days: self.zoom_changed(num_days))
+        align = gtk.Alignment(1.0, 0.0, 0.0, 0.0)
+        align.add(self.timebar)
+        align.show()
+        evbox = gtk.EventBox()
+        evbox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("white"))
+        evbox.show()
+        timebox = gtk.HBox(False, 0)
+        timebox.pack_start(evbox, True, True)
+        timebox.pack_start(align, False, True)
+        timebox.show()
+        self.content_vbox.pack_start(timebox, False, False)
+
+        # Frame containing timebar and iconview inside scrolled window
+        body.pack_start(self.content_frame, True, True, 0)
+
+        # Bound the height request of the scrolled window and icon view
+        #self.scroll.connect("size-request", self._scroll_get_best_size)
+        #self.scroll.get_vadjustment().connect("changed",
+        #                                      lambda adj: self.scroll.queue_resize_no_redraw())
+
+        self.view.set_size_request(500, -1)
+        self.view.connect("item-activated", lambda v, p: self.hide()) # Iconify on item open
+
+        # Setup the toolbar
+        self._add_toolbar_items()
+
+        # Select an initial sidebar button
+        self.find_first_button()
+
+    def set_gravity(self, gravity):
+        # Override GtkWindow::set_gravity
+        assert self.toolbar.parent == self._content
+
+        self._content.remove(self.toolbar)
+        if gravity in (gtk.gdk.GRAVITY_SOUTH,
+                       gtk.gdk.GRAVITY_SOUTH_WEST,
+                       gtk.gdk.GRAVITY_SOUTH_EAST):
+            # Toolbar & sidebar at the bottom
+            self._content.pack_end(self.toolbar, False, False, 0)
+            self._sidebar_align.set_property("yalign", 1.0)
+        else:
+            # Toolbar & sidebar at the top
+            self._content.pack_start(self.toolbar, False, False, 0)
+            self._sidebar_align.set_property("yalign", 0.0)
+
+        gtk.Window.set_gravity(self, gravity)
+
+    def get_zoom_level(self):
+        return self.timebar.get_zoom_level()
+
+    def get_zoom_level_list(self):
+        return self.timebar.get_zoom_level_list()
+
+    def set_zoom_level(self, zoom):
+        self.timebar.set_zoom_level(zoom)
+
+    def show_hide_zoomer(self, show):
+        if show:
+            if self.active_source:
+                self.timebar.set_items(self.active_source.get_items())
+            self.timebar.show()
+        else:
+            self.timebar.hide()
+
+    def _scroll_get_best_size(self, scroll, req):
+        '''
+        Sets the height request of the scrolled window to either the upper bound
+        of the scrollbar or 70% of the screen height, whichever is smaller.
+        '''
+        vadj = scroll.get_property("vadjustment")
+        upper = int(vadj.get_property("upper"))
+        upper = min(upper, int(self.get_screen().get_height() * 0.7))
+
+        if upper == 0 or upper == scroll.allocation.height:
+            # Avoid unneeded or bogus resize
+            return False
+
+        req.height = upper
+        return True
+
+    def _load_items_done(self, ondone_cb):
+        '''
+        Do some magic to get a decent size request out of an iconview.  Reset
+        the scrolled window upper bound to 0, and resize the window.
+        '''
+        if ondone_cb:
+            ondone_cb()
+
+        vadj = self.scroll.get_property("vadjustment")
+        vadj.set_property("upper", 0)
+
+        ### NOTE: Awn applet isn't a toplevel, it's embedded in an AppletDialog
+        #w, h = self.size_request()
+        #self.resize(w, h)
+
+    def load_items(self, items, ondone_cb = None):
+        '''
+        Wrap the ondone callback to resize the scrolled window after reloading
+        the iconview.
+        '''
+        self.view.load_items(items, lambda: self._load_items_done(ondone_cb))
+
+    def _favorite_selection_changed(self, view, fav, block_id, img):
+        # Block the toggled handler from triggering
+        fav.handler_block(block_id)
+        selected = view.get_selected_items()
+        if len(selected) == 1:
+            model = view.get_model()
+            item = model.get_value(model.get_iter(selected[0]), 2)
+
+            pix = icon_factory.load_icon("gnome-favorites", gtk.ICON_SIZE_LARGE_TOOLBAR)
+            if not item.get_is_pinned():
+               pix = icon_factory.greyscale(pix)
+            img.set_from_pixbuf(pix)
+
+            fav.set_active(item.get_is_pinned())
+            fav.set_sensitive(item.get_can_pin())
+        else:
+            fav.set_active(False)
+            fav.set_sensitive(False)
+        fav.handler_unblock(block_id)
+
+    def _favorite_toggled(self, fav):
+        selected = self.view.get_selected_items()
+        if len(selected) == 1:
+            model = self.view.get_model()
+            item = model.get_value(model.get_iter(selected[0]), 2)
+            if fav.get_active():
+                item.pin()
+            else:
+                item.unpin()
+
+    def add_favorite_toolitem(self):
+        img = icon_factory.load_image("gnome-favorites", gtk.ICON_SIZE_LARGE_TOOLBAR)
+        
+        i = gtk.ToggleToolButton()
+        i.set_label(_("Favorite"))
+        i.set_icon_widget(img)
+        i.set_is_important(True)
+        i.set_sensitive(False)
+        i.set_tooltip(self.tooltips, _("Add to Favorites"))
+        i.show_all()
+        self.toolbar.insert(i, -1)
+        
+        block_id = i.connect("toggled", self._favorite_toggled)
+        
+        sel_changed_cb = lambda: self._favorite_selection_changed(self.view, i, block_id, img)
+        self.view.connect("selection-changed", lambda view: sel_changed_cb())
+        bookmarks.connect("reload", lambda b: sel_changed_cb())
+
+        self.fav = i
+
+    def _make_toolbar_expander(self, expand = True):
+        sep = gtk.SeparatorToolItem()
+        sep.set_draw(False)
+        sep.set_expand(expand)
+        sep.show()
+        return sep
+
+    def _add_toolbar_items(self):
+        # Right-align the zoom and search tool items
+        self.toolbar.insert(self._make_toolbar_expander(), -1)
+
+        for i in self.topic.get_toolbar_items(self.tooltips):
+            ### Uncomment to pack space between elements
+            #self.toolbar.insert(self._make_toolbar_expander(), -1)
+            if i:
+                i.show_all()
+                if isinstance(i, ToolMenuButton):
+                    for menu_item in i.get_menu() or []:
+                        menu_item.connect("activate", lambda menu_item: self.hide())
+                elif isinstance(i, gtk.ToolButton):
+                    i.connect("clicked", lambda btn: self.hide())
+                self.toolbar.insert(i, -1)
+
+        self.add_favorite_toolitem()
+
+        # Try to disassociate the Favorite button from the search box
+        self.toolbar.insert(self._make_toolbar_expander(False), -1)
+
+        self.add_search_toolitem()
+
+        # Right-align the zoom and search tool items
+        self.toolbar.insert(self._make_toolbar_expander(), -1)
+
+
+def get_topic_window_mod(self):
+    if not self.topic_window:
+        self.topic_window = TopicBox(self)
+    return self.topic_window
+
+### Override Topic to use the applet menu version.
+Topic.get_topic_window = get_topic_window_mod
+
+
+class GimmieAwnApplet(awn.AppletSimple):
+    def __init__ (self, uid, orient, height, topic):
+        awn.AppletSimple.__init__ (self, uid, orient, height)
+        self.topic = topic
+        self.topic_win = None
+
+        self.set_icon(topic.get_icon(height))
+
+        self.title = awn.awn_title_get_default()
+        self.dialog = awn.AppletDialog(self)
+        self.connect("button-press-event", self.button_press)
+        self.connect("enter-notify-event", self.enter_notify)
+        self.connect("leave-notify-event", self.leave_notify)
+
+    def button_press(self, widget, event):
+        if not self.topic_win:
+            self.topic_win = self.topic.get_topic_window()
+            self.dialog.add(self.topic_win)
+        self.title.hide(self)
+        self.topic_win.search_tool_item.entry.grab_focus()
+        self.dialog.show_all()
+
+    def enter_notify(self, widget, event):
+        self.title.show(self, self.topic.get_name())
+
+    def leave_notify(self, widget, event):
+        self.title.hide(self)
+
+
+def start(topic):
+    assert topic, "Invalid topic!"
+    
+    print "%s: Starting pid=%s args=%s" % (sys.argv[0], os.getpid(), sys.argv[1:])
+
+    bindtextdomain('gimmie', gimmie_globals.localedir)
+    textdomain('gimmie')
+
+    # Tell gobject/gtk we are threaded
+    gtk.gdk.threads_init()
+
+    awn.init(sys.argv[1:])
+
+    applet = GimmieAwnApplet(awn.uid, awn.orient, awn.height, topic)
+    awn.init_applet(applet)
+    applet.show_all()
+
+    gtk.main()
+
+
+if __name__ == "__main__":
+    print "Just for testing!  This shouldn't be invoked directly!"
+    try:
+        from gimmie_applications import ApplicationsTopic
+    except:
+        from gimmie.gimmie_applications import ApplicationsTopic
+    start(ApplicationsTopic())

Modified: trunk/gimmie/gimmie_computer.py
==============================================================================
--- trunk/gimmie/gimmie_computer.py	(original)
+++ trunk/gimmie/gimmie_computer.py	Thu Feb  7 21:48:26 2008
@@ -1,3 +1,4 @@
+#!/usr/bin/python
 
 import datetime
 import os
@@ -997,3 +998,13 @@
         tools.append(btn)    
 
         return tools
+
+
+#
+# Avant-window-navigator applet entrypoint
+#
+
+if __name__ == "__main__":
+    # Assume we're being launched as an Awn applet
+    import gimmie_awn
+    gimmie_awn.start(ComputerTopic())

Modified: trunk/gimmie/gimmie_library.py
==============================================================================
--- trunk/gimmie/gimmie_library.py	(original)
+++ trunk/gimmie/gimmie_library.py	Thu Feb  7 21:48:26 2008
@@ -1,3 +1,4 @@
+#!/usr/bin/python
 
 import glob
 import os
@@ -360,17 +361,11 @@
         gtk.Menu.__init__(self)
 
         # Include all the mounted drives
-        computer = gimmie_get_topic_for_uri("topic://Computer")
-        device_source = computer.get_source_for_uri("source://Devices")
-        for item in device_source.get_items():
-            if isinstance(item, DriveItem) and item.get_is_mounted():
-                self.append(self._add_place_item(item.get_name(),
-                                                 item.get_uri(),
-                                                 item.get_icon(gtk.ICON_SIZE_LARGE_TOOLBAR)))
-
-        sep = gtk.SeparatorMenuItem()
-        sep.show()
-        self.append(sep)
+        devcnt = self._add_devices()
+        if devcnt:
+            sep = gtk.SeparatorMenuItem()
+            sep.show()
+            self.append(sep)
 
         # Include all the Gtk bookmarks
         for uri, name, mime, icon in places.get_places():
@@ -386,6 +381,20 @@
         else:
             self.append(self._add_place_item(_("Trash"), "trash://", "gnome-fs-trash-full"))
 
+    def _add_devices(self):
+        devcnt = 0
+        computer = gimmie_get_topic_for_uri("topic://Computer")
+        if computer:
+            device_source = computer.get_source_for_uri("source://Devices")
+            for item in device_source.get_items():
+                if isinstance(item, DriveItem) and item.get_is_mounted():
+                    mi = self._add_place_item(item.get_name(),
+                                              item.get_uri(),
+                                              item.get_icon(gtk.ICON_SIZE_LARGE_TOOLBAR))
+                    self.append(mi)
+                    devcnt += 1
+        return devcnt
+
     def _add_place_item(self, name, uri, icon_name = "gnome-fs-directory"):
         menu_item = gtk.ImageMenuItem(name)
         menu_item.set_image(icon_factory.load_image(icon_name, gtk.ICON_SIZE_LARGE_TOOLBAR))
@@ -492,3 +501,13 @@
             tools.append(btn)
 
         return tools
+
+
+#
+# Avant-window-navigator applet entrypoint
+#
+
+if __name__ == "__main__":
+    # Assume we're being launched as an Awn applet
+    import gimmie_awn
+    gimmie_awn.start(DocumentsTopic())

Modified: trunk/gimmie/gimmie_people.py
==============================================================================
--- trunk/gimmie/gimmie_people.py	(original)
+++ trunk/gimmie/gimmie_people.py	Thu Feb  7 21:48:26 2008
@@ -1,3 +1,4 @@
+#!/usr/bin/python
 
 import datetime
 import os
@@ -305,3 +306,12 @@
 
         return tools
 
+
+#
+# Avant-window-navigator applet entrypoint
+#
+
+if __name__ == "__main__":
+    # Assume we're being launched as an Awn applet
+    import gimmie_awn
+    gimmie_awn.start(PeopleTopic())

Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in	(original)
+++ trunk/po/POTFILES.in	Thu Feb  7 21:48:26 2008
@@ -1,5 +1,9 @@
 # List of source files containing translatable strings.
 # Please keep this file sorted alphabetically.
+data/awn/gimmie_computer.desktop.in.in
+data/awn/gimmie_programs.desktop.in.in
+data/awn/gimmie_library.desktop.in.in
+data/awn/gimmie_people.desktop.in.in
 data/gimmie.schemas.in
 data/GNOME_GimmieApplet.server.in.in
 data/GNOME_GimmieApplet.xml



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]