LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   user interface for C language program in linux (https://www.linuxquestions.org/questions/programming-9/user-interface-for-c-language-program-in-linux-815294/)

iqra 06-20-2010 12:53 PM

user interface for C language program in linux
 
hiii,

i want to make user inteface for my C program in linux.
is there any way other than GTK Glade interface?? i never used Glade before so i do not know weahter i could make UserInterface for my C program in that or not? as Glade has its own programing syntax!

plz help!!! :-)

Regards!

Sergei Steshenko 06-20-2010 01:25 PM

Quote:

Originally Posted by iqra (Post 4009481)
hiii,
...
plz help!!! :-)
...

First read the manual, then ask. I.e. you can write your GUI directly in gtk+.

ryan858 06-20-2010 04:35 PM

I'm a newb too, and have never messed with making GUI's (well I've tried a couple times and got overwhelmed and gave up), but I think the basic principal is, you use a framework and build your app around it... Think of it like constructing a building... You have to build up the framework (i.e. steel beams and stuff) then lay your concrete on top of that so it doesn't all collapse. Of course you can do it without that framework, and build something of wood or whatnot, like a house (though that still uses a frame, but that's beside the point). And you can use different frameworks to suit your needs or personal preference.

Keep in mind this is a very lamens-term description, coming from a guy who knows next to nothing about the subject...

But anyway, you can use the Qt libs, or GKT+, or whatever you want. I'm sure there are more, but those are the popular ones. Basically you make your app in plain old C, as a command-line tool, then add in the GUI components, or you can start from scratch and use your CLI (Command Line Interface) tool as a reference, while building the GUI app from the ground up, based on the source code of CLI version.

It's more complicated than how I worded it, but that's the basic gist of it.

And like I said, please keep in mind that I may actually have no idea what I'm talking about! (But I think I do!) :)

easuter 06-20-2010 07:22 PM

I think as far as using C for GUI programming you are pretty much limited to GTK and (ugh) Motif.
Visit the GTK website, they have lots of documentation you can browse through.

theNbomr 06-20-2010 11:14 PM

The original post said "user interface", so that could include curses/ncurses. Not graphical, but still a UI, and not too hard to learn, although the experience will not be very transferable to other UIs.
--- rod.

dugan 06-21-2010 12:01 AM

Quote:

Originally Posted by theNbomr (Post 4009758)
The original post said "user interface", so that could include curses/ncurses.

Or SDL and OpenGL, which are also C-based.

MTK358 06-21-2010 08:11 AM

Nobody said you have to use Glade, just design the UI in your code!

Also check out Qt (It also has a GUI-based interface designer called "Qt Designer", although there is nothing wrong with writing the UI in your code).

dugan 06-21-2010 08:54 AM

Quote:

Originally Posted by ryan858 (Post 4009600)
you can use the Qt libs

Quote:

Originally Posted by MTK358 (Post 4010167)
check out Qt

Qt needs C++.

theNbomr 06-21-2010 09:56 AM

Quote:

Originally Posted by dugan (Post 4009773)
Or SDL and OpenGL, which are also C-based.

Aren't those really graphics libraries/toolkits more than UIs?
--- rod.

MTK358 06-21-2010 09:57 AM

Yes, they're not UIs.

iqra 06-21-2010 11:19 AM

thanks to all for ur sugestions.. :-)

n sorry i didnt use a word 'Graphical'. thats what i actually need a GUI for my program. i need that type of tool or software that support C language and i just have to design the GUI and do not have to code again evry thing (of my program).

i worked on Windows( used Dreamweaver , Visual Studio) so i was wondering if i find such tool in Linux also!

MTK358 06-21-2010 11:57 AM

So you want a graphical program to lay out the widgets for your program's GTK+ GUI?

Then you want Glade.

theNbomr 06-21-2010 11:58 AM

I think if you use Glade to generate the skeleton of your application GUI, you can drop to a C-only environment at the point when you're happy with the basic arrangement. As I understand it, the basic premise of GTK vs Windows is not very different in principle. Everything is a callback, and a response to a certain type of signal. I've never done any Windows GUI programming, but I believe the same concept is true there. In fact, I think the same is true for most GUI building toolkits.
I have done a bit of GTK coding, and after the initial learning curve, I found it fairly straightforward. You just need to have a decent reference on hand, to get the syntax right, and to see what options are possible. For GTK, I think the definitive reference is the online one at the GTK website. I also used a book which had a little more detail, but that was a few years ago, and I don't know what's been published more recently that is up-to-date and complete.

--- rod.

dugan 06-21-2010 11:59 AM

Quote:

Originally Posted by theNbomr (Post 4010280)
Aren't those really graphics libraries/toolkits more than UIs?

They give you the tools to build a UI, which is also what you get from ncurses.

Blender has an OpenGL-based UI.

theNbomr 06-21-2010 03:22 PM

Quote:

Originally Posted by dugan (Post 4010452)
They give you the tools to build a UI, which is also what you get from ncurses.

Blender has an OpenGL-based UI.

Okay, I think I mis-worded my question. I suppose any graphics toolkit could be used to build a UI, but I still see a distinction between toolkits which are for general purpose graphics like drawing swirly colors and so on, versus a UI toolkit, which uses graphics to provide widgets which are active in some way, and which provides some framework for handling user actions from such as pointers and keyboards.

Curses provides a little of that, with things like menus and dialogs.

--- rod.

rogx 06-22-2010 01:42 AM

try FLTK
 
try FLTK www.fltk.org
(I prefer the stable release: v1.1.10)

it's really cross-platform, and, also if it's C++,
You can create/edit Your GUI whith Fluid in few clicks
and make Your routines with simple plain C.
(But use g++ to compile).
A very little knowledge of C++ is needed to do more
complex GUI editing.

bye,
Giovanni Rosso

MTK358 06-22-2010 06:35 AM

If you're going to go with C++, I recommend you try Qt Creator.

It has a great graphical widget layout editor.

Agrouf 06-22-2010 06:50 AM

http://lmgtfy.com/?q=C+UI+toolkit

ryan858 06-25-2010 04:05 PM

I don't see the problem with using a C++ library or whatever to make the gui... C++ is backwards compat. with C. C++ includes C. You can compile a C only source with g++, but not c++ with gcc... So C is compat. with C++ stuff, just not vice-versa, but that's not and issue here. It would be if you were trying to use C libs and stuff with C++... wouldn't work. But I don't see any problem with the other way 'round.

Even if, for some odd unforeseen reason, it doesn't work, then I (personally) don't think it's that difficult to convert C to C++. But there again, that's usually not necessary, since basically anything that works with C++ will work with C.

Basically, C++ IS C. It's an expanded version of C, with all of C fully intact.

theNbomr 06-25-2010 04:34 PM

Quote:

Originally Posted by ryan858 (Post 4015147)
I don't see the problem with using a C++ library or whatever to make the gui... C++ is backwards compat. with C. C++ includes C. You can compile a C only source with g++, but not c++ with gcc... So C is compat. with C++ stuff, just not vice-versa, but that's not and issue here. It would be if you were trying to use C libs and stuff with C++... wouldn't work. But I don't see any problem with the other way 'round.

Even if, for some odd unforeseen reason, it doesn't work, then I (personally) don't think it's that difficult to convert C to C++. But there again, that's usually not necessary, since basically anything that works with C++ will work with C.

Basically, C++ IS C. It's an expanded version of C, with all of C fully intact.

Interesting take on the matter. So a GUI that is written in and requires C++ to use it can be used to create applications written only in C? Sounds a bit miraculous to me. Are there no parts of the GUI API that are defined in terms of C++ constructs? It would be very good news to me, if it is true.

--- rod.

Agrouf 06-25-2010 09:46 PM

Indeed, it's easy to mix C and C++. You can easily make a C wrapper around the C++ library you use. C and C++ mix very well.

Sergei Steshenko 06-26-2010 02:27 AM

Quote:

Originally Posted by theNbomr (Post 4015169)
Interesting take on the matter. So a GUI that is written in and requires C++ to use it can be used to create applications written only in C? Sounds a bit miraculous to me. Are there no parts of the GUI API that are defined in terms of C++ constructs? It would be very good news to me, if it is true.

--- rod.

You might also be interested in http://llvm.org/docs/FAQ.html#translatecxx .

theNbomr 06-26-2010 11:06 AM

Quote:

Originally Posted by Sergei Steshenko (Post 4015435)
You might also be interested in http://llvm.org/docs/FAQ.html#translatecxx .

How would that be useful in this case? The original intention was to code in C, not C++.
Unless you're proposing to translate the entire Qt lib into C-ish code....
--- rod.

Sergei Steshenko 06-26-2010 11:50 AM

Quote:

Originally Posted by theNbomr (Post 4015707)
...
Unless you're proposing to translate the entire Qt lib into C-ish code....
--- rod.

I think it's a possibility. It's an especially interesting possibility if one wants to create, say, Qt bindings to a scripting language which much better supports "C" binding than C++ bindings.

jiml8 06-27-2010 12:37 PM

Quote:

Originally Posted by theNbomr (Post 4010449)
I think if you use Glade to generate the skeleton of your application GUI, you can drop to a C-only environment at the point when you're happy with the basic arrangement. As I understand it, the basic premise of GTK vs Windows is not very different in principle. Everything is a callback, and a response to a certain type of signal. I've never done any Windows GUI programming, but I believe the same concept is true there. In fact, I think the same is true for most GUI building toolkits.
I have done a bit of GTK coding, and after the initial learning curve, I found it fairly straightforward. You just need to have a decent reference on hand, to get the syntax right, and to see what options are possible. For GTK, I think the definitive reference is the online one at the GTK website. I also used a book which had a little more detail, but that was a few years ago, and I don't know what's been published more recently that is up-to-date and complete.

--- rod.

This is all essentially accurate.

jiml8 06-27-2010 12:49 PM

Quote:

Originally Posted by theNbomr (Post 4015169)
Interesting take on the matter. So a GUI that is written in and requires C++ to use it can be used to create applications written only in C? Sounds a bit miraculous to me. Are there no parts of the GUI API that are defined in terms of C++ constructs? It would be very good news to me, if it is true.

--- rod.

Yup.

You do ordinarily need to write a C-callable stub function to pick up the C++ interface in the library you want to use, but after you do that, you are good to go.

I frequently go the other way, writing C++ callable C functions to pick up gtk C interfaces rather than use the gtk C++ libs (since pretty much all systems have the gtk libs, but the gtkmm libs are not as commonly found)

Also, for OP, Glade is a tool that does give you a capability that is strongly reminiscent of what Visual Studio gives, but Glade is far less intrusive than VS because VS imposes certain architectural requirements on you (and overwrites your code if you don't adhere to the requirements) that lead to somewhat bloated code. Glade, on the other hand, generates an XML file that is parsed at runtime by a parser that is built into the gtk libraries. This imposes no architectural constraints on your code, other than the requirement to invoke the builder when you invoke gtk. You also can rearrange your interface with no need to recompile - except, of course, in the case of changed functionality.

Personally I like Glade and recommend it. It isn't hard at all to use.

For a long time, I didn't use QT because of their licensing. However, they have recently changed that and I am looking a bit at QT now.

MTK358 06-27-2010 03:02 PM

Quote:

Originally Posted by jiml8 (Post 4016475)
For a long time, I didn't use QT because of their licensing. However, they have recently changed that and I am looking a bit at QT now.

Qt Designer is awesome!


All times are GMT -5. The time now is 03:28 PM.