gget r85 - trunk/gget



Author: johans
Date: Sat Aug 16 23:24:45 2008
New Revision: 85
URL: http://svn.gnome.org/viewvc/gget?rev=85&view=rev

Log:
Added a confirmation dialog when quitting with active downloads.

Added:
   trunk/gget/QuitDialog.py
Modified:
   trunk/gget/AddDownloadDialog.py
   trunk/gget/Configuration.py
   trunk/gget/DownloadList.py
   trunk/gget/MainWindow.py
   trunk/gget/Makefile.am
   trunk/gget/Notification.py
   trunk/gget/PreferencesDialog.py
   trunk/gget/StatusIcon.py
   trunk/gget/TrayIcon.py
   trunk/gget/Utils.py

Modified: trunk/gget/AddDownloadDialog.py
==============================================================================
--- trunk/gget/AddDownloadDialog.py	(original)
+++ trunk/gget/AddDownloadDialog.py	Sat Aug 16 23:24:45 2008
@@ -66,12 +66,18 @@
         self.cancel_button = xml.get_widget("add_cancel_button")
 
     def __connect_widgets(self):
+        self.dialog.connect("delete-event", self.__dialog_delete)
+
         self.uri_entry.connect("changed", self.__uri_entry_changed)
         self.uri_entry.connect("activate", self.__uri_entry_activate)
 
         self.add_button.connect("clicked", self.__add_button_clicked)
         self.cancel_button.connect("clicked", self.__cancel_button_clicked)
 
+    def __dialog_delete(self, dialog, event):
+        self.dialog.destroy()
+        return False
+
     def __uri_entry_changed(self, entry):
         uri = entry.get_text()
         if len(uri) > 0 and Utils.is_supported_uri(uri):

Modified: trunk/gget/Configuration.py
==============================================================================
--- trunk/gget/Configuration.py	(original)
+++ trunk/gget/Configuration.py	Sat Aug 16 23:24:45 2008
@@ -37,6 +37,7 @@
 KEY_SHOW_STATUS_ICON   = "/general/show_status_icon"
 KEY_SHOW_MAIN_WINDOW   = "/general/show_main_window"
 KEY_SHOW_NOTIFICATIONS = "/general/show_notifications"
+KEY_SHOW_QUIT_DIALOG   = "/general/show_quit_dialog"
 KEY_AUTOSTART          = "/general/autostart"
 KEY_WINDOW_WIDTH       = "/general/window_width"
 KEY_WINDOW_HEIGHT      = "/general/window_height"
@@ -82,6 +83,7 @@
                      KEY_SHOW_STATUS_ICON:   'bool',
                      KEY_SHOW_MAIN_WINDOW:   'bool',
                      KEY_SHOW_NOTIFICATIONS: 'bool',
+                     KEY_SHOW_QUIT_DIALOG:   'bool',
                      KEY_AUTOSTART:          'bool',
                      KEY_WINDOW_WIDTH:       'int',
                      KEY_WINDOW_HEIGHT:      'int',
@@ -221,6 +223,15 @@
     show_notifications = property(get_show_notifications,
             set_show_notifications)
 
+    # Show Quit dialog
+    def get_show_quit_dialog(self):
+        return self.__get_option(KEY_SHOW_QUIT_DIALOG)
+
+    def set_show_quit_dialog(self, show_quit_dialog):
+        self.__set_option(KEY_SHOW_QUIT_DIALOG, show_quit_dialog)
+
+    show_quit_dialog = property(get_show_quit_dialog, set_show_quit_dialog)
+
     # Autostart
     def get_autostart(self):
         return self.__get_option(KEY_AUTOSTART)

Modified: trunk/gget/DownloadList.py
==============================================================================
--- trunk/gget/DownloadList.py	(original)
+++ trunk/gget/DownloadList.py	Sat Aug 16 23:24:45 2008
@@ -192,6 +192,14 @@
             if download.status == Download.COMPLETED:
                 self.remove_download(download)
 
