Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

split Pixbuf loader process.

  • Loading branch information...
commit 8007cc7e2dc86238e195eb4a4adfc6bd647e6655 1 parent 7cb9b6d
@kou kou authored
Showing with 22 additions and 16 deletions.
  1. +22 −16 app.rb
View
38 app.rb
@@ -99,6 +99,27 @@ def prepare_real_name(name)
end
end
+def load_pixbuf(info)
+ screen_name = info[:screen_name]
+ profile_image_url = info[:profile_image_url]
+ *profile_image_url_components = profile_image_url.split(/\//)
+ profile_image_last_component = profile_image_url_components.last
+ profile_image_url_components[-1] =
+ u(profile_image_last_component.gsub(/_normal\.([a-zA-Z]+)\z/, '.\1'))
+ profile_image_url = profile_image_url_components.join("/")
+
+ extension = $1
+ image_data = cache_file("images", "#{screen_name}.#{extension}") do
+ open(profile_image_url, "rb") do |image_file|
+ image_file.read
+ end
+ end
+ loader = Gdk::PixbufLoader.new
+ loader.write(image_data)
+ loader.close
+ loader.pixbuf
+end
+
def render_to_surface_big(surface, scale, paper, info, font)
margin = paper.width * 0.03
image_width = image_height = paper.width * 0.3
@@ -139,22 +160,7 @@ def render_to_surface_big(surface, scale, paper, info, font)
context.move_to(margin, paper.height - layout.pixel_size[1] - margin)
context.show_pango_layout(layout)
- *profile_image_url_components = info[:profile_image_url].split(/\//)
- profile_image_last_component = profile_image_url_components.last
- profile_image_url_components[-1] =
- u(profile_image_last_component.gsub(/_normal\.([a-zA-Z]+)\z/, '.\1'))
- profile_image_url = profile_image_url_components.join("/")
-
- extension = $1
- image_data = cache_file("images", "#{screen_name}.#{extension}") do
- open(profile_image_url, "rb") do |image_file|
- image_file.read
- end
- end
- loader = Gdk::PixbufLoader.new
- loader.write(image_data)
- loader.close
- pixbuf = loader.pixbuf
+ pixbuf = load_pixbuf(info)
if pixbuf
context.save do
context.translate(paper.width - image_width - margin,
Please sign in to comment.
Something went wrong with that request. Please try again.