Posts Tagged ‘gnome’

Douban provider for Alexandria

04月 30, 2010

Alexandra is a desktop book collection manager on gnome written in ruby. With an extensible architecture, Alexandria uses different sources to retrieve book’s data, including Amazon and many local sites.

Douban.com is considered to be most applicable data source for books published in Chinese. So I write this provider according to Alexandria’s SPI. Now it’s possible to add Chinese books and manage reading lists.

alexandria

Now the code can be found in Alexandria’s bug tracker:
http://rubyforge.org/tracker/index.php?func=detail&aid=28160&group_id=205&atid=865

However, the patch file of book_providers.rb in that list is for svn trunk head version only. To use it with currently stable version of Ubuntu, first, make sure you have Alexandria version 0.6.5-0ubuntu1 and libjson-ruby1.8 installed.

Download douban.rb from rubyforge:
http://rubyforge.org/tracker/download.php/205/865/28160/4923/douban.rb
Copy the file to /usr/lib/ruby/1.8/alexandria/book_providers/ with super user privileges.
Use this patch to /usr/lib/ruby/1.8/alexandria/book_providers.rb
[cc lang="ruby"]
310a311,323
< begin
< begin
< require 'json'
< rescue LoadError
< require 'rubygems'
< require 'json'
< end
< require 'alexandria/book_providers/douban'
< rescue LoadError =< ex
< log.error{ex}
< log.warn {'Fail to load douban as provider'}
< end
<
[/cc]

Feel free to report issue here.

Virtual Machine Searcher for Gnome Deskbar Applet

02月 12, 2010

Very glad to announce another daily-coding work: an extension for gnome deskbar applet to search and launch virtual machine. There is a plugin for gnome-do that does the same job. That’s what I create the the plugin for. I switched to deskbar because gnome-do’s Do.exe reminds me nightmares when I was a M$ Windows user. The deskbar applet has been a great replacement, however, the virtualbox plugin in Do is really impressive while deskbar doesn’t provide me the same functionality.

You can ignore words above and just take a look at the screenshot:
deskbar-virtualbox

Download

Download the extension from (the highlighted one):
http://bitbucket.org/sunng/daily-coding/downloads/?highlight=5137

You can also trace the development at bitbucket project. However, the repository is mixed with other small code snippets. Currently, mercurial doesn’t support subdirectory pull. So there is no way to grab the deskbar-applet individually.

Installation

copy this file to /usr/lib/deskbar-applet/deskbar-applet/modules-2.20-compatible/ (Ubuntu installation for example) with super user privilege. Right click desktbar applet, select Preference, Searchers tab, hit “Reload” button, then check the Virtualbox Deskbar Module.
deskbar-preference

Issue

Feel free the report issues on bitbucket:
http://bitbucket.org/sunng/daily-coding/issues/

使用gnome-dictionary和dictd

02月 7, 2010

最近琢磨字典多一些,以前一直不知道gnome自带的gnome-dictionary如何使用,因为默认的字典源里都没有中文字典,而且离线更是无法使用。其实不然,字典服务可以自架,并且可以使用自己的字典。

在自己的机器上架设dictionary server,以ubuntu为例:

安装dictd / dict
sudo apt-get install dictd dict

前者是字典服务器,后者是字典服务客户端。还可以从仓库里安装已经打包好的字典,如
sudo apt-get install dict-stardic
是一个英汉字典

dictd安装好后会默认自启动,也可以通过
sudo service dictd start
来控制dictd的启动、重启和关闭。

通过dict测试服务的状况
dict -D
命令会列出可用的数据库(即字典)

在gnome-dictionary中添加字典源 Edit->Preference->Source->Add
Name: 自定义的字典名
Transport: Dictionary Source
Hostname: 127.0.0.1
Port: 2628

Close之后可以到主界面打开侧边栏,在Dictionary Source中双击选定此字典,在Aailable Dictionaries里双击选中目标字典,于是就可以在gnome-dictionary里使用本地的字典服务了。

