GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Apr 24, 2014 12:54 am

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 
Offline

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?

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


Top
 Profile  
 
 Post subject: Re: Basic "Pre-Requisites" for GLADE3 Programming
PostPosted: Mon Jul 15, 2013 2:16 pm 
Offline
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.


Top
 Profile  
 
 Post subject: Re: Basic "Pre-Requisites" for GLADE3 Programming
PostPosted: Fri Aug 09, 2013 11:40 pm 
Offline
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:

Code:
class DemoBehaviour (object):

    def __init__(self):
        super(DemoBehaviour, self).__init__()
        self.builder = Gtk.Builder()
        self.builder.add_from_file("builderdemo.glade")
        self.builder.connect_signals(self)

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

    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.


Top
 Profile  
 
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: No registered users and 2 guests


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:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group