Tuesday, December 22, 2009

Winter brake

I take a winter brake, so I suspend posts and comments to this blog for a moment. Resume will be January 8, 2010.

I wish you a Merry Christmas and a Happy New Year.

Saturday, December 19, 2009

Qt 4.6's ECMAScript

I forgot to write about ECMAScript changes in phosphorescence: Qt Conference - Tokyo 2009.

Until Qt 4.5, QtScript and QtWebkit have each implementation of ECMAScript engine. But from Qt 4.6, these are unified to QtWebkit's one - JavaScriptCore from Webkit.

Wednesday, December 16, 2009

Qt Conference - Tokyo 2009

In 2 days ago, Qt Conference - Tokyo 2009 was held at Tsukiji, Tokyo. There are many sessions and many notable topics like below:
  • Qt is running on everywhere, PC OSs, Mobile ones, STB, Coffee maker and so on.
  • Qt had been open-sourced into the open-repository - on Gitorious.
  • From 4.6, Qt supports Mulit-touch feature on Mulit-touch ready OS like Mac OS X, Windows 7 and so on.
  • And from 4.6, Qt refines Webkit integration and brings State Chart XML support.
  • From 4.7, Qt will support Declarative UI as QML.
  • In Asia, Taiwan and Korea are the region where Qt is widely used in. ASUS is most one.
  • HOW-TOs about distributing Qt application with Comercial, LGPL, or GPL license.
  • Qt 4.6's GUI New Feature 1/4: Animation framework. That is to change properties of QObject dynamically.
  • Qt 4.6's GUI New Feature 2/4: State machine. That is made with State Chart XML.
  • Qt 4.6's GUI New Feature 3/4: Graphical effects - like shade, blur and so on.
  • Qt 4.6's GUI New Feature 4/4: Multi-touch and Gesture - like tap, pinch, swipe and so on.
  • Qt 4.6 supports Symbian S60 3rd1, 3rd2 and 5th.
  • Qt 4.6 supports Windows Mobile 5 and 6. But 6.5 is not yet. Qt 4.7 will support Windows Mobile 6.5.
  • Qt 4.6 for Maemo5 is built on Gtk GUI framework, but from Maemo6, Qt itself will become GUI framework.
  • QtCreator is not only IDE, but also is good sample for cross-platform application. We can see its source code from Gitorious.
  • QtCreator helps our debugging and Unit-testing. And Squish/Qt integrates auto-testing and regression testing.
  • Translation flow for Qt application: lupdate -> edit .ts -> lrelease -> load .qm
  • Tips for Using String classes, QObject::tr() or qtTrid() and QT_NO_CAST_FROM_ASCII
  • Hiring translators is more expensive than hiring us - the developers. For example, in Japan translation price is 27 yen per one word.
  • From symbian^3, it will become based on Qt and more. And from symbian^4, it will become full-Qt-based.
And one more notable topic, download count is 2.5 times than before setting LGPL license.

Monday, December 14, 2009

NetBeans 6.8 has been released finally

In 4 days ago, NetBeans 6.8 FCS has been released.


This Ruby bundle installer bundles JRuby 1.4.0 and FCS of Glassfish server 3(JavaEE 6). But there are one bug for non-English users. Plugin URL contains language code like catalog_ja.xml.gz.

So we should remove it like catalog.xml.gz.

Friday, December 11, 2009

Ruby 1.9.1 p376 was released

In the first day of this week, ruby 1.9.1 p376 was released. So I download and re-install its package like this entry. Let's check.
> /opt/ruby-1.9.1/bin/ruby --version
ruby 1.9.1p376 (2009-12-07 revision 26041) [i686-linux]

Then I re-build QtRuby like this entry.

Tuesday, December 8, 2009

Euler's formula in Ruby

require 'mathn'
def euler(prec=10)
  result = Math.exp(Complex(0, -Math::PI))
  "#{result.real.round(prec)}+#{result.imag.round(prec)}i"
end

Let's execute this method with default argument.
> euler
"-1.0+0.0i"
And execute with argument.
> euler 14
"-1.0+-0.0i"
But more precision...
> euler 15
"-1.0+-0.0i"
> euler 16
"-1.0+-1.0e-16i"
It occurs because of floating-point error.

Saturday, December 5, 2009

Qt 4.6.0 was released

In the first day of this month, Qt 4.6.0 was released. I download and install Qt 4.6.0 SDK (LGPL) from here.

But I decide to keep on using Qt 4.5.3 on openSUSE 11.2, so I install to my another Windows 7 machine. Qt SDK for Windows bundles latest MinGW.

Thursday, December 3, 2009

Panel for publishing AWDwR 3rd Japanese edition

Today, panel for publishing AWDwR 3rd Japanese edition was held in Ikebukuro, Tokyo.

While I have been using Ruby and QtRuby in non-business, now I have to use Ruby on Rails on business. So I bought this book and start studying. And I attend today's panel by Shugo Maeda(translation supervisor) and other supervisors.

