GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Sun Nov 23, 2014 8:48 am

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Odd custom widget problems
PostPosted: Sun Dec 23, 2007 4:24 am 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
Hi, I've been trying to figure this out all day and I've about reached the end of my rope. I'm writing a widget similar to a GtkCombo, but instead of having a button next to the entry, it catches a keystroke then pops up a window with a tree view. I've gotten it to work with just combining widgets together, but I'm getting strange problems in trying to make it an actual widget. The source files are as follows:

< the link to main.c is no longer valid, and pupwin.c and .h are no longer the problem ones, see this post: http://www.gtkforums.com/viewtopic.php?p=2215#2215 >
http://tdreblen.googlepages.com/pupwin.c
http://tdreblen.googlepages.com/pupwin.h

pupwin.c is the source for my widget
pupwin.h is the header for my widget
main.c is a program that uses my widget

the problem that I'm getting is that in connecting the "focus_in_event" for the PupWin's parent window (in pupwin_set_parent_win()), the pupwin variable is valid, but once it calls pupwin_popdown(), the passed PupWin is corrupt. In GDB the value of pupwin->popped is 0 in pupwin_set_parent_win() but as soon as it's passed to pupwin_popdown() it's set to something like 375621, also, pupwin->keyletter is set to '\0' when it's passed to pupwin_popdown(). Forgive my oddly commented code , I wasn't really planning on releasing this. Also, forgive me if this is something stupidly easy. Thank you for any help that you can give...


Last edited by dreblen on Wed Dec 26, 2007 6:18 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 23, 2007 4:38 pm 
Offline
Never Seen the Sunlight

Joined: Wed Sep 21, 2005 3:07 am
Posts: 384
Location: Fairfax, Virginia
Check out the API for focus-in-event at http://library.gnome.org/devel/gtk/unst ... s-in-event

The format of the function is the following:

Code:
gboolean user_function (GtkWidget *widget,
                        GtkDirectionType arg1,
                        gpointer data);


Therefore, your PupWin is being cast as a GtkDirectionType object, so it should be your third parameter instead. Also, note the gboolean return value instead of void ...

_________________
Andrew Krause

Foundations of GTK+ Development: Buy now for only $31.49!


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 23, 2007 6:35 pm 
Offline
Never Seen the Sunlight

Joined: Thu Jun 14, 2007 11:02 pm
Posts: 923
Location: Falun, WI USA
thank you! I took a look at your link and adjusted my pupwin_popdown() function so that it's prototype is this:
[code=]gboolean pupwin_popdown(GtkWidget *widget, GdkEventFocus *event, PupWin *pupwin)[/code]
Also, I realized this morning that it would be better to connect the focus out event on the pupwin->popwin rather that the focus in event on the parent window, so that's what I did and it works properly now. I'll have to look at the signal prototypes from now on ;) So once again, thank you!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group