From mblondel at rubyforge.org Tue Jul 19 22:27:13 2005 From: mblondel at rubyforge.org (Mathieu Blondel) Date: Tue Jul 19 22:34:32 2005 Subject: [Nihongobenkyo-list] Nihongo Benkyo under Windows (c) : that works too ! Message-ID: <20050720022825.22691.qmail@bahamut.ffworld.com> Hello everyone. Today I had the opportunity to access to a laptop running Windows XP so I tried to make Nihongo Benkyo 0.1 work on it ;) It appeared not to be a big deal although there were a few problems. Therefore I seriously consider to "officially" support Windows. However, I don't have Windows on my personal laptop so I'm looking for people to test if the modifications I make under Linux also work with Windows. To those who may be interested, here are the steps I followed (about 15 min needed) : 1) follow the four steps here : http://ruby-gnome2.sourceforge.jp/hiki.cgi?Install+Guide+for+Windows . You should be able to view a little windows if it worked. (Ruby was installed in c:ruby in my case) 2) install http://rubyforge.org/frs/download.php/3086/sqlite3-ruby-1.1.0-msvcrt-bin.zip . Just double clicking on the install.rb file worked like a charm for me. 3) it's time to install Nihongo Benkyo 0.1 itself - Dowload it at http://rubyforge.org/frs/download.php/4955/nihongobenkyo-0.1.tar.gz - Unzip the package Now we need to fix the problems with the code in Window : - Replace pre-setup.rb with the pre-setup.rb attached to this email - Replace lib/nihongobenkyo/preference.rb by the preference.rb attached to this email - Replace lib/nihongobenkyo/ui/main_app.rb with main_app.rb attached to this email Now we will proceed to the install in a DOS prompt, - Go to the package directory - Run : ruby install.rb config - Run : ruby install.rb setup - Run : ruby install.rb install - A file bin/nihongobenkyo is generated, place it in c:/ruby/bin/ 4) Download http://www.sqlite.org/sqlitedll-3_2_2.zip. Copy the dll file in c:/ruby/bin/ 5) Dowload a database at http://rubyforge.org/frs/download.php/4957/dic.tar.bz2 and put the dic.db file in c:/ruby/bin/ 6) To run Nihongo Benkyo, go to c:/ruby/bin/ and type in a prompt : ruby nihongobenkyo Concerning the selection, in windows it is required to copy the word selected by yourself. To sum up the issues to be solved more cleanly : - Gconf2 is not support in Windows (write our own config script, e.g. in a xml file ?) - In Unix, Gdk::Selection::PRIMARY but in Windows Gdk::Selection::CLIPBOARD - The pre-setup is slightly different in Windows Mathieu Blondel -------------- next part -------------- # Nihongo Benkyo # Copyright (C) 2005 Mathieu Blondel # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #require 'gconf2' require 'singleton' module NihongoBenkyo DB_DIR = File.join(".") DB_PATH = File.join(DB_DIR,"dic.db") class Preferences include Singleton APP_DIR = '/apps/nihongobenkyo/' def initialize #@client = GConf::Client.default unless(FileTest.exists?(DB_DIR)) Dir.mkdir(DB_DIR) end unless(FileTest.exists?(DB_PATH)) File.new(DB_PATH, File::CREAT).close end end def method_missing(id, *args) #~ method = id.id2name #~ if match = /(.*)=$/.match(method) #~ if args.length != 1 #~ raise "Set method #{method} should be called with " + #~ "only one argument (was called with #{args.length})" #~ end #~ @client[APP_DIR + match[1]] = args.first #~ else #~ unless args.empty? #~ raise "Get method #{method} should be called " + #~ "without argument (was called with #{args.length})" #~ end #~ @client[APP_DIR + method] #~ end false end end end -------------- next part -------------- # Copyright (C) 2004-2005 Dafydd Harries, Mathieu Blondel # # Loosely based on pre-setup.rb from rbbr by Masao Mutoh. basename = "nihongobenkyo" config = Config::CONFIG podir = srcdir_root + "/po/" # Extract translations from PO files into other files. system("intltool-merge -d po nihongobenkyo.desktop.in nihongobenkyo.desktop") # Create MO files. Dir.glob("po/*.po") do |file| lang = /po\/(.*)\.po/.match(file).to_a[1] mo_path_bits = ['data', 'locale', lang, 'LC_MESSAGES'] mo_path = File.join(mo_path_bits) (0 ... mo_path_bits.length).each do |i| path = File.join(mo_path_bits[0 .. i]) puts path Dir.mkdir(path) unless FileTest.exists?(path) end system("ruby c:/ruby/bin/rmsgfmt po/#{lang}.po -o #{mo_path}/#{basename}.mo") raise "rmsgfmt failed on po/#{lang}.po" if $? != 0 end -------------- next part -------------- A non-text attachment was scrubbed... Name: screen-winxp.JPG Type: image/jpeg Size: 41830 bytes Desc: not available Url : http://rubyforge.org/pipermail/nihongobenkyo-list/attachments/20050720/bab7290f/screen-winxp-0001.jpg -------------- next part -------------- # Nihongo Benkyo # Copyright (C) 2005 Mathieu Blondel # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA module NihongoBenkyo module UI class MainApp < GladeBase include GetText GetText.bindtextdomain(NihongoBenkyo::TEXTDOMAIN, nil, nil, "UTF-8") def initialize super("main_app.glade") @prefs = Preferences.instance @db = Database.instance initialize_signals load_preferences scan_selection end def on_search word = @search_combobox_entry.child.text word.strip! @search_combobox_entry << word @result_textview.buffer.text = "" n = 0 @db.search(word) do |entry_id, kana, kanji| @result_textview.buffer.text += "#{kanji} [#{kana}] " @db.search_translations(entry_id) do |translation| @result_textview.buffer.text += translation + " / " end @result_textview.buffer.text += "\n" n += 1 end @statusbar.push(0, _("Matches found: ") + n.to_s) end def on_quit save_preferences Gtk.main_quit end def on_settings PreferencesDialog.new(@main_app) end def on_about AboutDialog.new(@main_app).show end private def scan_selection @thread = Thread.new(@search_combobox_entry) do |combobox| last_selection = nil Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD).request_text do |clipboard, text| last_selection = text end while true Gtk::Clipboard.get(Gdk::Selection::CLIPBOARD).request_text do |clipboard, text| if text != last_selection unless text.nil? or not(@scan_selection.active?) combobox.child.text = last_selection = text on_search @main_app.present end end end sleep(0.8) end end end def initialize_signals @search_combobox_entry.child.signal_connect("grab_focus") do @search_combobox_entry.child.text = "" end @search_combobox_entry.child.signal_connect("activate") do on_search end @search_menu_item.signal_connect("select") do @search_combobox_entry.child.grab_focus end @view_statusbar.signal_connect("toggled") do @statusbar.visible = @view_statusbar.active? end end def load_preferences @view_statusbar.active = @prefs.view_statusbar @scan_selection.active = @prefs.scan_selection end def save_preferences @prefs.view_statusbar = @view_statusbar.active? @prefs.scan_selection = @scan_selection.active? end end end end