Class: Object

Inherits:
BasicObject
Includes:
Types
Defined in:
lib/shoes/ruby.rb,
lib/green_shoes.rb,
lib/plugins/thread.rb,
lib/ext/hpricot/blankslate.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.hpricot_slate_method_addedObject



53
# File 'lib/ext/hpricot/blankslate.rb', line 53

alias_method :hpricot_slate_method_added, :method_added

.method_added(name) ⇒ Object

Detect method additions to Object and remove them in the BlankSlate class.



57
58
59
60
61
# File 'lib/ext/hpricot/blankslate.rb', line 57

def method_added(name)
  hpricot_slate_method_added(name)
  return if self != Object
  Hpricot::BlankSlate.hide(name)
end

Instance Method Details

#alert(msg, options = {:block => true}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/shoes/ruby.rb', line 10

def alert msg, options={:block => true}
  $dde = true
  dialog = Gtk::MessageDialog.new(
    get_win,
    Gtk::Dialog::MODAL,
    Gtk::MessageDialog::INFO,
    Gtk::MessageDialog::BUTTONS_OK,
    msg.to_s
  )
  dialog.title = options.has_key?(:title) ? options[:title] : "Green Shoes says:"
  if options[:block]
    dialog.run
    dialog.destroy
  else
    dialog.signal_connect("response"){ dialog.destroy }
    dialog.show
  end
end

#ask(msg, args = {}) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/shoes/ruby.rb', line 46

def ask msg, args={}
  $dde = true
  dialog = Gtk::Dialog.new(
    "Green Shoes asks:", 
    get_win,
    Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT,
    [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT],
    [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT]
  )
  dialog.vbox.add Gtk::Label.new msg
  dialog.vbox.add(el = Gtk::Entry.new)
  el.visibility = false if args[:secret]
  dialog.set_size_request 300, 100
  dialog.show_all
  ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? el.text : nil
  dialog.destroy
  ret
end

#ask_color(title = 'Pick a color...') ⇒ Object



96
97
98
99
100
101
102
103
104
# File 'lib/shoes/ruby.rb', line 96

def ask_color title = 'Pick a color...'
  $dde = true
  dialog = Gtk::ColorSelectionDialog.new title
  dialog.icon = Gdk::Pixbuf.new File.join(DIR, '../static/gshoes-icon.png')
  dialog.run
  ret = dialog.colorsel.current_color.to_a.map{|c| c / 65535.0}
  dialog.destroy
  ret
end

#ask_open_fileObject



65
66
67
# File 'lib/shoes/ruby.rb', line 65

def ask_open_file
  dialog_chooser "Open File...", Gtk::FileChooser::ACTION_OPEN, Gtk::Stock::OPEN
end

#ask_open_folderObject



73
74
75
# File 'lib/shoes/ruby.rb', line 73

def ask_open_folder
  dialog_chooser "Open Folder...", Gtk::FileChooser::ACTION_SELECT_FOLDER, Gtk::Stock::OPEN
end

#ask_save_fileObject



69
70
71
# File 'lib/shoes/ruby.rb', line 69

def ask_save_file
  dialog_chooser "Save File...", Gtk::FileChooser::ACTION_SAVE, Gtk::Stock::SAVE
end

#ask_save_folderObject



77
78
79
# File 'lib/shoes/ruby.rb', line 77

def ask_save_folder
  dialog_chooser "Save Folder...", Gtk::FileChooser::ACTION_CREATE_FOLDER, Gtk::Stock::SAVE
end

#confirm(msg) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/shoes/ruby.rb', line 29

def confirm msg
  $dde = true
  dialog = Gtk::Dialog.new(
    "Green Shoes asks:", 
    get_win,
    Gtk::Dialog::MODAL | Gtk::Dialog::DESTROY_WITH_PARENT,
    [Gtk::Stock::OK, Gtk::Dialog::RESPONSE_ACCEPT],
    [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_REJECT]
  )
  dialog.vbox.add Gtk::Label.new msg
  dialog.set_size_request 300, 100
  dialog.show_all
  ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? true : false
  dialog.destroy
  ret
end

#dialog_chooser(title, action, button) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/shoes/ruby.rb', line 81

def dialog_chooser title, action, button
  $dde = true
  dialog = Gtk::FileChooserDialog.new(
    title,
    get_win,
    action,
    nil,
    [Gtk::Stock::CANCEL, Gtk::Dialog::RESPONSE_CANCEL],
    [button, Gtk::Dialog::RESPONSE_ACCEPT]
  )
  ret = dialog.run == Gtk::Dialog::RESPONSE_ACCEPT ? dialog.filename : nil
  dialog.destroy
  ret
end

#exitObject



106
107
108
109
# File 'lib/shoes/ruby.rb', line 106

def exit
  Gtk.main_quit
  File.delete Shoes::TMP_PNG_FILE if File.exist? Shoes::TMP_PNG_FILE
end

#get_winObject



115
116
117
118
119
# File 'lib/shoes/ruby.rb', line 115

def get_win
  Gtk::Window.new.tap do |s|
    s.icon = Gdk::Pixbuf.new File.join(DIR, '../static/gshoes-icon.png')
  end
end

#invoke_in_shoes_mainloop(&blk) ⇒ Object



4
5
6
7
8
# File 'lib/plugins/thread.rb', line 4

def invoke_in_shoes_mainloop(&blk)
  return unless defined?($__shoes_app__)
  return unless Shoes::App===$__shoes_app__
	$__shoes_app__.get_queue().push( blk )
end

#to_sObject



111
112
113
# File 'lib/shoes/ruby.rb', line 111

def to_s
  super.gsub '<', '&lt;'
end