Use nocase string as g_hash_table's key

/* ghashtabledemo.c -- GHashTable demo */#include <glib.h>#include <string.h>void print_entry(gpointer key, gpointer data, gpointer user_data){  /* user_data not used */  g_print("key: %-10s     value: %-10s\n", (gchar *)key, (gchar *)data);}guint g_str_case_hash (gconstpointer key) { gchar *upkey = g_ascii_strdown (key, strlen(key)); guint hash = g_str_hash (upkey); g_free (upkey); return hash;}gboolean g_str_case_equal (gconstpointer a, gconstpointer b) { if (!g_ascii_strcasecmp (a, b))  return TRUE; else  return g_str_equal […]

How to add a menuitem in Nautilus context menu.

1. In src/file-manager directory, add command section and menuitem section in nautilus-directory-view-ui.xml.<commands>    ...    <cmd name=”Name Convert”        _label=”Name _Convert”        _tip=”Convert the file name”/>    ...</commands><popup name=“selection“ tearoff=“0“>    ....    <placeholder name=“File Actions“ delimit=“top“>        ...       <menuitem name=”Name Convert” verb=”Name Convert”/>        ...    </placeholder>    ...</popup> 2. In fm-directory-view.c:    #define FM_DIRECTORY_VIEW_COMMAND_NAME_CONVERT    “/commands/Name Convert“    In real_merge_menus () function, BonoboUIVerb verbs [] array, add […]

Java动态代理的示例

public interface SomeClass { public abstract void someMethod(); public abstract void someOtherMethod(final String text); } public class SomeClassImpl implements SomeClass{ private String userName; public SomeClassImpl(final String userName) { this.userName = userName; } public void someMethod( ) { System.out.println(this.userName); } public void someOtherMethod(final String text) { System.out.println(text); } } import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; public […]

Monty Python和Monty Python Quote

我在翻译"Struts Kick Start"时遇到Monty Python Quote,不解何意,最后终于google到下面这篇文章,看来Monty Python团体对市井文化有很大的影响 🙂 "MONTY PYTHON"(巨蟒)小组成立于60年代后期,成员包括Graham Chapman, John Cleese, Terry Gilliam, Eric Idle, Terry Jones,和Michael Palin。这六位成员在组团之前已经彼此熟识,首先是在大学时代-Graham,John和Eric同在剑桥就读,Terry J和Michael则是在牛津;后来他们又在一些电视喜剧节目中互相有过合作,例如著名的The Frost Report。 1967年,John和Graham合力创作并出演了“At Last, the 1948 Show”节目,同时出演的还有Marty Feldman, Tim Brooke-Taylor和Aimi MacDonald,Eric也在剧中时有出现。第二年,Eric,Michael和Terry J合力创作了儿童节目”Do Not Adjust Your Set”(DNAYS),出演的还有David Jason2和the Bonzo Dog (Doo Dah)乐队(乐队中的Neil Innes后来成了PYTHON附属成员中重要的一员),更重要的是,Terry Gilliam负责了此节目的动画部分。 1969年初,Michael和Terry J合写并出演了一出名为”The Complete and Utter History of Britain“的系列现场短剧。John也参与了此剧,当时他已经决定要与Michael进行合作。 BBC的一位制作人Barry Took为两人安排了一次会面。 John带上了自己的写作伙伴Graham,Michael也带上了DNAYS剧组的同事Terry J,Eric和Terry […]

How to create customized widget in glade project.

1. Create a new glade project, either Gnome or Gtk+. 2. In "Gtk+ Addtional" tab, click the "Custom Widget" button labeled with "C", and add this DUMMY widget into any container of a top-level window. 3. In "Properties" dialog, fill the "Name" field, and then fill the "Creation Function" field (e.g., create_gtksrcview), other arguments can […]

IIIM server code reading note (part 2)

* Singleton -- the most commonly used pattern. There are some singleton classes in IIIMSF such as IMLog, IMSignal etc, and basicly follows the scheme below: class Singleton { static Singleton * _pInstance; Singleton (); vitual ~Singleton (); public: static Singleton * get_instance (); static Singleton * construct (); static void * cleanup (); }; […]

IIIM server code reading note (part 1)

* UML static structure: +----------+ | <<if>> |---o request_accept () | IMAccept |---o request_connect () +----------+ +--------+ A +---------|>| IMAuth | | | +--------+ | | +-------+ +-----------+ +--------+ | IMSvr |<>----+----| IMUserMgr |<>-----| IMUser | +-------+ | +-----------+ 1 * +--------+ | | . | +-------+ +--------+ +--------+ | +----| LEMgr |<>-----| LEBase |-.-.-.->| […]

X RECORD extension example

/*  * To enable record extension in Xorg/XFree86, add the following  line in  * Section "Module"  *     Load         "record"  */ #include <stdio.h> #include <stdlib.h> #include <X11/Xlibint.h> #include <X11/Xlib.h> #include <X11/Xutil.h> #include <X11/cursorfont.h> #include <X11/keysymdef.h> #include <X11/keysym.h> #include <X11/extensions/record.h> #include <X11/extensions/XTest.h> /* for this struct, refer to libxnee */ typedef union {   unsigned char    type […]