Category Archives: Program

Continuous Integration: 持续集成

原文见:http://www.martinfowler.com/articles/continuousIntegration.html 这儿还有一篇中文的说明:http://bbs.scmlife.com/viewthread.php?tid=5500 我是在研究trac的plugin的时候,发现有一个plugin看不懂,不知道是干什么的,就搜索了一下。

Posted in Program | Tagged , , | 1 Comment

gnome thumbnails的生成

在$HOME/.thumbnails/目录下有一系列的缩略图文件,以供系统调用。 其生成规律: md5(“file:///home/….”) 大小是128×96的PNG图片 不过,为了更好的cache,提高速度,这儿有讨论,拟把md5的hash拆分成目录。 http://lists.freedesktop.org/archives/xdg/2007-August/008749.html

Posted in Program | Tagged , , | Leave a comment

strange problem in using Gtk::IconView

非常奇怪的问题,在使用Gtk::IconView的时候遇到的。 假设model的数据重新刷新后,但和刷新前的数据相同,这时候IconView里的显示就会发生奇怪的现象,首先height边大,若再次刷新,则text会奇怪的显示(左对齐),而且text每行的长度很短,导致item的height被变相拉大。 Use Gtk::IconView to display some pdf’s thumbnail, and without any problem. But encounter a strange problem, the iconview item’s height will increase after a model’s update if the model’s content unchanged. For e.g., I use a update() function … Continue reading

Posted in Program | Tagged , , | 1 Comment

gtkmm中实现二级弹出式菜单

其实很简单: Gtk::Menu menuPopup; Gtk::MenuItem testitem(“test sub”); Gtk::Menu::MenuList& menulist = menuPopup.items(); menulist.push_back( Gtk::Menu_Helpers::MenuElem(“_Add”,sigc::mem_fun(*this, &DocView::insert_doc) ) ); menulist.push_back( Gtk::Menu_Helpers::MenuElem(“_Open”,sigc::mem_fun(*this, &DocView::open_doc) ) ); menulist.push_back( Gtk::Menu_Helpers::MenuElem(“_Edit”,sigc::mem_fun(*this, &DocView::edit_doc) ) ); menuPopup.append(testitem); //必须用指针形式,否则无法弹出 Gtk::Menu* submenu=manage(new Gtk::Menu()); submenu.items().push_back( Gtk::Menu_Helpers::MenuElem(“_Add”,sigc::mem_fun(*this, &DocView::insert_doc) ) ); testitem.set_submenu(*submenu); 关键就在于要用指针,我一开始没用,怎么也没有找到问题。

Posted in Program | Tagged , , , | Leave a comment

gtkmm中断开一个信号

其实也很简单,就是在文档中没有看到。 Easy enough: sigc::connection c = widget.signal_whatever().connect(sigc::mem_fun(whatever, whatever)); Then keep hold of c until you want to disconnect, and when you do, call c.disconnect(). Works in libsigc++ 1.2 as well, with the appropriate changes: SigC::Connection c = widget.signal_whatever().connect(SigC::slot(whatever, whatever)); c.disconnect(); … Continue reading

Posted in Program | Tagged , , | Leave a comment

遍历TreeStore

如何遍历TreeStore? gtkmm的邮件列表上有一个简单的例子,但是经过测试,发现只能遍历到第二层枝。 Gtk::TreeModel::Children child=refTreeModel->children();//只能获取到第一级分类 Gtk::TreeModel::Children::iterator iter ; for( iter = child.begin() ; iter != child.end() ; iter++ ) { if ((*iter)[columns.id]==t[i].parent_id) { row=*(refTreeModel->append(iter->children())); break; } } 最终通过递归实现全部遍历,代码如下。 void CategoryView::getrow(Gtk::TreeModel::Children child,unsigned int pid, Gtk::TreeModel::Row& row) { Gtk::TreeModel::Children::iterator iter; for( iter = … Continue reading

Posted in Linux, Program | Tagged , , | Leave a comment

c++中的string转换

如何转换string到其他类型?如何从其他类型转换到string? 代码1:toString template <class T> std::string toString(const T& a) { std::ostringstream ost; ost << a; return ost.str(); } 代码2:fromString template<typename T>T fromString( const std::string& s) { std::istringstream is(s); T t; is >> t; return t; } 使用方法: int d = … Continue reading

Posted in Program | Tagged , , | Leave a comment

使用FileChooserDialog打开多文件

单文件比较简单, 看到这个函数的原型是这样的: Glib::SListHandle<Glib::ustring> Gtk::FileChooser::get_filenames ( ) const 因此,就以为要使用这样的变量来进行声明: Glib::SListHandle<Glib::ustring> filenames =dialog.get_filenames(); for(int i=0;i<filenames.size();i++) { //Notice that this is a std::string, not a Glib::ustring. //std::string filename = dialog.get_filename(); std::cout << “File selected: ” << filenames[i] << std::endl; } 结果发现编译不通过,再仔细看看,Glib::SListHandle并没有重载[]操作符。 再网络上搜索后发现有人和我的问题相同: That … Continue reading

Posted in Program | Tagged , , | 2 Comments

在ubuntu gutsy下编译codeblocks svn版本

本来一直用的是feisty下的一个源: deb http://lgp203.free.fr/ubuntu/ feisty main 但是自从svn4413版本后就出现问题了,执行codeblocks提示错误: codeblocks: /usr/lib/libwx_gtk2u_aui-2.8.so.0: version `WXU_2.8.5′ not found (required by codeblocks) 因此,决定自己编译SVN版本,首先下载: svn co svn://svn.berlios.de/codeblocks/trunk codeblocks 编译前首先要作一些准备工作: sudo aptitude install debhelper fakeroot wx-common 然后修改codeblocks/debian/control文件,使其中的一些依赖替换为当前gutsy里的版本: Build-Depends: debhelper, autotools-dev, libc6-dev, libstdc++6-4.1-dev, libwxgtk2.8-dev, wx-common, zip 然后就可以编译了: cd codeblocks ./bootstrap … Continue reading

Posted in Linux, Program | Tagged , , , | Leave a comment

转换vbb 3.0.3到phpbb3

集思学院已经用了很长时间的vbb3.0.3,现在有些功能在我们的服务器已经出问题了,而且不想再跟vbb了,因为数字流域论坛已经转换到phpbb了,为了以后维护方便,决定从vbb3.0.3转换到phpbb 3 rc1。(估计RC2版本就要出来了,BUG已经很少了) 因为之前已经写了一个webwiz到phpbb的转换程序,所以再写vbb3到phpbb3的转换程序,比上次要轻松不少,但webwiz的设计思想就是来源于phpbb,所以很多库结构都非常像,而vbb的结构和phpbb有较大差异,在调试过程中还是耗费了大量的时间,回头来看,大约耗费了有一个礼拜的时间。感觉我都能提供有偿论坛转换服务了,哈哈。 转换过程: 首先要进行数据库的UTF8转换。之前论坛采用的是gb2312编码,但论坛上有台湾的注册用户,原来也能显示繁体中文,所以应该采用的是gbk或gb18030的编码。 在进行数据库的备份之前,要在原来的vb论坛后台把附件的存贮方式修改为文件方式,上传头像的存贮方式也修改为文件方式,而customprofilepic我没有找到对应的phpbb设置,所以这一块就直接丢弃了。 然后导出数据库: mysql -uroot –add-drop-table –default-character-set=latin1 cngis > cngis.sql 进行编码的转换: iconv -c -f gb18030 -t utf8 cngis.sql > cngisutf8.sql 然后修改此sql文件,替换所有的latin1为utf8,并在文件的开始处添加: SET NAMES utf8; SET CHARACTER_SET_CLIENT=utf8; SET CHARACTER_SET_RESULTS=utf8; 然后新建一个数据库cngisutf8,作为我们的测试数据库并尝试导入此sql文件。 mysql -uroot cngisutf8 < cngisutf8.sql 若在导入过程中没有错误,那么恭喜你,你太幸运了。 … Continue reading

Posted in Linux, Program | Tagged , , | 18 Comments