Questions tagged [glib]

GLib is a general-purpose and cross-platform utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on.

GLib is a general-purpose and cross-platform utility library, which provides many useful data types, macros, type conversions, string utilities, file utilities, a main loop abstraction, and so on.

For many applications, C with GLib and GObject is an alternative to C++ with STL. It works on many UNIX-like platforms, Windows, OS/2 and BeOS. GLib is released under the GNU Library General Public License (GNU LGPL).

The GLib reference manual can be found at the GNOME developer site.

1529 questions
14
votes
2 answers

Why would anyone use gboolean (GLib) instead of bool type?

I've been reading some code which uses gtk+ and I've encountered types like gboolean and gunichar. As long as I can understand the point of using gunichar instead of wchar_t (glib gunichar and wchar_t), I can't really understand the point of using…
Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
14
votes
2 answers

Why does GLib redefine types?

What is the reasoning behind types to be redefined in GLib? Why do they turn char into gchar, int into gint, etc.?
Lucas
  • 13,679
  • 13
  • 62
  • 94
13
votes
1 answer

GLib's GAsyncQueue vs. POSIX message_queue

Does anyone have any idea of the relative performance of GLib's GAsyncQueue vs. POSIX message_queue for inter-thread communication? I will have many small messages (both one way and request-response types), to be implemented in C on top of Linux…
dbikash
  • 345
  • 2
  • 12
13
votes
2 answers

glib.h: No such file or directory

I tried installing gtk and glib using sudo apt-get install libglib2.0-dev and sudo apt-get install libgtk2.0-dev but locate glib.h does not return any path for glib results of locate glib.h are $ locate…
chinmay
  • 321
  • 1
  • 6
  • 19
13
votes
3 answers

When to unref a GVariant that has a floating reference?

https://developer.gnome.org/glib/unstable/glib-GVariant.html#g-variant-ref-sink I have read the above glib manual which says: "GVariant uses a floating reference count system. All functions with names starting with g_variant_new_ return floating…
kaylum
  • 13,833
  • 2
  • 22
  • 31
12
votes
1 answer

Why does Glibmm/Gtkmm not include the unary dereferencing operator, *, for Glib::RefPtr?

Glib::RefPtr allows dereferencing via '->' but not via '*'. Why is this? I can of course do: class Foo {}; Glib::RefPtr fooPtr; fooPtr.operator->(); The docs specifically mention that they left operator*() out. But they do not offer any…
Catskul
  • 17,916
  • 15
  • 84
  • 113
11
votes
1 answer

Is GHashTable (glib2) thread safe?

I have multiple threads adding, modifying and looking up data in GHashTable. Is it threadsafe, or do I need to implement threadsafety myself?
iseletsk
  • 477
  • 3
  • 9
11
votes
3 answers

How can I deactivate 'Warning: Source ID 510 was not found when attempting to remove it - GLib.source_remove(self._idle_event_id)'?

When I execute #!/usr/bin/env python import matplotlib.pyplot as plt plt.plot([1, 2, 3, 4]) plt.show() (and more complex examples) I get /usr/local/lib/python3.4/dist-packages/ matplotlib/backends/backend_gtk3.py:215: Warning: Source ID 7 was…
Martin Thoma
  • 124,992
  • 159
  • 614
  • 958
11
votes
4 answers

Vala vapi files documentation

I'd like to hack on an existing GLib based C project using Vala. Basically what I'm doing is, at the beginning of my build process, using valac to generate .c and .h files from my .vala files and then just compiling the generated files the way I…
Jordan
  • 1,599
  • 4
  • 26
  • 42
11
votes
1 answer

Will strcmp compare utf-8 strings in code point order?

In a C program, I want to sort a list of valid UTF-8-encoded strings in Unicode code point order. No collation, no locale-awareness. So I need a compare function. It's easy enough to write such a function that iterates over the unicode characters.…
skagedal
  • 2,323
  • 23
  • 34
11
votes
1 answer

Macro for iterating over a GList

I am using GLib's doubly linked list structure, GList. I would like to know if there is any standard macro for iterating over a GList. I couldn't find any such thing in the GLib documentation. As a result I have made my own macro, but I'd rather use…
James
  • 3,597
  • 2
  • 39
  • 38
10
votes
1 answer

How portable is GLib?

I know this question might sound strange because GLib is a portability library, but how portable is it? To name one example: Does GLib (including GObject) run on microcontrollers or does it depend on some kind of operating system? Are there any…
drakide
  • 1,757
  • 2
  • 15
  • 23
9
votes
1 answer

How can I set the log level in glib

Is there a way to change the log level in glib so e.g. in a release version of an application the debug messages of g_debug won't be logged to the stdout? Do I really need to implement my own log handler for this (g_log_set_handler)?
Oliver Sauder
  • 1,124
  • 12
  • 29
9
votes
1 answer

Logind and gdbus: Not getting notifications

I use DBus to communicate with logind to get informations about active sessions, etc. I have created the code using gdbus-codegen. I can get informations by using the call and get methods, but I do not receive notifications (I have a g_main_loop…
Nidhoegger
  • 4,973
  • 4
  • 36
  • 81
9
votes
3 answers

glib memory allocation VS std *alloc and free

I tend to use std *alloc/free functions to allocate/free dynamic memory in my C programs. I wonder if there are any good reasons to use the GLIB Memory Allocation functions instead of the std ones. I'd be grateful if the comunity could point out…
Manuel Salvadores
  • 16,287
  • 5
  • 37
  • 56