Skip to content

Commit

Permalink
Add new commands to menu and command list
Browse files Browse the repository at this point in the history
Context menu: remove "get list" command, as it's available in command
palette and main menu.

Added new gist view commands: rename file, change gist description,
delete file, delete gist. Commands themselves are not implemented yet.

Main menu: split the Gist submenu into two logical blocks - commands
that are always enabled (create gist/open gist) and gist view commands.
  • Loading branch information
Alexey Ermakov committed Jan 13, 2012
1 parent c948a3e commit bda3637
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 20 deletions.
5 changes: 2 additions & 3 deletions Context.sublime-menu
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
[
{ "command": "gist", "caption": "Create Public Gist" },
{ "command": "gist_private", "caption": "Create Private Gist" },
{ "command": "gist_list", "caption": "Get Gist List" }
{ "command": "gist", "caption": "Create Public Gist…" },
{ "command": "gist_private", "caption": "Create Private Gist…" }
]
24 changes: 20 additions & 4 deletions Gist.sublime-commands
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
[
{
"caption": "Gist (public): Create from Selected Text",
"caption": "Gist: Create Public Gist",
"command": "gist"
},
{
"caption": "Gist (private): Create from Selected Text",
"caption": "Gist: Create Private Gist",
"command": "gist_private"
},
{
"caption": "Gist: Open Gist",
"command": "gist_list"
},
{
"caption": "Gist: Copy Gist URL",
"command": "gist_copy_url"
Expand All @@ -20,7 +24,19 @@
"command": "gist_update"
},
{
"caption": "Gist: Get List",
"command": "gist_list"
"caption": "Gist: Rename File",
"command": "gist_rename_file"
},
{
"caption": "Gist: Change Gist Description",
"command": "gist_rename"
},
{
"caption": "Gist: Delete Gist File",
"command": "gist_delete_file"
},
{
"caption": "Gist: Delete Gist",
"command": "gist_delete"
}
]
10 changes: 7 additions & 3 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,16 @@
"caption": "Gist",
"children":
[
{ "command": "gist", "caption": "Create Public Gist" },
{ "command": "gist_private", "caption": "Create Private Gist" },
{ "command": "gist", "caption": "Create Public Gist…" },
{ "command": "gist_private", "caption": "Create Private Gist…" },
{ "command": "gist_list", "caption": "Open Gist…" },
{ "caption": "-" },
{ "command": "gist_copy_url", "caption": "Copy Gist URL" },
{ "command": "gist_open_browser", "caption": "Open Gist In Browser"},
{ "command": "gist_update", "caption": "Update Gist" },
{ "command": "gist_list", "caption": "Get Gist List" }
{ "command": "gist_rename_file", "caption": "Rename File…" },
{ "command": "gist_rename", "caption": "Change Gist Description…" },
{ "command": "gist_delete", "caption": "Delete Gist" }
]
}

Expand Down
16 changes: 6 additions & 10 deletions gist.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,20 @@ def on_gist_description(description):
for region in selections:
create_gist_with_text(self.view.substr(region))

class GistCopyUrl(sublime_plugin.TextCommand):
class GistViewCommand(object):
"""A base class for commands operating on a gistified view"""
def is_enabled(self):
return self.view.settings().get("gist_html_url") is not None
return self.view.settings().get("gist_url") is not None

class GistCopyUrl(GistViewCommand, sublime_plugin.TextCommand):
def run(self, edit):
sublime.set_clipboard(self.view.settings().get("gist_html_url"))

class GistOpenBrowser(sublime_plugin.TextCommand):
def is_enabled(self):
return self.view.settings().get("gist_html_url") is not None

class GistOpenBrowser(GistViewCommand, sublime_plugin.TextCommand):
def run(self, edit):
webbrowser.open(self.view.settings().get("gist_html_url"))

class GistUpdateCommand(sublime_plugin.TextCommand):
def is_enabled(self):
return self.view.settings().get("gist_url") is not None

class GistUpdateCommand(GistViewCommand, sublime_plugin.TextCommand):
@catch_errors
def run(self, edit):
text = self.view.substr(sublime.Region(0, self.view.size()))
Expand Down

0 comments on commit bda3637

Please sign in to comment.