Many questions
Hi everybody, I have several questions: 1) How do we use the GThreadedSocketService and how do we specify the function to run when the connection is established? I'm using these function in a GUI application (see protocoltool on sourceforge); when the connection is made/closed, the GUI's controls are enabled/disabled. 2) Can an application load a linux kernel module? For example, my application may need i2c drivers. Does glib/gtk/gnome have anything to load kernel modules? How can it be done? 3) Now, for unrelated questions, what are the hook functions used for? They look interesting, but being an amateur programmer, I have no idea of the context where they may be used. Are they useful in an user application? 4) How do we properly use the g_cancellable functions and when are these used? Are they useful in an user application? Thanks! JP Note: please reply to this mailing list for convenience of other users. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Can g_error() write logs to files?
Hi, all! I want g_error() to write messages to files, because released edition shouldn't to print any messages on terminal. But if find any bugs, should to find error messages to send support team. I have read'd GLib sources, but not find any useful information. How do I use g_error () to write error log files? Thank you for all. -- Mike. Blog: http://ekd123.org/ Fedora Project Contributor - Translator. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Strange dead lock with g_threads_enter
Hi everyone, I am working on a multi-threaded application. The thing is, it working perfectly for a while, but after that it fall into a deadlock. Here is the code layout: // Thread function // It is signaled to wake up for every 1 second gpointer motion_compile_thread(gpointer data) { ... while (TRUE) { if (!g_mutex_trylock(cp_mutex)) continue; g_cond_wait(compile_cv, cp_mutex); g_mutex_unlock(mutex); gdk_threads_enter(); // do somethin do_refresh() gdk_threads_leave(); } void do_refresh(void) { if (!g_mutex_trylock(cp_mutex)) continue; // do something, but guarantee won't cause recursive call to do_refresh g_mutex_unlock(cp_mutex); } The program worked without problem for a while(about 5 minute) but after that it hangs. Here is the gdb backtrace. (gdb) bt #0 0xb7fe1424 in __kernel_vsyscall () #1 0xb74c9e82 in __lll_lock_wait () from /lib/libpthread.so.0 #2 0xb74c535b in _L_lock_505 () from /lib/libpthread.so.0 #3 0xb74c5181 in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79475b6 in ?? () from /usr/lib/libgdk-x11-2.0.so.0 #5 0xb7985e3e in ?? () from /usr/lib/libgdk-x11-2.0.so.0 #6 0xb7515096 in g_main_context_prepare () from /usr/lib/libglib-2.0.so.0 #7 0xb7515f33 in ?? () from /usr/lib/libglib-2.0.so.0 #8 0xb7516a1b in g_main_loop_run () from /usr/lib/libglib-2.0.so.0 #9 0xb7af95b9 in gtk_main () from /usr/lib/libgtk-x11-2.0.so.0 #10 0x080536b3 in gui_main (builder=0x80e0828) at gui/gui-main.c:185 #11 0x08052e15 in main (argc=1, argv=0xb1e4) at main.c:127 (gdb) thread 2 [Switching to thread 2 (Thread 0xb322cb70 (LWP 24441))]#0 0xb7fe1424 in __kernel_vsyscall () (gdb) bt #0 0xb7fe1424 in __kernel_vsyscall () #1 0xb74c9e82 in __lll_lock_wait () from /lib/libpthread.so.0 #2 0xb74c535b in _L_lock_505 () from /lib/libpthread.so.0 #3 0xb74c5181 in pthread_mutex_lock () from /lib/libpthread.so.0 #4 0xb79475b6 in ?? () from /usr/lib/libgdk-x11-2.0.so.0 #5 0xb7947b80 in gdk_threads_enter () from /usr/lib/libgdk-x11-2.0.so.0 #6 0x0805b676 in motion_compile_thread (data=0x8117330) at motion.c:96 #7 0xb753ebcf in ?? () from /usr/lib/libglib-2.0.so.0 #8 0xb74c2df0 in start_thread () from /lib/libpthread.so.0 #9 0xb743f98e in clone () from /lib/libc.so.6 >From what I can see, the program is stuck because the main thread locked a mutex in #3. But from the backtrace, the mutex seems to be locked by gtk_main_loop_run() which is something I can't control, and somehow it locked the same mutex as gdk_threads_enter()? any ideas? Thanks, Wei-Ning Huang ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkSwitch — lack of specific signal
Le 05/03/2011 03:17, John Lumby a écrit : > > A! Thank you Tadej.No, mine had only two parameters, the obj > ptr and the data ptr.I added the paramspec in between and now all works > perfectly. > By the way - this seems a bit unpleasant, that some callbacks have a > prototype of (objptr, dataptr) and others have (objptr, paramspec, > dataptr).How would I know which one to use? Is it that some are in the > gtk layer (2 params) but other like notify::active are in the gdk layer (3 > params)?And I kind of feel something should have alerted me although I don't > know what - I guess the compiler doesn't know. > I suppose this is all described somewhere - where?(I am new to gtk > application programming). Check the documentation [1] ;) For example, for GtkWidget's signals see [2] or for GtkWindow see [3]... and so on. Cheers, Colomban [1] http://library.gnome.org/devel/gtk/stable/ [2] http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget.signal-details [3] http://library.gnome.org/devel/gtk/stable/GtkWindow.html#GtkWindow.signal-details > Cheers, John > >> Subject: RE: GtkSwitch — lack of specific signal >> From: tadeb...@gmail.com >> To: johnlu...@hotmail.com >> CC: gtk-app-devel-list@gnome.org >> Date: Sat, 5 Mar 2011 02:50:05 +0100 >> >> Hello. >> >>> Thanks both. I tried notify::active and it works as well as event-after >>> but still the data pointer argument is bad on entry to the callback(it's >>> not zero but not a valid GTK_WIDGET either). I don't know why - maybe >>> something related to GtkSwitch or maybe a mistake in my code somewhere. >>> Cheers, John Lumby >> >> Are you sure your functions has the right prototype? GObject::notify >> signal handlers should have callbacks defined like this: >> >> void >> notify_callback (GObject*obj, >> GParamSpec *pspec, >> gpointer *data) >> { >> /* La la la */ >> } >> >> Cheers, >> Tadej >> >> -- >> Tadej Borovšak >> tadeboro.blogspot.com >> tadeb...@gmail.com >> tadej.borov...@gmail.com >> ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: GtkSwitch — lack of specific signal
A! Thank you Tadej.No, mine had only two parameters, the obj ptr and the data ptr.I added the paramspec in between and now all works perfectly. By the way - this seems a bit unpleasant, that some callbacks have a prototype of (objptr, dataptr) and others have (objptr, paramspec, dataptr).How would I know which one to use? Is it that some are in the gtk layer (2 params) but other like notify::active are in the gdk layer (3 params)?And I kind of feel something should have alerted me although I don't know what - I guess the compiler doesn't know. I suppose this is all described somewhere - where?(I am new to gtk application programming). Cheers, John > Subject: RE: GtkSwitch — lack of specific signal > From: tadeb...@gmail.com > To: johnlu...@hotmail.com > CC: gtk-app-devel-list@gnome.org > Date: Sat, 5 Mar 2011 02:50:05 +0100 > > Hello. > > > Thanks both. I tried notify::active and it works as well as event-after > > but still the data pointer argument is bad on entry to the callback(it's > > not zero but not a valid GTK_WIDGET either). I don't know why - maybe > > something related to GtkSwitch or maybe a mistake in my code somewhere. > > Cheers, John Lumby > > Are you sure your functions has the right prototype? GObject::notify > signal handlers should have callbacks defined like this: > > void > notify_callback (GObject*obj, > GParamSpec *pspec, > gpointer *data) > { > /* La la la */ > } > > Cheers, > Tadej > > -- > Tadej Borovšak > tadeboro.blogspot.com > tadeb...@gmail.com > tadej.borov...@gmail.com > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: GtkSwitch — lack of specific signal
Hello. > Thanks both. I tried notify::active and it works as well as event-after > but still the data pointer argument is bad on entry to the callback(it's not > zero but not a valid GTK_WIDGET either). I don't know why - maybe > something related to GtkSwitch or maybe a mistake in my code somewhere. > Cheers, John Lumby Are you sure your functions has the right prototype? GObject::notify signal handlers should have callbacks defined like this: void notify_callback (GObject*obj, GParamSpec *pspec, gpointer *data) { /* La la la */ } Cheers, Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: GtkSwitch — lack of specific signal
Thanks both. I tried notify::active and it works as well as event-after but still the data pointer argument is bad on entry to the callback(it's not zero but not a valid GTK_WIDGET either). I don't know why - maybe something related to GtkSwitch or maybe a mistake in my code somewhere. Cheers, John Lumby Emmanuele wrote> > On 2011-03-04 at 12:45, John Lumby wrote: > > > I have been playing with a small application using the new (in gtk3) > > GtkSwitch ("light switch" style) widget. > > I want a signal for when the state is toggled, e.g. "switched". > > you can use "notify::active". > > ciao, > Emmanuele. > > -- > W: http://www.emmanuelebassi.name > B: http://blogs.gnome.org/ebassi Yeti wrote: > I've never used GtkSwitch but from a quick glance at the docs I suppose> you > have to connect to "notify::active", i.e. watch changes of the> property > "active".> > Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkSwitch — lack of specific signal
On 2011-03-04 at 12:45, John Lumby wrote: > I have been playing with a small application using the new (in gtk3) > GtkSwitch ("light switch" style) widget. The reference manual does not > mention any signal specific to this widget, and I think it would be > nice to have one. I want a signal for when the state is toggled, e.g. > "switched". you can use "notify::active". ciao, Emmanuele. -- W: http://www.emmanuelebassi.name B: http://blogs.gnome.org/ebassi ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Resolving links and shortcuts
It's a long shot but I just wondered if glib or gtk+ have any functionality for resolving shortcuts on the Windows platform? i.e. opening a shortcut and returning the path to whatever object it's pointing to? I know I can achieve this with COM and iShellLink but ideally, I'd prefer to use glib or gtk+ if possible. I'm aware that hard links and symbolic links are supported on NTFS partitions, so (as a substitute) a function to resolve a hard link or symbolic link might suffice if shortcuts aren't supported directly. John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkSwitch — lack of specific signal
On Fri, Mar 04, 2011 at 12:45:18PM -0500, John Lumby wrote: > I have been playing with a small application using the new (in gtk3) > GtkSwitch ("light switch" style) widget. The reference manual does > not mention any signal specific to this widget, and I think it would > be nice to have one. I want a signal for when the state is > toggled, e.g. "switched". I've never used GtkSwitch but from a quick glance at the docs I suppose you have to connect to "notify::active", i.e. watch changes of the property "active". Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkSwitch — lack of specific signal
I have been playing with a small application using the new (in gtk3) GtkSwitch ("light switch" style) widget. The reference manual does not mention any signal specific to this widget, and I think it would be nice to have one. I want a signal for when the state is toggled, e.g. "switched". I eventually (after a lot of trial and error) found I could almost do what I needed by using the "event-after" signal, (snippet below), but with that signal, I found that the data pointer is null (zero) on entry to my callback. I don't know if that is because it is not really valid to use a signal with this widget at all? or some obscure bug? or just maybe that gtk3 is a bit new? By the way, the trial-and-error part is that although I found many different signal types which were delivered to my cb, the event-after was the only one that was delivered exactly once and once only, after the user toggled the switch. GtkWidget *do_light_switch (GtkWidget *do_widget){ [...] GtkSwitch *light_switch_widg; GtkImage *light_on_image; g_signal_connect_object ( GTK_WIDGET (light_switch_widg), "event-after", G_CALLBACK (turn_light_on_off) , GTK_WIDGET (light_on_image) , G_CONNECT_AFTER); In my callback, the data pointer is 0 (confirmed with gdb) yet the pointer is set correctly in the above g_signal_connect_object .I eventually resorted to storing the value of the light_on_image in a static savearea and referencing it from there in the cb : save_light_on_image_ptr = GTK_WIDGET (light_on_image); (which worked and also confirmed that the pointer was set correctly at the time of the g_signal_connect_object). Or can someone spot something I did wrong? John Lumby ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list