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 * Conversion parameters: 26 * inFile = glib-Warnings-and-Assertions.html 27 * outPack = glib 28 * outFile = Messages 29 * strct = 30 * realStrct= 31 * ctorStrct= 32 * clss = Messages 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * - glib.Str 47 * structWrap: 48 * module aliases: 49 * local aliases: 50 * overrides: 51 */ 52 53 module glib.Messages; 54 55 public import gtkc.glibtypes; 56 57 private import gtkc.glib; 58 private import glib.ConstructionException; 59 60 61 private import glib.Str; 62 63 64 65 66 /** 67 * Description 68 * These functions provide support for outputting messages. 69 * The g_return family of macros (g_return_if_fail(), 70 * g_return_val_if_fail(), g_return_if_reached(), g_return_val_if_reached()) 71 * should only be used for programming errors, a typical use case is 72 * checking for invalid parameters at the beginning of a public function. 73 * They should not be used if you just mean "if (error) return", they 74 * should only be used if you mean "if (bug in program) return". 75 * The program behavior is generally considered undefined after one of these 76 * checks fails. They are not intended for normal control flow, only to 77 * give a perhaps-helpful warning before giving up. 78 */ 79 public class Messages 80 { 81 82 /** 83 */ 84 85 /** 86 * Sets the print handler. 87 * Any messages passed to g_print() will be output via the new handler. 88 * The default handler simply outputs the message to stdout. 89 * By providing your own handler you can redirect the output, to a GTK+ 90 * widget or a log file for example. 91 * Params: 92 * func = the new print handler. 93 * Returns: the old print handler. 94 */ 95 public static GPrintFunc setPrintHandler(GPrintFunc func) 96 { 97 // GPrintFunc g_set_print_handler (GPrintFunc func); 98 return g_set_print_handler(func); 99 } 100 101 /** 102 * Sets the handler for printing error messages. 103 * Any messages passed to g_printerr() will be output via the new handler. 104 * The default handler simply outputs the message to stderr. 105 * By providing your own handler you can redirect the output, to a GTK+ 106 * widget or a log file for example. 107 * Params: 108 * func = the new error message handler. 109 * Returns: the old error message handler. 110 */ 111 public static GPrintFunc setPrinterrHandler(GPrintFunc func) 112 { 113 // GPrintFunc g_set_printerr_handler (GPrintFunc func); 114 return g_set_printerr_handler(func); 115 } 116 117 /** 118 * Prompts the user with [E]xit, [H]alt, show [S]tack trace or [P]roceed. 119 * This function is intended to be used for debugging use only. The following 120 * example shows how it can be used together with the g_log() functions. 121 * $(DDOC_COMMENT example) 122 * If [E]xit is selected, the application terminates with a call to 123 * _exit(0). 124 * If [H]alt is selected, the application enters an infinite loop. 125 * The infinite loop can only be stopped by killing the application, 126 * or by setting glib_on_error_halt to FALSE (possibly via a debugger). 127 * If [S]tack trace is selected, g_on_error_stack_trace() is called. This 128 * invokes gdb, which attaches to the current process and shows a stack trace. 129 * The prompt is then shown again. 130 * If [P]roceed is selected, the function returns. 131 * This function may cause different actions on non-UNIX platforms. 132 * Params: 133 * prgName = the program name, needed by gdb for the [S]tack trace option. 134 * If prg_name is NULL, g_get_prgname() is called to get the program name 135 * (which will work correctly if gdk_init() or gtk_init() has been called). 136 */ 137 public static void onErrorQuery(string prgName) 138 { 139 // void g_on_error_query (const gchar *prg_name); 140 g_on_error_query(Str.toStringz(prgName)); 141 } 142 143 /** 144 * Invokes gdb, which attaches to the current process and shows a stack trace. 145 * Called by g_on_error_query() when the [S]tack trace option is selected. 146 * This function may cause different actions on non-UNIX platforms. 147 * Params: 148 * prgName = the program name, needed by gdb for the [S]tack trace option. 149 * If prg_name is NULL, g_get_prgname() is called to get the program name 150 * (which will work correctly if gdk_init() or gtk_init() has been called). 151 */ 152 public static void onErrorStackTrace(string prgName) 153 { 154 // void g_on_error_stack_trace (const gchar *prg_name); 155 g_on_error_stack_trace(Str.toStringz(prgName)); 156 } 157 }