+    def has_active_downloads(self):
+        """Checks if there are any active downloads in progress."""
+        downloads = list(self.downloads)
+        for download in downloads:
+            if download.status in [Download.CONNECTING, Download.DOWNLOADING]:
+                return True
+        return False
+
     def __save_xml(self):
         """Adds a header and indents the xml tree before saving it to disk."""
         Utils.debug_print("Saved download list to: %s" %

Modified: trunk/gget/MainWindow.py
==============================================================================
--- trunk/gget/MainWindow.py	(original)
+++ trunk/gget/MainWindow.py	Sat Aug 16 23:24:45 2008
@@ -2,20 +2,20 @@
 
 # Copyright (C) 2008 Johan Svedberg <johan svedberg com>
 
-# This file is part of gget.
+# This file is part of GGet.
 
-# gget is free software; you can redistribute it and/or modify
+# GGet 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 2 of the License, or
 # (at your option) any later version.
 
-# gget is distributed in the hope that it will be useful,
+# GGet 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 gget; if not, write to the Free Software
+# along with GGet; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import sys
@@ -23,6 +23,7 @@
 from gettext import gettext as _
 
 import gtk
+import gtk.gdk
 import gobject
 import gconf
 import gnomevfs
@@ -37,6 +38,7 @@
 from AddDownloadDialog import AddDownloadDialog
 from PreferencesDialog import PreferencesDialog
 from DetailsDialog import DetailsDialog
+from QuitDialog import QuitDialog
 from gget import NAME
 
 # D&D targets
@@ -681,7 +683,10 @@
 
     def quit(self, widget=None):
         """Quits the application. Called from various places."""
-        # TODO: Shutdown gracefully
+        if self.download_list.has_active_downloads() and self.config.show_quit_dialog:
+            quit_dialog = QuitDialog()
+            if quit_dialog.dialog.run() in [-4, 0]:
+                return
         gtk.main_quit()
 
     def __add_config_notifications(self):

Modified: trunk/gget/Makefile.am
==============================================================================
--- trunk/gget/Makefile.am	(original)
+++ trunk/gget/Makefile.am	Sat Aug 16 23:24:45 2008
@@ -15,6 +15,7 @@
 	MainWindow.py		\
 	Notification.py		\
 	PreferencesDialog.py	\
+	QuitDialog.py		\
 	StatusIcon.py		\
 	TrayIcon.py		\
 	Utils.py

Modified: trunk/gget/Notification.py
==============================================================================
--- trunk/gget/Notification.py	(original)
+++ trunk/gget/Notification.py	Sat Aug 16 23:24:45 2008
@@ -2,20 +2,20 @@
 
 # Copyright (C) 2008 Johan Svedberg <johan svedberg com>
 
-# This file is part of gget.
+# This file is part of GGet.
 
-# gget is free software; you can redistribute it and/or modify
+# GGet 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 2 of the License, or
 # (at your option) any later version.
 
-# gget is distributed in the hope that it will be useful,
+# GGet 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 gget; if not, write to the Free Software
+# along with GGet; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import sys

Modified: trunk/gget/PreferencesDialog.py
==============================================================================
--- trunk/gget/PreferencesDialog.py	(original)
+++ trunk/gget/PreferencesDialog.py	Sat Aug 16 23:24:45 2008
@@ -2,20 +2,20 @@
 
 # Copyright (C) 2008 Johan Svedberg <johan svedberg com>
 
-# This file is part of gget.
+# This file is part of GGet.
 
-# gget is free software; you can redistribute it and/or modify
+# GGet 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 2 of the License, or
 # (at your option) any later version.
 
-# gget is distributed in the hope that it will be useful,
+# GGet 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 gget; if not, write to the Free Software
+# along with GGet; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import os.path
@@ -49,6 +49,7 @@
         self.status_icon_checkbutton.set_active(self.config.show_status_icon)
         self.main_window_checkbutton.set_active(self.config.show_main_window)
         self.notifications_checkbutton.set_active(self.config.show_notifications)
+        self.quit_dialog_checkbutton.set_active(self.config.show_quit_dialog)
         self.autostart_checkbutton.set_active(self.config.autostart)
 
         self.main_window_checkbutton.set_sensitive(self.config.show_status_icon)
@@ -91,6 +92,7 @@
         self.status_icon_checkbutton = xml.get_widget("status_icon_checkbutton")
         self.main_window_checkbutton = xml.get_widget("main_window_checkbutton")
         self.notifications_checkbutton = xml.get_widget("notifications_checkbutton")
+        self.quit_dialog_checkbutton = xml.get_widget("quit_dialog_checkbutton")
 
         self.autostart_checkbutton = xml.get_widget("autostart_checkbutton")
 
@@ -178,6 +180,8 @@
                 self.__main_window_checkbutton_toggled)
         self.notifications_checkbutton.connect("toggled",
                 self.__notifications_checkbutton_toggled)
+        self.quit_dialog_checkbutton.connect("toggled",
+                self.__quit_dialog_checkbutton_toggled)
 
         self.autostart_checkbutton.connect("toggled",
                 self.__autostart_checkbutton_toggled)
@@ -228,6 +232,8 @@
                 self.__show_main_window_key_changed)
         self.config.add_notify(Configuration.KEY_SHOW_NOTIFICATIONS,
                 self.__show_notifications_key_changed)
