Fedora Linux Support Community & Resources Center
  #1  
Old 15th April 2011, 12:21 AM
silllykone Offline
Registered User
 
Join Date: Mar 2011
Posts: 11
linuxopera
Should I split up Gtk+ code?

I'm starting to do Gtk+ programming. One thing I find when doing a project is that my main() method (I'm using C++) is getting really bogged down--not necessarily with running time, but with code. Would it be good practice to set up the code in different functions like this:
Code:
*GtkWidget addMenubar()
{
// Create a menubar and return a pointer.
}

*GtkWidget addTextfield()
{
//Create a text field and return a pointer
}
int main()
{
  GtkWidget *menubar = addMenubar();
  GtkWidget *textField = addTextfield();
  //...Do some other stuff...
  // Add all the elements to the window and show.
}
Or would it not even be worth it?
Reply With Quote
  #2  
Old 15th April 2011, 08:59 AM
giulix Offline
"Fixed" by (vague) request
 
Join Date: Oct 2005
Location: GMT+ 1
Posts: 2,950
linuxfedorafirefox
Re: Should I split up Gtk+ code?

For OO languages, it is common practice to organize files by class, grouping classes that have a common purpose in namespaces (packages in Java). Your current approach looks as if you're planning to use standard GTK+ libs and a procedural approach. Look into gtkmm instead: That will guide you towards a more object-oriented approach...
Reply With Quote
Reply

Tags
code, gtk, split

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
zip and split cgourdet Programming & Packaging 1 11th December 2009 07:01 PM
how to split .zip file thisObject Using Fedora 4 12th May 2007 06:06 AM
Need to split Jongi Servers & Networking 0 3rd April 2007 09:40 PM
How to split files? tonytiger Using Fedora 5 29th May 2005 10:14 AM


Current GMT-time: 19:35 (Thursday, 24-04-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat