[Glade-users] gtk_main_quit functionality



i dont think is bad idea,

another option would be this:
exit(EXIT_FAILURE);

is useful if another program or process needs the exit status of your
execution

On Thu, Aug 26, 2010 at 12:51 PM, Arthur Shats <ashats at hotmail.com> wrote:

 In my _button_clicked callback, I open a file and write to it all the
input from the entry fields. However,  I first check if the file exists and
if not, I want to quit and exit the program (with no warning), so I call *gtk_main_quit().
*However, I notice that even though it does close my window, it still
executes the rest of the callback. I don't want that. If my file doesn't
exist, I need to exit (gracefully) right away, so I use return right after
*gtk_main_quit(). *Is it the right way to exit?
I am writing in C, here is the code excerpt:

void on_button1_clicked (GtkButton *button, gpointer user_data) {

  FILE *fp;

  fp = fopen("filename", "r");
  if (fp == NULL) {
     gtk_main_quit();
     return;  /* if I don't have this return, it would continue on and
print "I am here"
  }

  printf("I am here\n");

  /*** more code here **/
}

So, is calling *_main_quit *and *return* the right way to end the program?

Thanks,
Arthur.

_______________________________________________
Glade-users maillist  -  Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/glade-users/attachments/20100826/3da1fd80/attachment.html 




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