Reply
Thread Tools
Posts: 87 | Thanked: 98 times | Joined on Oct 2007 @ Austria
#11
Very cool!

After staring at this page (the closest thing to python-hildondesktop documentation I found) for a while, I came up with this variation to spiritgeeks plugin:

Code:
import gtk
import hildondesktop as hd
import os

class XTermLaunch(hd.TaskNavigatorItem):

	def launch_xterm(self, widget):
		os.spawnlp(os.P_NOWAIT, "maemo-invoker", "maemo-invoker", "osso-xterm.launch")


	def open_menu(self, widget):
		if not self.button.get_active(): 
			self.menu.popup(None, None, self.menu_position, 1, 
				gtk.get_current_event_time())
			self.button.set_active(True)
		else:
			self.menu.popdown()
			self.button.set_active(False)
		return True

	def menu_position(self, menu):
		pos = self.button.get_allocation()
		return (pos.x + pos.width, pos.y, False)


	def deactivate(self, widget):
		self.button.set_active(False)

	def __init__(self):
		hd.TaskNavigatorItem.__init__(self)

		img_file = "/usr/share/icons/hicolor/64x64/apps/terminal.png"

		self.button = button = hd.ToggleButton()
		button.set_image(gtk.image_new_from_file(img_file))
		button.connect("pressed", self.open_menu)
		button.show()
		self.add(button)

		self.menu = menu = gtk.Menu()
		menu.connect("deactivate", self.deactivate)
		for i in range(0, 5):
			item = hd.hildon_thumb_menu_item_new_with_labels("X Terminal", 
				"X Terminal", "Start X Terminal")
			item.connect("activate", self.launch_xterm)
			item.set_image(gtk.image_new_from_file(img_file))
			item.set_size_request(300, -1)
			menu.append(item)
		hd.hildon_menu_set_thumb_mode(menu, True)
		menu.show_all()


def hd_plugin_get_objects():
	plugin = XTermLaunch()
	return [plugin]
This uses the hildondesktop.ThumbMenuItem class to display big menu items with two lines(name and description). I guess you could do the same with stock gtk widgets and it probably wouldn't look that different.

A script menu that lists the scripts in some directory like ~/scripts would definitely nice to have!

Last edited by hns; 2008-03-05 at 22:55.
 

The Following User Says Thank You to hns For This Useful Post:
Posts: 109 | Thanked: 91 times | Joined on Dec 2007
#12
Originally Posted by SpiritGeek View Post
Yay! With the new official desktop bindings, I have written my first task navigator panel in Python. It's just a simple shortcut to launch X Terminal.
This is terrific!

Originally Posted by SpiritGeek View Post
Make sure you have the required libraries installed:
hildon-desktop-python-loader_0.0.2-1_armel.deb
python2.5-hildondesktop_0.0.2-1_armel.deb
(For some reason those wouldn't install for me just by clicking. I had to download them locally and install with dpgk -i.)

I love my N810.
Thanks for the clear & complete directions.

Earlier today, I did what I shouldn't...and ran "apt-get upgrade" on my N810. It seemed to go fine, until I rebooted...I'm not sure what new (or upgraded) app caused the conflict, but my tablet was rebooted after processing all the init scripts.

I narrowed the problem down to the navigation panel "contacts" plugin, or one of it's dependencies. I don't use that contact app, so I removed it with "apt-get remove osso-contacts-plugin". This allowed the tablet to work fine, but left a "twin" of the app selector plugin, since Maemo insists on having two plugins (plus the network shortcuts) on the navigation panel at all times.

So, your app is _perfect_. After installing it, and a trivial edit to ~user/.osso/hildon-desktop/tasknavigator.conf, I've now got the standard Maemo application launcher and your x-terminal icon on the navigation panel, without the (useless) contacts plugin!
 
Reply


 
Forum Jump


All times are GMT. The time now is 08:34.