Thread: How do i interface a C code in GTK+ ?

  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    1

    How do i interface a C code in GTK+ ?

    Hi,

    I use Ubuntu 9.10

    I have written a C code for multicasting application.
    I need to interface my C code into a GUI . i.e, ./<file> should open a new window and my application(C code) should run there.

    I tried to get some basics of GUI programming using GTK+ tutotials. But being a newbie in GUI programming, I am lost in figuring out how to to interface a C code in GTK+ .

    Please help me out with this.

    Thanks,
    Spatika.

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by spatika View Post
    I need to interface my C code into a GUI . i.e, ./<file> should open a new window and my application(C code) should run there.
    Do you mean the program output in your terminal? Just use a shell script like this:
    Code:
    #!/bin/sh
    
    Terminal --hide-menubar --hide-borders --geometry 129x37+0+0 -e /home/bin/myprogam
    This will launch a seperate terminal window and start "myprogram" in it. It is just an example, the syntax for the gnome-terminal you are probably using in Ubuntu might be slightly different.

    If you want a real GUI (using gtk), then you have to create an interface. You could just use a text area and pipe the output of a command into it; however, I will tell you from experience there is no advantage to doing this and there are a number of potentially serious disadvantages. Which is why *no one* really does that. Also, any kind of "terminal" in X windows is a GUI already; it runs a text console inside of it, so having another style of text window to do the same thing only worse would be redundant.

    If you want to design an interface using gtk, you will have to think about what controls are needed, what kind of widgets to use for that, etc, and if there is text output from the program that you want seen, how you are going to display that. A read-only "textview" is one possibility. Probably you want to get a little more advanced and break that information up to exploit some different possibilities of the GUI, eg, a current connections list where you could click on a connection to get a little pop-up containing more detailed info. That's work; you'll have to keep going with those tutorials. I know there is a specific one for the text widget:
    http://www.bravegnu.org/gtktext/
    Last edited by MK27; 06-15-2009 at 08:00 AM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 03-21-2006, 07:52 AM
  2. Updated sound engine code
    By VirtualAce in forum Game Programming
    Replies: 8
    Last Post: 11-18-2004, 12:38 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Results for the Encryption Contest -- June 23, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-07-2002, 08:04 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM