Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test.rb to actually use gtksourceview5 #1636

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 30 additions & 23 deletions gtksourceview5/sample/test.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
#!/usr/bin/env ruby
#
# test.rb - Ruby/GtkSourceView4 sample script.
# test.rb - Ruby/GtkSourceView5 sample script.
#
# Copyright (c) 2006-2020 Ruby-GNOME Project Team
# Copyright (c) 2006-2024 Ruby-GNOME Project Team
# This program is licenced under the same licence as Ruby-GNOME.
#
# $Id: test.rb,v 1.4 2007/06/03 02:11:07 mutoh Exp $

require 'gtksourceview4'

window = Gtk::Window.new
window.signal_connect('delete-event') { Gtk.main_quit }
require 'gtksourceview5'

view = GtkSource::View.new
window.add(Gtk::ScrolledWindow.new.add(view))
view.show_line_numbers = true
view.insert_spaces_instead_of_tabs = true
view.indent_width = 2
view.show_right_margin = true
view.right_margin_position = 80

lang = GtkSource::LanguageManager.new.get_language('ruby')
view.buffer.language = lang
view.buffer.highlight_syntax = true
view.buffer.highlight_matching_brackets = true
view.buffer.text = File.read(__FILE__)
provider = Gtk::CssProvider.new
provider.load(data: 'textview { font-family: Monospace; font-size: 8pt; }')
view.style_context.add_provider(provider)
main = Gtk::Application.new("org.test.gtksourceview5")

window.set_default_size(480, 480)
window.show_all
main.signal_connect("activate") do |app|
window = Gtk::Window.new()
window.application = app
Beagle123 marked this conversation as resolved.
Show resolved Hide resolved

view = GtkSource::View.new
window.set_child(Gtk::ScrolledWindow.new.set_child(view))
Beagle123 marked this conversation as resolved.
Show resolved Hide resolved
view.show_line_numbers = true
view.insert_spaces_instead_of_tabs = true
view.indent_width = 2
view.show_right_margin = true
view.right_margin_position = 80

lang = GtkSource::LanguageManager.new.get_language('ruby')
view.buffer.language = lang
view.buffer.highlight_syntax = true
view.buffer.highlight_matching_brackets = true
view.buffer.text = File.read(__FILE__)
provider = Gtk::CssProvider.new
provider.load(data: 'textview { font-family: Monospace; font-size: 8pt; }')
view.style_context.add_provider(provider)

window.set_default_size(480, 480)
window.present
end

main.run

Gtk.main
Loading