Ticket #2411: path-mapping-dict.patch
File path-mapping-dict.patch, 7.6 KB (added by eerorika, 10 years ago) |
---|
-
deluge/ui/gtkui/common.py
diff --git a/deluge/ui/gtkui/common.py b/deluge/ui/gtkui/common.py index a7715ed..0728130 100644
a b def associate_magnet_links(overwrite=False): 263 263 log.error("Unable to register Deluge as default magnet uri handler.") 264 264 return False 265 265 return False 266 267 from deluge.configmanager import ConfigManager 268 def files_available(): 269 return client.is_localhost() or ConfigManager("gtkui.conf")["path_mapping"] 270 271 def open_file(path): 272 open_file = True 273 if not client.is_localhost(): 274 from re import subn 275 open_file = False 276 path_mapping = ConfigManager("gtkui.conf")["path_mapping"] 277 for local, remote in path_mapping.items(): 278 path, open_file = subn('^%s' % local, remote, path) 279 if(open_file): 280 break 281 if open_file: 282 deluge.common.open_file(path) -
deluge/ui/gtkui/connectionmanager.py
diff --git a/deluge/ui/gtkui/connectionmanager.py b/deluge/ui/gtkui/connectionmanager.py index 71aab09..4f9d341 100644
a b def __load_options(self): 327 327 self.glade.get_widget("chk_autoconnect").set_active(self.gtkui_config["autoconnect"]) 328 328 self.glade.get_widget("chk_autostart").set_active(self.gtkui_config["autostart_localhost"]) 329 329 self.glade.get_widget("chk_donotshow").set_active(not self.gtkui_config["show_connection_manager_on_start"]) 330 self.glade.get_widget("entry_path_mapping").get_buffer().set_text(str(self.gtkui_config["path_mapping"])) 330 331 331 332 def __save_options(self): 332 333 """ … … def __save_options(self): 335 336 self.gtkui_config["autoconnect"] = self.glade.get_widget("chk_autoconnect").get_active() 336 337 self.gtkui_config["autostart_localhost"] = self.glade.get_widget("chk_autostart").get_active() 337 338 self.gtkui_config["show_connection_manager_on_start"] = not self.glade.get_widget("chk_donotshow").get_active() 339 from ast import literal_eval 340 buffer = self.glade.get_widget("entry_path_mapping").get_buffer() 341 self.gtkui_config["path_mapping"] = literal_eval(buffer.get_text(*buffer.get_bounds())) 338 342 339 343 def __update_buttons(self): 340 344 """ -
deluge/ui/gtkui/files_tab.py
diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index 0856f36..2ae2ef5 100644
a b def __init__(self): 237 237 self.torrent_id = None 238 238 239 239 def start(self): 240 attr = "hide" if not client.is_localhost() else "show"240 attr = "hide" if not deluge.ui.gtkui.common.files_available() else "show" 241 241 for widget in self.localhost_widgets: 242 242 getattr(widget, attr)() 243 243 … … def clear(self): 341 341 self.torrent_id = None 342 342 343 343 def _on_row_activated(self, tree, path, view_column): 344 if client.is_localhost:344 if deluge.ui.gtkui.common.files_available(): 345 345 component.get("SessionProxy").get_torrent_status(self.torrent_id, ["save_path", "files"]).addCallback(self._on_open_file) 346 346 347 347 def get_file_path(self, row, path=""): … … def _on_open_file(self, status): 361 361 path = self.get_file_path(select).split("/") 362 362 filepath = os.path.join(status["save_path"], *path) 363 363 log.debug("Open file '%s'", filepath) 364 deluge. common.open_file(filepath)364 deluge.ui.gtkui.common.open_file(filepath) 365 365 366 366 ## The following 3 methods create the folder/file view in the treeview 367 367 def prepare_file_store(self, files): -
deluge/ui/gtkui/glade/connection_manager.glade
diff --git a/deluge/ui/gtkui/glade/connection_manager.glade b/deluge/ui/gtkui/glade/connection_manager.glade index cfe3906..ffce7a4 100644
a b 449 449 <property name="position">2</property> 450 450 </packing> 451 451 </child> 452 <child> 453 <widget class="GtkVBox" id="vbox_path_mapping"> 454 <property name="visible">True</property> 455 <property name="can_focus">False</property> 456 <child> 457 <widget class="GtkLabel" id="label_path_mapping"> 458 <property name="visible">True</property> 459 <property name="can_focus">False</property> 460 <property name="xalign">0</property> 461 <property name="label" translatable="yes">Path Mapping 462 Example: 463 {'/path/on/server': '/local/path', 464 '/another/remote/path': '/another/local/path'}</property> 465 </widget> 466 <packing> 467 <property name="expand">True</property> 468 <property name="fill">True</property> 469 <property name="position">0</property> 470 </packing> 471 </child> 472 <child> 473 <widget class="GtkTextView" id="entry_path_mapping"> 474 <property name="height_request">48</property> 475 <property name="visible">True</property> 476 <property name="can_focus">True</property> 477 <property name="accepts_tab">False</property> 478 </widget> 479 <packing> 480 <property name="expand">True</property> 481 <property name="fill">True</property> 482 <property name="position">1</property> 483 </packing> 484 </child> 485 </widget> 486 <packing> 487 <property name="expand">True</property> 488 <property name="fill">True</property> 489 <property name="position">3</property> 490 </packing> 491 </child> 452 492 </widget> 453 493 </child> 454 494 </widget> -
deluge/ui/gtkui/gtkui.py
diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py index bbe1195..8ec03a5 100644
a b def start(): 167 167 "sidebar_position": 170, 168 168 "show_rate_in_title": False, 169 169 "focus_main_window_on_add": True, 170 "createtorrent.trackers": [] 170 "createtorrent.trackers": [], 171 "path_mapping": {}, 171 172 } 172 173 173 174 class GtkUI(object): -
deluge/ui/gtkui/menubar.py
diff --git a/deluge/ui/gtkui/menubar.py b/deluge/ui/gtkui/menubar.py index 214c4b7..d8ab4b2 100644
a b def start(self): 184 184 "menuitem_open_folder", 185 185 "separator4" 186 186 ] 187 if not client.is_localhost():187 if not deluge.ui.gtkui.common.files_available(): 188 188 for widget in non_remote_items: 189 189 self.torrentmenu_glade.get_widget(widget).hide() 190 190 self.torrentmenu_glade.get_widget(widget).set_no_show_all(True) … … def on_menuitem_recheck_activate(self, data=None): 306 306 def on_menuitem_open_folder_activate(self, data=None): 307 307 log.debug("on_menuitem_open_folder") 308 308 def _on_torrent_status(status): 309 deluge. common.open_file(status["save_path"])309 deluge.ui.gtkui.common.open_file(status["save_path"]) 310 310 for torrent_id in component.get("TorrentView").get_selected_torrents(): 311 311 component.get("SessionProxy").get_torrent_status(torrent_id, ["save_path"]).addCallback(_on_torrent_status) 312 312