From 9f1efa8802189f21203e494aab96003af5c2c8b3 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Wed, 8 Aug 2007 03:21:43 +0000 Subject: [PATCH] more gobject tweaks --- src/browser.py | 6 ------ src/common.py | 1 - src/interface.py | 56 ++++++++++++++++++++++++------------------------ 3 files changed, 28 insertions(+), 35 deletions(-) delete mode 100644 src/browser.py diff --git a/src/browser.py b/src/browser.py deleted file mode 100644 index 89d865c0e..000000000 --- a/src/browser.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import webbrowser -import sys -webbrowser.open(sys.argv[1]) diff --git a/src/common.py b/src/common.py index a6643b88b..b23b092be 100644 --- a/src/common.py +++ b/src/common.py @@ -32,7 +32,6 @@ import os.path import xdg.BaseDirectory import gobject -gobject.threads_init() PROGRAM_NAME = "Deluge" PROGRAM_VERSION = "0.5.4" diff --git a/src/interface.py b/src/interface.py index 12be7e6e4..6d36bf2a2 100644 --- a/src/interface.py +++ b/src/interface.py @@ -48,7 +48,6 @@ import tab_details class DelugeGTK: def __init__(self): - gobject.threads_init() self.ipc_manager = ipc_manager.Manager(self) #Start the Deluge Manager: self.manager = core.Manager(common.CLIENT_CODE, common.CLIENT_VERSION, @@ -116,42 +115,42 @@ class DelugeGTK: self.update_interface = True def new_release_check(): - import urllib - new_release = urllib.urlopen("http://download.deluge-torrent.org/version").read().strip() - if new_release > common.PROGRAM_VERSION: - gtk.gdk.threads_enter() - dialog = gtk.MessageDialog(parent = None, - flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, - buttons = gtk.BUTTONS_YES_NO, - message_format=_("There is a newer version of Deluge. Would you like to be taken to our download site?"), + import urllib + new_release = urllib.urlopen("http://download.deluge-torrent.org/version").read().strip() + if new_release > common.PROGRAM_VERSION: + gtk.gdk.threads_enter() + dialog = gtk.MessageDialog(parent = None, + flags = gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, + buttons = gtk.BUTTONS_YES_NO, + message_format=_("There is a newer version of Deluge. Would you like to be taken to our download site?"), type=gtk.MESSAGE_QUESTION) - dialog.set_title('New Release!') - result = dialog.run() - dialog.destroy() - if result == gtk.RESPONSE_YES: - common.open_url_in_browser('http://download.deluge-torrent.org') - elif result == gtk.RESPONSE_NO: - pass - gtk.gdk.threads_leave() + dialog.set_title('New Release!') + result = dialog.run() + dialog.destroy() + if result == gtk.RESPONSE_YES: + common.open_url_in_browser('http://download.deluge-torrent.org') + elif result == gtk.RESPONSE_NO: + pass + gtk.gdk.threads_leave() - + def send_info(): - import time + import time def _run_script(): - import urllib - import platform + import urllib + import platform - pygtk = '%i.%i.%i' %(gtk.pygtk_version[0],gtk.pygtk_version[1],gtk.pygtk_version[2]) + pygtk = '%i.%i.%i' %(gtk.pygtk_version[0],gtk.pygtk_version[1],gtk.pygtk_version[2]) gtk.gdk.threads_enter() - urllib.urlopen("http://download.deluge-torrent.org/stats.php?processor=" + \ - platform.machine() + "&python=" + platform.python_version() \ - + "&os=" + platform.system() + "&pygtk=" + pygtk) + urllib.urlopen("http://download.deluge-torrent.org/stats.php?processor=" + \ + platform.machine() + "&python=" + platform.python_version() \ + + "&os=" + platform.system() + "&pygtk=" + pygtk) - f = open(os.path.join(common.CONFIG_DIR, 'infosent'), 'w') - f.write("") - f.close + f = open(os.path.join(common.CONFIG_DIR, 'infosent'), 'w') + f.write("") + f.close gtk.gdk.threads_leave() info_file = os.path.join(common.CONFIG_DIR, 'infosent') @@ -1354,6 +1353,7 @@ class DelugeGTK: ## For testing purposes, create a copy of the interface if __name__ == "__main__": + gobject.threads_init() interface = DelugeGTK() interface.start()