Ticket #2411: remote-path.patch
File remote-path.patch, 8.5 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..afce40a 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")["pathmapping"] 270 271 def path_to_local(path): 272 from re import subn 273 pathmapping = ConfigManager("gtkui.conf")["pathmapping"] 274 found_count = 0 275 if not pathmapping: 276 return path, found_count 277 for mapstr in pathmapping.splitlines(): 278 mapping = mapstr.split('=', 2) 279 if(len(mapping) < 2): 280 continue 281 path, found_count = subn('^%s' % mapping[0], mapping[1], path) 282 if(found_count): 283 break 284 return path, found_count -
deluge/ui/gtkui/connectionmanager.py
diff --git a/deluge/ui/gtkui/connectionmanager.py b/deluge/ui/gtkui/connectionmanager.py index 71aab09..9e1b3dd 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_pathmapping").get_buffer().set_text(self.gtkui_config["pathmapping"]) 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 buffer = self.glade.get_widget("entry_pathmapping").get_buffer() 340 self.gtkui_config["pathmapping"] = buffer.get_text(*buffer.get_bounds()) 338 341 339 342 def __update_buttons(self): 340 343 """ -
deluge/ui/gtkui/files_tab.py
diff --git a/deluge/ui/gtkui/files_tab.py b/deluge/ui/gtkui/files_tab.py index 0856f36..f239ec4 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 from deluge.ui.gtkui.common import files_available 241 attr = "hide" if not files_available() else "show" 241 242 for widget in self.localhost_widgets: 242 243 getattr(widget, attr)() 243 244 … … def clear(self): 341 342 self.torrent_id = None 342 343 343 344 def _on_row_activated(self, tree, path, view_column): 344 if client.is_localhost: 345 from deluge.ui.gtkui.common import files_available 346 if files_available(): 345 347 component.get("SessionProxy").get_torrent_status(self.torrent_id, ["save_path", "files"]).addCallback(self._on_open_file) 346 348 347 349 def get_file_path(self, row, path=""): … … def get_file_path(self, row, path=""): 352 354 return self.get_file_path(self.treestore.iter_parent(row), path) 353 355 354 356 def _on_open_file(self, status): 357 save_path = status["save_path"] 358 open_file = True 359 if not client.is_localhost(): 360 from deluge.ui.gtkui.common import path_to_local 361 save_path, open_file = path_to_local(save_path) 362 if not open_file: 363 return 355 364 paths = self.listview.get_selection().get_selected_rows()[1] 356 365 selected = [] 357 366 for path in paths: 358 367 selected.append(self.treestore.get_iter(path)) 359 360 368 for select in selected: 361 369 path = self.get_file_path(select).split("/") 362 filepath = os.path.join(s tatus["save_path"], *path)370 filepath = os.path.join(save_path, *path) 363 371 log.debug("Open file '%s'", filepath) 364 372 deluge.common.open_file(filepath) 365 373 -
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..61de802 100644
a b 449 449 <property name="position">2</property> 450 450 </packing> 451 451 </child> 452 <child> 453 <widget class="GtkVBox" id="vbox_pathmapping"> 454 <property name="visible">True</property> 455 <property name="can_focus">False</property> 456 <child> 457 <widget class="GtkLabel" id="label_pathmapping"> 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_pathmapping"> 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..843b754 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 "pathmapping": "", 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..78cc64a 100644
a b def start(self): 184 184 "menuitem_open_folder", 185 185 "separator4" 186 186 ] 187 if not client.is_localhost(): 187 from deluge.ui.gtkui.common import files_available 188 if not files_available(): 188 189 for widget in non_remote_items: 189 190 self.torrentmenu_glade.get_widget(widget).hide() 190 191 self.torrentmenu_glade.get_widget(widget).set_no_show_all(True) … … def on_menuitem_recheck_activate(self, data=None): 306 307 def on_menuitem_open_folder_activate(self, data=None): 307 308 log.debug("on_menuitem_open_folder") 308 309 def _on_torrent_status(status): 309 deluge.common.open_file(status["save_path"]) 310 save_path = status["save_path"] 311 open_file = True 312 if not client.is_localhost(): 313 from deluge.ui.gtkui.common import path_to_local 314 save_path, open_file = path_to_local(save_path) 315 if(open_file): 316 deluge.common.open_file(save_path) 310 317 for torrent_id in component.get("TorrentView").get_selected_torrents(): 311 318 component.get("SessionProxy").get_torrent_status(torrent_id, ["save_path"]).addCallback(_on_torrent_status) 312 319