glib

gobject io monitoring + nonblocking reads

I've got a problem with using the io_add_watch monitor in python (via gobject). I want to do a nonblocking read of the whole buffer after every notification. Here's the code (shortened a bit): class SomeApp(object): def __init__(self): # some other init that does a lot of stderr debug writes fl = fcntl.fcntl(0, fcntl.F_G...

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 something standard if it exists. To Illustrate the the issue: Usually I write a lot of c...

GLib Convert gchar* to gint

I have a string that I want to convert to an int. I am aware that there are other methods for doing this such as atoi; however, I'd really like to use a glib function if one exists. Does such a function exist? Thanks! ...

Watching sockets with Glib on Windows puts them in non-blocking mode

The following code does not work correctly on Windows (but does on Linux): sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setblocking(True) sock.connect(address) gobject.io_add_watch( sock.fileno(), gobject.IO_OUT | gobject.IO_ERR | gobject.IO_HUP, callback) Snippets o...

Under Gtk+/Glib are there any utility functions, where we can read and write config File?

I have a config file in which I have keys and values, like this: key1=value1 key2=value2 key3=value3 So is there any utility functions in Gtk/Glib that can read this file and retrieve the value corresponds to key? ...

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. ? ...

What should I use instread of g_strncasecmp?

It looks like g_strncasecmp is deprecated, so I am looking for another function to do the same thing. ...

How g_main_loop works in gtk programming ?

I am new to GTK+ programming. I came across an API called g_main_loop(). I have used it in my code but I am still unaware that how exactly it works. Can somebody explain g_main_loop() with small code snippet? ...

g_strduping a char array member element

typedef struct { char name[10]; } A; A * inst = get_instance_of_A(); char *str = g_strdup ( inst->name ); The last line doesn't compile. I also tried &(inst->name) with no luck. The error I get is: Error: char is not a structure type. I understand that char[] and char * are different types altogether. But shouldn't g_strdup be able ...

are glib signals asynchronous?

When using glib to dispatch signals through emit, are all the "listeners"/handlers called back-to-back or is control relinquished to the event loop after each listener/handler? ...

Unable to compile basic GLIB program after GLIB install

I can't seem to compile this basic program using glib.h... #include glib.h #include stdio.h int main () { return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ; return 0; } glib.h is located in /usr/local/include/glib-2.0 So I compiled with $ gcc -v -c -mcpu=v9 -I/usr/local/include/glib-2.0 testme2.c ...

How to walk a directory in C

I am using glib in my application, and I see there are convenience wrappers in glib for C's remove, unlink and rmdir. But these only work on a single file or directory at a time. As far as I can see, neither the C standard nor glib include any sort of recursive directory walk functionality. Nor do I see any specific way to delete an ent...

How can I link to my own verson of GLib rather than the system installed one?

I have been looking through the source of GLib and GObject and writing programs to use certain features of each. But now I'd like to debug though something in the GLib source code without installing anything on my system. I have a built version of the source code somewhere and I'd like to use those .so files rather than the system inst...

Glib use in an iPhone App

Hi, I would like to develop an iPhone App based on an existing open-source Objective-C framework, however that framework makes extensive use of the glib library and I cannot find a way to build and include the glib library for an iPhone app (non jailbreak). Is there any way this can be done, or is there any recommended approach to port...

how do I iterate over a "gslist" in Python?

Let's say I get a glib gpointer to a glib gslist and would like to iterate over the latter, how would I do it? I don't even know how to get to the gslist with the gpointer for starters! Update: I found a workaround - the python bindings in this instance wasn't complete so I had to find another solution. ...

glibc, glib and gnulib

what are differences in the strength and features in gnulib glib and glibc Thanks! ...

Why use glib functions?

Hello, While programming in C and GTK+, Why is it "better" to use g_strdup_printf, g_free, g_strcmp0 etc... and fellow glib functions? Merci! ...

Does using large libraries inherently make slower code?

I have a psychological tic which makes me reluctant to use large libraries (like GLib or Boost) in lower-level languages like C and C++. In my mind, I think: Well, this library has thousands of man hours put into it, and it's been created by people who know a lot more about the language than I ever will. Their authors and fan...

python glib main loop: delaying until loop is entered

Is there a way to schedule the execution of a callable until the glib main loop is entered? Alternatively, is there a signal I can subscribe to that will indicate that the main loop is entered? ...

Glib hash table replace

I'm using GLib Hash Table. I'm trying to get the current value of the key that I found and then increment its value. I'm not quite sure how can I replace the existing value. typedef struct { gchar *key; guint my_int; } my_struct; char *v; v = g_hash_table_lookup(table, my_struct.key); if (v == NULL) g_hash_table_insert(tab...