How to use gtk-demos?

I want to compile code showed in gtk-demos (which is actually a standalone application). I want to learn gtk using c/c++, but online examples are sparse or bad.

problem is that they dont have main functions, but they do have:

GtkWidget* do_<insert_demo_name> (GtkWidget *do_widget)

for example demos/gtk-demo/tabs.c · main · GNOME / gtk · GitLab

So how do i use those do_* functions in main function and compile them as a standalone file?

Another unrelated question is that i’m planning to use opengl in my gtk application, but all examples i saw had some padding / margin applied to GLArea which i had no idea how to remove.
take a look at this image to see what i mean, opengl area has like 5 pixel padding around it on all sides, and i haven’t able to find any code that adds that padding.
is it hardcoded in gtk?

To anyone reading, thanks for attention :slight_smile:

You don’t: the do_* functions are called by the main gtk-demo application.

The point of showing the code is not to copy paste it as is: it’s to read it.

If you want to put the code inside a stand alone example, you’ll have to:

  1. write your own GtkApplication instantiation
  2. write your own GtkApplicationWindow
  3. include the widgets created by the desired demo inside the application window

Hi, thanks for reply.

The point of showing the code is not to copy paste it as is: it’s to read it.

i know that gtk-demos are not designed to do that, but personally if i cant run the code (as standalone), i can’t understand the code.

I’ll still try to figure out how to incorporate them in main function, and thanks for the hint :slight_smile:

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.