[DRE-commits] [ruby-gnome2] 04/31: New upstream version 3.0.1

Daisuke Higuchi dai at moszumanska.debian.org
Mon Oct 10 13:40:17 UTC 2016


This is an automated email from the git hooks/post-receive script.

dai pushed a commit to branch exp/debian
in repository ruby-gnome2.

commit 4df4eeb08b47b3f27206c661e73d962981cd4923
Author: HIGUCHI Daisuke (VDR dai) <dai at debian.org>
Date:   Sun Oct 9 21:56:16 2016 +0900

    New upstream version 3.0.1
---
 NEWS                                               |  29 +++
 glib2/ext/glib2/rbglib.h                           |   2 +-
 glib2/ext/glib2/rbgobj_flags.c                     |   1 +
 gtk3/sample/tutorial/README.md                     | 105 +++++++-
 gtk3/sample/tutorial/exampleapp9/app-menu.ui       |  18 ++
 .../tutorial/exampleapp9/exampleapp.gresource.xml  |   9 +
 gtk3/sample/tutorial/exampleapp9/exampleapp.rb     | 268 +++++++++++++++++++++
 gtk3/sample/tutorial/exampleapp9/gears-menu.ui     |  16 ++
 .../exampleapp9/org.gtk.exampleapp.gschema.xml     |  25 ++
 gtk3/sample/tutorial/exampleapp9/prefs.ui          |  70 ++++++
 gtk3/sample/tutorial/exampleapp9/window.ui         | 117 +++++++++
 vte3/lib/vte3/loader.rb                            |  19 ++
 vte3/lib/vte3/{loader.rb => version.rb}            |  42 ++--
 vte3/test/test-version.rb                          |  53 ++++
 14 files changed, 745 insertions(+), 29 deletions(-)

diff --git a/NEWS b/NEWS
index 4658d80..e362e7b 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,35 @@
 
 = NEWS
 
