µ±Ç°Î»ÖãºLinux½Ì³Ì - Gnome - ÔÚ Gtk+/Gnome ÖÐʹÓÃÖÐÎijõ̽

ÔÚ Gtk+/Gnome ÖÐʹÓÃÖÐÎijõ̽

Õâ¸öÖÜĩѧϰÁËһϠGtk+/Gnome , ¿´ÁË¿´ bluefish µÄÔ­Âë, ·¢ÏÖÓà Gtk+/Gnome д֧³ÖÖÐÎÄ ÊäÈëÊä³öµÄ GUI ½çÃæʵÔÚÊǼþºÜ¼òµ¥µÄÊÂÇé. дÁËÒ»¸öʾÀýÐÔµÄС³ÌÐò, Ï£ÍûÄܸøÏóÎÒÒ»ÑùµÄ ³õѧÕßÒ»µã°ïÖú.

¿ª·¢»·¾³ºÍ¿ª·¢¹¤¾ß

ÌÖÂÛ Linux ÖÐÎÄ»·¾³µÄÎÄÕÂÒѾ­Óв»ÉÙÁË, ÆäʵÏÖÔÚ³£¼ûµÄ Linux Contribution µÄ×ÀÃæ»·¾³ ¶¼Êǹú¼Ê»¯µÄ, Ö»Òª¶ÔһЩÅäÖÃÎļþÐÞ¸ÄһϾÍÄÜʵÏÖºº×ÖÏÔʾ. ºº×ÖÊäÈëÒ²ÒѾ­×ñÑ­ XIM ±ê×¼ ÁË, Ö»Òª¿Í»§³ÌÐò½ÓÊÜ XIM , ÀíÂÛÉÏ˵¾Í¿ÉÒÔÊäÈ뺺×Ö. ¹Ø¼üµÄÎÊÌâÔÚÓÚ²¢²»ÊÇËùÓдó¼ÒÊìϤ µÄÓ¦ÓÃÈí¼þ¶¼Ö§³Ö¹ú¼Ê»¯, ÓеÄʱºò¼´Ê¹Èí¼þ±¾ÉíÖ§³Ö, Ò²ÐèÒª½øÐÐһЩÉèÖù¤×÷.

ÎҵŤ×÷»·¾³ÊÇ Mandrake 7.2 ºÍ chinput 3.0. KDE ×ÀÃæʵÏÖºº»¯. Ò»°ãÀ´ËµÎҵı༭¹¤¾ß ÊÇ Vim, Èç¹ûÏëÊäÈ뺺×Ö¾ÍÐèÒªÓÐÒ»¸öÖ§³Ö XIM µÄ Terminal, rxvt-CLE ÊÇÒ»¸ö²»´íµÄÑ¡Ôñ. ÎÒÏë Gnome-Terminal ÏÔȻҲӦ¸Ã¿ÉÒÔʵÏÖºº×ÖÊäÈëÊä³ö, µ«ÏÖÔÚÎÒ»¹Ã»Óи㶨. Ö÷ÒªµÄÎÊÌâ ÊDz»ÖªµÀÔÚʲôµØ·½¿ÉÒÔÉèÖà fontset, ÒòΪֻÓÐÕâÑù²ÅÄÜʵÏÖÖÐÓ¢ÎÄ»ìºÍÏÔʾ. ¹ýÁ½Ìì¿´¿´ ËüµÄÔ­Âë, ÐÞ¸ÄÒ»ÏÂÓ¦¸Ã²»ÄÑ.

ͼÐλ¯µÄ±à¼­Æ÷¿ÉÒÔʹÓà Gedit, »¹ÓÐÎÒÏÖÔÚÕýÔÚÓÃÀ´±àдÕâ¸ö HTML ÎļþµÄ bluefish. Èç¹û ÄãÏëÔÚ bluefish ÖÐʹÓÃ×Ô¼º¶¨ÒåµÄ fontset, ¶ø²»ÊÇ Gtk+ ȱʡµÄÉèÖþÍÐèÒª°Ñ ~/.bluefish/rcfile ÖÐµÄ fontset ±äÁ¿ÉèΪ 1.
Ïó Netscape Ö®ÀàµÄÈí¼þµÄ¹ú¼Ê»¯ÒѾ­×÷µÄºÜºÃÁË, ÔÚÄãÉèºÃ locale ºÍ XIM Ö®ºó, ÊäÈëÊä³ö ¶¼ºÜÁîÈËÂúÒâ. µ±È»¿ÉÄÜÄ㻹ÐèÒªÉèÖÃÒ»ÏÂÅäÖÃÎļþÖеÄ×ÖÌå.


