From 0a7789f6491af71d7e572c338ab0a32253fa8c15 Mon Sep 17 00:00:00 2001 From: Marcos Pinto Date: Tue, 18 Sep 2007 01:52:32 +0000 Subject: [PATCH] add about dialog and open_url_in_browser --- TODO | 1 - deluge/ui/functions.py | 11 + deluge/ui/gtkui/aboutdialog.py | 76 ++ deluge/ui/gtkui/glade/main_window.glade | 931 ++++++++++++------------ deluge/ui/gtkui/menubar.py | 3 + 5 files changed, 556 insertions(+), 466 deletions(-) create mode 100644 deluge/ui/gtkui/aboutdialog.py diff --git a/TODO b/TODO index b782985d1..e93528a79 100644 --- a/TODO +++ b/TODO @@ -19,6 +19,5 @@ * Create a new status icon.. a red alert icon to show there is an error with the torrent.. ie, disk full alert and stuff like that.. * Add the tracker responses to the torrent details -* About dialog * Fast resume saving * Restart daemon function diff --git a/deluge/ui/functions.py b/deluge/ui/functions.py index 531f1423e..5de6bc472 100644 --- a/deluge/ui/functions.py +++ b/deluge/ui/functions.py @@ -159,3 +159,14 @@ def get_listen_port(core=None): core = get_core() return int(core.get_listen_port()) +def open_url_in_browser(link): + """Opens link in the desktop's default browser""" + import threading + import webbrowser + class BrowserThread(threading.Thread): + def __init__(self, link): + threading.Thread.__init__(self) + self.url = link + def run(self): + webbrowser.open(self.url) + BrowserThread(link).start() diff --git a/deluge/ui/gtkui/aboutdialog.py b/deluge/ui/gtkui/aboutdialog.py new file mode 100644 index 000000000..4980c3eb9 --- /dev/null +++ b/deluge/ui/gtkui/aboutdialog.py @@ -0,0 +1,76 @@ +# +# self.aboutdialog.py +# +# Copyright (C) 2007 Marcos Pinto ('markybob') +# +# Deluge is free software. +# +# You may redistribute it and/or modify it under the terms of the +# GNU General Public License, as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# deluge 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 deluge. If not, write to: +# The Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor +# Boston, MA 02110-1301, USA. +# +# In addition, as a special exception, the copyright holders give +# permission to link the code of portions of this program with the OpenSSL +# library. +# You must obey the GNU General Public License in all respects for all of +# the code used other than OpenSSL. If you modify file(s) with this +# exception, you may extend this exception to your version of the file(s), +# but you are not obligated to do so. If you do not wish to do so, delete +# this exception statement from your version. If you delete this exception +# statement from all source files in the program, then also delete it here. + +import pygtk +pygtk.require('2.0') +import gtk +import pkg_resources + +import deluge.common +import deluge.ui.functions as functions + +class AboutDialog: + def __init__(self): + # Get the glade file for the about dialog + def url_hook(dialog, url): + functions.open_url_in_browser(url) + gtk.about_dialog_set_url_hook(url_hook) + self.about = gtk.glade.XML(pkg_resources.resource_filename(\ + "deluge.ui.gtkui", "glade/aboutdialog.glade")).get_widget(\ + "aboutdialog") + self.about.set_position(gtk.WIN_POS_CENTER) + self.about.set_name("Deluge") + self.about.set_version(deluge.common.get_version()) + self.about.set_authors(["Andrew Resch", "Marcos Pinto"]) + self.about.set_artists(["Andrew Wedderburn"]) + self.about.set_translator_credits(_("translator-credits")) + self.about.set_license(_("Deluge is free software, you can redistribute \ +it and/or\nmodify it under the terms of the GNU General Public\n License as \ +published by the Free Software Foundation,\neither version 2 of the License, \ +or (at your option) any\nlater version. Deluge is distributed in the hope \ +that it\nwill be useful, but WITHOUT ANY WARRANTY, without even \nthe implied \ +warranty of MERCHANTABILITY or FITNESS\nFOR A PARTICULAR PURPOSE. See the GNU \ +General\nPublic License for more details. You should have received\na copy of \ +the GNU General Public License along with\nDeluge, but if not, write to the \ +Free Software Foundation,\n Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110\ +-\n1301 USA")) + self.about.set_website("http://deluge-torrent.org") + self.about.set_website_label("http://deluge-torrent.org") + self.about.set_icon(deluge.common.get_logo(32)) + self.about.set_logo(gtk.gdk.pixbuf_new_from_file( + deluge.common.get_pixmap("deluge-about.png"))) + + def run(self): + self.about.show_all() + self.about.run() + self.about.destroy() diff --git a/deluge/ui/gtkui/glade/main_window.glade b/deluge/ui/gtkui/glade/main_window.glade index dd79347db..04a171142 100644 --- a/deluge/ui/gtkui/glade/main_window.glade +++ b/deluge/ui/gtkui/glade/main_window.glade @@ -172,6 +172,7 @@ gtk-about True True + @@ -347,6 +348,376 @@ 1 2 10 + + + True + 0 + + + True + 10 + 10 + 15 + 15 + + + True + 5 + + + True + 0.10000000149 + + + False + False + + + + + True + 5 + 4 + 5 + + + True + 0 + + + 1 + 2 + + + + + True + 0 + + + 3 + 4 + + + + + True + 0 + + + 1 + 2 + 1 + 2 + + + + + True + 0 + + + 3 + 4 + 1 + 2 + + + + + True + 0 + + + 1 + 2 + 2 + 3 + + + + + True + 0 + + + 3 + 4 + 2 + 3 + + + + + True + 0 + + + 1 + 2 + 3 + 4 + + + + + True + 0 + + + 3 + 4 + 3 + 4 + + + + + True + 5 + + + True + 0 + <b>Downloaded:</b> + True + + + + + + + True + 5 + + + True + 0 + <b>Uploaded:</b> + True + + + + + 1 + 2 + + + + + True + 5 + + + True + 0 + <b>Seeders:</b> + True + + + + + 2 + 3 + + + + + True + 5 + + + True + 0 + <b>Share Ratio:</b> + True + + + + + 3 + 4 + + + + + True + 15 + 5 + + + True + 0 + <b>Speed:</b> + True + + + + + 2 + 3 + + + + + True + 15 + 5 + + + True + 0 + <b>Speed:</b> + True + + + + + 2 + 3 + 1 + 2 + + + + + True + 15 + 5 + + + True + 0 + <b>Peers:</b> + True + + + + + 2 + 3 + 2 + 3 + + + + + True + 15 + 5 + + + True + 0 + <b>ETA:</b> + True + + + + + 2 + 3 + 3 + 4 + + + + + True + 0 + 1 + <b>Pieces:</b> + True + + + 4 + 5 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + + + + + 1 + 2 + 4 + 5 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 15 + 5 + + + True + 0 + 1 + <b>Availability:</b> + True + + + + + 2 + 3 + 4 + 5 + + + + + True + 0 + True + PANGO_WRAP_WORD_CHAR + + + 3 + 4 + 4 + 5 + + + + + + False + 1 + + + + + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + <b>Statistics</b> + True + + + label_item + + + + + + GTK_FILL + + True @@ -367,33 +738,54 @@ 2 2 - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b># of files:</b> + True + + + + + 2 + 3 + GTK_FILL + + + + True 0 1 2 - 5 - 6 + 2 + 3 - + True 0 1 2 - 4 - 5 + 1 + 2 - + True 0 True @@ -402,77 +794,27 @@ 1 2 - 3 - 4 - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 - + True 0 - 0 1 - <b>Name:</b> + <b>Total Size:</b> True - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Next Announce:</b> - True - - - - - 5 - 6 - GTK_FILL - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b>Tracker Status:</b> - True - - - - - - - 4 - 5 + 1 + 2 GTK_FILL @@ -505,28 +847,76 @@ - + True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 1 + <b>Tracker Status:</b> + True + + + + + + + 4 + 5 + GTK_FILL + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + True 0 1 - <b>Total Size:</b> + <b>Next Announce:</b> True - 1 - 2 + 5 + 6 GTK_FILL - + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 5 + + + True + 0 + 0 + 1 + <b>Name:</b> + True + + + + + GTK_FILL + + + + True 0 True @@ -535,56 +925,37 @@ 1 2 + 3 + 4 - + True 0 1 2 - 1 - 2 + 4 + 5 - + True 0 1 2 - 2 - 3 + 5 + 6 - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - 1 - <b># of files:</b> - True - - - - - 2 - 3 - GTK_FILL - - @@ -607,376 +978,6 @@ GTK_FILL - - - True - 0 - - - True - 10 - 10 - 15 - 15 - - - True - 5 - - - True - 0.10000000149 - - - False - False - - - - - True - 5 - 4 - 5 - - - True - 0 - True - PANGO_WRAP_WORD_CHAR - - - 3 - 4 - 4 - 5 - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 15 - 5 - - - True - 0 - 1 - <b>Availability:</b> - True - - - - - 2 - 3 - 4 - 5 - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - 5 - - - True - 0 - - - - - 1 - 2 - 4 - 5 - - - - - True - 0 - 1 - <b>Pieces:</b> - True - - - 4 - 5 - - - - - True - 15 - 5 - - - True - 0 - <b>ETA:</b> - True - - - - - 2 - 3 - 3 - 4 - - - - - True - 15 - 5 - - - True - 0 - <b>Peers:</b> - True - - - - - 2 - 3 - 2 - 3 - - - - - True - 15 - 5 - - - True - 0 - <b>Speed:</b> - True - - - - - 2 - 3 - 1 - 2 - - - - - True - 15 - 5 - - - True - 0 - <b>Speed:</b> - True - - - - - 2 - 3 - - - - - True - 5 - - - True - 0 - <b>Share Ratio:</b> - True - - - - - 3 - 4 - - - - - True - 5 - - - True - 0 - <b>Seeders:</b> - True - - - - - 2 - 3 - - - - - True - 5 - - - True - 0 - <b>Uploaded:</b> - True - - - - - 1 - 2 - - - - - True - 5 - - - True - 0 - <b>Downloaded:</b> - True - - - - - - - True - 0 - - - 3 - 4 - 3 - 4 - - - - - True - 0 - - - 1 - 2 - 3 - 4 - - - - - True - 0 - - - 3 - 4 - 2 - 3 - - - - - True - 0 - - - 1 - 2 - 2 - 3 - - - - - True - 0 - - - 3 - 4 - 1 - 2 - - - - - True - 0 - - - 1 - 2 - 1 - 2 - - - - - True - 0 - - - 3 - 4 - - - - - True - 0 - - - 1 - 2 - - - - - False - 1 - - - - - - - - - True - GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - <b>Statistics</b> - True - - - label_item - - - - - - GTK_FILL - - diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 7252806b6..85e17d09c 100644 --- a/deluge/ui/gtkui/menubar.py +++ b/deluge/ui/gtkui/menubar.py @@ -156,3 +156,6 @@ class MenuBar: ## Help Menu ## def on_menuitem_about_activate(self, data=None): log.debug("on_menuitem_about_activate") + from aboutdialog import AboutDialog + AboutDialog().run() +