1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 25 module glib.Messages; 26 27 private import glib.Str; 28 private import glib.c.functions; 29 public import glib.c.types; 30 31 32 /** */ 33 public struct Messages 34 { 35 36 /** 37 * Prompts the user with 38 * `[E]xit, [H]alt, show [S]tack trace or [P]roceed`. 39 * This function is intended to be used for debugging use only. 40 * The following example shows how it can be used together with 41 * the g_log() functions. 42 * 43 * |[<!-- language="C" --> 44 * #include <glib.h> 45 * 46 * static void 47 * log_handler (const gchar *log_domain, 48 * GLogLevelFlags log_level, 49 * const gchar *message, 50 * gpointer user_data) 51 * { 52 * g_log_default_handler (log_domain, log_level, message, user_data); 53 * 54 * g_on_error_query (MY_PROGRAM_NAME); 55 * } 56 * 57 * int 58 * main (int argc, char *argv[]) 59 * { 60 * g_log_set_handler (MY_LOG_DOMAIN, 61 * G_LOG_LEVEL_WARNING | 62 * G_LOG_LEVEL_ERROR | 63 * G_LOG_LEVEL_CRITICAL, 64 * log_handler, 65 * NULL); 66 * ... 67 * ]| 68 * 69 * If "[E]xit" is selected, the application terminates with a call 70 * to _exit(0). 71 * 72 * If "[S]tack" trace is selected, g_on_error_stack_trace() is called. 73 * This invokes gdb, which attaches to the current process and shows 74 * a stack trace. The prompt is then shown again. 75 * 76 * If "[P]roceed" is selected, the function returns. 77 * 78 * This function may cause different actions on non-UNIX platforms. 79 * 80 * On Windows consider using the `G_DEBUGGER` environment 81 * variable (see [Running GLib Applications](glib-running.html)) and 82 * calling g_on_error_stack_trace() instead. 83 * 84 * Params: 85 * prgName = the program name, needed by gdb for the "[S]tack trace" 86 * option. If @prg_name is %NULL, g_get_prgname() is called to get 87 * the program name (which will work correctly if gdk_init() or 88 * gtk_init() has been called) 89 */ 90 public static void onErrorQuery(string prgName) 91 { 92 g_on_error_query(Str.toStringz(prgName)); 93 } 94 95 /** 96 * Invokes gdb, which attaches to the current process and shows a 97 * stack trace. Called by g_on_error_query() when the "[S]tack trace" 98 * option is selected. You can get the current process's program name 99 * with g_get_prgname(), assuming that you have called gtk_init() or 100 * gdk_init(). 101 * 102 * This function may cause different actions on non-UNIX platforms. 103 * 104 * When running on Windows, this function is *not* called by 105 * g_on_error_query(). If called directly, it will raise an 106 * exception, which will crash the program. If the `G_DEBUGGER` environment 107 * variable is set, a debugger will be invoked to attach and 108 * handle that exception (see [Running GLib Applications](glib-running.html)). 109 * 110 * Params: 111 * prgName = the program name, needed by gdb for the "[S]tack trace" 112 * option 113 */ 114 public static void onErrorStackTrace(string prgName) 115 { 116 g_on_error_stack_trace(Str.toStringz(prgName)); 117 } 118 119 /** 120 * Sets the print handler. 121 * 122 * Any messages passed to g_print() will be output via 123 * the new handler. The default handler simply outputs 124 * the message to stdout. By providing your own handler 125 * you can redirect the output, to a GTK+ widget or a 126 * log file for example. 127 * 128 * Params: 129 * func = the new print handler 130 * 131 * Returns: the old print handler 132 */ 133 public static GPrintFunc setPrintHandler(GPrintFunc func) 134 { 135 return g_set_print_handler(func); 136 } 137 138 /** 139 * Sets the handler for printing error messages. 140 * 141 * Any messages passed to g_printerr() will be output via 142 * the new handler. The default handler simply outputs the 143 * message to stderr. By providing your own handler you can 144 * redirect the output, to a GTK+ widget or a log file for 145 * example. 146 * 147 * Params: 148 * func = the new error message handler 149 * 150 * Returns: the old error message handler 151 */ 152 public static GPrintFunc setPrinterrHandler(GPrintFunc func) 153 { 154 return g_set_printerr_handler(func); 155 } 156 }