接下来安装自己的字典。stardict的网站上有很多中文字典,上面也都标示了授权协议。要在dictd里使用这些字典,需要进行一个简单的格式转换。安装一个工具
sudo apt-get install dictconv

它的使用方法:
dictconv -o OUTPUT_FILE INPUT_FILE

在input_file指定stardict的.ifo文件,在output_file指定要生成的dictd的.index文件。这个转换非常耗时,需要有足够的耐心。这个操作将会生成.index和.dict文件。对.dict文件进行压缩:
dictzip OUT.dict

转换完成后,编辑/var/lib/dictd/db.list文件,在其中添加一个database定义
database YOUR_DB_NAME{
data PATH_TO_DICT_DZ
index PATH_TO_INDEX
}

其中PATH_TO_DICT_DZ是上一步的.dz文件,PATH_TO_INDEX是到上一步生成的.index文件的路径。编辑完成后,重启dictd服务
sudo service dictd restart

使用dict -D可以查看启用的字典。

建议备份/var/lib/dictd/db.list文件,因为每次从apt-get安装字典后,这个文件都会被覆盖。

dictd服务也可以在fantasdic里访问。

Patch for Fantasdic Google Source

02月 2, 2010

I found fantasdic a great powerful dictionary tool with friendly UI and supports multiply sources. Unfortunately, this project seems to be no longer maintained. The latest version is 1.0-beta7.
fantasdic-google

The google translate source was created in 2007. As the google translate service page changed, this module doesn’t work any more, so I just picked up my vim then created this patch for those still want to use it.

This patch has dependency with ruby’s json module, so before you apply it, run:
sudo gem install json
or
sudo apt-get install libjson-ruby1.8

Download the patch at:
https://bugzilla.gnome.org/attachment.cgi?id=152835

Patch it (Ubuntu installation as example):
cd /usr/lib/ruby/1.8/fantasdic/sources/
sudo patch google_translate.rb /home/sun/google_translate.rb.diff

Restart fantasdic, then your get it works! And this bug is tracked at:
https://bugzilla.gnome.org/show_bug.cgi?id=605641

翻译po

01月 31, 2010

翻译一个po文件。确认安装了gettext工具包。

cd到po目录,创建pot
intltool-update –pot

创建相应的语言文件,例如zh_CN
msginit -l zh_CN.utf8

程序会提示选择或输入邮箱,之后就会生成zh_CN.po文件,打开文件,逐条编辑msgstr即可。

手动编辑LINGUAS文件,按顺序将zh_CN添加到其中。

可以通过这个命令查看翻译的进度
msgfmt -cv zh_CN.po

对于更新pot更新的情况,可以使用命令更新po文件
intltool-update zh_CN

参考:

Emerillon: map viewer for gnome desktop

01月 30, 2010

自从libchamplain / geoclue等库发布之后,gnome桌面的地理信息工具和支持发展很迅速:例如之前提到过的eye-of-gnome的地理信息插件,根据EXIF信息在地图上显示。现在gnome桌面上终于有一个专门的地图查看器了,仍然是基于libchamplain,名字叫做emerillon

Emerillon Map Viewer

仍然是使用open street maps,这两年上海的地图发展的非常不错,连最新的二号线东延都已经被标注出来了。相比之下,南京的地图就还是一片空白。

在Ubuntu上安装emerillon,可以从其网站上下载源码编译安装:
http://www.novopia.com/emerillon/download.html

emerillon的几个主要依赖:

  • libchamplain
  • librest
  • ethos

libchamplain在ubuntu 9.10的仓库已经包含

librest也在软件仓库中,不过需要注意的是ubuntu将librest安装在pkg-config里时的名字叫做rest.pc,而emerillon查找的是rest-0.6.pc,所以需要手动建立一个软连接:
sudo ln -s /usr/lib/pkgconfig/rest.pc /usr/lib/pkgconfig/rest-0.6.pc

ethos是一个Gtk的插件框架,目前还不在软件仓库中,需要从网站下载代码编译:
http://git.dronelabs.com/ethos/
ethos网站上提到的PPA源中的版本偏旧,不建议使用。

