Skip to content

Commit

Permalink
Small changes to browser bar for Ticket#398:
Browse files Browse the repository at this point in the history
* Changed Browser Bar command to a toggle, moved to view menu
* Sensitized command to whether a html tab is focussed
* Added keybinding
  • Loading branch information
kattrali committed Nov 15, 2010
1 parent 8bfede5 commit a5b7bbc
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 40 deletions.
10 changes: 8 additions & 2 deletions plugins/application/features/step_definitions/speedbar_steps.rb
Expand Up @@ -58,5 +58,11 @@ def get_speedbar_text_field(field_name)
item.value.should be_false
end



Then /^there should( not)? be an open speedbar$/ do |negate|
speedbar = Redcar.app.focussed_window.speedbar
if negate
speedbar.should == nil
else
speedbar.should_not == nil
end
end
6 changes: 6 additions & 0 deletions plugins/application/lib/application.rb
Expand Up @@ -57,6 +57,12 @@ def self.sensitivities
win.focussed_notebook.focussed_tab
end
end,
Sensitivity.new(:open_htmltab, Redcar.app, false, [:focussed_window, :tab_focussed]) do |tab|
if win = Redcar.app.focussed_window and
tab = win.focussed_notebook.focussed_tab
tab.is_a?(HtmlTab)
end
end,
Sensitivity.new(:open_trees, Redcar.app, false, [:focussed_window, :tree_added, :tree_removed]) do |tree|
if win = Redcar.app.focussed_window
trees = win.treebook.trees
Expand Down
5 changes: 5 additions & 0 deletions plugins/html_view/features/browser_bar.feature
Expand Up @@ -13,6 +13,7 @@ Feature: Navigating web content in HtmlTabs using the browser bar
And I replace the contents with "<html>I see you!</html>"
And I save the tab
And I close the focussed tab
And I open the browser bar
And I press "Refresh" in the speedbar
Then the HTML tab should say "I see you!"

Expand Down Expand Up @@ -40,3 +41,7 @@ Feature: Navigating web content in HtmlTabs using the browser bar
When I press "+" in the speedbar
And I open the web bookmarks tree
Then I should see "Other" in the tree

Scenario: When a HTML tab loses focus, the browser bar is hidden
When I open a new edit tab
Then there should not be an open speedbar
Expand Up @@ -56,7 +56,7 @@
end

When /^I open the browser bar$/ do
Redcar::HtmlView::OpenBrowserBar.new.run
Redcar::HtmlView::ToggleBrowserBar.new.run
end

When /^I open a web preview$/ do
Expand Down
23 changes: 18 additions & 5 deletions plugins/html_view/lib/html_view.rb
Expand Up @@ -16,15 +16,20 @@ def self.jquery_path
File.expand_path(File.join(Redcar.root, %w(plugins html_view assets jquery-1.4.min.js)))
end

def self.keymaps
map = Redcar::Keymap.build("main", [:osx, :linux, :windows]) do
link "Alt+Shift+B", ToggleBrowserBar
end
[map]
end

def self.menus
Redcar::Menu::Builder.build do
sub_menu "File" do
item "Web Preview", :command => HtmlView::FileWebPreview, :priority => 8
item "Web Preview", :command => FileWebPreview, :priority => 8
end
sub_menu "Edit" do
sub_menu "Document Navigation" do
item "Open Browser Bar", :command => HtmlView::OpenBrowserBar, :priority => 5
end
sub_menu "View" do
item "Toggle Browser Bar", :command => ToggleBrowserBar, :priority => 11
end
end
end
Expand All @@ -37,6 +42,14 @@ def self.storage
end
end

def self.show_browser_bar?
if win = Redcar.app.focussed_window and
win.speedbar and win.speedbar.is_a?(BrowserBar)
return true
end
false
end

def self.tidy_url(url)
unless url.include?("://")
if File.exists?(url)
Expand Down
7 changes: 7 additions & 0 deletions plugins/html_view/lib/html_view/browser_bar.rb
Expand Up @@ -3,6 +3,13 @@ module Redcar
class HtmlView
class BrowserBar < Redcar::Speedbar

def tab_changed(tab)
unless tab.is_a?(HtmlTab)
win = Redcar.app.focussed_window
win.close_speedbar
end
end

def html_tab
tab = Redcar.app.focussed_window.focussed_notebook_tab
tab if tab.is_a?(Redcar::HtmlTab)
Expand Down
18 changes: 12 additions & 6 deletions plugins/html_view/lib/html_view/commands.rb
Expand Up @@ -23,8 +23,8 @@ def execute
tab.html_view.controller = controller
tab.icon = HtmlTab.web_content_icon if tab.is_a?(HtmlTab)
tab.focus
if @display_bar
HtmlView::OpenBrowserBar.new.run
if @display_bar and not HtmlView.show_browser_bar?
HtmlView::ToggleBrowserBar.new.run
end
end
end
Expand All @@ -47,11 +47,17 @@ def execute
end
end

