ManPT's Technical Blog

PT's Technical Blog, about Ubuntu, Linux or C/C++, Java, Python or whatever geek, for PT's detemined to be a real geek......

Wednesday, January 21, 2009

推荐一电视软件:LiveStation

在PCWorld一篇推荐怎么在线看奥巴马宣誓仪式的文章中,留意到LiveStation,一跨平台的在线电视软件。



到其网站http://www.livestation.com下载了Linux版,是传统的run文件安装方式,安装还是挺简单的,虽然安装文件有点大。程序界面比较漂亮,打开配置窗口可以看出是用QT的。

虽然是国外的软件,但发现缓冲速度很快,当然,节目主要还是外语台,CNN、Fox这些不会少,不过细心一搜,还是有凤凰、TVB这些华语台的,虽然没PPStream那么丰富,清晰度还可以。

Thursday, January 15, 2009

整顿低俗的本质意义在此:

2009年1月9日下午3时许,牛博网的域名注册商中国万网停止了域名“bullog.cn”的访问权限,牛博网在中国国内的服务器亦被关闭,牛博国际也无法登陆,官方的理由是“大量登载时政类有害信息”。此前,牛博网的一些博客作者如冉云飞、梁文道、艾未未、王小山、莫之许、五岳散人、十年砍柴、阿丁等参与了《零八宪章》的联名签署;而中国政府竭力阻止零八宪章在国内传播后,在牛博网的一些博客中仍能找到有关的讯息。2009年1月5日中国政府以“全国整治互联网低俗之风”的名义,启动了大规模整顿与限制网络言论的系列行动,部份人士认为此次关闭牛博与这项整顿运动有关,亦标志着中国政治气候向“左”转。

http://zh.wikipedia.org/w/index.php?title=%E7%89%9B%E5%8D%9A%E7%BD%91&variant=zh-cn

Thursday, January 01, 2009

迎接2009……

C:printf("新年快乐!")
C++:cout<<"新年快乐!"
VC:MessageBox("新年快乐!")
C#:System.Console.WriteLine("新年快乐!")
Java:System.out.println("新年快乐!")
JScript:alert("新年快乐!")
ASP:Response.Write "新年快乐!"
PHP:echo "新年快乐!"
VB:Msg("新年快乐!")
VBScript:MsgBox "新年快乐!"
Delphi:ShowMessage('新年快乐!')
Shell:echo 新年快乐!
Perl:print '新年快乐!'
PowerBuilder:messagebox("新年快乐!")
COBOL:DISPLAY '新年快乐!'. 

Monday, December 29, 2008

ScribeFire 无痛使用Blogger




ScribeFire是很不错的一款firefox插件,通过调用标准博客的API来快速发博文。然而今天才知道“ScribeFire 无痛使用Blogger”的方法……
 
何为无痛?哦,云防火是也……

blogger的API地址不知为何会触发云防火的神经,如果按默认的设置添加blogger的账户,一连接就会发现整个blogspot不能用了……

解决办法很简单

把API调用的地址http://改成https://



好了,这篇文章就是在Scribefire下发的……这下不用请教刘翔也能用blogspot了。

Thursday, December 18, 2008

什么是代码?什么是程序?

什么是代码?什么是程序?

上了两年多的大学计算机专业,现在看这问题,实在感慨。

代码也许是书上的一段文字,程序也许是磁盘上的一个文件,老师们在给你讲述它的原理,它的结构,却从未提及它的本质。程序怎么出来的?从代码编译出来的。代码怎么出来的?人写出来的。人怎么会写代码?想出来的。思想是怎么出来的?这......

程序的本质,是人的创造力,也就是那所谓1%的灵感。这里有个很哲学的问题,貌似课本的说法是,量变会引起质变,而我得提醒,“引起”的意思是“可能会,可能不会,并不一定会”。“程序 = 算法 + 数据结构”这个说法,很明显地低估了等号左边的重量。

然而反观我们的高等教育,从一段代码里面挖掉几行,让你填空,瞧一瞧上下文,哦,有些地方差不多的,把语句抄过来,好,编译通过,实验课完了,回去写实验报告吧,下星期交。

原来现在的大学教育就是低能儿童智力开发。

我想,即使让学生们自己去开发个人品计算器、人名打架器,学生们的收获也要比啃上那几本砖头书多,至少他们知道自己能够创造东西,而不是只会学东西。

