Skip to content

Commit

Permalink
Use GdkPixbuf form in gtk2 gtk-demo files
Browse files Browse the repository at this point in the history
  • Loading branch information
cedlemo committed Jun 25, 2016
1 parent 7537d5b commit c5b59a2
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions gtk2/sample/gtk-demo/appwindow.rb
Expand Up @@ -184,7 +184,7 @@ def about_cb(*args)
Boston, MA 02111-1307, USA.
]

transparent = Gdk::Pixbuf.new(Demo.find_file("gtk-logo-rgb.gif")).add_alpha(true, 0xff, 0xff, 0xff)
transparent = GdkPixbuf::Pixbuf.new(:file => Demo.find_file("gtk-logo-rgb.gif")).add_alpha(true, 0xff, 0xff, 0xff)

Gtk::AboutDialog.set_email_hook {|about, link|
puts "send mail to #{link}"
Expand Down Expand Up @@ -222,7 +222,7 @@ def register_stock_icons
factory.add_default

filename = Demo.find_file('gtk-logo-rgb.gif')
pixbuf = Gdk::Pixbuf.new(filename)
pixbuf = GdkPixbuf::Pixbuf.new(:file => filename)

transparent = pixbuf.add_alpha(true, 0xff, 0xff, 0xff)

Expand Down
2 changes: 1 addition & 1 deletion gtk2/sample/gtk-demo/cairo-clip-image.rb
Expand Up @@ -23,7 +23,7 @@ def draw(cr)

cr.new_path

loader = Gdk::PixbufLoader.new
loader = GdkPixbuf::PixbufLoader.new
File.open("background.jpg", "rb") do |f|
loader.last_write(f.read)
end
Expand Down
2 changes: 1 addition & 1 deletion gtk2/sample/gtk-demo/cairo-image.rb
Expand Up @@ -18,7 +18,7 @@ def initialize

def draw(cr)
cr.save do
loader = Gdk::PixbufLoader.new
loader = GdkPixbuf::PixbufLoader.new
File.open("background.jpg", "rb") do |f|
loader.last_write(f.read)
end
Expand Down
6 changes: 3 additions & 3 deletions gtk2/sample/gtk-demo/iconview.rb
Expand Up @@ -37,10 +37,10 @@ def fill_store

def initialize
super('Gtk::IconView demo')
@file_pixbuf = Gdk::Pixbuf.new(Demo.find_file("gnome-fs-regular.png"))
@folder_pixbuf = Gdk::Pixbuf.new(Demo.find_file("gnome-fs-directory.png"))
@file_pixbuf = GdkPixbuf::Pixbuf.new(:file => Demo.find_file("gnome-fs-regular.png"))
@folder_pixbuf = GdkPixbuf::Pixbuf.new(:file => Demo.find_file("gnome-fs-directory.png"))

@store = Gtk::ListStore.new(String, String, TrueClass, Gdk::Pixbuf)
@store = Gtk::ListStore.new(String, String, TrueClass, GdkPixbuf::Pixbuf)
@parent = "/"

@store.set_default_sort_func do |a, b|
Expand Down
6 changes: 3 additions & 3 deletions gtk2/sample/gtk-demo/images.rb
Expand Up @@ -6,7 +6,7 @@
= Images
Gtk::Image is used to display an image; the image can be in a number of formats.
Typically, you load an image into a Gdk::Pixbuf, then display the pixbuf.
Typically, you load an image into a GdkPixbuf::Pixbuf, then display the pixbuf.
This demo code shows some of the more obscure cases, in the simple
case a call to Gtk::Image.new is all you need.
Expand Down Expand Up @@ -55,7 +55,7 @@ def initialize
pixbuf = nil
begin
filename = Demo.find_file('gtk-logo-rgb.gif')
pixbuf = Gdk::Pixbuf.new(filename)
pixbuf = GdkPixbuf::Pixbuf.new(:file => filename)
rescue
# This code shows off error handling. You can just use
# Gtk::Image.new instead if you don't want to report
Expand Down Expand Up @@ -159,7 +159,7 @@ def progressive_timeout(image)
@pixbuf_loader = nil
end

@pixbuf_loader = Gdk::PixbufLoader.new
@pixbuf_loader = GdkPixbuf::PixbufLoader.new

@pixbuf_loader.signal_connect('area_prepared') do |loader|
pixbuf = loader.pixbuf
Expand Down
16 changes: 9 additions & 7 deletions gtk2/sample/gtk-demo/pixbufs.rb
Expand Up @@ -5,7 +5,7 @@
=begin
= Pixbufs
A Gdk::Pixbuf represents an image, normally in RGB or RGBA format.
A GdkPixbuf::Pixbuf represents an image, normally in RGB or RGBA format.
Pixbufs are normally used to load files from disk and perform
image scaling.
Expand Down Expand Up @@ -51,9 +51,11 @@ def initialize

set_size_request(@background.width, @background.height)

@frame = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB,
false, 8,
@background.width, @background.height)
@frame = GdkPixbuf::Pixbuf.new(:colorspace => :rgb,
:has_alpha => false,
:bits_per_sample => 8,
:width => @background.width,
:height => @background.height)

@da = Gtk::DrawingArea.new

Expand Down Expand Up @@ -96,12 +98,12 @@ def load_pixbufs
# in the location where the file is installed.
#
filename = Demo.find_file(BACKGROUND_NAME)
@background = Gdk::Pixbuf.new(filename)
@background = GdkPixbuf::Pixbuf.new(:file => filename)

IMAGE_NAMES.each_with_index do |basename, i|
filename = Demo.find_file(basename)

@images[i] = Gdk::Pixbuf.new(filename)
@images[i] = GdkPixbuf::Pixbuf.new(:file => filename)
end
end

Expand Down Expand Up @@ -154,7 +156,7 @@ def timeout
dest = r1.intersect(r2)
if dest
@frame.composite!(image, dest.x, dest.y, dest.width, dest.height,
xpos, ypos, k, k, Gdk::Pixbuf::INTERP_NEAREST,
xpos, ypos, k, k, :nearest,
if (i & 1) == 1
[
127,
Expand Down
2 changes: 1 addition & 1 deletion gtk2/sample/gtk-demo/stock_browser.rb
Expand Up @@ -147,7 +147,7 @@ def create_model
# Make the result the proper size for our thumbnail
w, h = Gtk::IconSize.lookup(size)

scaled = info.small_icon.scale(w, h, Gdk::Pixbuf::INTERP_BILINEAR)
scaled = info.small_icon.scale(w, h, GdkPixbuf::Pixbuf::INTERP_BILINEAR)
info.small_icon = scaled
end

Expand Down
4 changes: 2 additions & 2 deletions gtk2/sample/gtk-demo/textview.rb
Expand Up @@ -188,14 +188,14 @@ def insert_text(buffer)
#

filename = Demo.find_file("gtk-logo-rgb.gif")
pixbuf = Gdk::Pixbuf.new(filename) if filename
pixbuf = GdkPixbuf::Pixbuf.new(:file => filename) if filename

unless pixbuf
$stderr.print "Failed to load image file gtk-logo-rgb.gif\n"
exit 1
end

scaled = pixbuf.scale(32, 32, Gdk::Pixbuf::INTERP_BILINEAR)
scaled = pixbuf.scale(32, 32, :bilinear)
pixbuf = scaled

##
Expand Down

0 comments on commit c5b59a2

Please sign in to comment.