31 static void my_log(
heraia_struct_t *main_struct, gchar *log_domain, GLogLevelFlags log_level,
const char *format, ...);
48 gchar *str_utf8 = NULL;
51 g_return_if_fail (format != NULL);
53 va_start(args, format);
54 str = g_strdup_vprintf(format, args);
57 str_utf8 = g_locale_to_utf8(str, -1, NULL, NULL, &err);
61 fputs(str_utf8, stdout);
66 fprintf(stderr, Q_(
"Can't convert output to the locale: %s\n"), err->message);
87 static void my_log(
heraia_struct_t *main_struct, gchar *log_domain, GLogLevelFlags log_level,
const char *format, ...)
91 gchar *display = NULL;
93 GtkTextBuffer *tb = NULL;
96 va_start(args, format);
97 str = g_strdup_vprintf(format, args);
102 case G_LOG_FLAG_RECURSION:
103 display = g_strdup_printf(Q_(
"%s - RECURSION: %s\n%c"), log_domain, str,
'\0');
104 g_print(
"%s\n", display);
108 case G_LOG_FLAG_FATAL:
109 display = g_strdup_printf(Q_(
"%s - FATAL: %s\n%c"), log_domain, str,
'\0');
110 g_print(
"%s\n", display);
114 case G_LOG_LEVEL_ERROR:
115 display = g_strdup_printf(Q_(
"%s - ERROR: %s\n%c"), log_domain, str,
'\0');
116 g_print(
"%s\n", display);
120 case G_LOG_LEVEL_CRITICAL:
121 display = g_strdup_printf(Q_(
"%s - CRITICAL: %s\n%c"), log_domain, str,
'\0');
124 case G_LOG_LEVEL_WARNING:
125 display = g_strdup_printf(Q_(
"%s - WARNING: %s\n%c"), log_domain, str,
'\0');
128 case G_LOG_LEVEL_MESSAGE:
129 display = g_strdup_printf(Q_(
"%s - MESSAGE: %s\n%c"), log_domain, str,
'\0');
132 case G_LOG_LEVEL_INFO:
133 display = g_strdup_printf(Q_(
"%s - INFO: %s\n%c"), log_domain, str,
'\0');
136 case G_LOG_LEVEL_DEBUG:
137 display = g_strdup_printf(Q_(
"%s - DEBUG: %s\n%c"), log_domain, str,
'\0');
140 case G_LOG_LEVEL_MASK:
144 g_print(
"%s", display);
147 tb = GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(logw_textview)));
149 gtk_text_buffer_get_end_iter(tb, &iStart);
150 gtk_text_buffer_insert(tb, &iStart, display, -1);
166 GtkTextView *logw_textview = NULL;
167 GtkTextBuffer *tb = NULL;
169 GtkTextMark *mark = NULL;
172 tb = GTK_TEXT_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(logw_textview)));
174 gtk_text_buffer_get_end_iter(tb, &end);
175 gtk_text_iter_set_line_offset(&end, 0);
176 mark = gtk_text_buffer_get_mark(tb,
"scroll");
177 gtk_text_buffer_move_mark(tb, mark, &end);
178 gtk_text_view_scroll_mark_onscreen(logw_textview, mark);
201 gchar *str_time = NULL;
202 gchar *str_time_utf8 = NULL;
203 gchar *str_utf8 = NULL;
204 GTimeVal *time = NULL;
207 if (!(main_struct->
debug == FALSE && log_level == G_LOG_LEVEL_DEBUG))
209 g_return_if_fail(format != NULL);
211 va_start(args, format);
212 str = g_strdup_vprintf(format, args);
214 str_utf8 = g_locale_to_utf8(str, -1, NULL, NULL, &err);
216 time = (GTimeVal *) g_malloc0 (
sizeof(GTimeVal));
217 g_get_current_time(time);
218 str_time = g_time_val_to_iso8601(time);
219 str_time_utf8 = g_locale_to_utf8(str_time, -1, NULL, NULL, &err);
248 g_free(str_time_utf8);
266 GtkWidget *cmi = NULL;
267 gboolean checked = FALSE;
268 GtkWidget *log_dialog = NULL;
273 checked = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(cmi));
327 GtkWidget *cmi = NULL;
328 GtkWidget *log_dialog = NULL;
330 if (main_struct != NULL && main_struct->
xmls != NULL && main_struct->
xmls->
main != NULL)
336 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(cmi), FALSE);
349 if (main_struct != NULL && main_struct->
xmls != NULL && main_struct->
xmls->
main != NULL)
378 GtkTextView *logw_textview = NULL;
379 GtkTextBuffer *tb = NULL;
383 if (main_struct != NULL)
389 if (main_struct->
xmls != NULL && main_struct->
xmls->
main != NULL)
392 tb = gtk_text_view_get_buffer(logw_textview);
393 gtk_text_buffer_get_end_iter(tb, &iStart);
394 gtk_text_buffer_create_mark(tb,
"scroll", &iStart, TRUE);
static void destroy_log_window(GtkWidget *widget, GdkEvent *event, gpointer data)
When the window is destroyed (Gtk's doc says that we may never get there)
This is the main structure.
#define HERAIA_LOG_DOMAIN
Defines heraia log domain (the one printed out on the logging window)
static void log_window_connect_signals(heraia_struct_t *main_struct)
Connecting the window signals to the right functions.
void print_message(const char *format,...)
Prints a message to stdout.
void record_and_hide_dialog_box(GtkWidget *dialog_box, window_prop_t *dialog_prop)
Record position and hide a dialog box.
all_window_prop_t * win_prop
Keeps window properties.
void log_message(heraia_struct_t *main_struct, GLogLevelFlags log_level, const char *format,...)
A function that helps logging a message a the specified level.
static void logw_close_clicked(GtkWidget *widget, gpointer data)
Close button is clicked.
xml_t * xmls
All the xmls used in the program, loaded at running time.
gboolean debug
Used to tell the program wether we want to display debug messages or not.
static void my_log(heraia_struct_t *main_struct, gchar *log_domain, GLogLevelFlags log_level, const char *format,...)
A function that allow me to printy things on stdout and in th log window.
void mw_cmi_show_logw_toggle(GtkWidget *widget, gpointer data)
The Check menu item for the Log window.
GtkBuilder * main
the main interface xml description
void move_and_show_dialog_box(GtkWidget *dialog_box, window_prop_t *dialog_prop)
Move the dialog box to the wanted position, shows it and says it in the displayed prop...
void log_window_init_interface(heraia_struct_t *main_struct)
Inits the log window interface Called once at init time.
static void scroll_down_textview(heraia_struct_t *main_struct)
Scrolling down to the new line at the end of the textview.
window_prop_t * log_box
log window
This file contains all the definitions and includes all other .h files.
GtkWidget * heraia_get_widget(GtkBuilder *xml, gchar *widget_name)
This is a wrapper to the GtkBuilder xml get widget.
static gboolean delete_log_window_event(GtkWidget *widget, GdkEvent *event, gpointer data)
Closing the window.