PS:《偷天换日》(The Italian Job)电影里有这么一个人,他抢了别人的金子,却不知道如何去构造自己的梦想,买到了别人想要的一切,却不知道自己想要什么,我想,这是一个人最大的悲剧。不是说,知识也是财富么,如果缺乏创造能力,即使占有再多的知识,又有何用呢?

Sunday, December 07, 2008

Create a exe file with icon in Mingw gcc

1. get a icon file name "logo.ico"
2. create an file name "logo.rc", contain a line:

1 ICON "icon.ico"
3. run : (windres was include in Mingw)
windres logo.rc logo.o
4. link the "logo.o" file together with other object files to the final exe file.

Thursday, December 04, 2008

编程笔记:Editable Treeview Cell

I found that programming gtk+ plays a lot of tricks. I implemented "editable treeview cells" today in my program, after spending quite a while looking up for examples on Google. The most I wanted to say is that, the Gtk manual was detailed enough, but it never tells you how to do, which makes me so desperate sometimes......

The solution was written in a tutorial, http://scentric.net/tutorial/sec-editable-cells.html

there seems quite several GTK tutorials, but most of their contents were duplicated, though I always learn the tricks from them... ^_^

Note:

  renderer = gtk_cell_renderer_text_new();
...
g_object_set_data(G_OBJECT(renderer), "my_column_num", GUINT_TO_POINTER(COLUMN_NAME));

...

renderer = gtk_cell_renderer_text_new();
...
g_object_set_data(G_OBJECT(renderer), "my_column_num", GUINT_TO_POINTER(COLUMN_YEAR_OF_BIRTH));

...

the "renderer" must be create several times in this trick, for a object couldn't carry the same property in different value twice, itn's it?

Labels: ,

Tuesday, December 02, 2008

编程笔记:GtkBuilder和popup menu

今天又奋战gtk的文档,看着别人写的旧版example代码,用GtkBuilder的方法重写,实现了一个自己想要的TreeView List。最后想在TreeView中加入一个右键菜单,却想不到小小的popup menu就给我设了两大难关。

首先找来找去没有见到有right-click的signal,Google了一下,从Maillist里面的解答找到头绪,由GtkWidget的button_press_event来实现。GTK+ Reference Manual里面一点都没提到这个信号,原来这个button指鼠标的button,键盘的键叫做key……

http://mail.gnome.org/archives/gtk-list/2002-August/msg00119.html

button_press_event emits when any mouse button pressed, when handling with this signal, use a callback prototype in this way:

gboolean callback (GtkWidget *widget,
GdkEventButton *event,
gpointer data);
and you can determine which button was press with event->button (values 1,2,3...3 stands for the right button, 1 for left and 2 for middle), and if you want give this signal back to the widget, just return FALSE.


另外一个问题是popup menu, 在glade3里面添加了一个popup menu, 照搬老方法,初始化程序的时候
tree->menu = GTK_WIDGET ( gtk_builder_get_object (builder, "menu1") );
弹出窗口:
gtk_menu_popup (GTK_MENU(user_data->menu), NULL, NULL, NULL, NULL, event->button, event->time);
郁闷的事情来了,程序运行的时候提示:
(tree:28254): GLib-GObject-WARNING **: invalid unclassed pointer in cast to `GtkMenu'

(tree:28254): Gtk-CRITICAL **: gtk_menu_popup: assertion `GTK_IS_MENU (menu)' failed
在Reference里面看了半天,注意到GtkBuilder Description的一段话:
A GtkBuilder holds a reference to all objects that it has constructed and drops these references when it is finalized. This finalization can cause the destruction of non-widget objects or widgets which are not contained in a toplevel window. For toplevel windows constructed by a builder, it is the responsibility of the user to call gtk_widget_destroy() to get rid of them and all the widgets they contain.
在Glade3里面看到,popup menu不属于toplevel的window,看来小menu在g_object_unref (G_OBJECT (builder));的时候被收回去了……可是怎么解决呢?总不能不收了builder吧,builder占的内存可不小的,很容易造成内存泄漏……

It's obvious that the menu allocation was released after initialing the application, I have to solve this problem.

In the Reference Manual, I found a function.

g_object_ref ()

gpointer g_object_ref (gpointer object);

Increases the reference count of object.

The reference count really mean something, worth to read about it carefully. I just add one more statement after getting the menu widget:

这个reference count大有来头。在gtk_builder_get_object (builder, "menu1")后,加了一句:
g_object_ref ((gpointer)tree->menu);
Yes,the whole world goes the right way now!!!!


Labels: , , , ,