Skip to content

Instantly share code, notes, and snippets.

@kattrali
Created August 12, 2011 15:40
Show Gist options
  • Save kattrali/1142313 to your computer and use it in GitHub Desktop.
Save kattrali/1142313 to your computer and use it in GitHub Desktop.
Skinning Redcar, one widget at a time
# Open in Redcar
# Run Plugins > Execute > Eval Current Tab (in Redcar itself)
# (This is a terrible hack)
require 'java'
def init
make_pretty
Redcar.app.add_listener(:window_added) do |win|
make_pretty
win.add_listener(:notebook_added) do |notebook|
make_pretty
end
end
end
def make_pretty
java_import org.eclipse.swt.widgets.Tree
Redcar::EditView.font = 'Monaco'
Redcar::EditTab.send(:define_method, "icon") do
get_file_icon(title,:file)
end
Redcar::Project::DirMirror::Node.send(:define_method, "icon") do
get_file_icon(text,@type)
end
main_node = Swt::Graphics::Color.new(Redcar::ApplicationSWT.display,120,120,130)
font_face = 'DejaVu Sans'
font = Swt::Graphics::Font.new(Redcar::ApplicationSWT.display,font_face,Redcar::EditView.font_size - 1,Swt::SWT::NORMAL)
bold = Swt::Graphics::Font.new(Redcar::ApplicationSWT.display,font_face,Redcar::EditView.font_size - 1,Swt::SWT::BOLD)
color = Swt::Graphics::Color.new(Redcar::ApplicationSWT.display,213,228,237)
Redcar.app.windows.each do |win|
if win.treebook and folder = win.treebook.controller.tab_folder
folder.tab_list.each do |w|
if w.is_a?(Tree)
w.items.each do |item|
item.font = bold
item.foreground = main_node
end
w.background = color
end
end
folder.tab_list.to_a.each{|w|w.font = font}
folder.font = font
end
items = win.controller.shell.children.to_a
items[0].children.to_a.first.children.to_a.first.font = font
items[2].children.to_a.each do |child|
sash = child.children.to_a.first
sash.font = font
sash.border_visible = false
end
end
end
def get_file_icon text, type
key = text.split('.').last.split(//).first.downcase
case type
when :file
if key =~ /[a-z]/
if key == 'a'
:document_attribute
else
:"document_attribute_#{key}"
end
else
:file
end
when :dir
:blue_folder
end
end
init
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment