clean up in FT window

This commit is contained in:
Nikos Kouremenos 2005-09-03 14:23:53 +00:00
parent d0ecafdcc2
commit ac7e0c2af8
2 changed files with 172 additions and 80 deletions

View File

@ -49,7 +49,7 @@ class FileTransfersWindow:
self.tree = self.xml.get_widget('transfers_list')
self.cancel_button = self.xml.get_widget('cancel_button')
self.pause_button = self.xml.get_widget('pause_restore_button')
self.remove_button = self.xml.get_widget('remove_button')
self.cleanup_button = self.xml.get_widget('cleanup_button')
self.notify_ft_checkbox = self.xml.get_widget(
'notify_ft_complete_checkbox')
notify = gajim.config.get('notify_on_file_complete')
@ -105,10 +105,6 @@ class FileTransfersWindow:
self.pause_menuitem = popup_xml.get_widget('pause_menuitem')
self.continue_menuitem = popup_xml.get_widget('continue_menuitem')
self.remove_menuitem = popup_xml.get_widget('remove_menuitem')
self.clean_up_menuitem = popup_xml.get_widget('clean_up_menuitem')
if gtk.gtk_version >= (2, 6, 0) and gtk.pygtk_version >= (2, 6, 0):
self.pause_button.set_image(gtk.image_new_from_stock(
gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU))
popup_xml.signal_autoconnect(self)
def find_transfer_by_jid(self, account, jid):
@ -172,9 +168,8 @@ class FileTransfersWindow:
[_('_Open Containing Folder'), gtk.RESPONSE_ACCEPT],
[ gtk.STOCK_OK, gtk.RESPONSE_OK ]])
button = dialog.get_button(1)
if gtk.gtk_version >= (2, 6, 0) and gtk.pygtk_version >= (2, 6, 0):
button.set_image(gtk.image_new_from_stock(
gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_BUTTON))
button.set_image(gtk.image_new_from_stock(
gtk.STOCK_DIRECTORY, gtk.ICON_SIZE_BUTTON))
dialog.show_all()
if file_props['type'] == 's':
button.hide()
@ -530,7 +525,7 @@ _('Connection with peer cannot be established.'))
self.pause_button.set_sensitive(False)
self.pause_menuitem.set_sensitive(False)
self.continue_menuitem.set_sensitive(False)
self.remove_button.set_sensitive(False)
self.cleanup_button.set_sensitive(False)
self.remove_menuitem.set_sensitive(False)
self.cancel_button.set_sensitive(False)
self.cancel_menuitem.set_sensitive(False)
@ -545,7 +540,6 @@ _('Connection with peer cannot be established.'))
current_iter = self.model.get_iter(path)
sid = self.model[current_iter][4].decode('utf-8')
file_props = self.files_props[sid[0]][sid[1:]]
self.remove_button.set_sensitive(is_row_selected)
self.remove_menuitem.set_sensitive(is_row_selected)
self.open_folder_menuitem.set_sensitive(is_row_selected)
is_stopped = False
@ -596,31 +590,26 @@ _('Connection with peer cannot be established.'))
self.set_buttons_sensitive(path, is_selected)
return True
def on_remove_button_clicked(self, widget):
selected = self.tree.get_selection().get_selected()
if selected is None or selected[1] is None:
return
s_iter = selected[1]
sid = self.model[s_iter][4].decode('utf-8')
file_props = self.files_props[sid[0]][sid[1:]]
if not file_props.has_key('tt_account'):
# file transfer is not set yet
return
account = file_props['tt_account']
if not gajim.connections.has_key(account):
# no connection to the account
return
gajim.connections[account].remove_transfer(file_props)
self.model.remove(s_iter)
def on_cleanup_button_clicked(self, widget):
i = len(self.model) - 1
while i >= 0:
iter = self.model.get_iter((i))
sid = self.model[iter][4].decode('utf-8')
file_props = self.files_props[sid[0]][sid[1:]]
if file_props.has_key('completed') and file_props['completed']:
self.model.remove(iter)
elif file_props.has_key('stopped') and file_props['stopped']:
self.model.remove(iter)
i -= 1
self.tree.get_selection().unselect_all()
self.set_all_insensitive()
def toggle_pause_continue(self, status):
if status:
label = _('Pause')
self.pause_button.set_label(label)
if gtk.gtk_version >= (2, 6, 0) and gtk.pygtk_version >= (2, 6, 0):
self.pause_button.set_image(gtk.image_new_from_stock(
gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU))
self.pause_button.set_image(gtk.image_new_from_stock(
gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU))
self.pause_menuitem.set_sensitive(True)
self.pause_menuitem.set_no_show_all(False)
@ -630,9 +619,8 @@ _('Connection with peer cannot be established.'))
else:
label = _('_Continue')
self.pause_button.set_label(label)
if gtk.gtk_version >= (2, 6, 0) and gtk.pygtk_version >= (2, 6, 0):
self.pause_button.set_image(gtk.image_new_from_stock(
gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_MENU))
self.pause_button.set_image(gtk.image_new_from_stock(
gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_MENU))
self.pause_menuitem.hide()
self.pause_menuitem.set_no_show_all(True)
self.continue_menuitem.set_sensitive(True)
@ -705,9 +693,9 @@ _('Connection with peer cannot be established.'))
def show_context_menu(self, event, iter):
# change the sensitive propery of the buttons and menuitems
if len(self.model) == 0:
self.clean_up_menuitem.set_sensitive(False)
self.cleanup_button.set_sensitive(False)
else:
self.clean_up_menuitem.set_sensitive(True)
self.cleanup_button.set_sensitive(True)
path = None
if iter is not None:
path = self.model.get_path(iter)
@ -776,21 +764,6 @@ _('Connection with peer cannot be established.'))
if path is not None:
return True
def on_clean_up_menuitem_activate(self, widget):
i = len(self.model) - 1
while i >= 0:
iter = self.model.get_iter((i))
sid = self.model[iter][4].decode('utf-8')
file_props = self.files_props[sid[0]][sid[1:]]
if file_props.has_key('completed') and file_props['completed']:
self.model.remove(iter)
elif file_props.has_key('stopped') and file_props['stopped']:
self.model.remove(iter)
i -= 1
self.tree.get_selection().unselect_all()
self.set_all_insensitive()
def on_open_folder_menuitem_activate(self, widget):
selected = self.tree.get_selection().get_selected()
if selected is None or selected[1] is None:
@ -815,7 +788,22 @@ _('Connection with peer cannot be established.'))
#FIXME: change the stock
def on_remove_menuitem_activate(self, widget):
self.on_remove_button_clicked(widget)
selected = self.tree.get_selection().get_selected()
if selected is None or selected[1] is None:
return
s_iter = selected[1]
sid = self.model[s_iter][4].decode('utf-8')
file_props = self.files_props[sid[0]][sid[1:]]
if not file_props.has_key('tt_account'):
# file transfer is not set yet
return
account = file_props['tt_account']
if not gajim.connections.has_key(account):
# no connection to the account
return
gajim.connections[account].remove_transfer(file_props)
self.model.remove(s_iter)
self.set_all_insensitive()
def on_file_transfers_window_key_press_event(self, widget, event):
if event.keyval == gtk.keysyms.Escape: # ESCAPE