Gtk+/Gnome ʾÀý

/* ÔÚ gtk+/gnome ±à³ÌÖÐʹÓÃÖÐÎÄʾÀý ""base.c""
*
* Õâ¶Î´úÂëʹÓà gtk+/gnome Éú³ÉÒ»¸ö±à¼­´°¿Ú, ͨ¹ýϵͳµÄ XIM Server
* ÊäÈ뺺×Ö, ÊäÈëµÄ×ÖÌåʹÓñ¾³ÌÐòÖеĶ¨Òå.
*
* ±àÒë·½·¨:
* gcc -o base base.c ``gnome-config --cflags --libs gnome gtk gnomeui``
*
*/
#include
/* ºê¶¨Òå:
* ÔÚ PACKAGE_LOCALE_DIR ´¦¶¨ÒåÄãµÄ locale ËùÔÚµÄλÖÃ.
* ÎÒʹÓà Mandrake 7.2, LC_ALL=zh_CN.GB2312
* */
#define PACKAGE ""base""
#define PACKAGE_LOCALE_DIR ""/usr/local/share/locale""

gint delete_event ( GtkWidget *widget, GdkEvent *event, gpointer data )
{
g_print(""delete event occerred "");
return(FALSE);
}

void destroy( GtkWidget *widget, gpointer data )
{
gtk_main_quit();
}

int main ( int argc, char *argv[] )
{
GtkWidget *window;
GtkWidget *text;

/* ÓйØÐÞ¸Ä×ÖÌåµÄ±äÁ¿ */
GtkStyle *style;
GdkFont *tmpfont;
gchar *fontstring;

/* ÉèÖÃʹÓÃ×ÖÌå: Á½ÖÖ×ÖÌå·Ö±ð¶ÔÓ¦Ó¢ÎĺÍÖÐÎÄ. ¸ù¾ÝÄãµÄ Xwindow
* ÐÞ¸ÄÕâ¾ä»°, ʹÓÃϵͳ¿Éʶ±ðµÄ×ÖÌå.
* ¿ÉÓÃ
* xlsfonts |grep gb
* ÃüÁîÕÒ³öÄãµÄÖÐÎÄ×ÖÌå.
* */
fontstring = ""-*-fixed-medium-r-normal--16-*-*-*-*-*-iso8859-1,-*-simsun-medium-r-normal--16-*-*-*-*-*-gb2312.1980-0"";

/* ¼ÓÔØ locale:
* ÕâÁ½¾ä»°±ØÐë */
bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
textdomain (PACKAGE);

/* Gnome ³õʼ»¯ */
gnome_init (PACKAGE, ""0.1"", argc, argv);

window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), ""delete_event"",
GTK_SIGNAL_FUNC (delete_event), NULL);
gtk_signal_connect (GTK_OBJECT (window), ""destroy"",
GTK_SIGNAL_FUNC (destroy), NULL);
text = gtk_text_new (NULL, NULL);

/* ÉèÖÃ×Ô¶¨ÒåµÄ×ÖÌå: */
style = gtk_rc_get_style (GTK_WIDGET(text));
tmpfont = style->font;
if(!(style->font = gdk_fontset_load(fontstring)))
g_print(""fontset_load false "");
gdk_font_unref(tmpfont);
gtk_widget_set_style(GTK_WIDGET(text), style);


gtk_container_add (GTK_CONTAINER (window), text);
gtk_widget_show (text);
gtk_widget_show (window);
gtk_text_set_editable (GTK_TEXT (text), TRUE);
gtk_main ();
return(0);
}

Snapshot

ÔõôÑù, ͦƯÁÁ°É. ¾ÍÊÇÕâô¼òµ¥!