LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Help in GTK+ programming (http://www.linuxquestions.org/questions/programming-9/help-in-gtk-programming-811604/)

supravat 06-01-2010 10:17 PM

Help in GTK+ programming
 
I have created a executable file using c and I have also created a GUI using GTK+. Now how can I call the executable file from the GUI with arguments passing to the executable file.

Can any one please help me.....

exvor 06-01-2010 10:23 PM

How did you create the GUI because there are two ways to do this in GTK+.

supravat 06-01-2010 10:50 PM

I have created the GUI using normal c programming.... That's the only way I know.. Is there any other option ???

exvor 06-01-2010 11:03 PM

Hmmm strange. Why not just incorporate the c program into the GUI program? I suppose you could just use a system call but that would not be advisable.

wje_lq 06-01-2010 11:53 PM

Quote:

Originally Posted by exvor (Post 3989497)
Why not just incorporate the c program into the GUI program?

That would indeed be the way to do it, with the following wrinkle:
Quote:

Originally Posted by exvor (Post 3989497)
I suppose you could just use a system call but that would not be advisable.

A call to system() might be just the thing to do. If you sometimes or often use that other program stand-alone, without using GTK+, it would be helpful from a maintenance point of view to keep the two programs (the one using GTK+ and the one it wants to run) separate. That way, if you want to make an improvement in the called program, you can make the change in only one place and it will be made for both the stand-alone operation and the GTK+ program.

If the stand-alone program produces output (a little or a lot), you have a couple of options.
  1. Don't really use system(); instead, use fork(), exec(), and waitpid(), and use pipes to read the output.
  2. In a system() call, direct the output to a file, just as you would if you were at a shell prompt:
    Code:

    if(system("fred_program > fred_output.txt"))
    {
      /* do error recovery here */
    }



All times are GMT -5. The time now is 08:58 AM.