Class: Gtk3App::Program

Inherits:
Object
  • Object
show all
Defined in:
lib/gtk3app/program.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Program

Returns a new instance of Program.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gtk3app/program.rb', line 6

def initialize(app)
  Widget::MainWindow.set_icon Such::Thing::PARAMETERS[:Logo]

  @window = Widget::MainWindow.new(:window!, 'delete-event'){quit!}

  @app_menu = Widget::AppMenu.new(@window, :app_menu!) do |w,*_,s|
    self.method(w.key).call if s=='activate'
  end

  @mini = @mini_menu = nil
  if @app_menu.children.which{|item| item.key==:minime!}
    @mini = Widget::MainWindow.new(:mini, 'delete-event'){quit!}
    @mini_menu = Widget::AppMenu.new(@mini, :mini_menu!) do |w,*_,s|
      self.method(w.key).call if s=='activate'
      minime! if s=='button_press_event'
    end
  end

  @fs = false
  @slot = nil
  app.run(self)
end

Instance Attribute Details

#app_menuObject (readonly)

Returns the value of attribute app_menu.



5
6
7
# File 'lib/gtk3app/program.rb', line 5

def app_menu
  @app_menu
end

#fsObject (readonly)

Returns the value of attribute fs.



5
6
7
# File 'lib/gtk3app/program.rb', line 5

def fs
  @fs
end

#miniObject (readonly)

Returns the value of attribute mini.



5
6
7
# File 'lib/gtk3app/program.rb', line 5

def mini
  @mini
end

#mini_menuObject (readonly)

Returns the value of attribute mini_menu.



5
6
7
# File 'lib/gtk3app/program.rb', line 5

def mini_menu
  @mini_menu
end

#slotObject (readonly)

Returns the value of attribute slot.



5
6
7
# File 'lib/gtk3app/program.rb', line 5

def slot
  @slot
end

#windowObject (readonly)

Returns the value of attribute window.



5
6
7
# File 'lib/gtk3app/program.rb', line 5

def window
  @window
end

Instance Method Details

#about!Object



34
35
36
37
38
39
40
# File 'lib/gtk3app/program.rb', line 34

def about!
  about = Such::AboutDialog.new :about_dialog
  about.transient_for = @window
  about. Widget::MainWindow.icon
  about.run
  about.destroy
end

#fs!Object



29
30
31
32
# File 'lib/gtk3app/program.rb', line 29

def fs!
  @fs ? @window.unfullscreen : @window.fullscreen
  @fs = !@fs
end

#help!Object



42
43
44
# File 'lib/gtk3app/program.rb', line 42

def help!
  system "#{CONFIG[:Open]} '#{Such::Thing::PARAMETERS[:HelpFile]}'"
end

#minime!Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/gtk3app/program.rb', line 53

def minime!
  if @window.visible?
    @slot = Slot.get
    if @slot
      s = CONFIG[:SlotsScale]
      x, y = CONFIG[:SLOTS_OFFSET]
      w, h = Gdk::Screen.width, Gdk::Screen.height
      case CONFIG[:SlotsOrientation]
      when :horizontal
        @mini.move(w-@slot*s+x, h-s+y)
      when :vertical
        @mini.move(w-s+x, h-@slot*s+y)
      else
        if @slot%2==0
          @mini.move(w-((@slot+2)/2)*s+x, h-s+y)
        else
          @mini.move(w-s+x, h-((@slot+1)/2)*s+y)
        end
      end
      @mini.keep_above=true
      @window.hide
      @mini.show
    end
  else
    release
    @mini.hide
    @window.show
  end
end

#quit!Object



83
84
85
86
# File 'lib/gtk3app/program.rb', line 83

def quit!
  release
  Gtk.main_quit
end

#releaseObject



46
47
48
49
50
51
# File 'lib/gtk3app/program.rb', line 46

def release
  if @slot
    Slot.release(@slot)
    @slot = nil
  end
end