ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
After trying to get QT/Kdevelop to work, I finally gave up on it at present due to several problems when compiling programs (missing development libraries and so on). I know I can install the QT development libraries, but I thought I might try something different.
So I have installed Anjuta and I created a small GTK+ application and I find the C interface quite nice though a touch inconvenient.
I also like Glade much better than QT Designer/Kommander Editor. It's code generator is fantastic!
Now the question is, is there a better way to write GTK+ programs? Not that I don't like GTK+. Far from it. It is a fantastic API and I wish I had tried GTK+ before QT.
I know that GTKmm is a C++ wrapper for GTK+, but the problem is that I am not sure if writing GTKmm program will create additional dependencies as I needed to install more libraries (glibmm, glademm and gtkmm and so on).
Anybody can confirm this? Is it possible to actually write GTK+ programs which statically bind the C++ libraries so that the dependencies are limited to the standard GTK+ C libraries?
Last edited by vharishankar; 04-10-2005 at 07:58 AM.
i am not much of a programmer, but if you were to write c++ programs using gtkmm, then I am sure it would be a dependency on most systems. gtkmm itself would probably need a few extra support packages to be installed alongside it as well.
If you like C++ -- real modern, correct, idiomatic C++ -- you'll probably like gtkmm.
I tried using gtkmm a year or two ago. At the time, it was difficult for me to get all the dependencies installed correctly (this was on redhat 9). I'm guessing that it's trivial to install on an apt-based system.
However, I have made a static binary so the user does not need to install libraries. If the user want to install from source, the user need to install libxml++, glibmm, gtkmm, libglademm.
With regard to the last item, note that code generation has been deprecated for a long time: the preferred solution is using libglade. If you want to use code generation at any cost, the way to go is using an external tool to process the .glade file and output code in your language of choice. The format of the .glade file is the same as Glade-2.
Originally posted by Harishankar Using libglade is another dependency. Why on earth should I want another dependency?
# UI changes can be seen more quickly, so UIs are able to improve.
# Designers without programming skills can create and edit UIs.
# We don't have great gui builder integrated with IDE for GTK+ like Netbeans for Java or Delphi
Last edited by melinda_sayang; 04-11-2005 at 10:45 AM.
Well there's nothing really much to be gained by separating the UI from the codebase. Especially when Glade integrates so well with an IDE like Anjuta. And I always like to be as less dependent on external libraries as possible.
So I really see no benefits even though the developers might tout it as a great improvement.
So, how easy/difficult is using libglade? I mean can you still reference the GTK widgets from the code easily using "lookup_widget"?
Originally posted by Harishankar
So, how easy/difficult is using libglade? I mean can you still reference the GTK widgets from the code easily using "lookup_widget"?
This is basic code using libglademm ( c++, part of gtkmm ), so you can judge your self.
Code:
#include <libglademm/xml.h>
#include <gtkmm.h>
#include <iostream>
Gtk::Dialog* pDialog = 0;
void on_button_clicked()
{
if(pDialog)
pDialog->hide(); //hide() will cause main::run() to end.
}
int main (int argc, char **argv)
{
Gtk::Main kit(argc, argv);
//Load the Glade file and instiate its widgets:
Glib::RefPtr<Gnome::Glade::Xml> refXml;
try
{
refXml = Gnome::Glade::Xml::create("basic.glade");
}
catch(const Gnome::Glade::XmlError& ex)
{
std::cerr << ex.what() << std::endl;
return 1;
}
//Get the Glade-instantiated Dialog:
refXml->get_widget("DialogBasic", pDialog);
if(pDialog)
{
//Get the Glade-instantiated Button, and connect a signal handler:
Gtk::Button* pButton = 0;
refXml->get_widget("quit_button", pButton);
if(pButton)
{
pButton->signal_clicked().connect( sigc::ptr_fun(on_button_clicked) );
}
kit.run(*pDialog);
}
return 0;
}
But I must say, since you told me to use libglade, I tried to install the libglade-dev package and its dependencies are so deep that it requires (almost) a whole Gnome install (I tried in apt in debian)!
That defeats the very purpose of my program. I want a simple GTK program which has very few dependencies apart from the GTK libraries.
Give me a good reason to use libglade. I don't see any reason to use it, unless Debian is quite wrong in asking for so many dependencies.
Last edited by vharishankar; 04-12-2005 at 08:22 AM.
What is the dependencies anyway??? As long as I know, libglade has nothing to do with gnome..... only with gtk+
This is my guess. Debian want to install the recommended package too with your library.....
I will give reason for using libglade in your project. To make your life easier. If you scare that would make the installation hard, consider autopackage.
I wouldn't worry about using GTKmm or libglade. In particular:
- libglade and GTK+ are installed on nearly all Linux distributions.
- The GTKmm bindings are not, but they can be statically linked if you wish to build an autopackage style installer
I've used GTKmm a bit, and they are very nice bindings indeed. I'd strongly recommend them.
I recommend against gtkmm. Gtk2 is already a very object oriented structure, and it's wonderful to code in. You can just use it in your c++ program; obviously the wierdest things are like converting between string and gchar.. But I would definitely recommend not using gtkmm.
There I think are things to make your app easily portable to things like windows, but I don't know if that's something you want.
Remember, c++ can always compile against c libraries.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.