3

I know how to use Glade generated XML file (*.glade) and to load it in c++ code. But for educational purpose I need to see the c++ source code alternative to the XML file. I just want to see the same GUI (made on Glade with output in XML format), but in c++ source code with the GTK+ library classes explicitly defined.

Meanwhile I've found this tool and hopefully it is compatible with the latest Glade XML code.

Pekov
  • 527
  • 1
  • 9
  • 23
  • I do not understand your question. Are you looking for something like this: https://developer.gnome.org/gtkmm-tutorial/stable/sec-text-entry.html.en – Martin Sand Sep 30 '17 at 07:46
  • @MartinSand Glade generates `*.glade` file, which is in XML code. I want to take this file and to generate `*.cpp` file that represents the GUI of the Glade XML file. – Pekov Sep 30 '17 at 08:19
  • Ah, ok. I am not aware about a tool to do this. I once did it manually. Is there any reason why you want to do this? – Martin Sand Sep 30 '17 at 09:12
  • @MartinSand Mainly because of educational purpose. Also because I have some GTK+ projects that do not use Glade and I can use Glade here just for easy reference instead of writing the GTK+ code for every widget. – Pekov Sep 30 '17 at 09:44

2 Answers2

1

The only way I do it is to make a c file with glib-compile-resource and add it as a resource. Note glib-compile-resource only compiles resources listed /defined in a defined xml file. You have to create resources.xml. All you do is regenerate the c file and add it to your program. with gcc resource.c youprogram.cpp etc. In your code use builder->add_from_resouce. See Glade and Builder. That way you dont have to worry about generating cpp files.

Bret Joseph
  • 401
  • 3
  • 13
  • see glib-compile-resource documentation you probably are trying to compile a glade file directly with glib-compile-resource dont do that – Bret Joseph Jul 14 '19 at 17:02
0

While it is not what you have asked for, maybe GtkInspector will help. It allows to inspect native Gtk at runtime and manipulate it, you can gain insights ("What was actually applied to Gtk?") and modify internals on the fly - without recompiling.

It can be compared to Web Inspector from WebKit.

Peter
  • 2,240
  • 3
  • 23
  • 37