Class: Ruiby_gtk

Inherits:
Gtk::Window
  • Object
show all
Includes:
Ruiby_dsl, Ruiby_threader
Defined in:
lib/ruiby_gtk/windows.rb

Overview

Creative Commons BY-SA : Regis d'Aubarede <regis.aubarede@gmail.com> LGPL

windows.rb : main ruiby windows

Direct Known Subclasses

Editor, PopupForm, PopupTable

Instance Method Summary (collapse)

Methods included from Ruiby_threader

#after, #anim, #init_threader, #threader

Methods included from Ruiby_dsl

#_, #_accept?, #_cbox, #_check_append, #_create_log_window, #_dyn_check_button, #_dyn_entry, #_dyn_ientry, #_dyn_islider, #_dyn_label, #_label, #_make_prop_line, #_nocodeeeeeeeeeee, #_pack, #_paned, #_radio_buttons, #_set_accepter, #_sub_image, #aaa_generalities, #accordion, #aitem, #alabel, #append_to, #apply_options, #attribs, #autoslot, #background, #backgroundi, #bourrage, #box, #button, #button_expand, #button_icon_text, #buttoni, #calendar, #calendar_set_time, #canvas, #canvasOld, #cell, #cell_bottom, #cell_hspan, #cell_hspan_left, #cell_hspan_right, #cell_hvspan, #cell_left, #cell_pass, #cell_right, #cell_span, #cell_top, #cell_vspan, #cell_vspan_bottom, #cell_vspan_top, #center, #check_button, #clear, #clear_append_to, #clickable, #close_dialog, #color_choice, #color_conversion, #combo, #css_name, cv_color_html, #def_style, #delete, #dialog, #dialog_async, #entry, #fentry, #field, #fields, #flow, #flow_paned, #flowi, #force_update, #frame, #framei, #get_config, #get_current_container, #get_icon, #get_image_from, #get_pixbuf, #get_stockicon_pixbuf, #grid, #haccordion, #hide_app, #hradio_buttons, #html_color, #htoolbar, #htoolbar_with_icon_text, #ientry, #image, #islider, #label, #labeli, #left, #levelbar, #list, #log, #menu, #menu_bar, #menu_button, #menu_checkbutton, #menu_separator, #next_row, #notebook, #on_canvas_button_motion, #on_canvas_button_press, #on_canvas_button_release, #on_canvas_draw, #on_canvas_key_press, #page, #pclickable, #pclickablie, #plot, #popup, #pp_item, #pp_separator, #progress_bar, #properties, #propertys, #razslot, #regular, #right, #row, #scrolled, #separator, #show_all_children, #show_app, #show_methods, #slider, #slot, #slot_append_after, #slot_append_before, #sloti, #snapshot, #source_editor, #space, #spacei, #spacing, #stack, #stack_paned, #stacki, #syst_add_button, #syst_add_check, #syst_add_sepratator, #syst_icon, #syst_quit_button, #systray, #systray_setup, #table, #text_area, #text_area_dyn, #toggle_button, #toolbar_button, #toolbar_separator, #tooltip, #tree_grid, #update, #var_box, #var_boxi, #vbox_scrolled, #video, #vradio_buttons, #widget_properties

Methods included from Ruiby_default_dialog

#_gooooooooooo, #alert, #ask, #ask_color, #ask_dir_to_read, #ask_dir_to_write, #ask_file_to_read, #ask_file_to_write, #dialog_chooser, #edit, #error, #message, #prompt, #trace

Constructor Details

- (Ruiby_gtk) initialize(title, w, h)



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/ruiby_gtk/windows.rb', line 10

def initialize(title,w,h)
  super()
  init_threader()
  #threader(10) # must be call by user window, if necessary
  set_title(title)
  set_default_size(w,h)
  signal_connect "destroy" do 
      if @is_main_window
        @is_main_window=false
        Gtk.main_quit
      end
  end
  iconfn=Ruiby::DIR+"/../media/ruiby.png"
  set_icon(iconfn) if File.exists?(iconfn)
  p iconfn
  set_window_position Gtk::Window::Position::CENTER  # default, can be modified by window_position(x,y)
  @lcur=[self]
  @ltable=[]
  @current_widget=nil
  @cur=nil
  begin
    component  
  rescue
    error("COMPONENT() : "+$!.to_s + " :\n     " +  $!.backtrace[0..10].join("\n     "))
    exit(1)
  end
  begin
    show_all 
  rescue
    puts "Error in show_all : illegal state of some widget? "+ $!.to_s
  end
  if ARGV.any? {|v| v=="take-a-snapshot" }
    after(100) { 
      snapshot("#{Dir.exists?("media") ? "media/" : ""}snapshot_#{File.basename($0)}.png")
      after(100) { exit(0)  } 
    }
  end
end

Instance Method Details

- (Object) chrome(on = false)

show or supress the window system decoration



80
81
82
# File 'lib/ruiby_gtk/windows.rb', line 80

def chrome(on=false)
  set_decorated(on)
end

- (Object) component



58
59
60
# File 'lib/ruiby_gtk/windows.rb', line 58

def component
  raise("Abstract: 'def component()' must be overiden in a Ruiby class")
end

- (Object) on_destroy(&blk)



52
53
54
# File 'lib/ruiby_gtk/windows.rb', line 52

def on_destroy(&blk) 
      signal_connect("destroy") { blk.call }
end

- (Object) on_resize(&blk)



48
49
50
51
# File 'lib/ruiby_gtk/windows.rb', line 48

def on_resize(&blk)
  self.resizable=true
  signal_connect("configure_event") { blk.call } if blk
end

- (Object) rposition(x, y)

change position of window in the desktop. relative position works only in *nix system.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/ruiby_gtk/windows.rb', line 64

def rposition(x,y)
  if x==0 && y==0
    set_window_position Window::POS_CENTER
    return
  elsif     x>=0 && y>=0
    gravity= Gdk::Window::Gravity::NORTH_WEST
  elsif   x<0 && y>=0
    gravity= Gdk::Window::Gravity::NORTH_EAST
  elsif   x>=0 && y<0
    gravity= Gdk::Window::Gravity::SOUTH_WEST
  elsif   x<0 && y<0
    gravity= Gdk::Window::Gravity::SOUTH_EAST
  end
  move(x.abs,y.abs)
end

- (Object) ruiby_exit



55
56
57
# File 'lib/ruiby_gtk/windows.rb', line 55

def ruiby_exit()
  Gtk.main_quit 
end