View File

@ -18648,13 +18648,12 @@ Maybe I'll refactor later</property>
<property name="spacing">6</property>
<child>
<widget class="GtkButton" id="remove_button">
<widget class="GtkButton" id="cleanup_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="tooltip" translatable="yes">Removes completed, canceled and failed file transfers from the list</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-remove</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<accessibility>
@ -18662,7 +18661,71 @@ Maybe I'll refactor later</property>
<atkproperty name="AtkObject::accessible_description" translatable="yes">This action removes single file transfer from the list. If the transfer is active, it is first stopped and then removed</atkproperty>
<atkaction action_name="click" description="Removing selected file transfer"/>
</accessibility>
<signal name="clicked" handler="on_remove_button_clicked" last_modification_time="Wed, 03 Aug 2005 00:23:18 GMT"/>
<signal name="clicked" handler="on_cleanup_button_clicked" last_modification_time="Sat, 03 Sep 2005 14:03:13 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment91">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox2992">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image1143">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label358">
<property name="visible">True</property>
<property name="label" translatable="yes">Clean _up</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
@ -18672,11 +18735,73 @@ Maybe I'll refactor later</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">_Pause</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<signal name="clicked" handler="on_pause_restore_button_clicked" last_modification_time="Wed, 31 Aug 2005 22:31:50 GMT"/>
<child>
<widget class="GtkAlignment" id="alignment92">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox2993">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image1147">
<property name="visible">True</property>
<property name="stock">gtk-media-pause</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label359">
<property name="visible">True</property>
<property name="label" translatable="yes">_Pause</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
@ -18767,7 +18892,7 @@ Maybe I'll refactor later</property>
<signal name="activate" handler="on_continue_menuitem_activate" last_modification_time="Fri, 09 Sep 2005 22:48:03 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1127">
<widget class="GtkImage" id="image1144">
<property name="visible">True</property>
<property name="stock">gtk-media-play</property>
<property name="icon_size">1</property>
@ -18787,7 +18912,7 @@ Maybe I'll refactor later</property>
<signal name="activate" handler="on_pause_menuitem_activate" last_modification_time="Fri, 09 Sep 2005 22:48:03 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1128">
<widget class="GtkImage" id="image1145">
<property name="visible">True</property>
<property name="stock">gtk-media-pause</property>
<property name="icon_size">1</property>
@ -18821,7 +18946,7 @@ Maybe I'll refactor later</property>
<signal name="activate" handler="on_open_folder_menuitem_activate" last_modification_time="Fri, 09 Sep 2005 22:48:03 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1129">
<widget class="GtkImage" id="image1146">
<property name="visible">True</property>
<property name="stock">gtk-directory</property>
<property name="icon_size">1</property>
@ -18833,27 +18958,6 @@ Maybe I'll refactor later</property>
</child>
</widget>
</child>
<child>
<widget class="GtkImageMenuItem" id="clean_up_menuitem">
<property name="tooltip" translatable="yes">Removes completed, canceled and failed file transfers from the list</property>
<property name="label" translatable="yes">Clean _up</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_clean_up_menuitem_activate" last_modification_time="Fri, 09 Sep 2005 22:48:03 GMT"/>
<child internal-child="image">
<widget class="GtkImage" id="image1130">
<property name="visible">True</property>
<property name="stock">gtk-clear</property>
<property name="icon_size">1</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
</child>
</widget>
</child>
</widget>
</glade-interface>