X-Git-Url: http://git.maemo.org/git/?p=jamaendo;a=blobdiff_plain;f=jamaui%2Fui.py;h=5427aab37dc8cf2a7a3100da95aab73967467ee7;hp=2c0ad65ad12517eb25520f9424d5f40406ca4b5e;hb=76dd03fde1fef21b6a5678ee095e2190e0aab4f1;hpb=3f9780b2b25864881151f5d99b234587a65cf451 diff --git a/jamaui/ui.py b/jamaui/ui.py index 2c0ad65..5427aab 100644 --- a/jamaui/ui.py +++ b/jamaui/ui.py @@ -47,8 +47,8 @@ except: log.critical('Using GTK widgets, install "python2.5-hildon" ' 'for this to work properly.') else: - log.critical('This ui only works in maemo') - sys.exit(1) + log.critical('This ui (probably) only works in maemo') + import helldon as hildon from dbus.mainloop.glib import DBusGMainLoop @@ -62,16 +62,8 @@ from search import SearchWindow from featured import FeaturedWindow from radios import RadiosWindow from favorites import FavoritesWindow - -class PlaylistsWindow(hildon.StackableWindow): - def __init__(self): - hildon.StackableWindow.__init__(self) - self.set_title("Playlists") - - label = gtk.Label("Playlists") - vbox = gtk.VBox(False, 0) - vbox.pack_start(label, True, True, 0) - self.add(vbox) +from playlists import PlaylistsWindow +from listbox import ButtonListDialog class Jamaui(object): def __init__(self): @@ -98,17 +90,9 @@ class Jamaui(object): postoffice.connect('request-images', self, self.on_request_images) log.debug("Created main window.") - def save_settings(self): - settings.save() - def create_menu(self): self.menu = hildon.AppMenu() - #search = hildon.GtkButton(gtk.HILDON_SIZE_AUTO) - #search.set_label("Search") - #search.connect("clicked", self.on_search) - #self.menu.append(search) - player = hildon.GtkButton(gtk.HILDON_SIZE_AUTO) player.set_label("Open player") player.connect("clicked", self.on_player) @@ -119,23 +103,16 @@ class Jamaui(object): player.connect("clicked", self.on_favorites) self.menu.append(player) - #player = hildon.GtkButton(gtk.HILDON_SIZE_AUTO) - #player.set_label("Playlists") - #player.connect("clicked", self.on_playlists) - #self.menu.append(player) + player = hildon.GtkButton(gtk.HILDON_SIZE_AUTO) + player.set_label("Playlists") + player.connect("clicked", self.on_playlists) + self.menu.append(player) player = hildon.GtkButton(gtk.HILDON_SIZE_AUTO) player.set_label("Settings") player.connect("clicked", self.on_settings) self.menu.append(player) - - # Don't use localdb ATM - #refresh = hildon.GtkButton(gtk.HILDON_SIZE_AUTO) - #refresh.set_label("Refresh") - #refresh.connect("clicked", self.on_refresh) - #self.menu.append(refresh) - menu_about = hildon.GtkButton(gtk.HILDON_SIZE_AUTO) menu_about.set_label("About") menu_about.connect("clicked", self.show_about, self.window) @@ -154,7 +131,7 @@ class Jamaui(object): self.window.window.set_back_pixmap(background, False) bbox = gtk.HButtonBox() - alignment = gtk.Alignment(xalign=0.2, yalign=0.925, xscale=1.0) + alignment = gtk.Alignment(xalign=0.2, yalign=0.4, xscale=1.0) alignment.add(bbox) bbox.set_property('layout-style', gtk.BUTTONBOX_SPREAD) self.bbox = bbox @@ -181,27 +158,18 @@ class Jamaui(object): jamaendo.get_images_async(self.got_images, urls) def got_album_cover(self, albumid, size, cover): + gtk.gdk.threads_enter() postoffice.notify('album-cover', albumid, size, cover) + gtk.gdk.threads_leave() def got_images(self, images): + gtk.gdk.threads_enter() postoffice.notify('images', images) - - #def add_featured_button(self): - # self.featured_sel = hildon.TouchSelector(text=True) - # self.featured_sel.append_text("Albums of the week") - # self.featured_sel.append_text("Tracks of the week") - # self.featured_sel.append_text("New releases") - # btn = hildon.PickerButton(gtk.HILDON_SIZE_THUMB_HEIGHT, - # hildon.BUTTON_ARRANGEMENT_VERTICAL) - # btn.set_text("Featured", "Most listened to") - # btn.set_property('width-request', 225) - # btn.set_selector(self.featured_sel) - # self.featured_btn = btn - # self.bbox.add(btn) + gtk.gdk.threads_leave() def destroy(self, widget): postoffice.disconnect(['request-album-cover', 'request-images'], self) - self.save_settings() + settings.save() from player import the_player if the_player: the_player.stop() @@ -255,29 +223,19 @@ JAMENDO is an online platform that distributes musical works under Creative Comm dialog.destroy() def open_link(self, d, url, data): - #print "url: %s" % (url) import webbrowser webbrowser.open_new(url) - - #def on_refresh(self, button): - # dialog = RefreshDialog() - # dialog.show_all() - # dialog.run() - # dialog.hide() - def on_featured(self, button): - dialog = hildon.PickerDialog(self.window) - sel = hildon.TouchSelectorEntry(text=True) - for feature, _ in FeaturedWindow.features: - sel.append_text(feature) - dialog.set_selector(sel) - dialog.set_title("Featured") - sel.unselect_all(0) - if dialog.run() == gtk.RESPONSE_OK: - txt = sel.get_current_text() - self.featuredwnd = FeaturedWindow(txt) + dialog = ButtonListDialog('Featured', self.window) + def fn(btn, feature): + self.featuredwnd = FeaturedWindow(feature) self.featuredwnd.show_all() + dialog.response(gtk.RESPONSE_OK) + for feature, _ in FeaturedWindow.features: + dialog.add_button(feature, fn, feature) + dialog.show_all() + dialog.run() dialog.destroy() def on_radios(self, button): @@ -297,23 +255,21 @@ JAMENDO is an online platform that distributes musical works under Creative Comm dialog.set_title("Settings") dialog.add_button( gtk.STOCK_OK, gtk.RESPONSE_OK ) vbox = dialog.vbox - tbl = gtk.Table(1, 2) - tbl.attach(gtk.Label("Username:"), 0, 1, 0, 1) + hboxinner = gtk.HBox() + hboxinner.pack_start(gtk.Label("Username:"), False, False, 0) entry = hildon.Entry(gtk.HILDON_SIZE_FINGER_HEIGHT) entry.set_placeholder("jamendo.com username") if settings.user: entry.set_text(settings.user) - tbl.attach(entry, 1, 2, 0, 1) - vbox.pack_start(tbl, True, True, 2) + hboxinner.pack_start(entry, True, True, 0) + vbox.pack_start(hboxinner, True, True, 0) dialog.show_all() result = dialog.run() val = entry.get_text() dialog.destroy() - #print val, result if val and result == gtk.RESPONSE_OK: - #print "new user name:", val settings.user = val - self.save_settings() + settings.save() def on_favorites(self, button): @@ -323,22 +279,6 @@ JAMENDO is an online platform that distributes musical works under Creative Comm def on_player(self, button): open_playerwindow() - ''' - def on_search(self, button): - if self.searchbar: - self.searchbar.show() - else: - self.searchstore = gtk.ListStore(gobject.TYPE_STRING) - iter = self.searchstore.append() - self.searchstore.set(iter, 0, "Test1") - iter = self.searchstore.append() - self.searchstore.set(iter, 0, "Test2") - self.searchbar = hildon.FindToolbar("Search", self.searchstore, 0) - self.searchbar.set_active(0) - self.window.add_toolbar(self.searchbar) - self.searchbar.show() - ''' - def run(self): ossohelper.application_init('org.jamaendo', '0.1') self.create_window()