Crossfire Client, Branch  R11627
text.c
Go to the documentation of this file.
00001 const char * const rcsid_gtk_text_c =
00002     "$Id: text.c 9190 2008-06-01 08:53:05Z anmaster $";
00003 /*
00004     Crossfire client, a client program for the crossfire program.
00005 
00006     Copyright (C) 2001 Mark Wedel & Crossfire Development Team
00007 
00008     This program is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     This program is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with this program; if not, write to the Free Software
00020     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00021 
00022     The author can be reached via e-mail to crossfire-devel@real-time.com
00023 */
00024 #include <config.h>
00025 #include <stdio.h>
00026 #include <gtk/gtk.h>
00027 #ifndef WIN32
00028 #include <gdk/gdkx.h>
00029 #else
00030 #include <gdk/gdkwin32.h>
00031 #endif
00032 #include "client.h"
00033 #include "gx11.h"
00034 #include "gtkproto.h"
00035 static char NO_TITLE[] = "[no title]";
00036 
00037 #include "pixmaps/sign_flat.xpm"
00038 #include "pixmaps/sign_west.xpm"
00039 #include "pixmaps/sign_east.xpm"
00040 #include "pixmaps/close.xpm"
00041 GtkWidget* book_root = NULL;
00042 GtkWidget* book_notes = NULL;
00043 GdkBitmap* btnClose_bm = NULL;
00044 GdkPixmap* btnClose_pm = NULL;
00045 
00046 typedef struct picture_message_struct {
00047     const char *title;
00048     const char *const *xpm;
00049     int x;
00050     int y;
00051     int width;
00052     int height;
00053     int window_width;
00054     int window_height;
00055     GdkPixmap *picture;
00056 
00057 } picture_message;
00058 
00059 static picture_message sign_message[] = {
00060     {"sign",sign_flat_xpm,70,45,390,305,500,500,NULL},
00061     {"left sign",sign_west_xpm,95,85,615,190,750,400,NULL},
00062     {"right sign",sign_east_xpm,45,85,615,190,750,400,NULL},
00063     {"direction sign",sign_flat_xpm,70,45,390,305,500,500,NULL} };
00064 static void init_pictures(GtkWidget *refWindow) {
00065     if (btnClose_pm==NULL)
00066         btnClose_pm = gdk_pixmap_create_from_xpm_d(refWindow->window,&btnClose_bm,
00067                 &gtk_widget_get_style(refWindow)->bg[GTK_STATE_NORMAL],
00068                 (gchar**)close_xpm);
00069 }
00070 static void prepare_book_window(void) {
00071     if (!book_root){
00072         book_root= gtk_window_new (GTK_WINDOW_TOPLEVEL);
00073         gtk_window_set_title(GTK_WINDOW(book_root),"books");
00074         book_notes = gtk_notebook_new();
00075         gtk_notebook_set_tab_pos(GTK_NOTEBOOK(book_notes),GTK_POS_LEFT);
00076         gtk_container_add(GTK_CONTAINER(book_root),book_notes);
00077         gtk_widget_show(GTK_WIDGET(book_notes));
00078         gtk_widget_show(GTK_WIDGET(book_root));
00079         init_pictures (book_root);
00080         gtk_signal_connect (GTK_OBJECT (book_root), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &book_root);
00081         gtk_window_set_default_size(GTK_WINDOW(book_root),500,600);
00082         gtk_window_set_position(GTK_WINDOW(book_root),GTK_WIN_POS_CENTER);
00083     }
00084 }
00085 static GtkWidget *create_text_picture_window(picture_message *layout, char *message) {
00086     GtkWidget *window, *content, *fixed, *scroll, *close;
00087     window = gtk_window_new (GTK_WINDOW_DIALOG);
00088     gtk_window_set_title(GTK_WINDOW(window),layout->title);
00089     gtk_widget_set_app_paintable(window,TRUE);
00090     gtk_widget_realize(window);
00091     init_pictures(window);
00092     if (layout->picture == NULL){
00093         layout->picture = gdk_pixmap_create_from_xpm_d(window->window,NULL,
00094                 &gtk_widget_get_style(window)->bg[GTK_STATE_NORMAL],
00095                 (gchar**)layout->xpm);
00096     }
00097     gdk_window_set_back_pixmap(window->window,layout->picture,FALSE);
00098     content = gtk_text_new(NULL,NULL);
00099     gtk_text_set_editable(GTK_TEXT(content),FALSE);
00100     gtk_text_set_word_wrap(GTK_TEXT(content),TRUE);
00101     gtk_text_set_line_wrap(GTK_TEXT(content),TRUE);
00102     write_media(GTK_TEXT(content),message);
00103     gtk_window_set_default_size(GTK_WINDOW(window),layout->window_width,layout->window_height);
00104     gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
00105     fixed=gtk_fixed_new();
00106     gtk_widget_set_app_paintable(fixed,TRUE);
00107     gtk_container_add(GTK_CONTAINER(window),fixed);
00108     gtk_widget_realize(fixed);
00109     gdk_window_set_back_pixmap(fixed->window,layout->picture,TRUE);
00110 
00111     scroll = gtk_scrolled_window_new (NULL, NULL);
00112     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
00113                                     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
00114     gtk_widget_show (scroll);
00115     gtk_widget_set_usize(scroll,layout->width,layout->height);
00116     gtk_fixed_put(GTK_FIXED(fixed),scroll,layout->x,layout->y);
00117     close=gtk_button_new();
00118     gtk_widget_set_usize(close,0,0);
00119     gtk_fixed_put(GTK_FIXED(fixed),close,0,0);
00120     gtk_widget_show(fixed);
00121     gtk_widget_show(content);
00122 
00123     gtk_container_add(GTK_CONTAINER(scroll),content);
00124     gtk_text_set_adjustments(GTK_TEXT(content),
00125             NULL,
00126             gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll))
00127         );
00128 
00129     gtk_signal_connect_object (GTK_OBJECT (close), "clicked",
00130                    GTK_SIGNAL_FUNC(gtk_widget_destroy),
00131                    GTK_OBJECT (window));
00132     gtk_widget_grab_focus (GTK_WIDGET(close));
00133     return window;
00134 }
00135 static void show_media_message(const char *title, const char *message) {
00136     GtkWidget *window, *scroll, *content;
00137     window = gtk_window_new (GTK_WINDOW_DIALOG);
00138     gtk_window_set_title(GTK_WINDOW(window),message);
00139     gtk_window_set_default_size(GTK_WINDOW(window),500,500);
00140     gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
00141 
00142     content = gtk_text_new(NULL,NULL);
00143     gtk_text_set_editable(GTK_TEXT(content),FALSE);
00144     gtk_text_set_word_wrap(GTK_TEXT(content),TRUE);
00145     gtk_text_set_line_wrap(GTK_TEXT(content),TRUE);
00146     write_media(GTK_TEXT(content),message);
00147     gtk_widget_show(content);
00148 
00149     scroll = gtk_scrolled_window_new (NULL, NULL);
00150     gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
00151                                     GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
00152     gtk_container_add(GTK_CONTAINER(scroll),content);
00153     gtk_text_set_adjustments(GTK_TEXT(content),
00154             NULL,
00155             gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll))
00156         );
00157 
00158     gtk_widget_show(content);
00159     gtk_widget_show (scroll);
00160     gtk_widget_show (window);
00161 }
00166 static const char *const arcane_medium_fontname[] = {
00167     "-*-cuneifontlight-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00168     "-*-linotext-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00169     "-*-blackforest-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00170     "-*-becker-*-*-*-*-*-120-*-*-*-*-iso8859-*",
00171     "-*-arnoldboecklin-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00172     "-*-caligula-*-*-*-*-*-120-*-*-*-*-iso8859-*",
00173     NULL
00174     };
00175 static const char *const hand_medium_fontname[] = {
00176     "-*-dobkinscript-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00177     "-*-coronetscript-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00178     "-*-muriel-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00179     "-*-genoa-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00180     "-*-parkavenue-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00181     "-*-rechtmanscript-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00182     NULL
00183 };
00184 static const char *const strange_medium_fontname[] = {
00185     "-*-annstone-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00186     "-*-shalomstick-*-r-*-*-*-120-*-*-*-*-iso8859-*",
00187     NULL
00188 
00189 };
00190 static const char *const print_medium_fontname[] = {
00191     "-*-arial-medium-r-*-*-*-120-*-*-*-*-iso8859-*",
00192     "-*-bookman-light-r-*-*-*-120-*-*-*-*-iso8859-*",
00193     "-*-agate-normal-r-*-*-*-120-*-*-*-*-iso8859-*",
00194     NULL
00195     };
00196 static const char *const print_bold_fontname[] = {
00197     "-*-arial-bold-r-*-*-*-120-*-*-*-*-iso8859-*",
00198     "-*-bookman-demi-r-*-*-*-120-*-*-*-*-iso8859-*",
00199     "-*-agate-bold-r-*-*-*-120-*-*-*-*-iso8859-*",
00200     NULL
00201     };
00202 static const char *const print_italic_fontname[] = {
00203     "-*-arial-medium-i-*-*-*-120-*-*-*-*-iso8859-*",
00204     "-*-bookman-light-i-*-*-*-120-*-*-*-*-iso8859-*",
00205     "-*-agate-normal-i-*-*-*-120-*-*-*-*-iso8859-*",
00206     NULL
00207     };
00208 static const char *const print_italicbold_fontname[] = {
00209     "-*-arial-bold-i-*-*-*-120-*-*-*-*-iso8859-*",
00210     "-*-bookman-demi-i-*-*-*-120-*-*-*-*-iso8859-*",
00211     "-*-agate-bold-i-*-*-*-120-*-*-*-*-iso8859-*",
00212     NULL
00213     };
00214 static const char *const fixed_medium_fontname[] = {
00215     "-*-fixed-medium-r-*-*-*-120-*-*-*-*-iso8859-*",
00216     "-*-courrier-medium-*-*-*-*-120-*-*-*-*-iso8859-*",
00217     "-*-andale mono-medium-*-*-*-*-120-*-*-*-*-iso8859-*",
00218     NULL
00219     };
00220 static const char *const fixed_bold_fontname[] = {
00221     "-*-fixed-bold-r-*-*-*-120-*-*-*-*-iso8859-*",
00222     "-*-courrier-bold-*-*-*-*-120-*-*-*-*-iso8859-*",
00223     "-*-andale mono-medium-*-*-*-*-120-*-*-*-*-iso8859-*",
00224     NULL
00225     };
00226 static const char *const fixed_italic_fontname[] = {
00227     "-*-fixed-medium-o-*-*-*-120-*-*-*-*-iso8859-*",
00228     "-*-courrier-medium-o-*-*-*-120-*-*-*-*-iso8859-*",
00229     "-*-andale mono-medium-*-*-*-*-120-*-*-*-*-iso8859-*",
00230     NULL
00231     };
00232 static const char *const fixed_italicbold_fontname[] = {
00233     "-*-fixed-bold-i-*-*-*-120-*-*-*-*-iso8859-*",
00234     "-*-courrier-bold-o-*-*-*-120-*-*-*-*-iso8859-*",
00235     "-*-andale mono-*-*-*-*-*-120-*-*-*-*-iso8859-*",
00236     NULL
00237     };
00238 static GdkFont *load_a_font(const char *const font_list[]) {
00239     GdkFont* result;
00240     int i;
00241     for (i=0; font_list[i]!=NULL;i++){
00242         result = gdk_font_load(font_list[i]);
00243         if (result != NULL){
00244             LOG(LOG_INFO,"gtk::load_a_font","Loaded font %s.",font_list[i]);
00245             return result;
00246         }
00247     }
00248     return NULL;
00249 }
00250 static GdkFont *style_fixed[4];
00251 static GdkFont *style_arcane[4];
00252 static GdkFont *style_hand[4];
00253 static GdkFont *style_strange[4];
00254 static GdkFont *style_print[4];
00255 #define STYLE_BOLD 1
00256 #define STYLE_ITALIC 2
00257 static int style_inited = 0;
00258 
00259 static void init_fonts(void) {
00260     if (!style_inited){
00261         style_fixed[0]=load_a_font(fixed_medium_fontname);
00262         style_fixed[1]=load_a_font(fixed_bold_fontname);
00263         style_fixed[2]=load_a_font(fixed_italic_fontname);
00264         style_fixed[3]=load_a_font(fixed_italicbold_fontname);
00265 
00266         style_arcane[0]=load_a_font(arcane_medium_fontname);
00267         style_arcane[1]=style_arcane[2]=style_arcane[3]=style_arcane[0];
00268 
00269         style_hand[0]= load_a_font(hand_medium_fontname);
00270         style_hand[1]=style_hand[2]=style_hand[3]=style_hand[0];
00271 
00272         style_strange[0] = load_a_font(strange_medium_fontname);
00273         style_strange[1]=style_strange[2]=style_strange[3]=style_strange[0];
00274 
00275         style_print[0]=load_a_font(print_medium_fontname);
00276         style_print[1]=load_a_font(print_bold_fontname);
00277         style_print[2]=load_a_font(print_italic_fontname);
00278         style_print[3]=load_a_font(print_italicbold_fontname);
00279         style_inited=1;
00280     }
00281 }
00282 media_state write_media(GtkText* textarea, const char* message){
00283     media_state simple_state;
00284     simple_state.style=style_print;
00285     simple_state.has_color=0;
00286     simple_state.flavor=0;
00287     return write_media_with_state(textarea,message, simple_state);
00288 }
00289 media_state write_media_with_state(GtkText* textarea, const char* message, media_state current_state){
00290 
00291     char *current, *marker, *original;
00292     if (message==NULL)
00293         return current_state;
00294     init_fonts();
00295     current=malloc(strlen(message)+1);
00296     if (current==NULL){
00297         LOG(LOG_ERROR,"gtk::write_media","couldn't alloc memory for string manipualtion. Dropping media\n");
00298         return current_state;
00299     }
00300     strcpy(current,message);
00301     original=current;
00302     while( (marker=strchr(current,'['))!=NULL){
00303         *marker='\0';
00304         gtk_text_insert(textarea,current_state.style[current_state.flavor],current_state.has_color?&current_state.fore:NULL,NULL,current,marker-current);
00305         current = marker+1;
00306         if ( (marker = strchr(current,']')) ==NULL)
00307             return current_state;
00308         *marker='\0';
00309         if (!strcmp(current,"b"))
00310             current_state.flavor |=STYLE_BOLD;
00311         else if (!strcmp(current,"i"))
00312             current_state.flavor |=STYLE_ITALIC;
00313         else if (!strcmp(current,"/b"))
00314             current_state.flavor &=!STYLE_BOLD;
00315         else if (!strcmp(current,"/i"))
00316             current_state.flavor &=!STYLE_ITALIC;
00317         else if (!strcmp(current,"/color"))
00318             current_state.has_color = 0;
00319         else if (!strncmp(current,"color=",6))
00320             current_state.has_color = gdk_color_parse(current+6,&current_state.fore);
00321         else if (!strcmp(current,"fixed"))
00322             current_state.style = style_fixed;
00323         else if (!strcmp(current,"arcane"))
00324             current_state.style = style_arcane;
00325         else if (!strcmp(current,"hand"))
00326             current_state.style = style_hand;
00327         else if (!strcmp(current,"strange"))
00328             current_state.style = style_strange;
00329         else if (!strcmp(current,"print"))
00330             current_state.style = style_print;
00331         else
00332             LOG(LOG_INFO,"gtk::write_media_with_state","unidentified message: %s",current);
00333         current=marker+1;
00334     }
00335     gtk_text_insert(textarea,current_state.style[current_state.flavor],current_state.has_color?&current_state.fore:NULL,NULL,current,marker-current);
00336     free(original);
00337     return current_state;
00338 }
00339 static void add_book(char *title, char *message) {
00340     GtkWidget *content,*label,*hbox, *scroll, *panel, *close, *closepic;
00341     prepare_book_window();
00342 
00343     content = gtk_text_new(NULL,NULL);
00344     gtk_text_set_editable(GTK_TEXT(content),FALSE);
00345     gtk_text_set_word_wrap(GTK_TEXT(content),FALSE);
00346     gtk_text_set_line_wrap(GTK_TEXT(content),TRUE);
00347     write_media(GTK_TEXT(content),message);
00348 
00349     panel = gtk_vbox_new(FALSE,0);
00350     close = gtk_button_new();
00351     closepic = gtk_pixmap_new (btnClose_pm, btnClose_bm);
00352     gtk_container_add(GTK_CONTAINER(close),closepic);
00353     gtk_box_pack_start (GTK_BOX (panel), close, FALSE, FALSE, 0);
00354 
00355     hbox=gtk_hbox_new(FALSE,0);
00356 
00357     gtk_box_pack_start (GTK_BOX (hbox), content, TRUE, TRUE, 0);
00358     scroll = gtk_vscrollbar_new(GTK_TEXT (content)->vadj);
00359     gtk_box_pack_start (GTK_BOX (hbox),scroll, FALSE, FALSE, 0);
00360     gtk_box_pack_start (GTK_BOX (panel), hbox, TRUE, TRUE, 0);
00361 
00362     label = gtk_label_new(title);
00363 /*    tab = gtk_hbox_new();*/
00364 /*    button_pic = gtk_pixmap_new(btnClose_pm, btnClose_bm);*/
00365 /*    button = gtk_button_new();*/
00366 
00367     gtk_notebook_append_page(GTK_NOTEBOOK(book_notes),panel,label);
00368     gtk_widget_show(content);
00369     gtk_widget_show(label);
00370     gtk_widget_show(close);
00371     gtk_widget_show(closepic);
00372     gtk_widget_show(panel);
00373     gtk_widget_show(book_root);
00374     gtk_widget_show(hbox);
00375     gtk_widget_show(scroll);
00376 
00377     gtk_notebook_set_page(GTK_NOTEBOOK(book_notes),gtk_notebook_page_num(GTK_NOTEBOOK(book_notes),panel));
00378     gdk_window_raise (book_root->window);
00379     gtk_widget_grab_focus (GTK_WIDGET(close));
00380     gtk_signal_connect_object (GTK_OBJECT (close), "clicked",
00381                    GTK_SIGNAL_FUNC(gtk_widget_destroy),
00382                    GTK_OBJECT (panel));
00383 
00384 }
00385 /* we need access to those when a sign is auto applied.
00386  * We don't want to show player a new window while his character
00387  * keeps running in background
00388  */
00389 extern GtkWidget* gtkwin_info_text;
00390 extern GtkWidget* gtkwin_info_text2;
00391 static void book_callback(int flag, int type, int subtype, char *message) {
00392     LOG(LOG_DEBUG,"gtk::book_callback","got callback %d subtype %d\n",type,subtype);
00393     if (message!=NULL){
00394         char* title = message;
00395         while ( (*message!='\0') && (*message!='\n') )
00396             message++;
00397         if (*message!='\0'){
00398             *message='\0';
00399             message++;
00400         }
00401         if (*message=='\0'){
00402             message=title;
00403             title=NO_TITLE;
00404         }
00405         if (!want_config[CONFIG_POPUPS]) /*autoapply*/{
00406             if (use_config[CONFIG_SPLITINFO])
00407                 write_media(GTK_TEXT(gtkwin_info_text2),message);
00408             else
00409                 write_media(GTK_TEXT(gtkwin_info_text),message);
00410         } else
00411             add_book(title,message);
00412 
00413     }
00414 }
00415 static char *last_motd = NULL;
00416 static void motd_callback(int flag, int type, int subtype, char *message) {
00417 
00418     free(last_motd);
00419     last_motd = malloc(strlen(message)+1);
00420     if (last_motd==NULL)
00421         LOG(LOG_ERROR,"gtk::motd_callback","Outa memory, no save of motd");
00422     else
00423         strcpy(last_motd,message);
00424 
00425     if (!want_config[CONFIG_POPUPS] || last_motd == NULL) {
00426         write_media(GTK_TEXT(gtkwin_info_text), message);
00427     }
00428 }
00429 static void void_callback(int flag, int type, int subtype, char *message) {
00430 
00431     LOG(LOG_INFO,"gtk::void_callback","got message --\n%s\n",message);
00432 
00433 }
00434 static void sign_callback(int color, int type, int subtype, char *message) {
00435     GtkWidget *window;
00436 
00437     if ( (subtype>4) || (subtype <1))
00438         subtype=1;
00439     if (message==NULL)
00440         return;
00441 
00442     if ((!want_config[CONFIG_POPUPS]) || (!want_config[CONFIG_SIGNPOPUP])) /*autoapply*/{
00443         if (use_config[CONFIG_SPLITINFO])
00444             write_media(GTK_TEXT(gtkwin_info_text2),message);
00445         else
00446             write_media(GTK_TEXT(gtkwin_info_text),message);
00447     }else{
00448         window=create_text_picture_window(&(sign_message[subtype-1]), message);
00449         gtk_window_set_transient_for(GTK_WINDOW(window),GTK_WINDOW(gtkwin_root));
00450         gtk_widget_show(window);
00451     }
00452 
00453 }
00454 const char *getMOTD(void) {
00455     return last_motd==NULL?"Please read motd written\nin [i]green[/i] inside main\nmessage window":last_motd;
00456 }
00457 static char *rules = NULL;
00458 news_entry* first_news = NULL;
00459 const char *get_rules(void) {
00460     return rules;
00461 }
00462 news_entry *get_news(void) {
00463     return first_news;
00464 }
00465 static void admin_callback(int flag, int type, int subtype, char *message) {
00466     char* str1;
00467     news_entry* new;
00468     switch (subtype){
00469         case MSG_TYPE_ADMIN_NEWS:
00470             str1 = strstr(message,"\n");
00471             if (str1){
00472                 *str1= '\0';
00473                 str1+=strlen("\n");
00474                 new = malloc(sizeof(news_entry));
00475                 if (new){
00476                     new->title= malloc(strlen(message)+1);
00477                     new->content=malloc(strlen(str1)+1);
00478                     if ( (!new->title) || (!new->content)){
00479                         free(new->title);
00480                         free(new->content);
00481                         LOG(LOG_ERROR,"gtk::admin_callback","Outa memory, no save of news");
00482                         free(new);
00483                         return;
00484                     }
00485                     strcpy(new->title,message);
00486                     strcpy(new->content,str1);
00487                     new->next=first_news;
00488                     first_news=new;
00489                     if (use_config[CONFIG_SPLITINFO])
00490                         write_media(GTK_TEXT(gtkwin_info_text2),str1);
00491                     write_media(GTK_TEXT(gtkwin_info_text),str1);
00492                 } else {
00493                     LOG(LOG_ERROR,"gtk::admin_callback","Outa memory, no save of news");
00494                 }
00495                 return;
00496             }
00497             break;
00498 
00499         case MSG_TYPE_ADMIN_RULES:
00500             free(rules);
00501             rules = malloc(strlen(message)+1);
00502             if (rules){
00503                 strcpy(rules,message);
00504                 if (use_config[CONFIG_SPLITINFO])
00505                     write_media(GTK_TEXT(gtkwin_info_text2),message);
00506                 write_media(GTK_TEXT(gtkwin_info_text),message);
00507             }
00508             else
00509                 LOG(LOG_ERROR,"gtk::admin_callback","Outa memory, no save of rules");
00510             return;
00511 
00512     }
00513     draw_info(message, flag);
00514 }
00515 void init_text_callbacks(void) {
00516     setTextManager(MSG_TYPE_BOOK,book_callback);
00517     setTextManager(MSG_TYPE_MOTD,motd_callback);
00518 /*    setTextManager(MSG_TYPE_MONUMENT,void_callback);*/
00519     setTextManager(MSG_TYPE_SIGN,sign_callback);
00520     setTextManager(MSG_TYPE_ADMIN,admin_callback);
00521 }
00522 void cleanup_textmanagers(void) {
00523     news_entry* last_entry;
00524     free(last_motd);
00525     last_motd=NULL;
00526     free(rules);
00527     rules = NULL;
00528     last_entry= first_news;
00529     while (last_entry){
00530         first_news=last_entry->next;
00531         free(last_entry->content);
00532         free(last_entry->title);
00533         free(last_entry);
00534         last_entry=first_news;
00535     }
00536 
00537 }