glib

g_timeout_add inside a GThread

倾然丶 夕夏残阳落幕 提交于 2019-12-22 12:18:38
问题 I'm trying to add a timeout source specific to a particular GThread. In the main thread, I can create a GMainContext ( g_main_context_new ) and add a timeout ( g_timeout_add ). However, when I try to do it in a thread created with g_thread_create it simply doesn't work, the GSourceFunc is never called and I have no clue why. For the moment I've only got this the documentation: Callbacks require a bit of attention. Callbacks from GTK+ (signals) are made within the GTK+ lock. However callbacks

Does the glib list in the called function need to be free for deallocating memory

孤人 提交于 2019-12-20 05:54:57
问题 I have a simple program that uses glib list where I have a function which returns the list to the calling function .here in the called function i have decleared another list and the list is returned to the calling function. I have freed the list in the main function but is in delimma that whether the list in the called function need to be freed for memory performance. #include <stdio.h> #include <string.h> #include <glib.h> char *col_trim_whitespace(char *str) { char *end; // Trim leading

Why does GObject method still get called even if callback arguments don't match those in XML?

走远了吗. 提交于 2019-12-19 09:48:05
问题 Suppose I have a method like this <interface name="org.Test.ChildTest"> <!-- set_age(guint32 new_age): sets new age --> <method name="set_age"> <arg type="u" name="new_age" direction="in"/> </method> In my table of methods I have: { (GCallback) child_test_set_age, dbus_glib_marshal_child_test_BOOLEAN__UINT_POINTER, 0 } and the right GObject method signature is: gboolean child_test_set_age (ChildTest *childTest, guint ageIn, GError** error) Why does my method, child_test_set_age() , still get

Which gtk method I have to use to get temporary path in Ubuntu?

China☆狼群 提交于 2019-12-18 16:57:19
问题 How can I get the temporary directory path in Ubuntu? 回答1: On most Unix-like systems, you'd be looking for /tmp . If that's not quite the answer you were after, you should specify which bit of Ubuntu you're talking about. Certain applications will allow you to specify where their temporary files are put (such as with the TMP , TEMP or TMPDIR environment variables) but a lot of stuff would break under UNIX if /tmp didn't exist, so it's safe just to use that. If you want to make it configurable

Which gtk method I have to use to get temporary path in Ubuntu?

倾然丶 夕夏残阳落幕 提交于 2019-12-18 16:57:08
问题 How can I get the temporary directory path in Ubuntu? 回答1: On most Unix-like systems, you'd be looking for /tmp . If that's not quite the answer you were after, you should specify which bit of Ubuntu you're talking about. Certain applications will allow you to specify where their temporary files are put (such as with the TMP , TEMP or TMPDIR environment variables) but a lot of stuff would break under UNIX if /tmp didn't exist, so it's safe just to use that. If you want to make it configurable

Why does GLib redefine types?

大城市里の小女人 提交于 2019-12-17 19:49:07
问题 What is the reasoning behind types to be redefined in GLib? Why do they turn char into gchar , int into gint , etc.? 回答1: Check out Basic Types in the GLib documentation. Essentially, it's to guarantee that certain types will exist with certain semantics, regardless of which C compiler or platform you're using. The types that C guarantees anyway are typedef ed just to make all of the type names look uniform. 来源: https://stackoverflow.com/questions/1819561/why-does-glib-redefine-types

Obtain device path from pyudev with python

℡╲_俬逩灬. 提交于 2019-12-17 17:12:04
问题 Using pydev with python-2.7 , I wish obtain the device path of connected devices. Now I use this code: from pyudev.glib import GUDevMonitorObserver as MonitorObserver def device_event(observer, action, device): print 'event {0} on device {1}'.format(action, device) but device return a string like this: (u'/sys/devices/pci0000:00/pci0000:00:01.0/0000.000/usb1/1-2') How can I obtain a path like /dev/ttyUSB1 ? 回答1: Device(u'/sys/devices/pci0000:00/pci0000:00:01.0/0000.000/usb1/1-2') is a USB

Does glib2 actually leak memory with ALWAYS-MALLOC?

自古美人都是妖i 提交于 2019-12-14 03:52:48
问题 This question is not a duplicate of many others, bekause I do use G_DEBUG=gc-friendly and G_SLICE=always-malloc Here is the source code: #include <glib.h> int main (int argc, char *argv[]) { GHashTable *ht; ht=g_hash_table_new(g_str_hash,g_str_equal); g_hash_table_insert(ht,"foo","bar"); g_hash_table_destroy(ht); return 0; } And here is Valgrind's output on this code: # G_DEBUG=gc-friendly G_SLICE=always-malloc valgrind --leak-check=full --show-reachable=yes ./test_vg ==1880== Memcheck, a

Behaviour of an hashtable using glib

 ̄綄美尐妖づ 提交于 2019-12-14 03:24:53
问题 I want to update the Volume to each @IP. So that for example after each 5 s I add V(i) of each @IP(i). Ok Now the hash table works fine it keeps updated after every T seconds . But the problem is that after a certain period I find that sometimes the same ip adress is repeated twice or even a lot of times within the hash table . So that when I close the process I find the same @IP repeated too many times. It is like there is a problem with the hash table or something like that. Here is the

Redirecting output of an external application started with glib

丶灬走出姿态 提交于 2019-12-14 02:36:11
问题 I'm trying to use vala to start an external application using GLib with spawn_command_line_sync(). According to the documentation (http://valadoc.org/#!api=glib-2.0/GLib.Process.spawn_sync) you can pass a string to store the output of the external application. While this works fine when starting a script which prints a couple of lines, I need to call a program which will print the content of a binary file. (for example "cat /usr/bin/apt-get") Is there any way how I can receive the output of