glib

GLib atoms and memory chunks

The following code snippet is from The Official GNOME 2 Developer's Guide: GMemChunk my_chunk; my_chunk = g_mem_chunk_new("My Chunk", 42, 42*16, G_ALLOC_AND_FREE); gchar *data[50000]; gint i; /* allocate 40,000 atoms */ for(i = 0; i < 40000; i++) { data...

GLib Hash Table - Pointer

I'm trying to increment the value of some specific key if it was found. For some reason I keep getting the (pointer) address when I dump all keys:values from the hash table. Output a: 153654132 // should be 5 b: 1 c: 153654276 // should be 3 d: 1 e: 1 f: 153654420 // should be 3 int proc() { ...

Sort Hash Tables Glib - qsort

I'm trying to sort a GLib hash table by id that looks something like: key - id { "Red", 2, "BLue", 4, "Yellow", 5, "Orange", 8 } I'm just not sure how to approach this because GLib does not have a sort method. I was thinking to use qsort or GCompareFunc Any ideas will be appreciate it! ...

Need help implementing simple socket server using GIOService (GLib, Glib-GIO)

I'm learning the basics of writing a simple, efficient socket server using GLib. I'm experimenting with GSocketService. So far I can only seem to accept connections but then they are immediately closed. From the docs I can't figure out what step I am missing. I'm hoping someone can shed some light on this for me. When running the follo...

Glib segfault g_free hash table

I'm not quite sure why if I try to free the data I get segfault. Any help will be appreciate it. struct mystu { char *q; }; static GHashTable *hashtable; static void add_inv(char *q) { gpointer old_key, old_value; if(!g_hash_table_lookup_extended(hashtable, q, &old_key, &old_value)){ g_hash_table_insert(hashtable, g...

Glib::ustring and Japanese characters

Glib::ustring is supposed to work well with UTF8 but I have a problem when working with Japanese strings. If you compare those two strings, "わたし" and "ワタシ", using == operator or compare method, it will answer that those two strings are equals. I don't understand why. How Glib::ustring works ? The only way I found to get false to the c...

How to convert an integer to a string in GLib?

I want to convert an integer value to string in GLib. Is there any macro or function to da that? Or Can i store different data types in the same doubly linked list? ...

How to compile a program which needs a newer version of glib

Hi, I am trying to compile Webkit on Ubuntu 8.04. But when i run autogen.sh, I get the following error saying it needs a newer version of glib. So what is the safest way to install glib without screwing up the rest of my OS (since the rest needs 2.16 while webkit compile needs 2.21)? checking for GLIB... configure: error: Package re...

Need help in resolving a compiler error: error: invalid conversion from ‘int’ to ‘GIOCondition’

I have a simple cpp file which uses GIO. I have stripped out everything to show my compile error: Here is the error I get: My.cpp:16: error: invalid conversion from ‘int’ to ‘GIOCondition’ make[2]: *** [My.o] Error 1 Here is the complete file: #include <glib.h> static gboolean read_socket (GIOChannel *gio, GIOCondition condition, g...

glib on Symbian S60

Hello, I am interested in porting a C library that depends on glib to Symbian. After some research, I found that there is a Symbian port of glib. However I can't seem to find much documentation about it. Can anyone point me to the right direction as to whether this can be even done or not? If yes, how. ...

Use regular expressions with Glib

Hello, I would like to find all comment blocks(/*...*/) but the function g_regex_match_full always returns true. Here is the code : // Create the regex. start_block_comment_regex = g_regex_new("/\*.*\*/", G_REGEX_OPTIMIZE, 0, &regex_error); //Search the regex; if(TRUE == g_regex_match_full(start_block_comment_regex, current_line, -1, 0...

Looking for a smarter way to convert a Python list to a GList?

I'm really new to C -> Python interaction and am currently writing a small app in C which will read a file (using Python to parse it) and then using the parsed information to execute small Python snippets. At the moment I'm feeling very much like I'm reinventing wheels, for example this function: typedef gpointer (list_func)(PyObject *o...

How to install a newer version of Gtk2 and Glib in Ubuntu Hardy

The install of Gtk2 and Glib mentioned above is only the first part. What I really want to do is install a piece of software called Chart in my Ubuntu Hardy machine. Here is the instruction: "To run Chart you need Perl 5.10, Gtk2-Perl 1.220, and a list of Perl modules as long as your arm, per the Makefile.PL in the sources, all availa...

Inserting non-pod struct into a GHashTable

Hi there, I'm trying to build a GHashTable of instances of a struct containing ints, a time_t and a few char*'s. My question is, how do you insert an instance of a struct into a GHashTable? there are plenty of examples of how to insert a string or an int (using g_str_hash and g_int_hash respectively), but I'm guessing thatI want to use...

How to make command-line options mandatory with GLib?

I use GLib to parse some command-line options. The problem is that I want to make two of those options mandatory so that the program terminates with the help screen if the user omits them. My code looks like this: static gint line = -1; static gint column = -1; static GOptionEntry options[] = { {"line", 'l', 0, G_OPTION_ARG_INT,...

Glib convert epoch time to string.

I am using glibs functions to convert epoch time to string as follows. But each time it is giving me some random time. //Convert Time in string. GDate *date = g_date_new_julian(timestampsecs); gchar date_string[50]; g_date_strftime(date_string, 50, (const gchar*)"%a, %I:%M %p", (const GDate*)date); printf("Date String [%s]\n", date_st...

Compiling Glib Code on Ubuntu

I'm trying to compile ARCCC (https://sourceforge.net/projects/arccc/) on Ubuntu 9.10, but I'm getting the make error "glib.h: No such file or directory", and the autoconfig script reports that Glib isn't installed. However, I have the libglib2.0-dev package installed, which appears to provide all the glib headers. Is there something miss...

Where do I place GLib DLLs on a Windows machine?

I am using GLib in a Windows application. Where do I place the GLib DLLs? What is the "accepted" practice here? Do I use a shared location like C:\Windows\System32 or should I keep a local copy within my application folder? ...

Error while installing dependencies for PyGTK on Mac OS 10.6.3

I tried to install the following dependencies for PyGTK 2.16.0 (the Python GIMP Tool Kit) on Mac OS 10.6.3: glib 2.25.5 gettext-0.18 libiconv-1.13.1 When I tried to install glib, I got the following error message: gconvert.c:55:2: error: #error GNU libiconv not in use but included iconv.h is from libiconv The libiconv web page tal...

Should a g_object_new have a matching g_object_unref?

I'm using libnotify to show desktop notifications in my application; notify_notification_new() returns a NotifyNotification*, which should be passed as the first param to further function calls of the notification library. There is no notify_notification_free() which frees the pointer it returns. I looked up the source of notify_notifi...