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


I tried out the g_log stuff and it didn't seem to work.  Can you show
me what I'm doing wrong?  You'll need to catch up with the latest
SWT for GTK Java code and DLL's in order to run this:

import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.gtk.*;
public static void main (String [] args) {
        OS.gtk_init_check (new int [] {0}, null);
        Object proc = new Object () {
                int logProc (int int0, int int1, int int2, int int3) {
                        System.out.println ("***Got here!");
                        return 0;
                }
        };
        Callback logCallback = new Callback (proc, "logProc", 4);
        int logProc = logCallback.getAddress ();
        int handler_id = OS.g_log_set_handler (0, -1, logProc, 0);
        int handle = OS.gtk_window_new (OS.GTK_WINDOW_TOPLEVEL);
        OS.gtk_widget_show (handle);
        OS.gtk_widget_show (0); // BOGUS
        while (true) OS.gtk_main_iteration ();
}        

Here is the same example in C:

#include <gtk/gtk.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[] )
{
    GtkWidget *window;

    gtk_init(&argc, &argv);
    window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    gtk_widget_show (window);

/* Interesting stuff */
g_log_set_handler (G_LOG_DOMAIN, 0xFF, log_func, 12345);
gtk_list_select_all(0);
/* End of interesting stuff */

    gtk_main ();
    return(0);
}

Should I try using the deprecated g_set_error_handler etc. instead?

Steve



Havoc Pennington <hp@xxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

12/05/01 02:00 PM
Please respond to platform-swt-dev

       
        To:        platform-swt-dev@xxxxxxxxxxx
        cc:        
        Subject:        Re: [platform-swt-dev] GTK in CVS



Steve_Northover@xxxxxxx writes:
> The source for the GTK port of SWT is now in CVS.  Finally!

Great! (BTW, I responded to some mail from Boris and Mike Wilson a
couple weeks ago, and @oti.com email addresses were bouncing.)

> re GTK Warnings:
> We're having trouble tracking these down.  I can't find the GTK equivalent
> of the X/Xt error hander (to track exactly when they happen) and I can't
> create a simple example that causes them. We're only seeing them when
> running Eclipse. Havoc, any ideas?

It'll probably be a bit before I can try building the whole of Eclipse
on GTK, but here's some general info on the warnings stuff and how to
debug it:

The "Gtk-WARNING" messages come from passing invalid arguments such as
NULL objects to GTK functions; so these indicate a bug in the program,
rather than a recoverable error. Think of them as equivalent to
segmentation faults in seriousness.

There are two common ways to debug them. One is to run a GTK program
with the "--g-fatal-warnings" command line option, which is parsed by
gtk_init(). Programmatically, this will do the following:

  GLogLevelFlags fatal_mask;
                     
  fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
  fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
  g_log_set_always_fatal (fatal_mask);

Which results in calling abort() when you get a warning. This means
you will stop in the debugger. You could also just add the above code
instead of using --g-fatal-warnings.

Another way to approach things, if you don't want to abort on the
first warning, is to set a breakpoint on the g_log or g_logv
functions, which are used to print the messages.

Finally, you can set a "log handler" with g_log_set_handler().  This
doesn't let you recover from the error or anything like that, it's
just intended to let you redirect the text of the message elsewhere.

Also of course, typically the warnings do have some meaningful info in
them. If you get "assertion foo != NULL" failed, then that's passing a
NULL pointer where none is allowed; if you get "assertion GTK_IS_FOO()
failed" that usually means you passed in a dangling/garbage pointer,
so it did not contain valid type information.

> Areas where we could use input from the GTK community:
>
> - positioning widgets such that they do not move when the parent is
> resized (we are using a fixed + hacks)
>
> - everything to do with redraw, damaged areas, forcing paints, etc.
>
> - making Display.sleep() work properly
>

I'll try to check these out in the examples. The Sun guy doing the GTK
AWT peers ended up writing a simple custom widget that was a variant
of fixed, so he could get the desired behavior exactly right.

Havoc
_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top