LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-10-2005, 07:57 AM   #1
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
GTK+ programmer: C or C++?


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.
 
Old 04-10-2005, 11:01 AM   #2
reddazz
LQ Guru
 
Registered: Nov 2003
Location: N. E. England
Distribution: Fedora, CentOS, Debian
Posts: 16,298

Rep: Reputation: 77
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.
 
Old 04-10-2005, 12:01 PM   #3
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
I suspected as much

Never mind, I'll stick to C. It's still a nice experience though. Feels much "ligher" than QT, if you can relate to that.
 
Old 04-10-2005, 07:58 PM   #4
johnMG
Member
 
Registered: Jul 2003
Location: CT, USA
Distribution: Debian Sarge (server), Etch (work/home)
Posts: 601

Rep: Reputation: 32
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.
 
Old 04-11-2005, 04:44 AM   #5
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Rep: Reputation: 31
Look at my project. I made it using gtkmm.
http://wallpapoz.sf.net

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.

So I say.... go with gtkmm!!!!!

To make a static binary, I use this wonderful software:
http://statifier.sourceforge.net/

Don't use code generator. It is deprecated anyway.
 
Old 04-11-2005, 06:34 AM   #6
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
Quote:
Don't use code generator. It is deprecated anyway.
You mean the one in Glade GTK or Glade GTKmm?
 
Old 04-11-2005, 07:52 AM   #7
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Rep: Reputation: 31
both of them.....

See here:
http://glade.gnome.org/todo.html

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.
 
Old 04-11-2005, 09:59 AM   #8
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
Using libglade is another dependency. Why on earth should I want another dependency? I'd prefer code generation in GTK code, thank you very much.

I cannot understand some of the reasoning behind these design decisions.
 
Old 04-11-2005, 10:42 AM   #9
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Rep: Reputation: 31
Quote:
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.
 
Old 04-11-2005, 10:47 AM   #10
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
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"?

I have to keep re-learning again and again.
 
Old 04-12-2005, 05:30 AM   #11
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Rep: Reputation: 31
Quote:
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;
}
 
Old 04-12-2005, 08:20 AM   #12
vharishankar
Senior Member
 
Registered: Dec 2003
Distribution: Debian
Posts: 3,178

Original Poster
Blog Entries: 4

Rep: Reputation: 138Reputation: 138
melinda_sayang. Thanks for the code.

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.
 
Old 04-12-2005, 10:23 AM   #13
melinda_sayang
Member
 
Registered: Dec 2003
Location: Petaling Jaya
Distribution: Ubuntu
Posts: 475

Rep: Reputation: 31
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.

http://www.autopackage.org

Last edited by melinda_sayang; 04-12-2005 at 10:28 AM.
 
Old 04-13-2005, 12:00 PM   #14
mhearn
LQ Guru
 
Registered: Nov 2002
Location: Durham, England
Distribution: Fedora Core 4
Posts: 1,565

Rep: Reputation: 57
Hi,

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.
 
Old 04-13-2005, 08:10 PM   #15
MA_D
Member
 
Registered: Apr 2005
Location: Iowa
Distribution: Archlinux/RHEL/FreeBSD
Posts: 41

Rep: Reputation: 15
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Migrating the programmer Marc L. Linux - General 6 05-04-2010 03:19 AM
Programmer to Programmer ( Long Story Of A GUI ) mdoubledragon Programming 1 10-13-2005 05:41 PM
Should I become a programmer? coolblue Programming 10 09-18-2005 09:36 PM
looking for programmer and advice kosit Programming 1 05-06-2005 06:04 PM
programmer wanted. Ciccio Programming 57 01-11-2003 01:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration