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 public import gtkc.glibtypes; 31 32 33 /** */ 34 public struct Messages 35 { 36 37 /** 38 * Prompts the user with 39 * `[E]xit, [H]alt, show [S]tack trace or [P]roceed`. 40 * This function is intended to be used for debugging use only. 41 * The following example shows how it can be used together with 42 * the g_log() functions. 43 * 44 * |[<!-- language="C" --> 45 * #include <glib.h> 46 * 47 * static void 48 * log_handler (const gchar *log_domain, 49 * GLogLevelFlags log_level, 50 * const gchar *message, 51 * gpointer user_data) 52 * { 53 * g_log_default_handler (log_domain, log_level, message, user_data); 54 * 55 * g_on_error_query (MY_PROGRAM_NAME); 56 * } 57 * 58 * int 59 * main (int argc, char *argv[]) 60 * { 61 * g_log_set_handler (MY_LOG_DOMAIN, 62 * G_LOG_LEVEL_WARNING | 63 * G_LOG_LEVEL_ERROR | 64 * G_LOG_LEVEL_CRITICAL, 65 * log_handler, 66 * NULL); 67 * ... 68 * ]| 69 * 70 * If "[E]xit" is selected, the application terminates with a call 71 * to _exit(0). 72 * 73 * If "[S]tack" trace is selected, g_on_error_stack_trace() is called. 74 * This invokes gdb, which attaches to the current process and shows 75 * a stack trace. The prompt is then shown again. 76 * 77 * If "[P]roceed" is selected, the function returns. 78 * 79 * This function may cause different actions on non-UNIX platforms. 80 * 81 * On Windows consider using the `G_DEBUGGER` environment 82 * variable (see [Running GLib Applications](glib-running.html)) and 83 * calling g_on_error_stack_trace() instead. 84 * 85 * Params: 86 * prgName = the program name, needed by gdb for the "[S]tack trace" 87 * option. If @prg_name is %NULL, g_get_prgname() is called to get 88 * the program name (which will work correctly if gdk_init() or 89 * gtk_init() has been called) 90 */ 91 public static void onErrorQuery(string prgName) 92 { 93 g_on_error_query(Str.toStringz(prgName)); 94 } 95 96 /** 97 * Invokes gdb, which attaches to the current process and shows a 98 * stack trace. Called by g_on_error_query() when the "[S]tack trace" 99 * option is selected. You can get the current process's program name 100 * with g_get_prgname(), assuming that you have called gtk_init() or 101 * gdk_init(). 102 * 103 * This function may cause different actions on non-UNIX platforms. 104 * 105 * When running on Windows, this function is *not* called by 106 * g_on_error_query(). If called directly, it will raise an 107 * exception, which will crash the program. If the `G_DEBUGGER` environment 108 * variable is set, a debugger will be invoked to attach and 109 * handle that exception (see [Running GLib Applications](glib-running.html)). 110 * 111 * Params: 112 * prgName = the program name, needed by gdb for the "[S]tack trace" 113 * option 114 */ 115 public static void onErrorStackTrace(string prgName) 116 { 117 g_on_error_stack_trace(Str.toStringz(prgName)); 118 } 119 120 /** 121 * Sets the print handler. 122 * 123 * Any messages passed to g_print() will be output via 124 * the new handler. The default handler simply outputs 125 * the message to stdout. By providing your own handler 126 * you can redirect the output, to a GTK+ widget or a 127 * log file for example. 128 * 129 * Params: 130 * func = the new print handler 131 * 132 * Returns: the old print handler 133 */ 134 public static GPrintFunc setPrintHandler(GPrintFunc func) 135 { 136 return g_set_print_handler(func); 137 } 138 139 /** 140 * Sets the handler for printing error messages. 141 * 142 * Any messages passed to g_printerr() will be output via 143 * the new handler. The default handler simply outputs the 144 * message to stderr. By providing your own handler you can 145 * redirect the output, to a GTK+ widget or a log file for 146 * example. 147 * 148 * Params: 149 * func = the new error message handler 150 * 151 * Returns: the old error message handler 152 */ 153 public static GPrintFunc setPrinterrHandler(GPrintFunc func) 154 { 155 return g_set_printerr_handler(func); 156 } 157 }