GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Tue Sep 23, 2014 12:21 pm

All times are UTC

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Basic "Pre-Requisites" for GLADE3 Programming
PostPosted: Wed Jul 10, 2013 6:51 am 

Joined: Wed Jul 10, 2013 4:52 am
Posts: 1
Hi All,

I am learning the GLADE environment but keep getting stuck on the basics. I read a bunch of Micah's Tutorials, but small things like 'how to get gtk-build-convert' working from command line keep jamming me up. Anyone have any suggestions on "required reading" before getting in to GTK+ / GLADE Object Oriented Programming?

- Basic C
- Light C#
- Lots and Lots of Bash Scripting

 Post subject: Re: Basic "Pre-Requisites" for GLADE3 Programming
PostPosted: Mon Jul 15, 2013 2:16 pm 
Familiar Face

Joined: Thu Aug 27, 2009 9:44 pm
Posts: 21
Hi abrahamrhoffman,

in my experience it is highly recommended to have `devhelp` with the `GTK+ Reference Manual` of the GTK+ version you actually use at hand. Everytime i do some GTK+ related stuff `devhelp` is somewhere on my screen.

To get into glade from a programming perspective my advice is to read through the section `GtkBuilder` in the `GTK+ Reference Manual`. The `GtkBuilder` object is responsible for creating the instances of all the widgets you visually created with Glade previously.

Instantiating a widget however, doesn't mean that the widget is shown. That's the task of the programmer. Usually it is done by getting the main window by calling `gtk_builder_get_object ()` and afterwards calling `gtk_widget_show_all ()` on the window. The last mentioned procedure recursively shows all child widgets of the main window... For a detailed description of the mentioned methods look at the reference.

Another tip is to look at the `builder`-demo in `gtk3-demo`. `gtk3-demo` is a set of gtk3 demo's which illustrate most of the widgets and objects that come with gtk.

That is just a very short summary on the subject of how i would do the task.

 Post subject: Re: Basic "Pre-Requisites" for GLADE3 Programming
PostPosted: Fri Aug 09, 2013 11:40 pm 
Familiar Face

Joined: Tue Aug 06, 2013 1:09 pm
Posts: 6
You don't need gtk-builder-convert if you save your Glade project as GtkBuilder XML. It can be loaded directly into GTK in more recent GTK versions. It's fine to name the file with a .glade extension.

I'll just add that you can nominate callbacks for early lifecycle events like "realize" in a GtkBuilder UI definition. Realize fires when a widget is constructed, but before it is mapped (has a screen area (GdkWindow) allocated to it) and before it's shown. This is useful for all sorts of fancy fiddling while keeping the conceptual neatness described by saunderson: all you need to do in the code is define a callback matching the one you named, at least in high-level stuff like Python:

class DemoBehaviour (object):

    def __init__(self):
        super(DemoBehaviour, self).__init__()
        self.builder = Gtk.Builder()

    def run(self):
        window = self.builder.get_object("window1")

    def window1_realize_cb(self, widget):
        print "* realized"
        # ...

as a thumbnail sketch. Glade suggests names for the callback functions or methods, when you set them up on the Signals tab.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group