From b854e2869823991ebf08018671b56160cb5a3a7f Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Mon, 21 Sep 2009 16:03:52 +0200 Subject: [PATCH] Proper startup and text styling for Fremantle Make sure starting up gPodder looks good. Also, make sure that the correct text style is used for empty tree views and the OPML list model. --- data/ui/frmntl/gpodder.ui | 6 +-- data/ui/frmntl/gpodderpodcastdirectory.ui | 1 + src/gpodder/gtkui/frmntl/opml.py | 60 +++++++++++++++++++++++ src/gpodder/gtkui/frmntl/podcastdirectory.py | 42 ++++++++++++---- src/gpodder/gtkui/frmntl/style.py | 71 ++++++++++++++++++++++++++++ src/gpodder/gui.py | 33 +++++++++---- 6 files changed, 192 insertions(+), 21 deletions(-) create mode 100644 src/gpodder/gtkui/frmntl/opml.py create mode 100644 src/gpodder/gtkui/frmntl/style.py diff --git a/data/ui/frmntl/gpodder.ui b/data/ui/frmntl/gpodder.ui index 5171d78a..c190cdc3 100644 --- a/data/ui/frmntl/gpodder.ui +++ b/data/ui/frmntl/gpodder.ui @@ -147,7 +147,7 @@ HILDON_BUTTON_ARRANGEMENT_VERTICAL HILDON_SIZE_THUMB_HEIGHT True - True + False 200 @@ -159,7 +159,7 @@ HILDON_BUTTON_ARRANGEMENT_VERTICAL HILDON_SIZE_THUMB_HEIGHT True - True + False 200 @@ -171,7 +171,7 @@ HILDON_BUTTON_ARRANGEMENT_VERTICAL HILDON_SIZE_THUMB_HEIGHT True - True + False 200 diff --git a/data/ui/frmntl/gpodderpodcastdirectory.ui b/data/ui/frmntl/gpodderpodcastdirectory.ui index af2e94ec..1110daf9 100644 --- a/data/ui/frmntl/gpodderpodcastdirectory.ui +++ b/data/ui/frmntl/gpodderpodcastdirectory.ui @@ -26,6 +26,7 @@ False False HILDON_UI_MODE_EDIT + diff --git a/src/gpodder/gtkui/frmntl/opml.py b/src/gpodder/gtkui/frmntl/opml.py new file mode 100644 index 00000000..49924b8b --- /dev/null +++ b/src/gpodder/gtkui/frmntl/opml.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# +# gPodder - A media aggregator and podcast client +# Copyright (c) 2005-2009 Thomas Perl and the gPodder Team +# +# gPodder is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# gPodder is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +# +# gpodder.gtkui.opml - Module for displaying OPML feeds (2009-08-13) +# + + +import gtk +import gobject + +import gpodder + +import xml.sax.saxutils +import urllib + +from gpodder.gtkui.frmntl import style + +class OpmlListModel(gtk.ListStore): + C_SELECTED, C_DESCRIPTION_MARKUP, C_URL = range(3) + + def __init__(self, importer): + gtk.ListStore.__init__(self, bool, str, str) + + head_font = style.get_font_desc('SystemFont') + head_color = style.get_color('ButtonTextColor') + head = (head_font.to_string(), head_color.to_string()) + head = '%%s' % head + + sub_font = style.get_font_desc('SmallSystemFont') + sub_color = style.get_color('SecondaryTextColor') + sub = (sub_font.to_string(), sub_color.to_string()) + sub = '%%s' % sub + self._markup_template = '\n'.join((head, sub)) + + for channel in importer.items: + self.append([False, self._format_channel(channel), channel['url']]) + + def _format_channel(self, channel): + title = xml.sax.saxutils.escape(urllib.unquote_plus(channel['title'])) + description = xml.sax.saxutils.escape(channel['description']) + return self._markup_template % (title, description) + diff --git a/src/gpodder/gtkui/frmntl/podcastdirectory.py b/src/gpodder/gtkui/frmntl/podcastdirectory.py index e0353d80..f2969756 100644 --- a/src/gpodder/gtkui/frmntl/podcastdirectory.py +++ b/src/gpodder/gtkui/frmntl/podcastdirectory.py @@ -32,14 +32,18 @@ from gpodder import util from gpodder import opml from gpodder import youtube -from gpodder.gtkui.opml import OpmlListModel +from gpodder.gtkui.frmntl.opml import OpmlListModel from gpodder.gtkui.interface.common import BuilderWidget from gpodder.gtkui.frmntl.widgets import EditToolbarDeluxe +from gpodder.gtkui.draw import draw_text_box_centered + class gPodderPodcastDirectory(BuilderWidget): def new(self): + self._is_updating = False + if hasattr(self, 'custom_title'): self.main_window.set_title(self.custom_title) @@ -84,6 +88,30 @@ class gPodderPodcastDirectory(BuilderWidget): self.app_menu.popup(self.main_window) + def on_treeview_expose_event(self, treeview, event): + if event.window == treeview.get_bin_window(): + model = treeview.get_model() + if not self._is_updating: + return False + + if (model is not None and model.get_iter_first() is not None): + return False + + ctx = event.window.cairo_create() + ctx.rectangle(event.area.x, event.area.y, + event.area.width, event.area.height) + ctx.clip() + x, y, width, height, depth = event.window.get_geometry() + + text = _('Downloading podcast list, please wait...') + + from gpodder.gtkui.frmntl import style + font_desc = style.get_font_desc('LargeSystemFont') + draw_text_box_centered(ctx, treeview, width, height, text, font_desc) + + return False + + def on_selection_changed(self, selection): self.set_subscribe_button_sensitive() @@ -119,10 +147,9 @@ class gPodderPodcastDirectory(BuilderWidget): def download_opml_file(self, url, use_youtube=False): selection = self.treeview.get_selection() selection.unselect_all() - self.treeview.set_sensitive(False) - - banner = hildon.hildon_banner_show_animation(self.main_window, \ - '', _('Loading podcast list, please wait')) + self.treeview.set_model(None) + self._is_updating = True + self.treeview.queue_draw() hildon.hildon_gtk_window_set_progress_indicator(self.main_window, True) def download_thread_func(): @@ -136,8 +163,8 @@ class gPodderPodcastDirectory(BuilderWidget): else: model = None def download_thread_finished(): - if banner is not None: - banner.destroy() + self._is_updating = False + self.treeview.queue_draw() hildon.hildon_gtk_window_set_progress_indicator(\ self.main_window, False) self.action_select_all.set_property('visible', \ @@ -145,7 +172,6 @@ class gPodderPodcastDirectory(BuilderWidget): self.action_select_none.set_property('visible', \ model is not None) self.treeview.set_model(model) - self.treeview.set_sensitive(True) self.set_subscribe_button_sensitive() if model is None: diff --git a/src/gpodder/gtkui/frmntl/style.py b/src/gpodder/gtkui/frmntl/style.py new file mode 100644 index 00000000..17dedb11 --- /dev/null +++ b/src/gpodder/gtkui/frmntl/style.py @@ -0,0 +1,71 @@ +# -*- coding: utf-8 -*- +# +# gPodder - A media aggregator and podcast client +# Copyright (c) 2005-2009 Thomas Perl and the gPodder Team +# +# gPodder is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# gPodder is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + + +import gtk +import hildon + +# See the Fremantle Master Layout Guide for more information: +# http://tinyurl.com/fremantle-master-layout-guide + +# For implementation details, consult hildon/hildon-helper.c +# (the function is called hildon_change_style_recursive_from_list) + +logical_font_names = ( + 'SystemFont', + 'EmpSystemFont', + 'SmallSystemFont', # Used for secondary text in buttons/TreeViews + 'EmpSmallSystemFont', + 'LargeSystemFont', # Used for empty TreeView text + 'X-LargeSystemFont', + 'XX-LargeSystemFont', + 'XXX-LargeSystemFont', + 'HomeSystemFont', +) + +logical_color_names = ( + 'ButtonTextColor', + 'ButtonTextPressedColor', + 'ButtonTextDisabledColor', + 'ActiveTextColor', # Used for Button values, etc.. + 'SecondaryTextColor', # Used for additional/secondary information +) + +def get_font_desc(logicalfontname): + settings = gtk.settings_get_default() + font_style = gtk.rc_get_style_by_paths(settings, logicalfontname, \ + None, None) + font_desc = font_style.font_desc + return font_desc + +def get_color(logicalcolorname): + settings = gtk.settings_get_default() + color_style = gtk.rc_get_style_by_paths(settings, 'GtkButton', \ + 'osso-logical-colors', gtk.Button) + return color_style.lookup_color(logicalcolorname) + + +# For debugging; usage: python -m gpodder.gtkui.frmntl.style +if __name__ == '__main__': + for font_name in logical_font_names: + print font_name, '-> ', get_font_desc(font_name).to_string() + print '-----------' + for color_name in logical_color_names: + print color_name, '-> ', get_color(color_name).to_string() + diff --git a/src/gpodder/gui.py b/src/gpodder/gui.py index fe55cc59..2215ee18 100644 --- a/src/gpodder/gui.py +++ b/src/gpodder/gui.py @@ -231,6 +231,14 @@ class gPodder(BuilderWidget, dbus.service.Object): self.cover_downloader.register('cover-removed', self.cover_file_removed) if gpodder.ui.fremantle: + self.button_subscribe.set_name('HildonButton-thumb') + self.button_podcasts.set_name('HildonButton-thumb') + self.button_downloads.set_name('HildonButton-thumb') + + hildon.hildon_gtk_window_set_progress_indicator(self.main_window, True) + while gtk.events_pending(): + gtk.main_iteration(False) + self.episodes_window = gPodderEpisodes(self.main_window, \ on_treeview_expose_event=self.on_treeview_expose_event, \ show_episode_shownotes=self.show_episode_shownotes, \ @@ -263,10 +271,6 @@ class gPodder(BuilderWidget, dbus.service.Object): self.treeAvailable = self.episodes_window.treeview self.treeDownloads = self.downloads_window.treeview - self.button_subscribe.set_name('HildonButton-thumb') - self.button_podcasts.set_name('HildonButton-thumb') - self.button_downloads.set_name('HildonButton-thumb') - # Init the treeviews that we use self.init_podcast_list_treeview() self.init_episode_list_treeview() @@ -364,6 +368,12 @@ class gPodder(BuilderWidget, dbus.service.Object): self.delete_episode_list(old_episodes, confirm=False) self.update_podcast_list_model(set(e.channel.url for e in old_episodes)) + if gpodder.ui.fremantle: + hildon.hildon_gtk_window_set_progress_indicator(self.main_window, False) + self.button_subscribe.set_sensitive(True) + self.button_podcasts.set_sensitive(True) + self.button_downloads.set_sensitive(True) + # First-time users should be asked if they want to see the OPML if not self.channels: util.idle_add(self.on_itemUpdate_activate) @@ -589,7 +599,6 @@ class gPodder(BuilderWidget, dbus.service.Object): role = getattr(treeview, TreeViewHelper.ROLE) ctx = event.window.cairo_create() - png = treeview.get_pango_context() ctx.rectangle(event.area.x, event.area.y, event.area.width, event.area.height) ctx.clip() @@ -601,7 +610,7 @@ class gPodder(BuilderWidget, dbus.service.Object): text = _('Loading episodes') + '...' elif self.config.episode_list_view_mode != \ EpisodeListModel.VIEW_ALL: - text = _('Select "View" > "All episodes" to show episodes') + text = _('No episodes in current view') else: text = _('No episodes available') elif role == TreeViewHelper.ROLE_PODCASTS: @@ -613,11 +622,17 @@ class gPodder(BuilderWidget, dbus.service.Object): else: text = _('No subscriptions') elif role == TreeViewHelper.ROLE_DOWNLOADS: - text = _('No downloads') + text = _('No active downloads') else: raise Exception('on_treeview_expose_event: unknown role') - draw_text_box_centered(ctx, treeview, width, height, text) + if gpodder.ui.fremantle: + from gpodder.gtkui.frmntl import style + font_desc = style.get_font_desc('LargeSystemFont') + else: + font_desc = None + + draw_text_box_centered(ctx, treeview, width, height, text, font_desc) return False @@ -1661,8 +1676,6 @@ class gPodder(BuilderWidget, dbus.service.Object): if self.channels and self.active_channel is not None: if gpodder.ui.diablo: banner = hildon.hildon_banner_show_animation(self.gPodder, None, _('Loading episodes')) - elif gpodder.ui.fremantle: - banner = hildon.hildon_banner_show_animation(self.gPodder, '', _('Loading episodes')) else: banner = None -- 2.11.4.GIT