From: Hans v. T. <hth...@zo...> - 2009-05-24 11:47:27
|
Hello All, The following lets the user choose an item from a combo box. First of all, I've put the (text) combo in a popup window and accessed it as shown below. User activates a menu item, and can then change the choice. Is this the right way to program this? The reason I ask is, the user can also reset the choice, through another menu item (not shown here). Now, what happens, is that the first time the code below is activated, it runs as I expect. After a reset, however, it appears to run twice when the user activates it! The filechooser, in the filesave function, pops up two times, and I have to clean the MVars used in the forkIO (also not shown) to prevent blocking. Apart from this behavior, the GUI appears to work. Any ideas? onActionActivate cons $ do { ;onChanged asb $ do { mbasix1 <- comboBoxGetActive asb ;case mbasix1 of Nothing -> return () Just asix1 -> do { forkIO $ do { ------[snip] ;ambp <- get ambchk toggleActionActive ;if ambp then saveAmbs filesave stbar stcx attvarr2 rlspart ---------[snip] } -- end forkIO ;actionSetSensitive cons False } -- end Just ;widgetHideAll apop } -- end onChange ;widgetShowAll apop } -- end activate Many Thanks, Hans van Thiel |
From: Axel S. <Axe...@en...> - 2009-05-24 13:11:20
|
On May 24, 2009, at 13:49, Hans van Thiel wrote: > Hello All, > > The following lets the user choose an item from a combo box. > First of all, I've put the (text) combo in a popup window and accessed > it as shown below. User activates a menu item, and can then change the > choice. Is this the right way to program this? > > The reason I ask is, the user can also reset the choice, through > another > menu item (not shown here). Now, what happens, is that the first time > the code below is activated, it runs as I expect. After a reset, > however, it appears to run twice when the user activates it! The > filechooser, in the filesave function, pops up two times, and I > have to > clean the MVars used in the forkIO (also not shown) to prevent > blocking. > Apart from this behavior, the GUI appears to work. Any ideas? > > onActionActivate cons $ do { > ;onChanged asb $ do { > mbasix1 <- comboBoxGetActive asb > ;case mbasix1 of > Nothing -> return () > Just asix1 -> do { > forkIO $ do { > ------[snip] > ;ambp <- get ambchk toggleActionActive > ;if ambp > then saveAmbs filesave stbar stcx attvarr2 rlspart I'm not quite following the program logic, but one reason this program is brittle is that is calls Gtk2Hs from different threads. That is currently not yet supported directly and you would have to use postGUISync or postGUIAsync in module General in order to call Gtk2Hs functions from all but the main thread. I don't know if that is the problem here, but there is definitely something to fix here. A second guess is that you add a signal handler within a signal handler. That means that the second time onActionActivate is called your onChanged signal handler will be attached twice and, hence, the same function seems to run twice. Cheers, Axel. > ---------[snip] > } -- end forkIO > ;actionSetSensitive cons False > } -- end Just > ;widgetHideAll apop > } -- end onChange > ;widgetShowAll apop > } -- end activate > > Many Thanks, > > Hans van Thiel > > > ---------------------------------------------------------------------- > -------- > Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT > is a gathering of tech-side developers & brand creativity > professionals. Meet > the minds behind Google Creative Lab, Visual Complexity, Processing, & > iPhoneDevCamp asthey present alongside digital heavyweights like > Barbarian > Group, R/GA, & Big Spaceship. http://www.creativitycat.com > _______________________________________________ > Gtk2hs-users mailing list > Gtk...@li... > https://lists.sourceforge.net/lists/listinfo/gtk2hs-users |
From: Hans v. T. <hth...@zo...> - 2009-05-24 13:25:59
|
On Sun, 2009-05-24 at 15:11 +0200, Axel Simon wrote: > On May 24, 2009, at 13:49, Hans van Thiel wrote: > > > Hello All, > > > > The following lets the user choose an item from a combo box. > > First of all, I've put the (text) combo in a popup window and accessed > > it as shown below. User activates a menu item, and can then change the > > choice. Is this the right way to program this? > > > > The reason I ask is, the user can also reset the choice, through > > another > > menu item (not shown here). Now, what happens, is that the first time > > the code below is activated, it runs as I expect. After a reset, > > however, it appears to run twice when the user activates it! The > > filechooser, in the filesave function, pops up two times, and I > > have to > > clean the MVars used in the forkIO (also not shown) to prevent > > blocking. > > Apart from this behavior, the GUI appears to work. Any ideas? > > > > onActionActivate cons $ do { > > ;onChanged asb $ do { > > mbasix1 <- comboBoxGetActive asb > > ;case mbasix1 of > > Nothing -> return () > > Just asix1 -> do { > > forkIO $ do { > > ------[snip] > > ;ambp <- get ambchk toggleActionActive > > ;if ambp > > then saveAmbs filesave stbar stcx attvarr2 rlspart > > I'm not quite following the program logic, but one reason this > program is brittle is that is calls Gtk2Hs from different threads. > That is currently not yet supported directly and you would have to > use postGUISync or postGUIAsync in module General in order to call > Gtk2Hs functions from all but the main thread. > > I don't know if that is the problem here, but there is definitely > something to fix here. Brittle is the right word, I think, because there are some visual discontinuities as well..I wasn't aware of the thread issue and I'll check it out. > > A second guess is that you add a signal handler within a signal > handler. That means that the second time onActionActivate is called > your onChanged signal handler will be attached twice and, hence, the > same function seems to run twice. Ah, so that's it! Many thanks for the helpful response!! Best regards, Hans > > Cheers, > Axel. [snip] |