File: menubar.rb

package info (click to toggle)
ruby-gnome 4.3.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,320 kB
  • sloc: ruby: 55,206; ansic: 29,012; xml: 333; sh: 229; cpp: 45; makefile: 42
file content (50 lines) | stat: -rw-r--r-- 1,560 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
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
48
49
50
#!/usr/bin/env ruby
#
# Copyright (C) 2020,2023  ToshioCP (Toshio Sekiya)
# Copyright (C) 2023  Ruby-GNOME2 Project Team
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Ruby implementation of the C example in:
# https://toshiocp.github.io/Gtk4-tutorial/sec17.html

require_relative "utils"

require_gtk4

app = Gtk::Application.new("org.gtk.example", :flags_none)

app.signal_connect "activate" do
  window = Gtk::ApplicationWindow.new(app)
  window.application = app

  act_quit = Gio::SimpleAction.new("quit")
  app.add_action(act_quit)
  act_quit.signal_connect "activate" do |_simple_action, _parameter|
    window.destroy
  end

  menubar = Gio::Menu.new
  menu_item_menu = Gio::MenuItem.new("Menu")
  menu = Gio::Menu.new
  menu_item_quit = Gio::MenuItem.new("Quit", "app.quit")
  menu.append_item(menu_item_quit)
  menu_item_menu.submenu = menu
  menubar.append_item(menu_item_menu)
  app.menubar = menubar
  window.show_menubar = true

  window.show
end

app.run