2 "$Id: text.c 9190 2008-06-01 08:53:05Z anmaster $";
30 #include <gdk/gdkwin32.h>
37 #include "pixmaps/sign_flat.xpm"
38 #include "pixmaps/sign_west.xpm"
39 #include "pixmaps/sign_east.xpm"
40 #include "pixmaps/close.xpm"
48 const char *
const *
xpm;
60 {
"sign",sign_flat_xpm,70,45,390,305,500,500,NULL},
61 {
"left sign",sign_west_xpm,95,85,615,190,750,400,NULL},
62 {
"right sign",sign_east_xpm,45,85,615,190,750,400,NULL},
63 {
"direction sign",sign_flat_xpm,70,45,390,305,500,500,NULL} };
67 >k_widget_get_style(refWindow)->bg[GTK_STATE_NORMAL],
72 book_root= gtk_window_new (GTK_WINDOW_TOPLEVEL);
73 gtk_window_set_title(GTK_WINDOW(
book_root),
"books");
75 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(
book_notes),GTK_POS_LEFT);
80 gtk_signal_connect (GTK_OBJECT (
book_root),
"destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &
book_root);
81 gtk_window_set_default_size(GTK_WINDOW(
book_root),500,600);
82 gtk_window_set_position(GTK_WINDOW(
book_root),GTK_WIN_POS_CENTER);
86 GtkWidget *window, *content, *fixed, *scroll, *close;
87 window = gtk_window_new (GTK_WINDOW_DIALOG);
88 gtk_window_set_title(GTK_WINDOW(window),layout->
title);
89 gtk_widget_set_app_paintable(window,
TRUE);
90 gtk_widget_realize(window);
93 layout->
picture = gdk_pixmap_create_from_xpm_d(window->window,NULL,
94 >k_widget_get_style(window)->bg[GTK_STATE_NORMAL],
95 (gchar**)layout->
xpm);
97 gdk_window_set_back_pixmap(window->window,layout->
picture,
FALSE);
98 content = gtk_text_new(NULL,NULL);
99 gtk_text_set_editable(GTK_TEXT(content),
FALSE);
100 gtk_text_set_word_wrap(GTK_TEXT(content),
TRUE);
101 gtk_text_set_line_wrap(GTK_TEXT(content),
TRUE);
104 gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
105 fixed=gtk_fixed_new();
106 gtk_widget_set_app_paintable(fixed,
TRUE);
107 gtk_container_add(GTK_CONTAINER(window),fixed);
108 gtk_widget_realize(fixed);
109 gdk_window_set_back_pixmap(fixed->window,layout->
picture,
TRUE);
111 scroll = gtk_scrolled_window_new (NULL, NULL);
112 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
113 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
114 gtk_widget_show (scroll);
115 gtk_widget_set_usize(scroll,layout->
width,layout->
height);
116 gtk_fixed_put(GTK_FIXED(fixed),scroll,layout->
x,layout->
y);
117 close=gtk_button_new();
118 gtk_widget_set_usize(close,0,0);
119 gtk_fixed_put(GTK_FIXED(fixed),close,0,0);
120 gtk_widget_show(fixed);
121 gtk_widget_show(content);
123 gtk_container_add(GTK_CONTAINER(scroll),content);
124 gtk_text_set_adjustments(GTK_TEXT(content),
126 gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll))
129 gtk_signal_connect_object (GTK_OBJECT (close),
"clicked",
130 GTK_SIGNAL_FUNC(gtk_widget_destroy),
131 GTK_OBJECT (window));
132 gtk_widget_grab_focus (GTK_WIDGET(close));
136 GtkWidget *window, *scroll, *content;
137 window = gtk_window_new (GTK_WINDOW_DIALOG);
138 gtk_window_set_title(GTK_WINDOW(window),message);
139 gtk_window_set_default_size(GTK_WINDOW(window),500,500);
140 gtk_window_set_position(GTK_WINDOW(window),GTK_WIN_POS_CENTER);
142 content = gtk_text_new(NULL,NULL);
143 gtk_text_set_editable(GTK_TEXT(content),
FALSE);
144 gtk_text_set_word_wrap(GTK_TEXT(content),
TRUE);
145 gtk_text_set_line_wrap(GTK_TEXT(content),
TRUE);
147 gtk_widget_show(content);
149 scroll = gtk_scrolled_window_new (NULL, NULL);
150 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
151 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
152 gtk_container_add(GTK_CONTAINER(scroll),content);
153 gtk_text_set_adjustments(GTK_TEXT(content),
155 gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scroll))
158 gtk_widget_show(content);
159 gtk_widget_show (scroll);
160 gtk_widget_show (window);
167 "-*-cuneifontlight-*-r-*-*-*-120-*-*-*-*-iso8859-*",
168 "-*-linotext-*-r-*-*-*-120-*-*-*-*-iso8859-*",
169 "-*-blackforest-*-r-*-*-*-120-*-*-*-*-iso8859-*",
170 "-*-becker-*-*-*-*-*-120-*-*-*-*-iso8859-*",
171 "-*-arnoldboecklin-*-r-*-*-*-120-*-*-*-*-iso8859-*",
172 "-*-caligula-*-*-*-*-*-120-*-*-*-*-iso8859-*",
176 "-*-dobkinscript-*-r-*-*-*-120-*-*-*-*-iso8859-*",
177 "-*-coronetscript-*-r-*-*-*-120-*-*-*-*-iso8859-*",
178 "-*-muriel-*-r-*-*-*-120-*-*-*-*-iso8859-*",
179 "-*-genoa-*-r-*-*-*-120-*-*-*-*-iso8859-*",
180 "-*-parkavenue-*-r-*-*-*-120-*-*-*-*-iso8859-*",
181 "-*-rechtmanscript-*-r-*-*-*-120-*-*-*-*-iso8859-*",
185 "-*-annstone-*-r-*-*-*-120-*-*-*-*-iso8859-*",
186 "-*-shalomstick-*-r-*-*-*-120-*-*-*-*-iso8859-*",
191 "-*-arial-medium-r-*-*-*-120-*-*-*-*-iso8859-*",
192 "-*-bookman-light-r-*-*-*-120-*-*-*-*-iso8859-*",
193 "-*-agate-normal-r-*-*-*-120-*-*-*-*-iso8859-*",
197 "-*-arial-bold-r-*-*-*-120-*-*-*-*-iso8859-*",
198 "-*-bookman-demi-r-*-*-*-120-*-*-*-*-iso8859-*",
199 "-*-agate-bold-r-*-*-*-120-*-*-*-*-iso8859-*",
203 "-*-arial-medium-i-*-*-*-120-*-*-*-*-iso8859-*",
204 "-*-bookman-light-i-*-*-*-120-*-*-*-*-iso8859-*",
205 "-*-agate-normal-i-*-*-*-120-*-*-*-*-iso8859-*",
209 "-*-arial-bold-i-*-*-*-120-*-*-*-*-iso8859-*",
210 "-*-bookman-demi-i-*-*-*-120-*-*-*-*-iso8859-*",
211 "-*-agate-bold-i-*-*-*-120-*-*-*-*-iso8859-*",
215 "-*-fixed-medium-r-*-*-*-120-*-*-*-*-iso8859-*",
216 "-*-courrier-medium-*-*-*-*-120-*-*-*-*-iso8859-*",
217 "-*-andale mono-medium-*-*-*-*-120-*-*-*-*-iso8859-*",
221 "-*-fixed-bold-r-*-*-*-120-*-*-*-*-iso8859-*",
222 "-*-courrier-bold-*-*-*-*-120-*-*-*-*-iso8859-*",
223 "-*-andale mono-medium-*-*-*-*-120-*-*-*-*-iso8859-*",
227 "-*-fixed-medium-o-*-*-*-120-*-*-*-*-iso8859-*",
228 "-*-courrier-medium-o-*-*-*-120-*-*-*-*-iso8859-*",
229 "-*-andale mono-medium-*-*-*-*-120-*-*-*-*-iso8859-*",
233 "-*-fixed-bold-i-*-*-*-120-*-*-*-*-iso8859-*",
234 "-*-courrier-bold-o-*-*-*-120-*-*-*-*-iso8859-*",
235 "-*-andale mono-*-*-*-*-*-120-*-*-*-*-iso8859-*",
241 for (i=0; font_list[i]!=NULL;i++){
242 result = gdk_font_load(font_list[i]);
244 LOG(
LOG_INFO,
"gtk::load_a_font",
"Loaded font %s.",font_list[i]);
256 #define STYLE_ITALIC 2
291 char *current, *marker, *original;
293 return current_state;
295 current=malloc(strlen(message)+1);
297 LOG(
LOG_ERROR,
"gtk::write_media",
"couldn't alloc memory for string manipualtion. Dropping media\n");
298 return current_state;
300 strcpy(current,message);
302 while( (marker=strchr(current,
'['))!=NULL){
304 gtk_text_insert(textarea,current_state.
style[current_state.
flavor],current_state.
has_color?¤t_state.
fore:NULL,NULL,current,marker-current);
306 if ( (marker = strchr(current,
']')) ==NULL)
307 return current_state;
309 if (!strcmp(current,
"b"))
311 else if (!strcmp(current,
"i"))
313 else if (!strcmp(current,
"/b"))
315 else if (!strcmp(current,
"/i"))
317 else if (!strcmp(current,
"/color"))
319 else if (!strncmp(current,
"color=",6))
320 current_state.
has_color = gdk_color_parse(current+6,¤t_state.
fore);
321 else if (!strcmp(current,
"fixed"))
323 else if (!strcmp(current,
"arcane"))
325 else if (!strcmp(current,
"hand"))
327 else if (!strcmp(current,
"strange"))
329 else if (!strcmp(current,
"print"))
332 LOG(
LOG_INFO,
"gtk::write_media_with_state",
"unidentified message: %s",current);
335 gtk_text_insert(textarea,current_state.
style[current_state.
flavor],current_state.
has_color?¤t_state.
fore:NULL,NULL,current,marker-current);
337 return current_state;
340 GtkWidget *content,*label,*hbox, *scroll, *panel, *close, *closepic;
343 content = gtk_text_new(NULL,NULL);
344 gtk_text_set_editable(GTK_TEXT(content),
FALSE);
345 gtk_text_set_word_wrap(GTK_TEXT(content),
FALSE);
346 gtk_text_set_line_wrap(GTK_TEXT(content),
TRUE);
349 panel = gtk_vbox_new(
FALSE,0);
350 close = gtk_button_new();
352 gtk_container_add(GTK_CONTAINER(close),closepic);
353 gtk_box_pack_start (GTK_BOX (panel), close,
FALSE,
FALSE, 0);
355 hbox=gtk_hbox_new(
FALSE,0);
357 gtk_box_pack_start (GTK_BOX (hbox), content,
TRUE,
TRUE, 0);
358 scroll = gtk_vscrollbar_new(GTK_TEXT (content)->vadj);
359 gtk_box_pack_start (GTK_BOX (hbox),scroll,
FALSE,
FALSE, 0);
360 gtk_box_pack_start (GTK_BOX (panel), hbox,
TRUE,
TRUE, 0);
362 label = gtk_label_new(title);
367 gtk_notebook_append_page(GTK_NOTEBOOK(
book_notes),panel,label);
368 gtk_widget_show(content);
369 gtk_widget_show(label);
370 gtk_widget_show(close);
371 gtk_widget_show(closepic);
372 gtk_widget_show(panel);
374 gtk_widget_show(hbox);
375 gtk_widget_show(scroll);
377 gtk_notebook_set_page(GTK_NOTEBOOK(
book_notes),gtk_notebook_page_num(GTK_NOTEBOOK(
book_notes),panel));
379 gtk_widget_grab_focus (GTK_WIDGET(close));
380 gtk_signal_connect_object (GTK_OBJECT (close),
"clicked",
381 GTK_SIGNAL_FUNC(gtk_widget_destroy),
392 LOG(
LOG_DEBUG,
"gtk::book_callback",
"got callback %d subtype %d\n",type,subtype);
394 char* title = message;
395 while ( (*message!=
'\0') && (*message!=
'\n') )
421 LOG(
LOG_ERROR,
"gtk::motd_callback",
"Outa memory, no save of motd");
431 LOG(
LOG_INFO,
"gtk::void_callback",
"got message --\n%s\n",message);
434 static void sign_callback(
int color,
int type,
int subtype,
char *message) {
437 if ( (subtype>4) || (subtype <1))
449 gtk_window_set_transient_for(GTK_WINDOW(window),GTK_WINDOW(
gtkwin_root));
450 gtk_widget_show(window);
455 return last_motd==NULL?
"Please read motd written\nin [i]green[/i] inside main\nmessage window":
last_motd;
470 str1 = strstr(message,
"\n");
476 new->title= malloc(strlen(message)+1);
477 new->content=malloc(strlen(str1)+1);
478 if ( (!new->title) || (!new->content)){
481 LOG(
LOG_ERROR,
"gtk::admin_callback",
"Outa memory, no save of news");
485 strcpy(new->title,message);
486 strcpy(new->content,str1);
493 LOG(
LOG_ERROR,
"gtk::admin_callback",
"Outa memory, no save of news");
501 rules = malloc(strlen(message)+1);
503 strcpy(
rules,message);
509 LOG(
LOG_ERROR,
"gtk::admin_callback",
"Outa memory, no save of rules");
530 first_news=last_entry->
next;
532 free(last_entry->
title);
static GdkFont * style_hand[4]
const char * getMOTD(void)
static GtkWidget * create_text_picture_window(picture_message *layout, char *message)
void init_text_callbacks(void)
static const char *const hand_medium_fontname[]
static const char *const arcane_medium_fontname[]
static GdkFont * load_a_font(const char *const font_list[])
void setTextManager(int type, ExtTextManager callback)
static void init_pictures(GtkWidget *refWindow)
static picture_message sign_message[]
static GdkFont * style_fixed[4]
sint16 want_config[CONFIG_NUMS]
#define MSG_TYPE_ADMIN_RULES
static GdkFont * style_print[4]
static void admin_callback(int flag, int type, int subtype, char *message)
static const char *const strange_medium_fontname[]
static GdkFont * style_arcane[4]
void LOG(LogLevel level, const char *origin, const char *format,...)
const char *const rcsid_gtk_text_c
sint16 use_config[CONFIG_NUMS]
static const char *const print_italic_fontname[]
static const char *const fixed_italic_fontname[]
static const char *const fixed_italicbold_fontname[]
struct picture_message_struct picture_message
static const char *const fixed_bold_fontname[]
news_entry * get_news(void)
void cleanup_textmanagers(void)
static void sign_callback(int color, int type, int subtype, char *message)
static const char *const print_bold_fontname[]
media_state write_media_with_state(GtkText *textarea, const char *message, media_state current_state)
static GdkFont * style_strange[4]
static const char *const print_italicbold_fontname[]
static void add_book(char *title, char *message)
static void prepare_book_window(void)
static void book_callback(int flag, int type, int subtype, char *message)
static void show_media_message(const char *title, const char *message)
GtkWidget * gtkwin_info_text2
media_state write_media(GtkText *textarea, const char *message)
static void void_callback(int flag, int type, int subtype, char *message)
const char * get_rules(void)
void draw_info(const char *str, int color)
#define MSG_TYPE_ADMIN_NEWS
static void motd_callback(int flag, int type, int subtype, char *message)
static const char *const fixed_medium_fontname[]
static const char *const print_medium_fontname[]
static void init_fonts(void)
GtkWidget * gtkwin_info_text