+        self.config.add_notify(Configuration.KEY_SHOW_QUIT_DIALOG,
+                self.__show_quit_dialog_key_changed)
         self.config.add_notify(Configuration.KEY_AUTOSTART,
                 self.__autostart_key_changed)
         self.config.add_notify(Configuration.KEY_ASK_FOR_LOCATION,
@@ -288,6 +294,14 @@
         else:
             self.notifications_checkbutton.set_active(True)
 
+    def __show_quit_dialog_key_changed(self, client, cnxn_id, entry, data):
+        if not entry.value:
+            self.quit_dialog_checkbutton.set_active(True)
+        elif entry.value.type == gconf.VALUE_BOOL:
+            self.quit_dialog_checkbutton.set_active(entry.value.get_bool())
+        else:
+            self.quit_dialog_checkbutton.set_active(True)
+
     def __autostart_key_changed(self, client, cnxn_id, entry, data):
         if not entry.value:
             self.autostart_checkbutton.set_active(True)
@@ -406,6 +420,9 @@
     def __notifications_checkbutton_toggled(self, checkbutton):
         self.config.show_notifications = checkbutton.get_active()
 
+    def __quit_dialog_checkbutton_toggled(self, checkbutton):
+        self.config.show_quit_dialog = checkbutton.get_active()
+
     def __autostart_checkbutton_toggled(self, checkbutton):
         self.config.autostart = checkbutton.get_active()
 

Added: trunk/gget/QuitDialog.py
==============================================================================
--- (empty file)
+++ trunk/gget/QuitDialog.py	Sat Aug 16 23:24:45 2008
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2008 Johan Svedberg <johan svedberg com>
+
+# This file is part of GGet.
+
+# GGet 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 2 of the License, or
+# (at your option) any later version.
+
+# GGet 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 GGet; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+import gtk
+import gconf
+
+import GUI
+import Configuration
+from gget import NAME
+
+class QuitDialog:
+    def __init__(self):
+        self.config = Configuration.Configuration()
+
+        self.__get_widgets()
+        self.__connect_widgets()
+
+        self.config.add_notify(Configuration.KEY_SHOW_QUIT_DIALOG,
+                self.__show_quit_dialog_key_changed)
+
+        self.show_again_checkbutton.set_active(not self.config.show_quit_dialog)
+
+    def __get_widgets(self):
+        xml = gtk.glade.XML(GUI.glade_file, domain=NAME.lower())
+
+        self.dialog = xml.get_widget("quit_dialog")
+
+        self.show_again_checkbutton = xml.get_widget("show_quit_dialog_checkbutton")
+
+        self.no_button = xml.get_widget("quit_no_button")
+        self.yes_button = xml.get_widget("quit_yes_button")
+
+    def __connect_widgets(self):
+        self.dialog.connect("delete-event", self.__dialog_delete)
+        self.show_again_checkbutton.connect("toggled",
+                self.__show_again_checkbutton_toggled)
+        self.no_button.connect("clicked", self.__button_clicked)
+        self.yes_button.connect("clicked", self.__button_clicked)
+
+    def __dialog_delete(self, dialog, event):
+        self.dialog.destroy()
+        return False
+
+    def __show_again_checkbutton_toggled(self, checkbutton):
+        self.config.show_quit_dialog = not checkbutton.get_active()
+
+    def __button_clicked(self, button):
+        self.dialog.destroy()
+
+    def __show_quit_dialog_key_changed(self, client, cnxn_id, entry, data):
+        if not entry.value:
+            self.show_again_checkbutton.set_active(True)
+        elif entry.value.type == gconf.VALUE_BOOL:
+            self.show_again_checkbutton.set_active(not entry.value.get_bool())
+        else:
+            self.show_again_checkbutton.set_active(True)
+
+# vim: set sw=4 et sts=4 tw=79 fo+=l:

Modified: trunk/gget/StatusIcon.py
==============================================================================
--- trunk/gget/StatusIcon.py	(original)
+++ trunk/gget/StatusIcon.py	Sat Aug 16 23:24:45 2008
@@ -2,20 +2,20 @@
 
 # Copyright (C) 2008 Johan Svedberg <johan svedberg com>
 
-# This file is part of gget.
+# This file is part of GGet.
 
-# gget is free software; you can redistribute it and/or modify
+# GGet 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 2 of the License, or
 # (at your option) any later version.
 
-# gget is distributed in the hope that it will be useful,
+# GGet 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 gget; if not, write to the Free Software
+# along with GGet; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import gtk

Modified: trunk/gget/TrayIcon.py
==============================================================================
--- trunk/gget/TrayIcon.py	(original)
+++ trunk/gget/TrayIcon.py	Sat Aug 16 23:24:45 2008
@@ -2,20 +2,20 @@
 
 # Copyright (C) 2008 Johan Svedberg <johan svedberg com>
 
-# This file is part of gget.
+# This file is part of GGet.
 
-# gget is free software; you can redistribute it and/or modify
+# GGet 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 2 of the License, or
 # (at your option) any later version.
 
-# gget is distributed in the hope that it will be useful,
+# GGet 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 gget; if not, write to the Free Software
+# along with GGet; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import gtk

Modified: trunk/gget/Utils.py
==============================================================================
--- trunk/gget/Utils.py	(original)
+++ trunk/gget/Utils.py	Sat Aug 16 23:24:45 2008
@@ -2,20 +2,20 @@
 
 # Copyright (C) 2008 Johan Svedberg <johan svedberg com>
 
-# This file is part of gget.
+# This file is part of GGet.
 
-# gget is free software; you can redistribute it and/or modify
+# GGet 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 2 of the License, or
 # (at your option) any later version.
 
-# gget is distributed in the hope that it will be useful,
+# GGet 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 gget; if not, write to the Free Software
+# along with GGet; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 
 import fnmatch



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]