Changeset 2943
- Timestamp:
- 08/10/05 18:00:39 (3 years ago)
- Files:
-
- 1 modified
-
trunk/src/dialogs.py (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/dialogs.py
r2934 r2943 1596 1596 self.tree.append_column(col) 1597 1597 self.set_images() 1598 self.tree.get_selection().set_ select_function(self.select_func)1598 self.tree.get_selection().set_mode(gtk.SELECTION_SINGLE) 1599 1599 self.tooltip = FileTransfersTooltip() 1600 1600 self.xml.signal_autoconnect(self) … … 1605 1605 self.stop_menuitem = popup_xml.get_widget('stop_menuitem') 1606 1606 self.pause_menuitem = popup_xml.get_widget('pause_menuitem') 1607 self.continue_menuitem = popup_xml.get_widget('continue_menuitem') 1607 1608 self.remove_menuitem = popup_xml.get_widget('remove_menuitem') 1608 1609 self.clean_up_menuitem = popup_xml.get_widget('clean_up_menuitem') 1610 self.pause_button.set_image(gtk.image_new_from_stock( 1611 gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU)) 1609 1612 popup_xml.signal_autoconnect(self) 1610 1613 … … 1731 1734 self.images['pause'] = self.window.render_icon(gtk.STOCK_MEDIA_PAUSE, 1732 1735 gtk.ICON_SIZE_MENU) 1736 self.images['continue'] = self.window.render_icon(gtk.STOCK_MEDIA_PLAY, 1737 gtk.ICON_SIZE_MENU) 1733 1738 self.images['ok'] = self.window.render_icon(gtk.STOCK_APPLY, 1734 1739 gtk.ICON_SIZE_MENU) … … 1879 1884 1880 1885 def is_transfer_paused(self, file_props): 1881 if file_props.has_key(' error') and file_props['error'] != 0:1886 if file_props.has_key('stopped') and file_props['stopped']: 1882 1887 return False 1883 1888 if file_props['completed']: 1884 1889 return False 1885 if file_props.has_key('disconnect_cb') or \ 1886 file_props['disconnect_cb'] is None: 1890 if not file_props.has_key('disconnect_cb'): 1887 1891 return False 1888 1892 return file_props['paused'] 1889 1893 1890 1894 def is_transfer_active(self, file_props): 1891 if file_props.has_key(' error') and file_props['error'] != 0:1895 if file_props.has_key('stopped') and file_props['stopped']: 1892 1896 return False 1893 if file_props['completed'] or file_props['disconnect_cb'] is None: 1894 return False 1897 1898 if file_props['completed']: 1899 pass 1900 1895 1901 return not file_props['paused'] 1896 1902 … … 1900 1906 if file_props.has_key('completed') and file_props['completed']: 1901 1907 return True 1902 if file_props.has_key('disconnect_cb') and\1903 file_props[' disconnect_cb'] is not None:1908 if not file_props.has_key('stopped') or not \ 1909 file_props['stopped']: 1904 1910 return False 1905 1911 return True 1906 1907 def select_func(self, path): 1908 is_selected = False 1912 1913 def set_all_insensitive(self): 1914 self.pause_button.set_sensitive(False) 1915 self.pause_menuitem.set_sensitive(False) 1916 self.continue_menuitem.set_sensitive(False) 1917 self.remove_button.set_sensitive(False) 1918 self.remove_menuitem.set_sensitive(False) 1919 self.cancel_button.set_sensitive(False) 1920 self.stop_menuitem.set_sensitive(False) 1921 1922 def set_buttons_sensitive(self, path, is_row_selected): 1909 1923 current_iter = self.model.get_iter(path) 1910 selected = self.tree.get_selection().get_selected()1911 if selected[1] != None:1912 selected_path = self.model.get_path(selected[1])1913 if selected_path == path:1914 is_selected = True1915 1924 sid = self.model[current_iter][4] 1916 1925 file_props = self.files_props[sid[0]][sid[1:]] 1917 self.remove_button.set_sensitive(not is_selected) 1918 self.remove_menuitem.set_sensitive(not is_selected) 1926 self.remove_button.set_sensitive(is_row_selected) 1927 self.remove_menuitem.set_sensitive(is_row_selected) 1928 is_stopped = False 1919 1929 if self.is_transfer_stoped(file_props): 1920 is_s elected = True1921 self.cancel_button.set_sensitive(not is_s elected)1922 self.stop_menuitem.set_sensitive(not is_s elected)1923 if is_selected:1924 self.pause_button.set_sensitive(False)1925 self. pause_menuitem.set_sensitive(False)1926 el se:1930 is_stopped = True 1931 self.cancel_button.set_sensitive(not is_stopped) 1932 self.stop_menuitem.set_sensitive(not is_stopped) 1933 if not is_row_selected: 1934 # no selection, disable the buttons 1935 self.set_all_insensitive() 1936 elif not is_stopped: 1927 1937 if self.is_transfer_active(file_props): 1938 # file transfer is active 1939 self.toggle_pause_continue(True) 1928 1940 self.pause_button.set_sensitive(True) 1929 self.pause_menuitem.set_sensitive(True)1930 label = _('_Pause')1931 self.pause_button.set_label(label)1932 self.pause_menuitem.set_label(label)1933 1941 elif self.is_transfer_paused(file_props): 1942 # file transfer is paused 1943 self.toggle_pause_continue(False) 1934 1944 self.pause_button.set_sensitive(True) 1935 label = _('_Continue')1936 self.pause_button.set_label(label)1937 self.pause_menuitem.set_label(label)1938 1945 else: 1939 1946 self.pause_button.set_sensitive(False) 1940 1947 self.pause_menuitem.set_sensitive(False) 1948 self.continue_menuitem.set_sensitive(False) 1941 1949 return True 1942 1950 1951 def select_func(self, path): 1952 is_selected = False 1953 selected = self.tree.get_selection().get_selected_rows() 1954 if selected[1] != []: 1955 selected_path = selected[1][0] 1956 if selected_path == path: 1957 is_selected = True 1958 self.set_buttons_sensitive(path, is_selected) 1959 return True 1960 1943 1961 def on_remove_button_clicked(self, widget): 1944 1962 selected = self.tree.get_selection().get_selected() … … 1948 1966 sid = self.model[s_iter][4] 1949 1967 file_props = self.files_props[sid[0]][sid[1:]] 1950 if not self.is_transfer_stoped(file_props): 1951 file_props['disconnect_cb']() 1968 if not file_props.has_key('tt_account'): 1969 # file transfer is not set yet 1970 return 1971 account = file_props['tt_account'] 1972 if not gajim.connections.has_key(account): 1973 # no connection to the account 1974 return 1975 gajim.connections[account].remove_transfer(file_props) 1952 1976 self.model.remove(s_iter) 1953 self.remove_button.set_sensitive(False) 1954 self.remove_menuitem.set_sensitive(False) 1977 self.set_all_insensitive() 1978 1979 def toggle_pause_continue(self, status): 1980 if status: 1981 label = _('Pause') 1982 self.pause_button.set_label(label) 1983 self.pause_button.set_image(gtk.image_new_from_stock( 1984 gtk.STOCK_MEDIA_PAUSE, gtk.ICON_SIZE_MENU)) 1985 1986 self.pause_menuitem.set_sensitive(True) 1987 self.pause_menuitem.set_no_show_all(False) 1988 self.continue_menuitem.hide() 1989 self.continue_menuitem.set_no_show_all(True) 1990 1991 else: 1992 label = _('_Continue') 1993 self.pause_button.set_label(label) 1994 self.pause_button.set_image(gtk.image_new_from_stock( 1995 gtk.STOCK_MEDIA_PLAY, gtk.ICON_SIZE_MENU)) 1996 self.pause_menuitem.hide() 1997 self.pause_menuitem.set_no_show_all(True) 1998 self.continue_menuitem.set_sensitive(True) 1999 self.continue_menuitem.set_no_show_all(False) 1955 2000 1956 2001 def on_pause_restore_button_clicked(self, widget): … … 1965 2010 types = {'r' : 'download', 's' : 'upload'} 1966 2011 self.set_status(file_props['type'], file_props['sid'], types[sid[0]]) 1967 widget.set_label(_('Pause'))2012 self.toggle_pause_continue(True) 1968 2013 elif self.is_transfer_active(file_props): 1969 2014 file_props['paused'] = True 1970 2015 self.set_status(file_props['type'], file_props['sid'], 'pause') 1971 widget.set_label(_('_Continue'))2016 self.toggle_pause_continue(False) 1972 2017 1973 2018 def on_cancel_button_clicked(self, widget): … … 1977 2022 s_iter = selected[1] 1978 2023 sid = self.model[s_iter][4] 1979 1980 2024 file_props = self.files_props[sid[0]][sid[1:]] 1981 if not self.is_transfer_stoped(file_props): 1982 file_props['disconnect_cb']() 2025 if not file_props.has_key('tt_account'): 2026 return 2027 account = file_props['tt_account'] 2028 if not gajim.connections.has_key(account): 2029 return 2030 gajim.connections[account].disconnect_transfer(file_props) 1983 2031 self.set_status(file_props['type'], file_props['sid'], 'stop') 1984 2032 … … 2016 2064 2017 2065 def show_context_menu(self, event, iter): 2066 # change the sensitive propery of the buttons and menuitems 2067 path = self.model.get_path(iter) 2068 self.set_buttons_sensitive(path, True) 2069 2018 2070 event_button = self.get_possible_button_event(event) 2019 2071 self.file_transfers_menu.popup(None, self.tree, None, … … 2047 2099 return True 2048 2100 2101 2102 def on_transfers_list_button_release_event(self, widget, event): 2103 # hide tooltip, no matter the button is pressed 2104 self.tooltip.hide_tooltip() 2105 try: 2106 path, column, x, y = self.tree.get_path_at_pos(int(event.x), 2107 int(event.y)) 2108 except TypeError: 2109 self.tree.get_selection().unselect_all() 2110 return 2111 self.select_func(path) 2112 2049 2113 def on_transfers_list_button_press_event(self, widget, event): 2050 2114 # hide tooltip, no matter the button is pressed 2051 2115 self.tooltip.hide_tooltip() 2116 try: 2117 path, column, x, y = self.tree.get_path_at_pos(int(event.x), 2118 int(event.y)) 2119 except TypeError: 2120 self.tree.get_selection().unselect_all() 2121 return 2052 2122 if event.button == 3: # Right click 2053 try:2054 path, column, x, y = self.tree.get_path_at_pos(int(event.x),2055 int(event.y))2056 except TypeError:2057 self.tree.get_selection().unselect_all()2058 return2059 2123 self.tree.get_selection().select_path(path) 2060 2124 model = self.tree.get_model() … … 2062 2126 self.show_context_menu(event, iter) 2063 2127 return True 2128 2064 2129 2065 2130 def on_clean_up_menuitem_activate(self, widget): … … 2071 2136 if file_props.has_key('completed') and file_props['completed']: 2072 2137 self.model.remove(iter) 2138 elif file_props.has_key('stopped') and file_props['stopped']: 2139 self.model.remove(iter) 2073 2140 i -= 1 2074 2141 … … 2082 2149 self.on_cancel_button_clicked(widget) 2083 2150 2151 def on_continue_menuitem_activate(self, widget): 2152 self.on_pause_restore_button_clicked(widget) 2153 2084 2154 def on_pause_menuitem_activate(self, widget): 2085 2155 self.on_pause_restore_button_clicked(widget)
