Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] GTK in CVS

Steve_Northover@xxxxxxx writes:
> Ok, I added handlers for all 4 log domains but when I try to remove them I 
> get a bunch
> of error messages for each domain other than "Gtk" of the form:

The appended program works for me. I'm not sure what's wrong.
 
> It seems I can add them OK but can't remove them.  Havoc, should I keep 
> bothering you about
> this sort of thing or hold off for major issues?

Feel free to ask me if you feel like you're stuck after fooling around
with something for a while and checking the docs. There's also
gtk-list if you want to ask a wider audience (sometimes you can get a
faster answer, or even someone who knows stuff I don't ;-)

Another resource is bugzilla.gnome.org - anytime you're working around
GTK or have suggestions, or just find it not working, bug reports are
appreciated. Test cases are good if you have them, but not required.

Havoc



#include <gtk/gtk.h>
#include <stdio.h>

void
log_func (const gchar    *log_domain,
          GLogLevelFlags  log_level,
          const gchar    *message,
          gpointer        user_data)
{
  printf("HA-HA-HA\n");
}


int
main (int argc, char** argv)
{
  guint id1 = 0;
  guint id2 = 0;
  
  gtk_init (&argc, &argv);

  /* Use G_LOG_LEVEL_MASK instead of G_LOG_LEVEL_CRITICAL to handle
   * all types of messages, not just the warning/critical stuff.
   */
  id1 = g_log_set_handler ("Gtk",
                          G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING |
                          G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
                          log_func, NULL);

  id2 = g_log_set_handler ("GLib",
                           G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING |
                           G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
                           log_func, NULL);
  
  gtk_widget_show (NULL);
  g_string_truncate (NULL, 0);
  
  g_log_remove_handler ("Gtk", id1);
  g_log_remove_handler ("GLib", id2);

  gtk_widget_show (NULL);
  g_string_truncate (NULL, 0);
  
  return 0;
}




Back to the top