实际上也可以直接添加emerillon的PPA源:
deb http://ppa.launchpad.net/mathieu-tl/emerillon/ubuntu karmic main
deb-src http://ppa.launchpad.net/mathieu-tl/emerillon/ubuntu karmic main

另外,也可以通过Ubuntu Tweak安装。

作者Blog:
http://blog.pierlux.com/en/

Restore Nautilus to open gnome menu after installed PCManFM

10月 25, 2009

After installed PCMan File Manager with LXDE, the gnome “places” menu items were opened by PCManFM as default. To switch back to nautilus, follow these steps:

  1. check /usr/share/applications/nautilus-folder-hanlder.desktop
    make sure the line “Exec=nautilus” is not modified. (There are lots of hack article that teach user to change default file manager by modify this)
  2. check /usr/share/applications/defaults.list
    grep the line “x-directory” by
    cat /usr/share/applications/defaults.list | grep x-directory
    make sure the value was kept as “nautilus-folder-handler.desktop”, if not, restore it.
    Then grep the line “inode” by
    cat /usr/share/applications/defaults.list | grep inode
    also be sure about the result “nautilus-folder-handler.desktop”. if not, restore it again.
  3. So it must be your own configuration that has been changed. check ~/.local/share/applications/defaults.list
    grep the two lines described above, it must be changed to “pcmanfm-folder-handler.desktop”, so replace them by “nautilus-folder-handler.desktop”

To check the result, click menu item at once (no restart or logout needed), again, you see the slow file manager…

Jetty7/JSP, Eclipse/GTK2.18

10月 14, 2009

Jetty7.0上周发布了,这是jetty迁进eclipse社区之后的第一个正式版本。但是下载之后发现这个版本居然没有jsp支持。原来,jetty的jsp实现一直使用的是glassfish的实现,嵌入eclipse社区之后,这变成了一个问题。功能完全的版本(hightide)依然可以从codehaus的镜像里下载:
http://dist.codehaus.org/jetty/

比较一下大小就能看出,eclipse的版本只有2.1M,hightide的版本15M。为此,社区里有详细的讨论:
http://dev.eclipse.org/mhonarc/lists/jetty-dev/msg00198.html

Gnome2.28发布了,但是Eclipse在Gtk2.18上工作时,会发生按钮失灵的问题,主要集中在finish next和ok等关键的按钮。简单的解决方法是焦点在按钮上时通过按回车来执行。比较彻底的方法是在eclipse执行的环境中,设置环境变量GDK_NATIVE_WINDOWS=true

这个bug被报告在这里:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=291257

Gnome Shell

10月 4, 2009

续昨,好吧,这个无聊的国庆假期就献给karmic了。gnome-shell已经可以在软件仓库里找到了,apt-get安装即可。要使用gnome-shell可以执行
gnome-shell –replace

要把gnome-shell作为默认的窗口管理器,打开gnome的配置编辑器,找到/desktop/gnome/session/required_components,把panel和windown-manager全部改成gnome-shell,重新登录即可。

上个图:

当然了,还没有正式release,大家试用尝鲜注意安全第一。

libchamplain: Map Widget of Gnome Desktop

10月 3, 2009

续昨,虽然昨天升级到了gnome2.28,也安装了libchamplain,但是却没有发现这个库应用。Ubuntu上的Empathy似乎是没有把location support编译进去。看不到效果怎么办,好在libchamplain的作者还提供了另一个应用。这是一个eog的插件,用于读取照片的exif信息中的gps latitude和longitude,进而将他显示在libchamplain的地图里。

安装这个插件可以follow官方网站上的做法,当然开发包、头文件之类的东西要齐备。

libchamplain使用了clutter,在载入地图的时候还有fadein的效果。clutter是将要应用在下一代桌面gnome shell中的图形特效库。

插件是用C写的,可以看成是libchamplain的一个例子,作者说已经有了其他语言的binding,如此未来在gnome桌面上开发tile地图程序会变得简单。


加关注

Get every new post delivered to your Inbox.