+== Ruby-GNOME2 3.0.1: 2015-09-11
+
+It is a bug fix release of 3.0.0.
+
+=== Changes
+
+==== Ruby/GLib2
+
+  * Fixes
+    * Windows: Fixed a bug that large number flag value isn't usable.
+      [GitHub#538] [Reported by Abby Archer]
+
+==== Ruby/GTK3
+
+  * Improvements
+    * Updated tutorials.
+      [GitHub#534][GitHub#537] [Patch by cedlemo]
+
+==== Ruby/VTE3
+
+  * Improvements
+    * Added (({Vte::Version.or_later?})).
+      [GitHub#535] [Patch by cedlemo]
+
+=== Thanks
+
+  * cedlemo
+  * Abby Archer
+
 == Ruby-GNOME2 3.0.0: 2015-09-10
 
 It is a GTK+ 3.16 support release.
diff --git a/glib2/ext/glib2/rbglib.h b/glib2/ext/glib2/rbglib.h
index c6e51b0..03b7023 100644
--- a/glib2/ext/glib2/rbglib.h
+++ b/glib2/ext/glib2/rbglib.h
@@ -36,7 +36,7 @@ extern "C" {
 
 #define RBGLIB_MAJOR_VERSION 3
 #define RBGLIB_MINOR_VERSION 0
-#define RBGLIB_MICRO_VERSION 0
+#define RBGLIB_MICRO_VERSION 1
 
 #ifndef RSTRING_PTR
 #  define RSTRING_PTR(s) (RSTRING(s)->ptr)
diff --git a/glib2/ext/glib2/rbgobj_flags.c b/glib2/ext/glib2/rbgobj_flags.c
index 49ad720..a9519b8 100644
--- a/glib2/ext/glib2/rbgobj_flags.c
+++ b/glib2/ext/glib2/rbgobj_flags.c
@@ -225,6 +225,7 @@ resolve_flags_value(VALUE klass, GFlagsClass *gclass, VALUE flag_or_flags)
         value = 0;
         break;
     case RUBY_T_FIXNUM:
+    case RUBY_T_BIGNUM:
         value = NUM2UINT(flag_or_flags);
         break;
     case RUBY_T_STRING:
diff --git a/gtk3/sample/tutorial/README.md b/gtk3/sample/tutorial/README.md
index f73ce09..996d6da 100644
--- a/gtk3/sample/tutorial/README.md
+++ b/gtk3/sample/tutorial/README.md
@@ -312,7 +312,7 @@ In this example we create a subclass of `Gtk::Application` called ExampleApp. In
 *    open : opens files and shows them in a new window
 
 For more informations, see [here](https://wiki.gnome.org/HowDoI/GtkApplication).
-In this case, the signal "*activate*" will be triggered if no arguments are given to the `ExampleApp#run` method. And a default window will be created and will be presented to the user ( [see](https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-present).
+In this case, the signal "*activate*" will be triggered if no arguments are given to the `ExampleApp#run` method. And a default window will be created and will be presented to the user ( [`Gtk::Widget#present`](https://developer.gnome.org/gtk3/stable/GtkWindow.html#gtk-window-present)).
 
 If file names are given to the `ExampleApp#run` method, then it is the "*open*" signal that is called.
 Trought this event, you can manage the files that are stored in an array of `Gio::File` objects.
@@ -327,6 +327,109 @@ https://developer.gnome.org/gtk3/stable/ch01s04.html#id-1.2.3.12.6
 
 *    exampleapp2/exampleapp.rb
 
+In this step, we use a [`Gtk::Builder`](https://developer.gnome.org/gtk3/stable/GtkBuilder.html) template to associate a [`Gtk::Builder`](https://developer.gnome.org/gtk3/stable/GtkBuilder.html) ui file with our application window class.
+Our simple ui file puts a [`Gtk::HeaderBar`](https://developer.gnome.org/gtk3/stable/GtkHeaderBar.html) on top of a [`Gtk::Stack`](https://developer.gnome.org/gtk3/stable/GtkStack.html) widget. The header bar contains a [`Gtk::StackSwitcher`](https://developer.gnome.org/gtk3/stable/GtkStackSwitcher.html), which is a standalone widget to show a row of 'tabs' for the pages of a [`Gtk::Stack`](https://developer.gnome.org/gtk3/stable/GtkStack.html) .
+
+Here is the "window.ui" file that contains the template of the window:
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="ExampleAppWindow" parent="GtkApplicationWindow">
+    <property name="title" translatable="yes">Example Application</property>
+    <property name="default-width">600</property>
+    <property name="default-height">400</property>
+    <child>
+      <object class="GtkBox" id="content_box">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkHeaderBar" id="header">
+            <property name="visible">True</property>
+            <child type="title">
+              <object class="GtkStackSwitcher" id="tabs">
+                <property name="visible">True</property>
+                <property name="margin">6</property>
+                <property name="stack">stack</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkStack" id="stack">
+            <property name="visible">True</property>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
+```
+Unlike regular interface descriptions, in template XML descriptions, a`<template>` tag is expected as a direct child of the toplevel `<interface>` tag. Yhe `<template>` tag must specify the "*class*" attribute which must be the class name of the widget. Optionally, the "*parent*" attribute may be specified to indicate the direct parent class (superclass).
+
+More informations can be found in the part [building composite widgets from template XML](https://developer.gnome.org/gtk3/stable/GtkWidget.html#GtkWidget.description) of the `Gtk::Widget` documentation. 
+
+#### Link a template to a custom class widget.
+
+```ruby
+class ExampleAppWindow < Gtk::ApplicationWindow
+  type_register
+  class << self
+    def init
+      set_template(:resource => "/org/gtk/exampleapp/window.ui")
+    end
+  end
+
+  def initialize(application)
+    super(:application => application)
+  end
+
+  def open(file)
+    
+  end
+end
+```
+
+We create a subclass of Gtk::ApplicationWindow. Then we call the method `type_register` inherited from `GLib::Object` in order to register this class as a new [GType](https://developer.gnome.org/gobject/stable/chapter-gtype.html). See the file *ruby-gnome2/glib2/ext/glib2/rbgobj_object.c* for the C implementation. More informations on the gobject manipulation can be found [here](https://blogs.gnome.org/desrt/2012/02/26/a-gentle-introduction-to-gobject-construction/)
+
+The template of the interface is bound to the class using the `init` singleton method. We just open the *eigenclass*  with `class << self` and define the method `init` in which we call the `Gtk::Widget#set_template` method.
+
+After that, the `ExampleAppWindow#initialize` method must be overwritten. When `type_register` is used, *super* is equivalent to `GLib::Object#initialize` so you need to use properties style constructor (hash argument, see [here](https://github.com/ruby-gnome2/ruby-gnome2/issues/503))
+
+#### Load a resource file.
+
+You may have noticed that we used the `:resource => ` key as the argument of the method that sets a template. Now we need to use GLib's resource functionality to include the ui file in the binary. This is commonly done by listing all resources in a .gresource.xml file, such as this:
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gtk/exampleapp">
+    <file preprocess="xml-stripblanks">window.ui</file>
+  </gresource>
+</gresources>
+```
+In our script, we built the resource binary file with
+```ruby
+system("glib-compile-resources",
+       "--target", gresource_bin,
+       "--sourcedir", File.dirname(gresource_xml),
+       gresource_xml)
+```
+Then we make sure that this file is deleted when the script is done :
+
+```ruby
+at_exit do
+  FileUtils.rm_f(gresource_bin)
+end
+```
+The resource binary file is loaded so that each resources in it can be accessed via theirs respective paths.
+
+```ruby
+resource = Gio::Resource.load(gresource_bin)
+Gio::Resources.register(resource)
+```
+
 ### Opening files
 https://developer.gnome.org/gtk3/stable/ch01s04.html#id-1.2.3.12.7
 
diff --git a/gtk3/sample/tutorial/exampleapp9/app-menu.ui b/gtk3/sample/tutorial/exampleapp9/app-menu.ui
new file mode 100644
index 0000000..e1e131c
--- /dev/null
+++ b/gtk3/sample/tutorial/exampleapp9/app-menu.ui
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <menu id="appmenu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Preferences</attribute>
+        <attribute name="action">app.preferences</attribute>
+      </item>
+    </section>
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Quit</attribute>
+        <attribute name="action">app.quit</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/gtk3/sample/tutorial/exampleapp9/exampleapp.gresource.xml b/gtk3/sample/tutorial/exampleapp9/exampleapp.gresource.xml
new file mode 100644
index 0000000..ace59c8
--- /dev/null
+++ b/gtk3/sample/tutorial/exampleapp9/exampleapp.gresource.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gtk/exampleapp">
+    <file preprocess="xml-stripblanks">window.ui</file>
+    <file preprocess="xml-stripblanks">app-menu.ui</file>
+    <file preprocess="xml-stripblanks">gears-menu.ui</file>
+    <file preprocess="xml-stripblanks">prefs.ui</file>
+  </gresource>
+</gresources>
diff --git a/gtk3/sample/tutorial/exampleapp9/exampleapp.rb b/gtk3/sample/tutorial/exampleapp9/exampleapp.rb
new file mode 100644
index 0000000..ad90420
--- /dev/null
+++ b/gtk3/sample/tutorial/exampleapp9/exampleapp.rb
@@ -0,0 +1,268 @@
+# Copyright (C) 2015  Ruby-GNOME2 Project Team
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+#
+# Original:
+#   * URL: https://git.gnome.org/browse/gtk+/tree/examples/application8/exampleapp.c
+#   * URL: https://git.gnome.org/browse/gtk+/tree/examples/application8/exampleappwin.c
+#   * License: LGPL 2
+
+require "gtk3"
+
+require "fileutils"
+
+current_path = File.expand_path(File.dirname(__FILE__))
+gresource_bin = "#{current_path}/exampleapp.gresource"
+gresource_xml = "#{current_path}/exampleapp.gresource.xml"
+
+system("glib-compile-resources",
+       "--target", gresource_bin,
+       "--sourcedir", current_path,
+       gresource_xml)
+
+gschema_bin = "#{current_path}/gschemas.compiled"
+
+system("glib-compile-schemas", current_path)
+
+at_exit do
+  FileUtils.rm_f([gresource_bin, gschema_bin])
+end
+
+resource = Gio::Resource.load(gresource_bin)
+Gio::Resources.register(resource)
+
+ENV["GSETTINGS_SCHEMA_DIR"] = current_path
+
+def update_words(win)
+  tab = win.stack.visible_child
+  return unless tab
+  view = tab.child
+  buffer = view.buffer
+  iter = buffer.start_iter
+  strings = []
+  done = false
+  until iter.end?
+    until iter.starts_word
+      unless iter.forward_char
+        done = true
+        break
+      end
+    end
+    break if done
+    word_end = iter.clone
+    break  unless word_end.forward_word_end
+    strings << buffer.get_text(iter, word_end, false)
+    iter = word_end
+  end
+  children = win.words.children
+  children.each { |c| win.words.remove(c) } unless children.empty?
+  strings.each do |s|
+    row = Gtk::Button.new(:label => s)
+    row.signal_connect("clicked") { |_widget| win.searchentry.text = s }
+    row.show
+    win.words.add(row)
+  end
+end
+
+def update_lines(win)
+  tab = win.stack.visible_child
+  return unless tab
+  view = tab.child
+  buffer = view.buffer
+  iter = buffer.start_iter
+  count = 0
+  until iter.end?
+    count += 1
+    break unless iter.forward_line
+  end
+  win.lines.text = count.to_s
+end
+
+class ExampleAppPrefs < Gtk::Dialog
+  type_register
+
+  class << self
+    def init
+      set_template(:resource => "/org/gtk/exampleapp/prefs.ui")
+      bind_template_child("font")
+      bind_template_child("transition")
+    end
+  end
+
+  def initialize(args)
+    parent = args[:transient_for]
+    super(:transient_for => parent, :use_header_bar => 1)
+    settings = Gio::Settings.new("org.gtk.exampleapp")
+    settings.bind("font",
+                  font,
+                  "font",
+                  Gio::SettingsBindFlags::DEFAULT)
+    settings.bind("transition",
+                  transition,
+                  "active-id",
+                  Gio::SettingsBindFlags::DEFAULT)
+  end
+end
+
+class ExampleAppWindow < Gtk::ApplicationWindow
+  type_register
+  class << self
+    def init
+      set_template(:resource => "/org/gtk/exampleapp/window.ui")
+      bind_template_child("stack")
+      bind_template_child("search")
+      bind_template_child("searchbar")
+      bind_template_child("searchentry")
+      bind_template_child("gears")
+      bind_template_child("words")
+      bind_template_child("sidebar")
+      bind_template_child("lines")
+      bind_template_child("lines_label")
+
+      set_connect_func do |name|
+        method(name)
+      end
+    end
+
+    private
+
+    def search_text_changed(search_entry)
+      text = search_entry.text
+      return if text.empty?
+
+      win = search_entry.toplevel
+      tab = win.stack.visible_child
+      view = tab.child
+      buffer = view.buffer
+      range = buffer.start_iter.forward_search(text,
+                                               Gtk::TextSearchFlags::CASE_INSENSITIVE)
+      return unless range
+      buffer.select_range(range[0], range[1])
+      view.scroll_to_iter(range[0], 0.0, false, 0.0, 0.0)
+    end
+
+    def visible_child_changed(stack, params)
+      return if stack.in_destruction?
+      win = stack.toplevel
+      win.searchbar.set_search_mode(false)
+      update_words(win)
+      update_lines(win)
+    end
+  end
+
+  def initialize(application)
+    super(:application => application)
+    @settings = Gio::Settings.new("org.gtk.exampleapp")
+    @settings.bind("transition",
+                   stack,
+                   "transition-type",
+                   Gio::SettingsBindFlags::DEFAULT)
+    search.bind_property("active", searchbar, "search-mode-enabled", :bidirectional)
+    @settings.bind("show-words",
+                   sidebar,
+                   "reveal-child",
+                   Gio::SettingsBindFlags::DEFAULT)
+    sidebar.signal_connect "notify::reveal-child" do |_sidebar, _gparamspec, _application|
+      update_words(self)
+    end
+    builder = Gtk::Builder.new(:resource => "/org/gtk/exampleapp/gears-menu.ui")
+    menu = builder.get_object("menu")
+    gears.set_menu_model(menu)
+    action = @settings.create_action("show-words")
+    add_action(action)
+    action = Gio::PropertyAction.new("show-lines", lines, "visible")
+    add_action(action)
+    lines.bind_property("visible", lines_label, "visible", :default)
+  end
+
+  def open(file)
+    basename = file.basename
+
+    scrolled = Gtk::ScrolledWindow.new
+    scrolled.show
+    scrolled.set_hexpand(true)
+    scrolled.set_vexpand(true)
+
+    view = Gtk::TextView.new
+    view.set_editable(false)
+    view.set_cursor_visible(false)
+    view.show
+    scrolled.add(view)
+
+    stack.add_titled(scrolled, basename, basename)
+
+    stream = file.read
+    buffer = view.buffer
+    buffer.text = stream.read
+    tag = buffer.create_tag
+    @settings.bind("font", tag, "font", Gio::SettingsBindFlags::DEFAULT)
+    buffer.apply_tag(tag, buffer.start_iter, buffer.end_iter)
+    search.sensitive = true
+    update_words(self)
+    update_lines(self)
+  end
+end
+
+class ExampleApp < Gtk::Application
+  def initialize
+    super("org.gtk.exampleapp", :handles_open)
+
+    signal_connect "startup" do |application|
+      quit_accels = ["<Ctrl>Q"]
+      action = Gio::SimpleAction.new("quit")
+      action.signal_connect("activate") do |_action, _parameter|
+        application.quit
+      end
+      application.add_action(action)
+      application.set_accels_for_action("app.quit", quit_accels)
+
+      action = Gio::SimpleAction.new("preferences")
+      action.signal_connect("activate") do |_action, _parameter|
+        win = application.windows.first
+        prefs = ExampleAppPrefs.new(:transient_for => win,
+                                    :use_header_bar => true)
+        prefs.present
+      end
+      application.add_action(action)
+
+      builder = Gtk::Builder.new(:resource => "/org/gtk/exampleapp/app-menu.ui")
+      app_menu = builder.get_object("appmenu")
+      application.set_app_menu(app_menu)
+    end
+
+    signal_connect "activate" do |application|
+      window = ExampleAppWindow.new(application)
+      window.present
+    end
+
+    signal_connect "open" do |application, files, _hint|
+      windows = application.windows
+      win = nil
+      if windows.empty?
+        win = ExampleAppWindow.new(application)
+      else
+        win = windows.first
+      end
+
+      files.each { |file| win.open(file) }
+
+      win.present
+    end
+  end
+end
+
+app = ExampleApp.new
+
+puts app.run([$PROGRAM_NAME] + ARGV)
diff --git a/gtk3/sample/tutorial/exampleapp9/gears-menu.ui b/gtk3/sample/tutorial/exampleapp9/gears-menu.ui
new file mode 100644
index 0000000..fb0e929
--- /dev/null
+++ b/gtk3/sample/tutorial/exampleapp9/gears-menu.ui
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<interface>
+  <!-- interface-requires gtk+ 3.0 -->
+  <menu id="menu">
+    <section>
+      <item>
+        <attribute name="label" translatable="yes">_Words</attribute>
+        <attribute name="action">win.show-words</attribute>
+      </item>
+      <item>
+        <attribute name="label" translatable="yes">_Lines</attribute>
+        <attribute name="action">win.show-lines</attribute>
+      </item>
+    </section>
+  </menu>
+</interface>
diff --git a/gtk3/sample/tutorial/exampleapp9/org.gtk.exampleapp.gschema.xml b/gtk3/sample/tutorial/exampleapp9/org.gtk.exampleapp.gschema.xml
new file mode 100644
index 0000000..a6929a8
--- /dev/null
+++ b/gtk3/sample/tutorial/exampleapp9/org.gtk.exampleapp.gschema.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+  <schema path="/org/gtk/exampleapp/" id="org.gtk.exampleapp">
+    <key name="font" type="s">
+      <default>'Monospace 12'</default>
+      <summary>Font</summary>
+      <description>The font to be used for content.</description>
+    </key>
+    <key name="transition" type="s">
+      <choices>
+        <choice value='none'/>
+        <choice value='crossfade'/>
+        <choice value='slide-left-right'/>
+      </choices>
+      <default>'none'</default>
+      <summary>Transition</summary>
+      <description>The transition to use when switching tabs.</description>
+    </key>
+    <key name="show-words" type="b">
+      <default>false</default>
+      <summary>Show words</summary>
+      <description>Whether to show a word list in the sidebar</description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/gtk3/sample/tutorial/exampleapp9/prefs.ui b/gtk3/sample/tutorial/exampleapp9/prefs.ui
new file mode 100644
index 0000000..95e1cb8
--- /dev/null
+++ b/gtk3/sample/tutorial/exampleapp9/prefs.ui
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="ExampleAppPrefs" parent="GtkDialog">
+    <property name="title" translatable="yes">Preferences</property>
+    <property name="resizable">False</property>
+    <property name="modal">True</property>
+    <child internal-child="vbox">
+      <object class="GtkBox" id="vbox">
+        <child>
+          <object class="GtkGrid" id="grid">
+            <property name="visible">True</property>
+            <property name="margin">6</property>
+            <property name="row-spacing">12</property>
+            <property name="column-spacing">6</property>
+            <child>
+              <object class="GtkLabel" id="fontlabel">
+                <property name="visible">True</property>
+                <property name="label">_Font:</property>
+                <property name="use-underline">True</property>
+                <property name="mnemonic-widget">font</property>
+                <property name="xalign">1</property>
+              </object>
+              <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkFontButton" id="font">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="transitionlabel">
+                <property name="visible">True</property>
+                <property name="label">_Transition:</property>
+                <property name="use-underline">True</property>
+                <property name="mnemonic-widget">transition</property>
+                <property name="xalign">1</property>
+              </object>
+              <packing>
+                <property name="left-attach">0</property>
+                <property name="top-attach">1</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkComboBoxText" id="transition">
+                <property name="visible">True</property>
+                <items>
+                  <item translatable="yes" id="none">None</item>
+                  <item translatable="yes" id="crossfade">Fade</item>
+                  <item translatable="yes" id="slide-left-right">Slide</item>
+                </items>
+              </object>
+              <packing>
+                <property name="left-attach">1</property>
+                <property name="top-attach">1</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/gtk3/sample/tutorial/exampleapp9/window.ui b/gtk3/sample/tutorial/exampleapp9/window.ui
new file mode 100644
index 0000000..b5f40fb
--- /dev/null
+++ b/gtk3/sample/tutorial/exampleapp9/window.ui
@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.8 -->
+  <template class="ExampleAppWindow" parent="GtkApplicationWindow">
+    <property name="title" translatable="yes">Example Application</property>
+    <property name="default-width">600</property>
+    <property name="default-height">400</property>
+    <child>
+      <object class="GtkBox" id="content_box">
+        <property name="visible">True</property>
+        <property name="orientation">vertical</property>
+        <child>
+          <object class="GtkHeaderBar" id="header">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkLabel" id="lines_label">
+                <property name="visible">False</property>
+                <property name="label" translatable="yes">Lines:</property>
+              </object>
+              <packing>
+                <property name="pack-type">start</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkLabel" id="lines">
+                <property name="visible">False</property>
+              </object>
+              <packing>
+                <property name="pack-type">start</property>
+              </packing>
+            </child>
+            <child type="title">
+              <object class="GtkStackSwitcher" id="tabs">
+                <property name="visible">True</property>
+                <property name="margin">6</property>
+                <property name="stack">stack</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkToggleButton" id="search">
+                <property name="visible">True</property>
+                <property name="sensitive">False</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+                <child>
+                  <object class="GtkImage" id="search-icon">
+                    <property name="visible">True</property>
+                    <property name="icon-name">edit-find-symbolic</property>
+                    <property name="icon-size">1</property>
+                  </object>
+                </child>
+              </object>
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkMenuButton" id="gears">
+                <property name="visible">True</property>
+                <property name="direction">none</property>
+                <property name="use-popover">True</property>
+                <style>
+                  <class name="image-button"/>
+                </style>
+              </object>
+              <packing>
+                <property name="pack-type">end</property>
+              </packing>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkSearchBar" id="searchbar">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkSearchEntry" id="searchentry">
+                <signal name="search-changed" handler="search_text_changed"/>
+                <property name="visible">True</property>
+              </object>
+            </child>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox" id="hbox">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkRevealer" id="sidebar">
+                <property name="visible">True</property>
+                <property name="transition-type">slide-right</property>
+                <child>
+                 <object class="GtkScrolledWindow" id="sidebar-sw">
+                   <property name="visible">True</property>
+                   <property name="hscrollbar-policy">never</property>
+                   <property name="vscrollbar-policy">automatic</property>
+                   <child>
+                     <object class="GtkListBox" id="words">
+                       <property name="visible">True</property>
+                       <property name="selection-mode">none</property>
+                     </object>
+                   </child>
+                 </object>
+                </child>
+              </object>
+            </child>
+            <child>
+              <object class="GtkStack" id="stack">
+                <signal name="notify::visible-child" handler="visible_child_changed"/>
+                <property name="visible">True</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/vte3/lib/vte3/loader.rb b/vte3/lib/vte3/loader.rb
index 423bd09..89b17d9 100644
--- a/vte3/lib/vte3/loader.rb
+++ b/vte3/lib/vte3/loader.rb
@@ -27,6 +27,15 @@ module Vte
       end
     end
 
+    def pre_load(repository, namespace)
+      define_version_module
+    end
+
+    def define_version_module
+      @version_module = Module.new
+      @base_module.const_set("Version", @version_module)
+    end
+
     def post_load(repository, namespace)
       require_libraries
     end
@@ -34,10 +43,20 @@ module Vte
     def require_libraries
       require "vte3/pty"
       require "vte3/terminal"
+      require "vte3/version"
 
       require "vte3/deprecated"
     end
 
+    def load_constant_info(info)
+      case info.name
+      when /_VERSION\z/
+        @version_module.const_set($PREMATCH, info.value)
+      else
+        super
+      end
+    end
+
     def initialize_post(object)
       super
       return unless object.is_a?(GLib::Object)
diff --git a/vte3/lib/vte3/loader.rb b/vte3/lib/vte3/version.rb
similarity index 56%
copy from vte3/lib/vte3/loader.rb
copy to vte3/lib/vte3/version.rb
index 423bd09..92e54b3 100644
--- a/vte3/lib/vte3/loader.rb
+++ b/vte3/lib/vte3/version.rb
@@ -1,4 +1,4 @@
-# Copyright (C) 2014-2015  Ruby-GNOME2 Project Team
+# Copyright (C) 2015  Ruby-GNOME2 Project Team
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
@@ -15,33 +15,21 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 
 module Vte
-  class Loader < GObjectIntrospection::Loader
-    private
-    def load_function_info(info)
-      name = info.name
-      case name
-      when "init"
-        # ignore
-      else
-        super
-      end
-    end
-
-    def post_load(repository, namespace)
-      require_libraries
-    end
+  module Version
+    if const_defined?(:MAJOR)
+      STRING = [MAJOR, MINOR, MICRO].join(".")
 
-    def require_libraries
-      require "vte3/pty"
-      require "vte3/terminal"
-
-      require "vte3/deprecated"
-    end
-
-    def initialize_post(object)
-      super
-      return unless object.is_a?(GLib::Object)
-      self.class.reference_gobject(object, :sink => true)
+      class << self
+        def or_later?(major, minor, micro=nil)
+          micro ||= 0
+          version = [
+            MAJOR,
+            MINOR,
+            MICRO,
+          ]
+          (version <=> [major, minor, micro]) >= 0
+        end
+      end
     end
   end
 end
diff --git a/vte3/test/test-version.rb b/vte3/test/test-version.rb
new file mode 100644
index 0000000..4348f3b
--- /dev/null
+++ b/vte3/test/test-version.rb
@@ -0,0 +1,53 @@
+# Copyright (C) 2015  Ruby-GNOME2 Project Team
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library 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
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+
+class TestVteVersion < Test::Unit::TestCase
+  include VteTestUtils
+
+  setup do
+    unless Vte::Version.const_defined?(:STRING)
+      omit("VTE doesn't provide version information")
+    end
+  end
+
+  test "STRING" do
+    major = Vte::Version::MAJOR
+    minor = Vte::Version::MINOR
+    micro = Vte::Version::MICRO
+    assert_equal([major, minor, micro].join("."),
+                 Vte::Version::STRING)
+  end
+
+  sub_test_case("#or_later?") do
+    test "same" do
+      assert_true(Vte::Version.or_later?(Vte::Version::MAJOR,
+                                             Vte::Version::MINOR,
+                                             Vte::Version::MICRO))
+    end
+
+    test "later" do
+      assert_true(Vte::Version.or_later?(Vte::Version::MAJOR,
+                                         Vte::Version::MINOR - 1,
+                                         Vte::Version::MICRO))
+    end
+
+    test "earlier" do
+      assert_false(Vte::Version.or_later?(Vte::Version::MAJOR,
+                                          Vte::Version::MINOR + 1,
+                                          Vte::Version::MICRO))
+    end
+  end
+end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-gnome2.git



More information about the Pkg-ruby-extras-commits mailing list