There are many inside stories about translation works and about impedances between Ruby communities and Rails communities (related with Jeremy Kemper's session in phosphorescence: The 2nd day of RubyWorld Conference 2009 (Morning)).

By the way, novelty of today's panel is a calculator.


But we already have NICE calculator like below:

Monday, November 30, 2009

Finish to read C++ GUI Programming with Qt 4

I've finished to read C++ GUI Programming with Qt 4 and to code its tutorials finally. My sample of last widget on this book is below:

This book is useful for my basic learnings. But this book had published when Qt version was 4.1, and 2nd edition of this book is for Qt 4.3. Of course, current version is Qt 4.5 and Qt 4.6 will be released soon. So I hope someone will publish Qt 4.5 / Qt 4.6 book in English ... or in Japanese if possible.

Friday, November 27, 2009

Evaluate RubyMine 2.0

While NetBeans 6.8 RC1 has never released (and been postponed 3 times), JetBrains releases yet another Ruby IDE ... RubyMine 2.0.

It's same with NetBeans that RubyMine runs on JVM. But it's not same with NetBeans that RubyMine 99 dollars while NetBeans is 0 dollars. So I have signed up its 30-days evaluation and install on openSUSE 11.2.

And I using it some days and I'm not feel bad. When evaluation period will be over and If NetBeans 6.8 FCS will not be released in that time, I will pay 99 dollars for RubyMine!?

Tuesday, November 24, 2009

Release of NetBeans 6.8 RC1 is postponed three times!

The release day at first plan was 11/09. The release day at second plan was 11/15. And the release day at latest plan is today, 11/24. But today, it is postponed also.

Saturday, November 21, 2009

Installing QtRuby on Ruby 1.9.1 from openSUSE source rpm

At 1st, install Ruby 1.9.1 with same instruction of this article:
phosphorescence: Install Ruby 1.9.1

Then I should go to install QtRuby with source from repository, but smoke/generator of QtRuby is still unstable yet as I had write in this article:
phosphorescence: Confusing about smoke/generator

So I decide to install from source RPM package of openSUSE 11.2 - my own environment.

Thursday, November 19, 2009

What version of Qt and QtRuby are bundled on openSUSE 11.2?

To see the version of Qt and qmake, type the command below:
> qmake --version
QMake version 2.01a
Using Qt version 4.5.3 in /usr/lib
Qt on openSUSE 11.2 is version 4.5.3 ... latest stable version.

And to see the version of QtRuby, familiar commands below:
> rbrcc -version
Ruby Resource Compiler for Qt version 4.5.3
> rbuic4 -v              
Qt User Interface Compiler version 4.5.3   
> rbqtapi -v             
QtRuby 2.0.5 using Qt-4.5.3
QtRuby on openSUSE 11.2 is version 2.0.5 ... it's trunk version.

Monday, November 16, 2009

I have installed openSUSE 11.2

I have installed openSUSE 11.2 on this weekend. It was very easy because of YaST installer and KDE 4.3 is more beautiful than older openSUSE's one.

But there is one curious point. It's non-English directory names in home directory. For example, my environment is below:

Friday, November 13, 2009

openSUSE 11.2 release memorial party


In yesterday, openSUSE 11.2 release memorial party was held at Tokyo, Japan. This party has became a count-down party because iso images of 11.2 were not mirrored yet, and had finished mirroring at the end of party.

So I try to download DVD iso image from now.

Tuesday, November 10, 2009

Ruby MinGW one-click installer RC1 was released

At 3 months ago, I introduced about Ruby MinGW one-click installer. And in yesterday, Ruby MinGW one-click installer release candidate 1 was released. So I try to install it on my... Winbows 7.


Saturday, November 7, 2009

Schedule of RubyKaigi2010 is unveiled.

Today is NOT April fool. In fact, both schedule and venue of RubyKaigi2010 are now unveiled.

RubyKaigi2010
Schedule: Augast 27 ~ 29, 2010
Venue:

Thursday, November 5, 2009

Qt is ready for mobile OS

From Qt 4.6, Symbian and Maemo are supported.
Nokia announces official Qt port to Maemo 5
Nokia releases Qt 4.6 and Qt Creator 1.3 betas, including support for Symbian

And, from Qt 4.7 (still planned!), Windows Mobile 6.5 will be full-supported.
Windows Mobile 6.5 support

Monday, November 2, 2009

Ruby initialize puzzle (more exercises)

(continued from phosphorescence: Ruby initialize puzzle (answer part))

If you want to call both initialize methods, you should write initialize method of Bar module like below:
module Bar
  def initialize(b)
    super
    puts "#{b} World"
  end
end

irb(main):018:0> Sample.new('qux')
Hello qux
qux World
=> #<Sample:0x256e918>

Saturday, October 31, 2009

Ruby initialize puzzle (answer part)

(continued from phosphorescence: Ruby initialize puzzle (question part))

The answer is:
irb(main):017:0> Sample.new('qux')
qux World
=> #<Sample:0x246f508>

The Ruby method super doesn't mean calling same method of super class, it means calling same method defined in last class.

For example, if same method is defined in super class only, it behaves to rewrite super class's one. But if same method is defined in included module like as this question, it behaves to rewrite included module's one because it's last defined method.

Thursday, October 29, 2009

Ruby initialize puzzle (question part)

There are classes and module like below:
class Foo
  def initialize(a)
    puts "Hello #{a}"
  end
end
module Bar
  def initialize(b)
    puts "#{b} World"
  end
end
class Sample < Foo
  include Bar
  def initialize(c)
    super
  end
end

When you call Sample.new('qux'), what standard output will you see?

Monday, October 26, 2009

Memo for Qt i18n

Chapter 17 of this Qt book is for internationalization (i18n). There are some leverage points. So I write memo of these points on this article.

(1) If you force to internationalize all characters, you must define below line in .pro file:
DEFINES += QT_NO_CAST_FROM_ASCII


(2) Wrap all characters with tr() (if you want to internationalize) or QLatin1String() (if you want not to internationalize).

Friday, October 23, 2009

Japan Linux Symposium

The 1st Japan Linux Symposium was held. I only attend opening and 2 sessions because I'm busy with public and private in this month (and I am absent 3 events related with openSUSE in this month).

Tuesday, October 20, 2009

Gestalt and Moonlight

I learned 'Gestalt' recently - that is browser-side Ruby/Python/XAML scripting (instead of ECMAScript) driven with jQuery and Silverlight. Is that the product only for Windows? No! Gestalt supports not only Silverlight but also Moonlight.

I try to run sample bundled with Gestalt onto the Firefox on the my openSUSE.
  1. Install Firefox add-on of moonlight from here
  2. Download the zip of Gestalt from here
  3. Uncompress the zip of Gestalt
  4. Open the XAML sample files Gestalt/samples/getting.started/03_xaml.html, Gestalt/samples/getting.started/04_animation.html and Gestalt/samples/getting.started/05_final.html
If Gestalt/samples/getting.started/03_xaml.html succeeded, Firefox renders like below:

But samples of Ruby or Python didn't work in intact. I guess it's suspicious that Moonlight on the openSUSE 11.1 is 1.0, not 2.0 even though Firefox add-on of moonlight is 2.0 beta.

Saturday, October 17, 2009

Qt 4.6 Beta

Qt 4.6 Beta and Qt Creator 1.3 have been announced.
There are both binary packages and source codes, exclude Qt 4.6 Beta binary package of Linux.

And I decide to use Qt 4.5.3 installed recently, unbtil 4.6 final version will be released.

Wednesday, October 14, 2009

1.9.2 release in Christmas was canceled

(continued from phosphorescence: Ruby 1.9.2 release plans will be re-scheduled)

In conclusion, Ruby 1.9.2 release in Christmas was canceled. If you can read Japanese, see the minutes of Ruby Developer's Meeting 20091013. The most important points are the following three:
  • preview2 ... the end of 2009/10
  • feature freeze ... the end of 2009/12
  • release requirement of 1.9.2 ... pass the rubyspec

Monday, October 12, 2009

Ruby 1.9 new features: All about encoding

The biggest change in Ruby 1.9 is the all about encoding. First, Encoding class had been created to deal encode information. If you see the all encodings in your Ruby environment, see the output of Encoding
> /opt/ruby-1.9.1/bin/irb
irb(main):001:0> RUBY_VERSION              
=> "1.9.1"                                 
irb(main):002:0> Encoding.constants.find_all{|const|Encoding.const_get(const).is_a?(Encoding)}
=> [:ASCII_8BIT, :Big5, :BIG5, :CP949, :Emacs_Mule, :EMACS_MULE, :EUC_JP, :EUC_KR, :EUC_TW, :GB18030, :GBK, :ISO_8859_1, :ISO_8859_2, :ISO_8859_3, :ISO_8859_4,:ISO_8859_5, :ISO_8859_6, :ISO_8859_7, :ISO_8859_8, :ISO_8859_9, :ISO_8859_10, :ISO_8859_11, :ISO_8859_13, :ISO_8859_14, :ISO_8859_15, :ISO_8859_16, :KOI8_R, :KOI8_U, :Shift_JIS, :SHIFT_JIS, :US_ASCII, :UTF_8, :UTF_16BE, :UTF_16LE, :UTF_32BE, :UTF_32LE, :Windows_1251, :WINDOWS_1251, :BINARY, :IBM437, :CP437, :IBM737, :CP737, :IBM775, :CP775, :CP850, :IBM850, :IBM852, :CP852, :IBM855, :CP855, :IBM857, :CP857, :IBM860, :CP860, :IBM861, :CP861, :IBM862, :CP862, :IBM863, :CP863,:IBM864, :CP864, :IBM865, :CP865, :IBM866, :CP866, :IBM869, :CP869, :Windows_1258, :WINDOWS_1258, :CP1258, :GB1988, :MacCentEuro, :MACCENTEURO, :MacCroatian, :MACCROATIAN, :MacCyrillic, :MACCYRILLIC, :MacGreek, :MACGREEK, :MacIceland, :MACICELAND, :MacRoman, :MACROMAN, :MacRomania, :MACROMANIA, :MacThai, :MACTHAI, :MacTurkish, :MACTURKISH, :MacUkraine, :MACUKRAINE, :CP950, :Stateless_ISO_2022_JP,:STATELESS_ISO_2022_JP, :EucJP, :EUCJP, :EucJP_ms, :EUCJP_MS, :EUC_JP_MS, :CP51932, :EucKR, :EUCKR, :EucTW, :EUCTW, :EUC_CN, :EucCN, :EUCCN, :GB12345, :CP936, :ISO_2022_JP, :ISO2022_JP, :ISO_2022_JP_2, :ISO2022_JP2, :ISO8859_1, :Windows_1252, :WINDOWS_1252, :CP1252, :ISO8859_2, :Windows_1250, :WINDOWS_1250, :CP1250, :ISO8859_3, :ISO8859_4, :ISO8859_5, :ISO8859_6, :Windows_1256, :WINDOWS_1256, :CP1256, :ISO8859_7, :Windows_1253, :WINDOWS_1253, :CP1253, :ISO8859_8, :Windows_1255, :WINDOWS_1255, :CP1255, :ISO8859_9, :Windows_1254, :WINDOWS_1254, :CP1254, :ISO8859_10, :ISO8859_11, :TIS_620, :Windows_874, :WINDOWS_874, :CP874, :ISO8859_13, :Windows_1257, :WINDOWS_1257, :CP1257, :ISO8859_14, :ISO8859_15, :ISO8859_16, :CP878, :SJIS, :Windows_31J, :WINDOWS_31J, :CP932, :CsWindows31J, :CSWINDOWS31J, :MacJapanese, :MACJAPANESE, :MacJapan, :MACJAPAN, :ASCII, :ANSI_X3_4_1968, :UTF_7, :CP65000, :CP65001, :UTF8_MAC, :UTF_8_MAC, :UCS_2BE, :UCS_4BE, :UCS_4LE, :CP1251]

Friday, October 9, 2009

New URLs of Qt Sample code on Chapter14

I still keep on studying about Qt with book: "C++ GUI Programming with Qt 4". I spent a long time to read this book until Chapter 14. So I found that Sample URLs of this chapter (no wonder) remains old.

I write its changes below:
BeforeAfter
ftp://ftp.trolltech.com/mirrors->ftp://ftp.qtsoftware.com/mirrors
ftp://ftp.trolltech.com/freebies/leafnode->ftp://ftp.qtsoftware.com/freebies/leafnode
http://doc.trolltech.com/qq/index.html->http://qt.nokia.com/doc/qq/index.html

Tuesday, October 6, 2009

Qt 4.5.3 was released

In the first day of this month, Qt 4.5.3 was released. I download and install Qt 4.5.3 SDK (LGPL) from here.
#./qt-sdk-linux-x86_64-opensource-2009.04.bin
Installation instructions of QtRuby are below:
>cmake \
> -DCMAKE_INSTALL_PREFIX=/opt/ruby-1.9.1 \
> -DRUBY_EXECUTABLE=/opt/ruby-1.9.1/bin/ruby \
> -DRUBY_LIBRARY=/opt/ruby-1.9.1/lib/libruby.so.1.9.1 \
> -DRUBY_INCLUDE_PATH=/opt/ruby-1.9.1/include/ruby-1.9.1 \
> -DQT_QMAKE_EXECUTABLE=/opt/qtsdk-2009.04/qt/bin/qmake \
> -DQT_MKSPECS_DIR=/opt/qtsdk-2009.04/qt/mkspecs \
> -Wno-dev \
> -DENABLE_SMOKE=on \
> -DENABLE_QTRUBY=on \
> -DENABLE_QTWEBKIT_SMOKE=on \
> -DENABLE_QTSCRIPT_SMOKE=on \
> -DENABLE_QTUITOOLS_SMOKE=on \
> -DENABLE_QTTEST_SMOKE=off \
> -DENABLE_PHONON_SMOKE=off \
> -DENABLE_QSCI_SMOKE=off \
> -DENABLE_QWT_SMOKE=off \
> -DENABLE_KDE_SMOKE=off \
> -DENABLE_KDEVPLATFORM_SMOKE=off \
> -DENABLE_KHTML_SMOKE=off \
> -DENABLE_KTEXTEDITOR_SMOKE=off \
> -DENABLE_SOLID_SMOKE=off \
> -DENABLE_PLASMA_SMOKE=off \
> -DENABLE_QTWEBKIT_RUBY=on \
> -DENABLE_QTUITOOLS_RUBY=on \
> -DENABLE_QTSCRIPT=on \
> -DENABLE_QTTEST=off \
> -DENABLE_PHONON_RUBY=off \
> -DENABLE_QSCINTILLA_RUBY=off \
> -DENABLE_QWT_RUBY=off \
> -DENABLE_SOPRANO_RUBY=off \
> -DENABLE_KDEVPLATFORM_RUBY=off \
> -DENABLE_KORUNDUM_RUBY=off \
> -DENABLE_KHTML_RUBY=off \
> -DENABLE_KTEXTEDITOR_RUBY=off \
> -DENABLE_SOLID_RUBY=off \
> -DENABLE_KROSSRUBY=off \
> -DENABLE_PLASMA_RUBY=off \
> -DENABLE_QIMAGEBLITZ_SMOKE=off
Then check QtRuby commands.
>/opt/ruby-1.9.1/bin/rbrcc -version
Ruby Resource Compiler for Qt version 4.5.3
>/opt/ruby-1.9.1/bin/rbuic4 -v
Qt User Interface Compiler version 4.5.3
>/opt/ruby-1.9.1/bin/rbqtapi -v
QtRuby 2.0.3 using Qt-4.5.3
And QtCreator of this installer was also updated to 1.2.1.

Saturday, October 3, 2009

Ruby 1.9.2 release plans will be re-scheduled

In the 2nd day of RubyKaigi 2009, release plans of Ruby 1.9.2 had been announced. But 4 days ago, InfoQ's article reported its re-scheduling. See also release manager's post and meeting for announcing new release plan.

Thursday, October 1, 2009

cannot attend Qt Developer Days 2009

Qt Developer Days 2009 will be held, in Germany after 2 weeks, in USA after 1 month. There are QtWebkit related session and hands-on, so I have wanted to go there. But I cannot attend both.

If this conference will be held in next year, please hold in Asia: of course, I hope it in Japan.

Monday, September 28, 2009

Confusing about smoke/generator

From several previous revision, QtRuby's and other kdebindings' code generation tool have been changed from kalyptus to smoke/generator. It's advantage to port kdebindings for non-Unix platforms: smoke/generator is based on C++ whereas kalyptus is based on Perl.

But now I'm confusing because smoke/generator fails after starting make immediately. There are message like below:
Cannot load library generator_smoke: (libgenerator_smoke.so: ...
Unfortunately, it's not only problem for me. Others are encountering this problem. And fortunately, the author is succeeding on his each environments.

I have decided not following trunk of QtRuby in a while. I only use released version.

Saturday, September 19, 2009

Autumn short vacation

Before going on vacation, I update summary of openSUSE Conference 2009 - Tokyo Branch.

In Japan (2009 only), the Japanese are extraordinally experiencing consecutive national holidays, me too. I take a autumn vacation, so I suspend posts and comments to this blog for a moment. Resume will be September 28, 2009.

Monday, September 14, 2009

Keyword: PubSubHubbub

In Tim Bray's Keynote Address at RubyWorld Conference 2009, I heard the word I never heard, "pubsubhubbub". What is this? I have searched this word and understood a little.

pubsubhubbub

It's publish/subscribe style feed protocol. This protocol is from 3 entities.
  • Publisher ... Publish Atom feed or RSS feed to the Hub
  • Subscriber ... Subscribe some feeds from the Hub
  • Hub ... Notify feeds between Publisher and Subscriber as push notification
Representative subscriber is Google Reader. Representative hub is the sample hub built with pubsubhubbub team. If you want to build and run your own hub with Ruby, you could use WebGlue. And representative publisher is... your own site. Of course, it's also possible on my site if I change the feed settings on this site (not yet). Blogger have already embedded meta tag like below:
<link rel='hub' href='http://pubsubhubbub.appspot.com/'/>

And screen capture of actual feed XML is below:

Friday, September 11, 2009

I had forgotten to apply Qt patch

At the beginning of this month, Qt announced patches for QSslCertificate class, but I had forgotten to apply patch for Qt 4.5.x. So today I download from here, and apply it.
> cd /opt/qtsdk-2009.03/qt
> patch -p1 < /path/to/cve-2009-2700-patch-4.4.x-4.5.x.diff

Tuesday, September 8, 2009

The 2nd day of RubyWorld Conference 2009 (Afternoon)


Some sessions delayed 15 minutes because of projector trouble.

I attended these sessions:

The 2nd day of RubyWorld Conference 2009 (Morning)


In venue, tea had been served in Japanese Tea Ceremony style.

I attended these sessions:

Monday, September 7, 2009

The 1st day of RubyWorld Conference 2009 (Afternoon)


This photo is "Matsue Open Source Lab." in front of Matsue station.

I attended these sessions:

The 1st day of RubyWorld Conference 2009 (Morning)

RubyWorld Conference 2009 was held at here.



I attended these sessions:

Friday, September 4, 2009

Pros and Cons of "Yet another UI File loading"

In last entry, I only introduced sample code of "Yet another UI File loading". In this post, I will write pros and cons of it.

Tuesday, September 1, 2009

Yet another UI File loading

In past entries, I wrote 2 normal approaches of loading UI file in QtRuby.

Today I introduce a little unusual approach.

require 'Qt4'
require 'rexml/document'

# define method instead of qtuiloader
def Qt.load_ruby_from_ui(file_path, rbuic4_command = 'rbuic4')
doc = REXML::Document.new(::File.new(file_path))
top_widget_name = REXML::XPath.first(doc, '/ui/class/text()').value
parent_name = REXML::XPath.first(doc, '/ui/widget/@class')
eval `#{rbuic4_command} #{file_path}`
top_widget = const_get("Ui_#{top_widget_name.gsub(/\A(\w)/) {$1.upcase}}").new
parent = Qt::const_get(parent_name.value.gsub(/\AQ/, '')).new
top_widget.setupUi(parent)
parent
end

Qt::Application.new(ARGV) do
window = Qt.load_ruby_from_ui(
'/opt/qtsdk-2009.03/qt/examples/widgets/stylesheet/layouts/default.ui',
'/opt/ruby-1.9.1/bin/rbuic4')
window.show
exec
end

In this approach, evaluate the output of rbuic4 command, and then use Module#const_get to instantiate top widget class and its parent class.

Saturday, August 29, 2009

install Chromium for Linux x86_64 on openSUSE

(continued from phosphorescence: Prepare to install Chromium for Linux x86_64 on openSUSE)

Let's start installation.

1st checkout depot_tools
> svn co http://src.chromium.org/svn/trunk/tools/depot_tools
...
> export PATH=`pwd`/depot_tools:"$PATH"

2nd, checkout chromium with Git: this takes a time (in my case it took 1.5 minutes).
> git clone --depth 1 git://git.chromium.org/chromium.git src

3rd, create gclient config file and edit.
> ./depot_tools/gclient config http://src.chromium.org/svn/trunk/src
Then I edit .gclient like below:
solutions = [
{ "name" : "src",
"url" : "http://src.chromium.org/svn/trunk/src",
"custom_deps" : {
# To use the trunk of a component instead of what's in DEPS:
#"component": "https://svnserver/component/trunk/",
# To exclude a component from your working copy:
#"data/really_large_component": None,
"src/third_party/WebKit/LayoutTests": None
},
"safesync_url": ""
}
]

4th, sync gclient: this takes a long time (in my case it took 15 minutes).
> ./depot_tools/gclient sync

Finally, build the chromium for x86_64: make takes so long long times (in my case it took 1.5 hours).
> ./src/tools/gyp/gyp -f make src/build/all.gyp -Dtarget_arch=x64
> cd src
> make CC="ccache gcc" CXX="ccache g++" -r BUILDTYPE=Release -j6 chrome V=1


And run the chromium.

Speaking of shortcomings, all related files of chromium (source, tools and binaries) spend lots of disk space.
> du -h --total /opt/chromium
...
2.4G /opt/chromium

Friday, August 28, 2009

Prepare to install Chromium for Linux x86_64 on openSUSE

1 week ago, Google announced Chromium had been ready for Linux x86_64. I learned in this article. So I started to install Chromium (Google Chrome for POSIX) on my openSUSE 11.1 x86_64. But, this was a very long way. So I decide to divide a post in two: "prepare to install" and "install". This entry is about prepare to install.

First, read documentations for downloading chromium and for building. Below 3 documents are useful.
Second, install the missing packages. If your Desktop environment is GNOME and if you install all major header files, don't worry about it. But if not - me the KDE user - some header files and packages are missing. For example, I add these packages and there dependencies: ccache, gpref, flex, bison, gtk2-devel, mozilla-nss-devel and gconf2-devel.

And last preparation, create installation root directory. For this time, I created /opt/chromium directory.
to be continued...

Tuesday, August 25, 2009

Method#parameters - Ruby 1.9.2 new feature

Most friendly new feature in Ruby 1.9.2 is Method#parameters. What is this? see the sample below:
> /opt/ruby-1.9.1/bin/irb
irb(main):001:0> def sample_method(a, b=0, *c, &d);end
=> nil
irb(main):002:0> self.method(:sample_method).parameters
=> [[:req, :a], [:opt, :b], [:rest, :c], [:block, :d]]

As you see, Method#parameters returns 2-dimensional array, not hash.

In each inner array, the first is parameter type and the last is parameter name. Parameter type is represented by symbol; :req is normal parameter, :opt is parameter with default value, :rest is variable parameter, and :block is block parameter.

Saturday, August 22, 2009

openSUSE benkyoukai 2009/08

Today, in Tokyo, openSUSE benkyoukai was held (What's benkyoukai? see the first part of past entry).

There was 1 session:
  • Script-Fu Tips of Gimp
But today, there are many lightning talks and its Q&As.
  • Renewal QtRuby
  • Program Semantics
  • screen command
At this time, I talked about "Renewal QtRuby".

Tuesday, August 18, 2009

drag move charm #2

(continued from phosphorescence: drag move charm #1)

Why sample widget cannot be moved with grabbing top level widget? It's handled in DragMoveCharm#event_filter method. I had surveyed and debugged this method. Then I found it is caused by incorrect decision of inheritance. See the example code:
> /opt/ruby-1.9.1/bin/irb
irb(main):001:0> require 'Qt'
=> true
irb(main):002:0> Qt::Application.new([])
=> #<Qt::Application:0x00000000c00918 objectName="irb">
irb(main):003:0> label = Qt::Label.new
=> #<Qt::Label:0x00000000befc58 objectName="", x=0, y=0, width=640, height=480>
irb(main):004:0> Qt::Label.ancestors
=> [Qt::Label, Qt::Frame, Qt::Widget, Qt::Object, Qt::PaintDevice, Object, Kernel, BasicObject]
irb(main):005:0> Qt::Label.ancestors.collect do |ancestor_class|
irb(main):006:1* label.is_a? ancestor_class
irb(main):007:1> end
=> [true, false, false, false, false, true, true, true]

After QtRuby 2.0.3, class method Module.ancestors returns not only Ruby's super classes but also Qt's super classes because Qt::Base class overrides this method. But, other related methods don't. Object#is_a? and its alias Object#kind_of? aren't overrode.

If override? Let's try:
> /opt/ruby-1.9.1/bin/irb
irb(main):001:0> require 'Qt'
=> true
irb(main):002:0> module Qt
irb(main):003:1> class Base
irb(main):004:2> def is_a?(mod)
irb(main):005:3> super || self.class.ancestors.include?(mod)
irb(main):006:3> end
irb(main):007:2> end
irb(main):008:1> end
=> nil
irb(main):009:0> Qt::Application.new([])
=> #<Qt::Application:0x00000000ba5c98 objectName="irb">
irb(main):010:0> label = Qt::Label.new
=> #<Qt::Label:0x00000000b94c40 objectName="", x=0, y=0, width=640, height=480>
irb(main):011:0> Qt::Label.ancestors
=> [Qt::Label, Qt::Frame, Qt::Widget, Qt::Object, Qt::PaintDevice, Object, Kernel, BasicObject]
irb(main):012:0> Qt::Label.ancestors.collect do |ancestor_class|
irb(main):013:1* label.is_a? ancestor_class
irb(main):014:1> end
=> [true, true, true, true, true, true, true, true]

It looks like well. So adding below code to override is_a? and kind_of? before execution.
unless Qt::Base.instance_methods(false).include?(:is_a?)
module Qt
class Base
def is_a?(mod)
super || self.class.ancestors.include?(mod)
end
alias :kind_of? :is_a?
end
end
end


Finally, run and move with grabbing top level widget successfully. See widget class code is here, and execution code is here.

Monday, August 17, 2009

drag move charm #1

When we want to move a window on the desktop, we grab the title bar of the window, move it with keeping on grabbing, and release it. Thus we can do it with title bar, but cannot otherwise.

In the graphics-dojo's example "drag move charm", we can move the window not only with grabbing title bar, but also with grabbing top level widget. I learn this example and start to write by QtRuby like below:
require 'Qt4'

class DragMoveData
attr_accessor :moving, :start_drag
alias :moving? :moving
end

class DragMoveCharm < Qt::Object

def initialize parent = nil
super
@drag_move_data = {}
end

def activate_on widget
unless @drag_move_data.include?(widget)
data = DragMoveData.new
data.start_drag = Qt::Point.new(0, 0)
data.moving = false
@drag_move_data[widget] = data
widget.install_event_filter(self)
end
end

def deactivate_from widget
@drag_move_data.delete(widget)
widget.remove_event_filter(self)
end

protected
def event_filter(widget, event)
consumed = widget.is_a?(Qt::Widget)
if consumed
type = event.type
case(type)
when Qt::Event::MouseButtonPress,
Qt::Event::MouseButtonRelease,
Qt::Event::MouseMove
consumed = event.kind_of?(Qt::MouseEvent) &&
event.modifiers == Qt::NoModifier &&
@drag_move_data.include?(widget)
if consumed
data = @drag_move_data[widget]
case(type)
when Qt::Event::MouseButtonPress
consumed = event.button == Qt::LeftButton
if consumed
data.start_drag = event.global_pos
data.moving = true
end
when Qt::Event::MouseButtonRelease
data.start_drag = Qt::Point.new(0, 0)
data.moving = false
consumed = false
when Qt::Event::MouseMove
consumed = data.moving?
if consumed
pos = event.global_pos
widget.move(widget.pos + pos - data.start_drag)
data.start_drag = pos;
end
end
end
else
consumed = false
end
end
consumed
end

alias :eventFilter :event_filter
end

and main codes to execute above classes:
require 'dragmovecharm'
require 'qtwebkit'

def image_show
Qt::Label.new do
self.text = "<img src='#{::File.dirname($PROGRAM_NAME)}/pudding.jpg'>"
self.adjust_size
self.window_title = 'Drag to move around'
show
end
end

def mini_browser
Qt::Dialog.new do
self.layout = Qt::VBoxLayout.new do
self.set_contents_margins(3, 15, 3, 3)
end
self.window_flags = Qt::FramelessWindowHint
self.size_grip_enabled = true
self.window_title = 'Drag to move around'
show

tab = Qt::TabWidget.new(self) do
search = Qt::WebView.new(self)
search.load(Qt::Url.new('http://www.google.com/m?hl=en'))
search.set_focus
self.add_tab(search, 'Search')
news = Qt::WebView.new(self)
news.load(Qt::Url.new('http://www.google.com/m/news?source=mobileproducts'))
self.add_tab(news, 'News')
bbc = Qt::WebView.new(self)
bbc.load(Qt::Url.new('http://news.bbc.co.uk/text_only.stm'))
self.add_tab(bbc, 'BBC')
fb = Qt::WebView.new(self)
fb.load(Qt::Url.new('http://iphone.facebook.com'))
self.add_tab(fb, 'Facebook')
end

self.layout.add_widget(tab)
self.resize(350, 500)
(tab.document_mode = true) if Qt::version >= '4.5'
end
end

Qt::Application.new(ARGV) do
charm = DragMoveCharm.new
charm.activate_on(image_show)
charm.activate_on(mini_browser)
exec
end

Run these codes, 2 charms(widgets) is shown successfully.

But, these can only be moved with grabbing title bar. These yet cannot be moved with grabbing top level widget. to be continued...

Friday, August 14, 2009

Qt Development Frameworks

3 days ago, Nokia announced they had changed Qt project name like below:
BeforeAfter
Qt Software->Qt Development Frameworks

Not only that, they are on changing project's web address. For example, top page goes like below:
BeforeAfter
http://www.qtsoftware.com/->http://qt.nokia.com/

And, documentation page goes:
BeforeAfter
http://doc.qtsoftware.com/->http://qt.nokia.com/doc/

So I had to fix documentation URI on my past entries. Now, I fixed all.

Tuesday, August 11, 2009

ruby-debug for Ruby 1.9

Ruby develop team had wanted a person who knows both Ruby 1.9 and ruby-debug very well to work ruby-debug on Ruby 1.9, as I wrote in phosphorescence: The 2nd day of RubyKaigi 2009 (Morning). Of course, Ruby 1.9 users too. When I read InfoQ's this article this morning, I knew that Ruby 1.9 ruby-debug project had launched. See below URL.

http://github.com/mark-moseley/ruby-debug/tree/master

Saturday, August 8, 2009

We (GUI Ruby user) still need CRuby

2 weeks ago, Charles Nutter(JRuby Core Developer) said JRuby's importance in his blog. I have 2 opinions (i.e. agree/disagree) for this entry.

Thursday, August 6, 2009

Ruby MinGW one-click installer (developing)

I found One-Click Ruby Installer for Windows MinGW edition a few days ago. This project is still developing now.

Qt SDK for Windows is built with MinGW. So I think it's advantageous building QtRuby on Windows using MinGW.

Monday, August 3, 2009

DigiFlip

I add some sample programs to my graphics-dojo clone repository. 'DigiFlip' sample(the one of added programs this time) is not simple-rewritable one from Qt to QtRuby. There are some points hard to implement. I will now list these.

point 1: Qt::Painter#setBrush
point 2: Qt::Pixmap#fill
  • It's similar with above point. A type of Qt::transparent is Qt::GlobalColor, but argument type of Qt::Pixmap#fill is Qt::Color. So Qt::GlobalColor object have to be wrapped with Qt::Color class.

point 3: Enum
  • This sample program manages 3 switching mode with enums: Slide, Flip, and Rotate. These are constants and declared as Qt::Enum instance. See also phosphorescence: Qt::Enum.

point 4: Qt::Painter#begin
  • If point 1~3 solved, some warning still occur.
    QPaintEngine::setSystemRect: Should not be changed while engine is active
    This message tells "Forgetting the method call Qt::Painter#begin". So I add this call with checking whether Qt::Painter is active.
        p = Qt::Painter.new(self)
        p.begin(@pixmap) unless p.active?

After implement correctly, let's run it.

'DigiFlip' is here, and others are found from repository top.

Friday, July 31, 2009

Qt::Enum

Most of QtRuby classes have basic classes of Qt. But Qt::Enum is QtRuby original class. Its behavior is almost same with Qt::Integer. And we can use it like as C++ enum.
require 'Qt4'

class Suits < Qt::Object
Heart = Qt::Enum.new(0, self)
Clover = Qt::Enum.new(1, self)
Diamond = Qt::Enum.new(2, self)
Spade = Qt::Enum.new(3, self)
end

Tuesday, July 28, 2009

What does "compatible for Ruby 1.9.1" mean ?

In phosphorescence: The 2nd day of RubyKaigi 2009 (Morning), I mentioned about "Ruby 1.9.x is compatible for Ruby 1.9.1" and announced to describe it after. So I describe about it.

It's simple, but outlandish rule. For example in 1.8.x(1.8.7),
> ruby -e 'puts RUBY_VERSION, $:'
1.8.7
/usr/lib64/ruby/site_ruby/1.8
/usr/lib64/ruby/site_ruby/1.8/x86_64-linux
/usr/lib64/ruby/site_ruby
/usr/lib64/ruby/vendor_ruby/1.8
/usr/lib64/ruby/vendor_ruby/1.8/x86_64-linux
/usr/lib64/ruby/vendor_ruby
/usr/lib64/ruby/1.8
/usr/lib64/ruby/1.8/x86_64-linux
.

But for example in 1.9.x(1.9.2),
> /opt/ruby-1.9.1/bin/ruby -e 'puts RUBY_VERSION, $:'
1.9.2
/opt/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/rake-0.8.7/bin
/opt/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/rake-0.8.7/lib
/opt/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/rdoc-2.4.3/bin
/opt/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/rdoc-2.4.3/lib
/opt/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/bin
/opt/ruby-1.9.1/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.5/lib
/opt/ruby-1.9.1/lib/ruby/site_ruby/1.9.1
/opt/ruby-1.9.1/lib/ruby/site_ruby/1.9.1/x86_64-linux
/opt/ruby-1.9.1/lib/ruby/site_ruby
/opt/ruby-1.9.1/lib/ruby/vendor_ruby/1.9.1
/opt/ruby-1.9.1/lib/ruby/vendor_ruby/1.9.1/x86_64-linux
/opt/ruby-1.9.1/lib/ruby/vendor_ruby
/opt/ruby-1.9.1/lib/ruby/1.9.1
/opt/ruby-1.9.1/lib/ruby/1.9.1/x86_64-linux

We need imprinting "such a thing" to ourselves. But more confusion from late majorities will occur perhaps when first stable 1.9.2 will be released.

Saturday, July 25, 2009

Ruby 1.9.2 preview 1 was released

During RubyKaigi 2009, ruby 1.9.2 preview 1 was also released. So I download and install its package like this entry. Let's check.
>/opt/ruby-1.9.1/bin/ruby --version
ruby 1.9.2dev (2009-07-18 trunk 24186) [x86_64-linux]

Then I re-build Qtruby, but make fails with below messages:
Scanning dependencies of target qtruby4shared
[ 56%] Building CXX object ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/Qt.o
[ 57%] Building CXX object ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/handlers.o
[ 59%] Building CXX object ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/marshall_types.o
/home/youhei/downloads/qt4-qtruby-2.0.3/ruby/qtruby/src/marshall_types.cpp: In function ‘void show_exception_message()’:
/home/youhei/downloads/qt4-qtruby-2.0.3/ruby/qtruby/src/marshall_types.cpp:77: error: ‘STR2CSTR’ was not declared in this scope
make[2]: *** [ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/marshall_types.o] エラー 1
make[1]: *** [ruby/qtruby/src/CMakeFiles/qtruby4shared.dir/all] エラー 2
make: *** [all] エラー 2

Well, it's often matter of preview release. See the ChangeLog of ruby trunk...
Sat Jan 31 22:29:05 2009 Tanaka Akira <akr ! fsij ! org>

* include/ruby/ruby.h (STR2CSTR): removed.
(rb_str2cstr): removed.

* object.c (rb_str2cstr): removed.

So I fix to use new ruby.h API(refer also some commit comments of the ChangeLog of ruby trunk), send a patch. Currently, it's committed into QtRuby's trunk.

After the revision number 1001987, Building QtRuby with Ruby 1.9.2 succeeds.

update summaries of RubyKaigi

I update summaries that I attend of RubyKaigi.

phosphorescence: The 1st day of RubyKaigi 2009
phosphorescence: The 2nd day of RubyKaigi 2009 (Morning)
phosphorescence: The 2nd day of RubyKaigi 2009 (Afternoon)
phosphorescence: The 3rd day of RubyKaigi 2009 (Morning)
phosphorescence: The 3rd day of RubyKaigi 2009 (Afternoon)

And I say again thanks to all staffs, speakers and attendees.

Wednesday, July 22, 2009

Ruby 1.9.1 p243 was released

During RubyKaigi 2009, ruby 1.9.1 p243 was released. So I download and re-install its package like this entry. Let's check.
>/opt/ruby-1.9.1/bin/ruby --version
ruby 1.9.1p243 (2009-07-16 revision 24175) [x86_64-linux]

Then I re-build Qtruby like this entry.

Sunday, July 19, 2009

The 3rd day of RubyKaigi 2009 (Afternoon)


All sessions of RubyKaigi 2009 is over.
Above photo is a novelty souvenir at this conference. This is a hand-held fan (in Japanese : 扇子).

In this afternoon, I attended these sessions:

The 3rd day of RubyKaigi 2009 (Morning)


Today is the 3rd day (a.k.a. last day) of RubyKaigi 2009. Order of today's session has been changed because of speaker's machine trouble. "Ruby - The Script Language" has become after "socket library improvement".

So I attended these sessions:

Saturday, July 18, 2009

The 2nd day of RubyKaigi 2009 (Afternoon)

In this afternoon, I attended these sessions:

The 2nd day of RubyKaigi 2009 (Morning)


Today is the 2nd day of RubyKaigi 2009.

I attended these sessions:

Friday, July 17, 2009

The 1st day of RubyKaigi 2009

Today is the 1st day of RubyKaigi 2009(only afternoon).
It held at here.



I attended these sessions:

Thursday, July 9, 2009

Summer vacation

I take a summer vacation, so I suspend posts and comments to this blog for a moment. Resume will be July 17, 2009: The 1st day of RubyKaigi 2009.

Tuesday, July 7, 2009

Transparent QtWebView #2

(continued from phosphorescence: Transparent QtWebView #1)
This entry had rewritten in 2009/08/03

The biggest reason of this failure is the impedance between Qt that allows overload to Ruby that doesn't allow overload. But in this case, it's 2nd biggest reason: type of Qt class mismatches. A type of Qt::transparent is Qt::GlobalColor, but 2nd argument type of Qt::Palette#setBrush is Qt::Brush. So Qt::GlobalColor object have to be wrapped with Qt::Brush class.

In addition, Qt::Painter#setBrush method is also too. To see the document of QBrush, constructor can take QGradient(superclass of Qt::LinearGradient corrsponding class) and Qt::GlobalColor.

Then I rewrite the previous code like below:
require 'Qt4'
require 'qtwebkit'

class Container < Qt::Widget
  def initialize parent = nil
    super

    @view = Qt::WebView.new self
    pal = @view.palette
    pal.set_brush(Qt::Palette::Base, Qt::Brush.new(Qt::transparent))
    @view.page.palette = pal
    @view.set_attribute(Qt::WA_OpaquePaintEvent, false)
    @view.load Qt::Url.new('http://en.mobile.wikipedia.org/')
    @view.zoom_factor = 0.8

    Qt::Object.connect(@view, SIGNAL( 'titleChanged(const QString&)' ),
      self, SLOT( 'setWindowTitle(const QString&)' ))

    @layout = Qt::VBoxLayout.new self
    @layout.add_widget @view

    linear_gradient = Qt::LinearGradient.new
    linear_gradient.set_color_at(0.0, Qt::Color.new(249, 247, 96))
    linear_gradient.set_color_at(1.0, Qt::Color.new(235, 203, 32))
    linear_gradient.coordinate_mode = Qt::Gradient::ObjectBoundingMode
    @gradient = Qt::Brush.new(linear_gradient)

    self.resize 320, 480
  end

  protected
  def paint_event event
    @painter = Qt::Painter.new self
    @painter.fill_rect(event.rect, Qt::transparent)
    @painter.pen = Qt::NoPen
    @painter.brush = @gradient
    @painter.opacity = 0.6
    @painter.draw_rounded_rect(self.rect, 10, 10)
    @painter.end
  end

  alias :paintEvent :paint_event
end

Qt::Application.new(ARGV) do
  Container.new do
    self.set_attribute(Qt::WA_TranslucentBackground, true)
    self.window_flags = Qt::FramelessWindowHint
    show
  end
  exec
end


And run it.

Run successfully. I push this code to my gitorious clone repository, see here.

Saturday, July 4, 2009

Transparent QtWebView #1

When I read Qt Labs Blogs, I found interesting post titled Transparent QWebView (or QWebPage). As reading this, it's easy that adding a few lines makes background of Webkit transparent, and it can make also by Python (via PyQt).

Then I learn example source codes from Qt's gitorius repository and start to try it by QtRuby. I write sample codes in rubyish like below:

require 'Qt4'
require 'qtwebkit'

class Container < Qt::Widget

  def initialize parent = nil
    super

    @view = Qt::WebView.new self
    transparent_palette = palette
    transparent_palette.setBrush(Qt::Palette::Base, Qt::transparent)
    @view.page.palette = transparent_palette
    @view.set_attribute(Qt::WA_OpaquePaintEvent, false)
    @view.load Qt::Url.new('http://en.mobile.wikipedia.org/')
    @view.zoom_factor = 0.8

    Qt::Object.connect(@view, SIGNAL( 'titleChanged(const QString&)' ),
      self, SLOT( 'setWindowTitle(const QString&)' ))

    @layout = Qt::VBoxLayout.new self
    @layout.add_widget @view

    @gradient = Qt::LinearGradient.new
    @gradient.set_color_at(0.0, Qt::Color.new(249, 247, 96))
    @gradient.set_color_at(1.0, Qt::Color.new(235, 203, 32))
    @gradient.set_coordinate_mode(Qt::Gradient::ObjectBoundingMode)

    self.resize 320, 480
  end

  protected
  def paint_event event
    @painter = Qt::Painter.new self
    @painter.fill_rect(event.rect, Qt::transparent)
    @painter.pen = Qt::NoPen
    @painter.brush = @gradient
    @painter.opacity = 0.6
    @painter.draw_rounded_rect(self.rect, 10, 10)
    @painter.end
  end

  alias :paintEvent :paint_event
end

Qt::Application.new(ARGV) do
  Container.new do
    self.set_attribute(Qt::WA_TranslucentBackground, true)
    self.window_flags = Qt::FramelessWindowHint
    show
  end
  exec
end

Let's run it!
> /opt/ruby-1.9.1/bin/ruby transparentweb.rb
transparentweb.rb:10:in `method_missing': undefined method `setBrush' for #<Qt::Palette:0x00000000bd3738> (NoMethodError)
from transparentweb.rb:10:in `initialize'
from transparentweb.rb:45:in `new'
from transparentweb.rb:45:in `block in <main>'
from /opt/ruby-1.9.1/lib/ruby/site_ruby/1.9.1/Qt/qtruby4.rb:2568:in `instance_eval'
from /opt/ruby-1.9.1/lib/ruby/site_ruby/1.9.1/Qt/qtruby4.rb:2568:in `run_initializer_block'
from /opt/ruby-1.9.1/lib/ruby/site_ruby/1.9.1/Qt/qtruby4.rb:431:in `initialize'
from /opt/ruby-1.9.1/lib/ruby/site_ruby/1.9.1/Qt/qtruby4.rb:431:in `initialize'
from transparentweb.rb:44:in `new'
from transparentweb.rb:44:in `<main>'

Oops, undefined method! Really?
> /opt/ruby-1.9.1/bin/rbqtapi -s Qt::Palette | grep setBrush
Qt::Palette#setBrush(Qt::Palette::ColorRole, Qt::Brush)
Qt::Palette#setBrush(Qt::Palette::ColorGroup, Qt::Palette::ColorRole, Qt::Brush)

Qt::Palette#setBrush exists. Umm... to be continued...

Thursday, July 2, 2009

QtWebkit over the proxy

I wrote some posts about QtWebkit. But these may fail if your program runs behind the proxy. Then I rewrite programs in phosphorescence: QtWebkit HTML5 practice like below. Additional codes are blue characters.

Qt program
#include <QApplication>
#include <QUrl>
#include <QWebView>
#include <QNetworkProxy>

int main(int argc, char *argv[]){
QApplication a(argc, argv);
QNetworkProxy proxy(QNetworkProxy::HttpProxy, "proxy.host", proxy.port);
QNetworkProxy::setApplicationProxy(proxy);

QUrl url("http://htmlfive.appspot.com/static/draw.html");
QWebView* webView = new QWebView();
webView->load(url);
webView->show();
return a.exec();
}

QtRuby program
require 'Qt4'
require 'qtwebkit'

Qt::Application.new(ARGV) do
proxy = Qt::NetworkProxy.new(Qt::NetworkProxy::HttpProxy, "proxy.host", proxy.port)
Qt::NetworkProxy.application_proxy = proxy

Qt::WebView.new do
self.load Qt::Url.new('http://htmlfive.appspot.com/static/gifter.html')
show
end
exec
end


proxy.host and proxy.port should replace ones of your proxy environment.

Monday, June 29, 2009

Qt 4.5.2 and Qt Creator 1.2 were released

In last Thursday, Qt 4.5.2 and Qt Creator 1.2 were released. I download and install Qt 4.5.2 SDK (LGPL) from here. It contains Qt 4.5.2 and Qt Creator 1.2 both.
#./qt-sdk-linux-x86_64-opensource-2009.03.bin
Release of Qt Creator 1.2 includes many UI changes like
  • Characters in menus and windows are well-translated.
  • Welcome screen indicates each Qt SDK samples.
  • and more...
Installation instructions of QtRuby are below:
>cmake \
> -DCMAKE_INSTALL_PREFIX=/opt/ruby-1.9.1 \
> -DRUBY_EXECUTABLE=/opt/ruby-1.9.1/bin/ruby \
> -DRUBY_LIBRARY=/opt/ruby-1.9.1/lib/libruby.so.1.9.1 \
> -DRUBY_INCLUDE_PATH=/opt/ruby-1.9.1/include/ruby-1.9.1 \
> -DQT_QMAKE_EXECUTABLE=/opt/qtsdk-2009.03/qt/bin/qmake \
> -DQT_MKSPECS_DIR=/opt/qtsdk-2009.03/qt/mkspecs \
> -Wno-dev \
> -DENABLE_SMOKE=on \
> -DENABLE_QTRUBY=on \
> -DENABLE_QTWEBKIT_SMOKE=on \
> -DENABLE_QTSCRIPT_SMOKE=on \
> -DENABLE_QTUITOOLS_SMOKE=on \
> -DENABLE_QTTEST_SMOKE=off \
> -DENABLE_PHONON_SMOKE=off \
> -DENABLE_QSCI_SMOKE=off \
> -DENABLE_QWT_SMOKE=off \
> -DENABLE_KDE_SMOKE=off \
> -DENABLE_KDEVPLATFORM_SMOKE=off \
> -DENABLE_KHTML_SMOKE=off \
> -DENABLE_KTEXTEDITOR_SMOKE=off \
> -DENABLE_SOLID_SMOKE=off \
> -DENABLE_PLASMA_SMOKE=off \
> -DENABLE_QTWEBKIT_RUBY=on \
> -DENABLE_QTUITOOLS_RUBY=on \
> -DENABLE_QTSCRIPT=on \
> -DENABLE_QTTEST=off \
> -DENABLE_PHONON_RUBY=off \
> -DENABLE_QSCINTILLA_RUBY=off \
> -DENABLE_QWT_RUBY=off \
> -DENABLE_SOPRANO_RUBY=off \
> -DENABLE_KDEVPLATFORM_RUBY=off \
> -DENABLE_KORUNDUM_RUBY=off \
> -DENABLE_KHTML_RUBY=off \
> -DENABLE_KTEXTEDITOR_RUBY=off \
> -DENABLE_SOLID_RUBY=off \
> -DENABLE_KROSSRUBY=off \
> -DENABLE_PLASMA_RUBY=off \
> -DENABLE_QIMAGEBLITZ_SMOKE=off
Then check QtRuby commands.
>/opt/ruby-1.9.1/bin/rbrcc -version
Ruby Resource Compiler for Qt version 4.5.2
>/opt/ruby-1.9.1/bin/rbuic4 -v
Qt User Interface Compiler version 4.5.2
>/opt/ruby-1.9.1/bin/rbqtapi -v
QtRuby 2.0.3 using Qt-4.5.2

Friday, June 26, 2009

Timetables of RubyKaigi2009 are revealed

2 days ago, timetables of RubyKaigi2009 are revealed.
In my opinion, it's unsatisfactory that ko1(Ruby 1.9 VM)'s session and Yehuda Katz(Merb/Rails3)'s one overlap.

Wednesday, June 24, 2009

QtWebkit HTML5 practice

At phosphorescence: QtWebKit practice and phosphorescence: QtWebkit practice with QtRuby, I wrote QtWebKit sample program with Qt and QtRuby. And I also mentioned QtWebkit suports HTML5 in the phosphorescence: HTML5 support in QtWebkit. Then, can HTML5 be rendered with QtWebKit?

First, access to the HTML5 demo: Canvas | Drawing Board by Qt program.
#include <QApplication>
#include <QUrl>
#include <QWebView>
int main(int argc, char *argv[]){
QApplication a(argc, argv);
QUrl url("http://htmlfive.appspot.com/static/draw.html");
QWebView* webView = new QWebView();
webView->load(url);
webView->show();
return a.exec();
}

This runs successfully:
and can draw lines in canvas by mouse successfully, too.

Second, access to the HTML5 demo: Canvas | 1st-Person Gifter by QtRuby program.
require 'Qt4'
require 'qtwebkit'

Qt::Application.new(ARGV) do
  Qt::WebView.new do
    self.load Qt::Url.new('http://htmlfive.appspot.com/static/gifter.html')
    show
  end
  exec
end

Of course. this runs successfully too and move in maze with arrow keys:

Note that canvas tag is rendered easily, but that video tag depends on environment like video format and codec in client. At least, in my environment (on openSUSE 11.1), video tag isn't rendered not only with QtWebkit but also with HTML5 support browsers(Firefox, Opera, Konqueror).

Monday, June 22, 2009

FizzBuzz with Object#tap

From Ruby 1.9.1, Object#tap is added. What's this? Let's train by FizzBuzz.

fizz_buzz = ->(i) do
case 0
when i % 15
puts 'FizzBuzz'
when i % 5
puts 'Buzz'
when i % 3
puts 'Fizz'
else
puts i
end
end
(1..40).collect do |i|
i.tap(&fizz_buzz)
end

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz
16
17
Fizz
19
Buzz
Fizz
22
23
Fizz
Buzz
26
Fizz
28
29
FizzBuzz
31
32
Fizz
34
Buzz
Fizz
37
38
Fizz
Buzz
=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40]

Object#tap evaluates block with self as block-argument, and then return self.

Friday, June 19, 2009

HTML5 support in QtWebkit

A few weeks ago, each developer conference was held by Google and Apple. In each conference, most impressive topic is about HTML5. Google announces Google Wave and recommends Google Chrome 2. And Apple annoucnes Safari 4. All technologies are related with HTML5.

On the other, how Qt supports HTML5? The answer is... already! Several features of Webkit(As you know, it's original program of Google Chrome and Safari) were supported in Qt 4.4, Qt improves its support level in Qt 4.5. See the movie from here:



Of course, API is opened.

Tuesday, June 16, 2009

openSUSE mascot on demand

Let's build openSUSE's mascot as you like!

Geeko Builder is rich web application that can create "Geeko"(mascot of openSUSE) with clicking only. I has built my own Geeko, like this:

We can download wallpaper(above) and avator(beside) from this site. And more, can permalink to each Geeko(like this) and vote. Please join and vote.

Saturday, June 13, 2009

I keep on studying about Qt

As I said in phosphorescence: Qt newbie seminar in Tokyo, I'm nwebie about Qt, and now studying with book: "C++ GUI Programming with Qt 4", but it's 1st edition.
Why 1st editon, not 2nd edition?
Because I'm reading it with Japanese translation edition that is translated until 1st edition, not 2nd edition.

By the way, the cover of Japanese translation edition is different from original one. See the cover!
As you can see, it's O'Reilly-ish. There is no wonder about it, Japanese translation edition is published from O'Reilly Japan (written in Japanese).

Wednesday, June 10, 2009

QtWebkit practice with QtRuby

I wrote QtWebKit sample program with Qt in phosphorescence: QtWebKit practice. Next, let's write corresponding program with QtRuby.
require 'Qt4'
require 'qtwebkit'

Qt::Application.new(ARGV) do
Qt::WebView.new do
self.load Qt::Url.new('http://www.wolframalpha.com/')
show
end
exec
end

Then run, succeed.

Monday, June 8, 2009

openSUSE benkyoukai 2009/06

2 days ago, in Tokyo, openSUSE benkyoukai was held (What's benkyoukai? see the first part of past entry).

At this time, I attend in the venue. There were 2 sessions:
  1. Tips at exchanging HDD with dual boot win and linux
  2. Tips for Gimp
I learn many tips from each speakers, and attendees(of course, me too) advice additional techniques to each speakers.

On this place after all sessions, one attendee who volunteers translations called, so less people translate informations (weekly news, wiki, and so on) from English to Japanese that we need more voluntaries. His call aroused me to transrate some information. So I went back to home soon, translated Bluetooth page of openSUSE wiki until now from English to Japanese.

Friday, June 5, 2009

QtWebKit practice

Qt includes web-rendering engine: QtWebKit. By using QWebView class, we can build simple web-rendering widget.
#include <QApplication>
#include <QUrl>
#include <QWebView>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QUrl url("http://www.wolframalpha.com/");
QWebView* webView = new QWebView();
webView->load(url);
webView->show();
return a.exec();
}

When this program runs, widget with rendering area rises.


It's just only rendering area. i.e.
  • objects on the rendering area can work alone.
    (e.g. input to text box, submit a button, page transition, and so on.)
  • operations out of the rendering area can't work alone.
    (e.g. access over the proxy, bookmark, and so on.)

Tuesday, June 2, 2009

More refactoring "Refactoring QtRuby Example #1"

In previous post : phosphorescence: Refactoring "Refactoring QtRuby Example #1", I had wrote below :
require 'Qt4'
require 'default/ui'

class Default < Qt::MainWindow
attr_reader :ui

def initialize(parent=nil)
super(parent)
@ui = UI::DefaultClass.new
@ui.setup_ui(self)
yield(self) if block_given?
ObjectSpace.define_finalizer(self, Default.delete_ui(@ui))
end

private
def Default.delete_ui(ui_to_delete)
proc {ui_to_delete.dispose unless ui_to_delete.disposed?}
end
end

But, it's still redundant yet. Ruby's super has following specifications.
  1. if the argument of super are omitted, all the arguments of original method are passed.
  2. super doesn't have to be top of the code block.

Then I refactor code block to below :
require 'Qt4'
require 'default/ui'

class Default < Qt::MainWindow
attr_reader :ui

def initialize(parent=nil)
@ui = UI::DefaultClass.new
super
@ui.setup_ui(self)
ObjectSpace.define_finalizer(self, Default.delete_ui(@ui))
end

private
def Default.delete_ui(ui_to_delete)
proc {ui_to_delete.dispose unless ui_to_delete.disposed?}
end
end

Original post phosphorescence: Refactoring QtRuby Example #1 has been corrected already. Then let's check working correctly.
irb(main):001:0> require 'Qt4'
=> true
irb(main):002:0> require 'default/default'
=> true
irb(main):003:0> Qt::Application.new(ARGV) do
irb(main):004:1* window = Default.new do|w|
irb(main):005:2* puts w.class
irb(main):006:2> puts w.ui.class
irb(main):007:2> end
irb(main):008:1> end
Default
UI::DefaultClass
=> #<Qt::Application:0x00000000c0acb0 objectName="irb">

Saturday, May 30, 2009

Speakers of RubyKaigi2009 are revealed

In RubyKaigi2009 Japanese site, all speakers are revealed. In English site, only keynote speakers are revealed, but session speakers are not yet at the moment.

Schedules are not revealed both in Japanese and in English site.

Wednesday, May 27, 2009

Qt Puzzle (answer part)

(continued from phosphorescence: Qt Puzzle (question part))

Difference between pattern 1 and pattern 2 is #include declaration. Entire QtGui module is included in pattern 1, and necessary Qt classes are included in pattern 2 one by one.

What happens by this difference? A compile error like below occurs.


log10 method is not found. log10 method is declared on <cmath>, and probably, some class in QtGui module includes it. But, it isn't QApplication class or QLabel class. So pattern 2 need to include <cmath> explicitly like below.
#include <QApplication>
#include <QLabel>
#include <cmath>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ QString::number(source_number)
+ ") = "
+ QString::number(log10(source_number));
QLabel *label = new QLabel(message);
label->show();
return a.exec();
}

Then, compile and run successfully. This dialog appears.

Monday, May 25, 2009

Qt Puzzle (question part)

There are 2 simple Qt programs.

pattern 1
#include <QtGui>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ QString::number(source_number)
+ ") = "
+ QString::number(log10(source_number));
QLabel *label = new QLabel(message);
label->show();
return a.exec();
}

pattern 2
#include <QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
int source_number = 100;
QString message = "log10("
+ QString::number(source_number)
+ ") = "
+ QString::number(log10(source_number));
QLabel *label = new QLabel(message);
label->show();
return a.exec();
}

2 programs are the same mostly, and these seem to run correctly. But, only pattern 1 runs correctly, and pattern 2 doesn't. Why? and How? to be continued...

Friday, May 22, 2009

rbrcc

Command rbrcc is a generator from Qt resource collection file(.qrc) to ruby class. Demos and examples of Qt 4.5.1 SDK have some resource collection files. Let's try to generate ruby classes from these resource collection files with below ruby codes:
qt_dir = '/opt/qtsdk-2009.02/qt'
target_dir = '/path/to/target_dir'
`find #{qt_dir}/demos #{qt_dir}/examples -name '*.qrc'`.split.each do |resouce_file|
  basename = File.basename resouce_file, '.qrc'
  `/opt/ruby-1.9.1/bin/rbrcc #{resouce_file} -o #{target_dir}/#{basename}.rb`
end

Ruby classes are generated, and these contain hex of binaries listed in resource collection files.

Tuesday, May 19, 2009

Where has Qt::Thread gone?

QThread class is a thread implementation of Qt. I tried to refer an appropriate API of QtRuby: i.e. Qt::Thread. Let's type rbqtapi command.
>/opt/ruby-1.9.1/bin/rbqtapi Qt::Thread
ERROR: class 'Qt::Thread' not found

Oh, what's wrong? Paths are correct and there's no typo. I searched about this matter on the web, then found some information on ruby-talk-google.

quote:
There's no Qt::Thread because Ruby lacks support for native threads
(at least, for the moment), so it's not really feasible to implement.

Okay, I see. Certainly, Qt's thread is native thread, and Ruby 1.8's thread had been a green thread. So it's no worse that QtRuby wasn't support QThread(Qt::Thread).

But now, Ruby 1.9's thread has become native thread. So this is improvement point for QtRuby.