From c60d10515f028f07e07bfabb9f31d8e6eb7c51a7 Mon Sep 17 00:00:00 2001 From: Toshiaki Asai Date: Sat, 6 Apr 2013 02:11:33 +0900 Subject: Twitter APIからふぁぼ・RT数を取得して表示できるようにしてみた MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/mui/cairo_sub_parts_favorite.rb | 4 ++++ core/mui/cairo_sub_parts_retweet.rb | 4 ++++ core/mui/cairo_sub_parts_voter.rb | 10 +++++++--- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'core') diff --git a/core/mui/cairo_sub_parts_favorite.rb b/core/mui/cairo_sub_parts_favorite.rb index 67672aa3..e9d7fd23 100644 --- a/core/mui/cairo_sub_parts_favorite.rb +++ b/core/mui/cairo_sub_parts_favorite.rb @@ -8,6 +8,10 @@ require 'cairo' class Gdk::SubPartsFavorite < Gdk::SubPartsVoter regist + def get_vote_count + [helper.message[:favorite_count] || 0, super].max + end + def get_default_votes helper.message.favorited_by end diff --git a/core/mui/cairo_sub_parts_retweet.rb b/core/mui/cairo_sub_parts_retweet.rb index a9fff4b9..5ea6544a 100644 --- a/core/mui/cairo_sub_parts_retweet.rb +++ b/core/mui/cairo_sub_parts_retweet.rb @@ -8,6 +8,10 @@ require 'cairo' class Gdk::SubPartsRetweet < Gdk::SubPartsVoter regist + def get_vote_count + [helper.message[:retweet_count] || 0, super].max + end + def get_default_votes helper.message.retweeted_by end diff --git a/core/mui/cairo_sub_parts_voter.rb b/core/mui/cairo_sub_parts_voter.rb index d34a88cb..ae53e07a 100644 --- a/core/mui/cairo_sub_parts_voter.rb +++ b/core/mui/cairo_sub_parts_voter.rb @@ -64,7 +64,7 @@ class ::Gdk::SubPartsVoter < Gdk::SubParts @votes[index] end end end def render(context) - if(not @votes.empty?) + if get_vote_count != 0 context.save{ context.translate(@margin, 0) put_title_icon(context) @@ -73,7 +73,7 @@ class ::Gdk::SubPartsVoter < Gdk::SubParts @last_height = height end def height - if @votes.empty? + if get_vote_count == 0 0 else icon_height end end @@ -154,8 +154,12 @@ class ::Gdk::SubPartsVoter < Gdk::SubParts layout = context.create_pango_layout layout.wrap = Pango::WRAP_CHAR layout.font_description = Pango::FontDescription.new(UserConfig[:mumble_basic_font]) - layout.text = "#{votes.size}" + layout.text = "#{get_vote_count}" layout end + def get_vote_count + votes.size + end + end -- cgit v1.2.3