/* append a string to a GtkTextBuffer */ void gtkui_details_print(GtkTextBuffer *textbuf, char *data) { GtkTextIter iter; gchar *unicode; if((unicode = gtkui_utf8_validate(data)) == NULL) return; gtk_text_buffer_get_end_iter(textbuf, &iter); gtk_text_buffer_insert(textbuf, &iter, unicode, -1); }
/* * print a USER_MSG() extracting it from the queue */ static void gtkui_msg(const char *msg) { GtkTextIter iter; gchar *unicode = NULL; DEBUG_MSG("gtkui_msg: %s", msg); if((unicode = gtkui_utf8_validate((char *)msg)) == NULL) return; gtk_text_buffer_get_end_iter(msgbuffer, &iter); gtk_text_buffer_insert(msgbuffer, &iter, unicode, -1); gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW (textview), endmark, 0, FALSE, 0, 0); return; }
/* int color - 2 for blue text (used in joined view) */ static void gtkui_data_print(int buffer, char *data, int color) { GtkTextIter iter; GtkTextBuffer *textbuf = NULL; GtkWidget *textview = NULL; GtkTextMark *endmark = NULL; char *unicode = NULL; switch(buffer) { case 1: textbuf = splitbuf1; textview = textview1; endmark = endmark1; break; case 2: textbuf = splitbuf2; textview = textview2; endmark = endmark2; break; case 3: textbuf = joinedbuf; textview = textview3; endmark = endmark3; break; default: return; } /* make sure data is valid UTF8 */ unicode = gtkui_utf8_validate(data); /* if interface has been destroyed or unicode conversion failed */ if(!data_window || !textbuf || !textview || !endmark || !unicode) return; gtk_text_buffer_get_end_iter(textbuf, &iter); if(color == 2) gtk_text_buffer_insert_with_tags_by_name(textbuf, &iter, unicode, -1, "blue_fg", "monospace", NULL); else gtk_text_buffer_insert_with_tags_by_name(textbuf, &iter, unicode, -1, "monospace", NULL); gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW (textview), endmark, 0, FALSE, 0, 0); }
/* * print an error */ static void gtkui_error(const char *msg) { GtkWidget *dialog; gchar *unicode = NULL; DEBUG_MSG("gtkui_error: %s", msg); if((unicode = gtkui_utf8_validate((char *)msg)) == NULL) return; dialog = gtk_message_dialog_new(GTK_WINDOW (window), GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", unicode); gtk_window_set_position(GTK_WINDOW (dialog), GTK_WIN_POS_CENTER); /* blocking - displays dialog waits for user to click OK */ gtk_dialog_run(GTK_DIALOG (dialog)); gtk_widget_destroy(dialog); return; }