nice add/remove dlgs

This commit is contained in:
Zach Tibbitts 2007-02-12 18:14:15 +00:00
parent d2ecf8a433
commit 2ac573c0b2
4 changed files with 898 additions and 762 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.1.4 on Fri Dec 22 14:02:17 2006 by zach@notapowerbook-->
<!--Generated with glade3 3.1.4 on Mon Feb 12 12:36:18 2007 by zach@notapowerbook-->
<glade-interface>
<widget class="GtkMenu" id="torrent_popup">
<property name="visible">True</property>
@ -77,4 +77,83 @@
</widget>
</child>
</widget>
<widget class="GtkDialog" id="remove_torrent_dlg">
<property name="title" translatable="yes">Remove Torrent</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">&lt;b&gt;Are you sure you want to remove the selected torrent(s) from Deluge?&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="padding">10</property>
</packing>
</child>
<child>
<widget class="GtkCheckButton" id="data_also">
<property name="visible">True</property>
<property name="label" translatable="yes">Delete downloaded files</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="warning">
<property name="visible">True</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
<property name="label">gtk-no</property>
<property name="use_stock">True</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="label">gtk-yes</property>
<property name="use_stock">True</property>
<property name="response_id">1</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View file

@ -30,6 +30,7 @@ import dbus, dbus.service
if getattr(dbus, 'version', (0,0,0)) >= (0,41,0):
import dbus.glib
_ = gettext.gettext
class DelugeGTK(dbus.service.Object):
def __init__(self, bus_name=dbus.service.BusName('org.deluge_torrent.Deluge',
@ -80,8 +81,8 @@ class DelugeGTK(dbus.service.Object):
def connect_signals(self):
self.wtree.signal_autoconnect({
## File Menu
"new_torrent": self.new_torrent_clicked,
"add_torrent": self.add_torrent_clicked,
"add_torrent_url": self.add_torrent_url_clicked,
"remove_torrent" : self.remove_torrent_clicked,
"menu_quit": self.quit,
## Edit Menu
@ -417,10 +418,33 @@ class DelugeGTK(dbus.service.Object):
uid = self.manager.add_torrent(torrent, ".", True)
self.store.append(self.get_list_from_unique_id(uid))
def add_torrent_url_clicked(self, obj=None):
pass
def remove_torrent_clicked(self, obj=None):
torrent = self.get_selected_torrent()
if torrent is not None:
self.manager.remove_torrent(torrent, False)
glade = gtk.glade.XML(dcommon.get_glade_file("dgtkpopups.glade"))
asker = glade.get_widget("remove_torrent_dlg")
warning = glade.get_widget("warning")
warning.set_text(" ")
data_also = glade.get_widget("data_also")
data_also.connect("toggled", self.remove_toggle_warning, warning)
response = asker.run()
asker.destroy()
if response == 1:
self.manager.remove_torrent(torrent, data_also.get_active())
def remove_toggle_warning(self, args, warning):
if not args.get_active():
warning.set_text(" ")
else:
warning.set_markup("<i>" + "Warning - all downloaded files for this torrent will be deleted!" + "</i>")
return False
def update_tracker(self, obj=None):
torrent = self.get_selected_torrent()

View file

@ -44,11 +44,20 @@ class TrayIcon:
def popup(self):
pass
## A simple file open dialog. I'm going to improve it later,
## this is a quick implementation for testing.
def show_file_open_dialog():
chooser = gtk.FileChooserDialog("Open", None, gtk.FILE_CHOOSER_ACTION_OPEN,
## Browse for .torrent files
def show_file_open_dialog(parent=None):
chooser = gtk.FileChooserDialog("Choose a .torrent file", parent, gtk.FILE_CHOOSER_ACTION_OPEN,
buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
f0 = gtk.FileFilter()
f0.set_name(".torrent files")
f0.add_pattern("*." + "torrent")
chooser.add_filter(f0)
f1 = gtk.FileFilter()
f1.set_name("All files")
f1.add_pattern("*")
chooser.add_filter(f1)
response = chooser.run()
if response == gtk.RESPONSE_OK:
result = chooser.get_filename()
@ -56,7 +65,6 @@ def show_file_open_dialog():
result = None
chooser.destroy()
return result
## Functions to create columns