Initialize function, allow passing in alternative progname

This commit is contained in:
Thomas Perl 2014-02-03 18:48:41 +01:00
parent f816b37f47
commit f96bfa6526
5 changed files with 15 additions and 11 deletions

View file

@ -25,6 +25,7 @@ import io.thp.pyotherside 1.0
Python { Python {
id: py id: py
property string progname: 'gpodder'
property bool ready: false property bool ready: false
signal downloading(int episode_id) signal downloading(int episode_id)
signal downloadProgress(int episode_id, real progress) signal downloadProgress(int episode_id, real progress)
@ -59,7 +60,9 @@ Python {
// Load the Python side of things // Load the Python side of things
importModule('main', function() { importModule('main', function() {
py.ready = true; py.call('main.initialize', [py.progname], function() {
py.ready = true;
});
}); });
} }

View file

@ -13,12 +13,6 @@ ApplicationWindow {
GPodderCore { GPodderCore {
id: py id: py
onReadyChanged: {
if (ready) {
podcastListModel.reload();
}
}
} }
menuBar: MenuBar { menuBar: MenuBar {

View file

@ -51,9 +51,15 @@ def run_in_background_thread(f):
class gPotherSide: class gPotherSide:
def __init__(self): def __init__(self):
self.core = core.Core() self.core = None
self._checking_for_new_episodes = False self._checking_for_new_episodes = False
def initialize(self, progname):
assert self.core is None, 'Already initialized'
self.core = core.Core(progname=progname)
pyotherside.send('podcast-list-changed')
def atexit(self): def atexit(self):
self.core.shutdown() self.core.shutdown()
@ -288,6 +294,7 @@ pyotherside.atexit(gpotherside.atexit)
pyotherside.send('hello', gpodder.__version__, gpodder.__copyright__) pyotherside.send('hello', gpodder.__version__, gpodder.__copyright__)
# Exposed API Endpoints for calls from QML # Exposed API Endpoints for calls from QML
initialize = gpotherside.initialize
load_podcasts = gpotherside.load_podcasts load_podcasts = gpotherside.load_podcasts
load_episodes = gpotherside.load_episodes load_episodes = gpotherside.load_episodes
show_episode = gpotherside.show_episode show_episode = gpotherside.show_episode

View file

@ -27,6 +27,8 @@ Item {
GPodderCore { id: py } GPodderCore { id: py }
GPodderPlayback { id: player } GPodderPlayback { id: player }
GPodderPodcastListModel { id: podcastListModel }
property real scalef: width / 480 property real scalef: width / 480
anchors.fill: parent anchors.fill: parent

View file

@ -27,8 +27,6 @@ SlidePage {
id: podcastsPage id: podcastsPage
hasPull: true hasPull: true
Component.onCompleted: podcastListModel.reload();
PullMenu { PullMenu {
PullMenuItem { PullMenuItem {
source: 'images/play.png' source: 'images/play.png'
@ -62,7 +60,7 @@ SlidePage {
section.property: 'section' section.property: 'section'
section.delegate: SectionHeader { text: section } section.delegate: SectionHeader { text: section }
model: GPodderPodcastListModel { id: podcastListModel } model: podcastListModel
delegate: PodcastItem { delegate: PodcastItem {
onClicked: pgst.loadPage('EpisodesPage.qml', {'podcast_id': id, 'title': title}); onClicked: pgst.loadPage('EpisodesPage.qml', {'podcast_id': id, 'title': title});