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 {
id: py
property string progname: 'gpodder'
property bool ready: false
signal downloading(int episode_id)
signal downloadProgress(int episode_id, real progress)
@ -59,7 +60,9 @@ Python {
// Load the Python side of things
importModule('main', function() {
py.ready = true;
py.call('main.initialize', [py.progname], function() {
py.ready = true;
});
});
}

View file

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

View file

@ -51,9 +51,15 @@ def run_in_background_thread(f):
class gPotherSide:
def __init__(self):
self.core = core.Core()
self.core = None
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):
self.core.shutdown()
@ -288,6 +294,7 @@ pyotherside.atexit(gpotherside.atexit)
pyotherside.send('hello', gpodder.__version__, gpodder.__copyright__)
# Exposed API Endpoints for calls from QML
initialize = gpotherside.initialize
load_podcasts = gpotherside.load_podcasts
load_episodes = gpotherside.load_episodes
show_episode = gpotherside.show_episode

View file

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

View file

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