Re: [Newbie...] GtkCombo troubles



On Fri, 2002-12-27 at 19:44, Mark B. wrote:
> take a look for yourself:
> 
> http://mysite.iptic.com/scottishpig/Main.cpp
> 
> You can obviously see what it's supposed to do-
> pigmentType is a GtkCombo and when one selects
> something in it, a variable is set to a corresponding
> number which will be used to call a function (defined
> in a another source file, not included).

I'm just taking a quick swipe at this...

I assume you mean for this variable setting that you are referring to
this part of the code:
	const gchar *PigType;
        //const_cast <char *> (
	PigType= gtk_editable_get_chars( GTK_EDITABLE( GTK_COMBO(pigmentType )->entry ), 0, -1 );
        if (strcmp(PigType, "image_map") == 0) {TypeofPig=2;}
        if (strcmp(PigType, "color") == 0) {TypeofPig=0;}
        if (strcmp(PigType, "pattern") == 0) {TypeofPig=1;}

Put that inside a new signal handler.  Connect that to the entry changed signal of the entry associated with the combo box.  Then when someone types in that entry area, or uses the combo box drop down menu to select something (and therefore the associated entry changes) it will execute your code.  The gtk tutorial mentions the activate signal, but I don't know if that works the same or not.  I am looking at what I have done with gtkmm, and that is along the lines of the gtkmm tutorial which uses the entry changed signal.  At least pick one of them though, because the way you have it now will only execute one time.

If you want to compare the two ways, view the combo box section of each tutorial.  Of course the syntax of gtkmm is completely different, but the concepts are somewhat similar, at least as far as what signals to connect to.

Also, to make you code easier to follow, I suggest changing finishEditor
to finishEditorButton, etc.  That slowed me down a little in following
your code.  That is only a suggestion though.  :)

-- 

Mark
http://www.utdallas.edu/~mej017200/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]