<commit_before>#!/usr/bin/env ruby
=begin
  pangolayout.rb - Ruby/GTK sample script.

  Copyright (c) 2005-2015  Ruby-GNOME2 Project Team
  This program is licenced under the same licence as Ruby-GNOME2.
=end

require "gtk3"

RADIUS =  80
N_WORDS = 16
HEIGHT = 400
WIDTH = 400

class PaintableWindow < Gtk::Window
  attr_reader :supports_alpha, :x, :y, :width, :height

  def initialize(name)
    super(name)
    set_app_paintable(true)
    set_decorated(true)
    set_default_size(WIDTH, HEIGHT)
    signal_connect("destroy") { Gtk.main_quit }
    set_double_buffered(false)

    # Get the size attributes when the window is resized
    signal_connect "size-allocate" do |_widget, rectangle|
      @x = rectangle.x
      @y = rectangle.y
      @width = rectangle.width
      @height = rectangle.height
    end

    signal_connect "screen-changed" do |widget, _old_screen|
      screen_changed(widget)
    end

    screen_changed(self)
  end

  private

  def screen_changed(widget)
    visual = widget.screen.rgba_visual
    if visual && widget.screen.composited?
      set_visual(visual)
      @supports_alpha = true
    else
      set_visual(widget.screen.system_visual)
      @supports_alpha = false
    end
  end
end

pangolayout = PaintableWindow.new("Pango Render")

pangolayout.signal_connect "draw" do |widget, cr|
  # Redraw on a clean destination
  # http://cairographics.org/manual/cairo-cairo-t.html#cairo-operator-t
  cr.set_operator(Cairo::OPERATOR_SOURCE)

  if  widget.supports_alpha
    cr.set_source_rgba(0, 0, 0, 0.3)
  else
    cr.set_source_rgb(1, 1, 1)
  end

  cr.paint
<commit_msg>gtk3 sample: remove a needless space<commit_after>#!/usr/bin/env ruby
=begin
  pangolayout.rb - Ruby/GTK sample script.

  Copyright (c) 2005-2015  Ruby-GNOME2 Project Team
  This program is licenced under the same licence as Ruby-GNOME2.
=end

require "gtk3"

RADIUS =  80
N_WORDS = 16
HEIGHT = 400
WIDTH = 400

class PaintableWindow < Gtk::Window
  attr_reader :supports_alpha, :x, :y, :width, :height

  def initialize(name)
    super(name)
    set_app_paintable(true)
    set_decorated(true)
    set_default_size(WIDTH, HEIGHT)
    signal_connect("destroy") { Gtk.main_quit }
    set_double_buffered(false)

    # Get the size attributes when the window is resized
    signal_connect "size-allocate" do |_widget, rectangle|
      @x = rectangle.x
      @y = rectangle.y
      @width = rectangle.width
      @height = rectangle.height
    end

    signal_connect "screen-changed" do |widget, _old_screen|
      screen_changed(widget)
    end

    screen_changed(self)
  end

  private

  def screen_changed(widget)
    visual = widget.screen.rgba_visual
    if visual && widget.screen.composited?
      set_visual(visual)
      @supports_alpha = true
    else
      set_visual(widget.screen.system_visual)
      @supports_alpha = false
    end
  end
end

pangolayout = PaintableWindow.new("Pango Render")

pangolayout.signal_connect "draw" do |widget, cr|
  # Redraw on a clean destination
  # http://cairographics.org/manual/cairo-cairo-t.html#cairo-operator-t
  cr.set_operator(Cairo::OPERATOR_SOURCE)

  if widget.supports_alpha
    cr.set_source_rgba(0, 0, 0, 0.3)
  else
    cr.set_source_rgb(1, 1, 1)
  end

  cr.paint

{'fraction_non_alphanumeric': 0.0943104514533086, 'fraction_numerical': 0.018243661100803957, 'mean_word_length': 3.3775372124492558, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2112437', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1121, 'n_words': 265}