Should I learn GObject and GLib to work with GTK? - gtk

I have to develop a native application on Linux for a school project.
I chose to work with GTK and I started to read the official guide.
The GTK API itself is pretty easy to understand but I'm facing problems with GObject and GLib, they are hard to learn and I don't know why they are used to.
Should I learn GObject and GLib to work with GTK?
The GObject official documentation is incredibly huge https://developer.gnome.org/gobject/stable/ and I will need few weeks to just learn GObject to finally learn GTK.

GTK+ is based on GLib and uses its main loop for event handling and memory management. If you code in C you have to understand how GLib works (otherwise you will have memory leaks). Lower level details of object system (GObject) are only interesting if you create custom widgets.
However, if your project's requirements allow Python or JavaScript then Glib/GObject are next to useless on their own and you can dive into GTK+ directly.
Source: authored apps using PyGObject, gtkmm and raw GTK+ in C.

Related

Swift for Windows and creating GUI

I tried to find some answers but cannot really find anything useful. Is there possibility to create a GUI using Swift under Windows?
I do not expect a real interoperability between MacOS and Windows GUI but I can't even find any documentation about creating GUI under Windows.
The best thing I could find in the past months was Silver, a commercial Swift implementation/fork:
With Silver, you can use Swift to write code directly against the .NET, Java, Android and Cocoa APIs. And you can also share a lot of non-UI code between platforms.
Developing Windows applications seems to be free, but the next option costs $799 already.
So you could say Silver is a Swift fork with some extras.
Swift updates and Silver updates aren't exactly in lock-step with one another, so you have to wait for the maintainers to update the language to be truly source compatible.
Silver extends the language with stuff familiar to Java/C# people.
See other limitations.
It seems Silver isn't even 1.0, yet.
I cannot add personal experience; I'm torn at the moment. It looks cool but I don't know how productive you can be, writing code in the latest Swift to compose your types and then hitting language road bumps in Silver. I guess that's why there's a Silver Cocoa bridge: because you'll be writing Silver code, not Swift code, although both are pretty similar.
There are some GUI examples in 'Swift for Windows' project at http://SwiftForWindows.github.io but the GUI toolkit is alpha version.

Is GObject used much outside of GNOME?

I understand GObject started out as part of gtk+ and was later separated from the GUI related elements. What I would like to know is: it used outside gtk+ ? what about other desktop environments, and other OSs like Windows or Mac OS? Are there any prominent examples of such cases?
There are some things here and there that use GObject without GTK+, but AFAIK they are few and far between.
I'm guessing that the most prominent ones right now are Clutter-based projects (it's a graphics-oriented UI library). There are also a small number of projects based on libgnt (text-based UI library), and possibly various non-GTK+ programs written in Vala (a C#-like programming language with GObject-based classes).
Edit: Also GStreamer (thanks liberforce!), which is a popular multimedia library. The vast majority of GStreamer projects also use GTK+, but I'm sure there are some non-GTK+ ones.

Is there a cross-platform framework for C?

I am curious to know if there is any kind of programming library/framework for the C language for cross-platform programming of course. I mean there are already frameworks like Wxwidgets, Boost, Qt, U++ and etc for C++ available but I have not yet found any for C .
Updated Info:
We are trying to build an underlying Framework/library to be used in our project. We are going to eliminate the dotnet and instead provide a counterpart for those libraries which is fast and less demanding.
We will be working on a server/client based project, and thus the underlying services must be fast and also portable. GUI is not our priority now, but libraries providing threading capabilities is of importance to us.
And for the ANSI part, I think we are fine with that at the moment unless something changes that in the future.
if you write plain ANSI C, it should work on every POSIX system.
The most successful example of cross platform C library is standard C library itself (IMHO).
If you're looking for GUI toolkit GTK is the answer,
if you're looking for terminal UI, ncurses is pretty portable.
If you're looking for general use libraries, as long as they're written in ANSI C, should work almost everywhere, as long as it doesn't use system level APIs.
Can you just tell us, what kind of library/framework you are looking for ?
GTK+ is long established and actively maintained cross-platform C-only (or primarily) toolkit. You'll find not only on-line documentation but also books written about it. It is the framework backing up the GNOME project.
GTK+ is meant to build applications with UI, first of all. However, even if you don't need UI you'll find that some GTK+ components, namely GLib, provide general multiplatform support comparable with Qt. Actually, I needed a framework without UI at first and chose GLib over APR because I was able to find documentation and tutorials easier.
GTK+ was initially developed on UN*X an X-Windows which remains the platform where you can get it running the most easily. I wouldn't say that it is more difficult on Windows; it is just that you have more compiling environment options. I started with prepared GTK+ packages and MinGW but ended up integrating GTK+ with MSVC.
GTK+ exists for a long time and some people may find it old-school. On the other hand, it shows that it has proven to be stable and useful. There are also bindings for C++ and C#.
As with every big framework, the more you need from it the longer you will have to learn. But the other way round it works too; the more you learn the more you'll be able to do with it. Consistent coding style helps getting used to it.
--- Ferda

Which are the databases used in gtk?

We can use databases sqlite,mysql etc with python and qt.But i dont know which database is used in gtk and how to use it.can anybody help me to find the database for gtk and also give some example for HOW TO USE IT (i am beginner).
GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, but it is not a programming language itself. It is written in C but has been designed from the ground up to support a wide range of languages, not only C/C++. Using GTK+ from languages such as Perl and Python (especially in combination with the Glade GUI builder) provides an effective method of rapid application development, therefor you can use any of the technologies you wrote.
As ergosys said, GTK favors no database API. You can use what you want.

is it possible to write system level code in vala

Is it possible to write system level source code in Vala.
like for a small Micro kernel OS?
or for use it in the Linux kernel for modules or device drivers?
Technically, yes, but in reality it's probably not very practical.
People have written kernel modules in Vala before, but AFAIK nothing really serious. Actually, someone wrote a Multiboot kernel using Vala a few years ago.
You can get around the dependency on GLib by using the posix profile (pass --profile posix), but it tends to be a bit buggy and lots of features aren't supported, including a lot of the stuff that makes programming in Vala a pleasant experience.
I don't think so. Vala is tied to the GObject and Glib gtype type system (inside GTK) - including its reference count based memory management. The Linux kernel uses a different (even if conceptually similar) memory management. And inside your microkernel OS, you need to provide one.
Some update to the answers above: the posix profile has been deleted from vala codebase in version 0.17.4, because it was unmaintained. Here is the announcement.