On Thu, May 10, 2012 at 04:45:09PM -0800, Christopher Howard wrote: > Quick glib question here: I've been getting into glib's error reporting > system and trying to integrate it into some code. (My code is using > glib, but not GTK+ itself.) Overall it seems rather straightforward, but > there was one point I was hoping for clarification on: > > In the g_set_error() parameters, the "domain" parameter is a GQuark. > Does this mean that I am supposed to use something like > "g_quark_from_string (MODULE_ERROR_DOMAIN_NAME)" for that parameter each > time I call g_set_error? > > That would make sense, from what I've read in the GQuark part of the > API. But I'm a little confused because the example given in the API for > g_set_error() usage does not do this. (In the example, they just pass in > some mysterious constant of unexplained origin.)
The mysterious constants follow the common usage pattern. For Bar in package Foo, header: #define FOO_BAR_ERROR foo_bar_error_quark() GQuark foo_bar_error_quark(void) G_GNUC_CONST; typedef enum { FOO_BAR_ERROR_BAD_WHATEVER... } FooBarError; and code: GQuark foo_bar_error_quark(void) { return g_quark_from_static_string("foo-bar-error-quark"); } You then do g_set_error(error, FOO_BAR_ERROR, FOO_BAR_ERROR_BAD_WHATEVER, ...); Yeti _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list