class OpenBrowserBar < Redcar::Command
class ToggleBrowserBar < Redcar::Command
sensitize :open_htmltab
def execute
window = Redcar.app.focussed_window
speedbar = Redcar::HtmlView::BrowserBar.new
window.open_speedbar(speedbar)
if win = Redcar.app.focussed_window
if HtmlView.show_browser_bar?
win.close_speedbar
else
speedbar = Redcar::HtmlView::BrowserBar.new
win.open_speedbar(speedbar)
end
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion plugins/outline_view/lib/outline_view.rb
Expand Up @@ -6,7 +6,7 @@ class OutlineView
def self.menus
Menu::Builder.build do
sub_menu "View" do
item "Current Document Outline", OutlineView::OpenOutlineViewCommand
item "Current Document Outline", :command => OutlineView::OpenOutlineViewCommand, :priority => :first
end
end
end
Expand Down
58 changes: 33 additions & 25 deletions plugins/redcar/redcar.rb
Expand Up @@ -1083,39 +1083,47 @@ def self.menus(window)
end
end
sub_menu "View", :priority => 30 do
sub_menu "Appearance" do
sub_menu "Appearance", :priority => 5 do
item "Font", SelectNewFont
item "Font Size", SelectFontSize
item "Theme", SelectTheme
end
item "Toggle Tree Visibility", :command => ToggleTreesCommand
item "Toggle Fullscreen", :command => ToggleFullscreen, :type => :check, :active => window ? window.fullscreen : false
separator
lazy_sub_menu "Windows" do
GenerateWindowsMenu.new(self).run
end
sub_menu "Notebooks" do
item "New Notebook", NewNotebookCommand
item "Close Notebook", CloseNotebookCommand
item "Rotate Notebooks", RotateNotebooksCommand
item "Move Tab To Other Notebook", MoveTabToOtherNotebookCommand
item "Switch Notebooks", SwitchNotebookCommand
group(:priority => 10) do
separator
item "Toggle Tree Visibility", :command => ToggleTreesCommand
item "Toggle Fullscreen", :command => ToggleFullscreen, :type => :check, :active => window ? window.fullscreen : false
end
sub_menu "Tabs" do
item "Previous Tab", SwitchTabDownCommand
item "Next Tab", SwitchTabUpCommand
item "Move Tab Left", MoveTabDownCommand
item "Move Tab Right", MoveTabUpCommand
group(:priority => 15) do
separator
item "Focussed Notebook", ShowTitle
(1..9).each do |num|
item "Tab #{num}", Top.const_get("SelectTab#{num}Command")
lazy_sub_menu "Windows" do
GenerateWindowsMenu.new(self).run
end
sub_menu "Notebooks" do
item "New Notebook", NewNotebookCommand
item "Close Notebook", CloseNotebookCommand
item "Rotate Notebooks", RotateNotebooksCommand
item "Move Tab To Other Notebook", MoveTabToOtherNotebookCommand
item "Switch Notebooks", SwitchNotebookCommand
end
sub_menu "Tabs" do
item "Previous Tab", SwitchTabDownCommand
item "Next Tab", SwitchTabUpCommand
item "Move Tab Left", MoveTabDownCommand
item "Move Tab Right", MoveTabUpCommand
separator
# GenerateTabsMenu.new(self).run # TODO: find a way to maintain keybindings with lazy menus
item "Focussed Notebook", ShowTitle
(1..9).each do |num|
item "Tab #{num}", Top.const_get("SelectTab#{num}Command")
end
end
end
group(:priority => :last) do
separator
item "Show Toolbar", :command => ToggleToolbar, :type => :check, :active => Redcar.app.show_toolbar?
item "Show Invisibles", :command => ToggleInvisibles, :type => :check, :active => EditView.show_invisibles?
item "Show Line Numbers", :command => ToggleLineNumbers, :type => :check, :active => EditView.show_line_numbers?
end
separator
item "Show Toolbar", :command => ToggleToolbar, :type => :check, :active => Redcar.app.show_toolbar?
item "Show Invisibles", :command => ToggleInvisibles, :type => :check, :active => EditView.show_invisibles?
item "Show Line Numbers", :command => ToggleLineNumbers, :type => :check, :active => EditView.show_line_numbers?
end
sub_menu "Bundles", :priority => 45 do
group(:priority => :first) do
Expand Down

0 comments on commit a5b7bbc

Please sign in to comment.