Some updates to the torrentcreator interface.

This commit is contained in:
Andrew Resch 2007-06-25 23:11:16 +00:00
parent 0407c8119a
commit 826057649c
2 changed files with 90 additions and 51 deletions

View File

@ -79,6 +79,7 @@ class TorrentCreator:
self.dialog = self.glade.get_widget("torrentcreator") self.dialog = self.glade.get_widget("torrentcreator")
self.glade.get_widget("piece_size_combobox").set_active(0) self.glade.get_widget("piece_size_combobox").set_active(0)
self.glade.get_widget("torrent_chooserbutton").connect("clicked", self.torrent_chooserbutton_clicked)
self.dialog.connect("destroy", self.destroy) self.dialog.connect("destroy", self.destroy)
self.dialog.show_all() self.dialog.show_all()
response = self.dialog.run() response = self.dialog.run()
@ -89,7 +90,16 @@ class TorrentCreator:
self.destroy() self.destroy()
return return
def torrent_chooserbutton_clicked(self, widget):
filechooser = gtk.FileChooserDialog(title=_("Save file as..."), parent=None, action=gtk.FILE_CHOOSER_ACTION_SAVE, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, gtk.RESPONSE_OK), backend=None)
response = filechooser.run()
# Update the torrentfile entry widget if a file was selected.
if response == gtk.RESPONSE_OK:
self.glade.get_widget("torrentfile_entry").set_text(filechooser.get_filename())
filechooser.destroy()
def create_torrent(self): def create_torrent(self):
# Create a torrent from the information provided in the torrentcreator dialog # Create a torrent from the information provided in the torrentcreator dialog
if self.glade.get_widget("folder_radiobutton").get_active(): if self.glade.get_widget("folder_radiobutton").get_active():
@ -97,7 +107,7 @@ class TorrentCreator:
else: else:
source = self.glade.get_widget("file_chooserbutton").get_filename() source = self.glade.get_widget("file_chooserbutton").get_filename()
torrent = self.glade.get_widget("torrent_chooserbutton").get_filename() torrent = self.glade.get_widget("torrentfile_entry").get_text()
piece_size = self.glade.get_widget("piece_size_combobox") piece_size = self.glade.get_widget("piece_size_combobox")
piece_size = piece_size.get_model().get_value(piece_size.get_active_iter(), 0).split(" ")[0] piece_size = piece_size.get_model().get_value(piece_size.get_active_iter(), 0).split(" ")[0]

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.2.2 on Mon Jun 25 02:38:11 2007 by andrew@fractal--> <!--Generated with glade3 3.2.2 on Mon Jun 25 15:46:49 2007 by andrew@fractal-->
<glade-interface> <glade-interface>
<widget class="GtkDialog" id="torrentcreator"> <widget class="GtkDialog" id="torrentcreator">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@ -42,7 +42,9 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">10</property> <property name="top_padding">10</property>
<property name="bottom_padding">10</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<property name="right_padding">12</property>
<child> <child>
<widget class="GtkVBox" id="vbox1"> <widget class="GtkVBox" id="vbox1">
<property name="visible">True</property> <property name="visible">True</property>
@ -59,6 +61,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">5</property> <property name="top_padding">5</property>
<property name="bottom_padding">5</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<widget class="GtkTable" id="table6"> <widget class="GtkTable" id="table6">
@ -67,16 +70,28 @@
<property name="n_rows">2</property> <property name="n_rows">2</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<child> <child>
<widget class="GtkRadioButton" id="folder_radiobutton"> <widget class="GtkFileChooserButton" id="file_chooserbutton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Folder:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="folder_chooserbutton">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -97,28 +112,16 @@
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkFileChooserButton" id="folder_chooserbutton"> <widget class="GtkRadioButton" id="folder_radiobutton">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="action">GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER</property> <property name="label" translatable="yes">Folder:</property>
<property name="response_id">0</property>
<property name="active">True</property>
<property name="draw_indicator">True</property>
</widget> </widget>
<packing> <packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFileChooserButton" id="file_chooserbutton">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
@ -153,6 +156,7 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="top_padding">5</property> <property name="top_padding">5</property>
<property name="bottom_padding">5</property>
<property name="left_padding">12</property> <property name="left_padding">12</property>
<child> <child>
<widget class="GtkVBox" id="vbox4"> <widget class="GtkVBox" id="vbox4">
@ -163,7 +167,43 @@
<property name="visible">True</property> <property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">1</property> <property name="n_rows">1</property>
<property name="n_columns">2</property> <property name="n_columns">3</property>
<child>
<widget class="GtkButton" id="torrent_chooserbutton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="response_id">0</property>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="stock">gtk-open</property>
<property name="icon_size">2</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="torrentfile_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="tooltip" translatable="yes">If no path is entered then the torrent file will be saved to the default torrent folder.</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child> <child>
<widget class="GtkLabel" id="label2"> <widget class="GtkLabel" id="label2">
<property name="visible">True</property> <property name="visible">True</property>
@ -175,17 +215,6 @@
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkFileChooserButton" id="torrent_chooserbutton">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property> <property name="expand">False</property>
@ -252,6 +281,7 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="wrap_mode">GTK_WRAP_CHAR</property> <property name="wrap_mode">GTK_WRAP_CHAR</property>
<property name="accepts_tab">False</property>
</widget> </widget>
</child> </child>
</widget> </widget>
@ -271,8 +301,6 @@
</child> </child>
</widget> </widget>
<packing> <packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property> <property name="position">2</property>
</packing> </packing>
</child> </child>
@ -300,6 +328,7 @@
<property name="can_focus">True</property> <property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property> <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="wrap_mode">GTK_WRAP_WORD_CHAR</property> <property name="wrap_mode">GTK_WRAP_WORD_CHAR</property>
<property name="accepts_tab">False</property>
</widget> </widget>
</child> </child>
</widget> </widget>
@ -378,17 +407,6 @@
<property name="n_rows">1</property> <property name="n_rows">1</property>
<property name="n_columns">2</property> <property name="n_columns">2</property>
<property name="column_spacing">10</property> <property name="column_spacing">10</property>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Piece Size:</property>
</widget>
<packing>
<property name="y_options"></property>
</packing>
</child>
<child> <child>
<widget class="GtkComboBox" id="piece_size_combobox"> <widget class="GtkComboBox" id="piece_size_combobox">
<property name="visible">True</property> <property name="visible">True</property>
@ -404,6 +422,17 @@
<property name="y_options"></property> <property name="y_options"></property>
</packing> </packing>
</child> </child>
<child>
<widget class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Piece Size:</property>
</widget>
<packing>
<property name="y_options"></property>
</packing>
</child>
</widget> </widget>
</child> </child>
</widget> </widget>