Re: Fake pushing a GTK+ button



On Tue, 2007-05-22 at 14:26 -0400, DanH wrote:
I have a program that has your basic set of buttons, windows, switches and
adjustables.  I have added a listener to tell me if a directory has been added
to or changed.  The printf statement works great and says, "Directory changed"
at all the right times and is silent at all the right other times.

All I wanted to do was to refresh the directory listing inside the program,
unfortunately, I don't know the data structure it uses to create the directory
tree.  

Easy enough, right?  All I have to do is tell the program that the refresh
button has been clicked whenever the directory changes.

gtk_button_clicked() emits the clicked signal on a button.

However, unless it is unavoidable, I would submit that thinking about
related actions in terms of the buttons to which they're connected is
seldom useful.  You have an action, "refresh directory listing."  It is
invoked by the refresh button.  Could you not just make a change of
directory also invoke this action?

Granted, there may be situations where this isn't practical.  But if you
can think in this way, I think it will lead to a better program
structure.

- Michael




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