Skip to content

Commit

Permalink
Merge pull request #13 from twolfson/dev/enable.disable.from.menu
Browse files Browse the repository at this point in the history
Added commands for enabling/disabling automatic syncing
  • Loading branch information
sobstel committed Jan 19, 2013
2 parents 7757606 + d4e0114 commit b1d0fe9
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Commands.sublime-commands
Expand Up @@ -2,5 +2,13 @@
{
"caption": "Side Bar: Reveal File",
"command": "reveal_in_side_bar"
},
{
"caption": "Side Bar: Enable Syncing",
"command": "side_bar_enable_sync"
},
{
"caption": "Side Bar: Disable Syncing",
"command": "side_bar_disable_sync"
}
]
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -12,6 +12,16 @@ http://www.sublimetext.com/forum/viewtopic.php?f=2&t=4080
Usage
-----

### Configuration

SyncedSideBar enables/disables automatic syncing via the setting `reveal-on-activate`.

If `true`, syncing will automatically happen. If `false`, syncing will be disabled.

Helper commands for enabling/disabling automatic syncing are available as 'Side Bar: Enable Sync' and 'Side Bar: Disable Sync'.

This can be found in the Command Palette (Command+Shift+P on Mac, Ctrl+Shift+P on Linux/Windows).

### Manually reveal files

Files can be manually revealed via the command 'Side Bar: Reveal File'.
Expand Down
29 changes: 29 additions & 0 deletions SyncedSideBar.py
@@ -1,3 +1,4 @@
import sublime
import sublime_plugin


Expand All @@ -7,3 +8,31 @@ def on_activated(self, view):
active = view.window()
if active and view.settings().get('reveal-on-activate') != False:
active.run_command('reveal_in_side_bar')


class SideBarUpdateSync(sublime_plugin.ApplicationCommand):

def run(self):
pass

def updateSync(self, value):
# Load in user settings
settings = sublime.load_settings("Preferences.sublime-settings")

# Update the setting
settings.set("reveal-on-activate", value)

# Save our changes
sublime.save_settings("Preferences.sublime-settings")


class SideBarEnableSync(SideBarUpdateSync):

def run(self):
self.updateSync(True)


class SideBarDisableSync(SideBarUpdateSync):

def run(self):
self.updateSync(False)

0 comments on commit b1d0fe9

Please sign in to comment.