Re: Beginners guide
Thanks for this. I can use all the help I can get. Date: Tue, 24 Apr 2018 19:39:06 +0100 From: Jim Reilly <jimreillyinde...@gmail.com> I have put together a guide to help beginners to get started using gtk+3.0 in the hope that it might be useful. I do not have a web site through which I can make it available so I have attached it to this e-mail so that, if anyone thinks it is worth reading, they can make it accessible to others. -- Marshall Lake -- ml...@mlake.net -- http://www.mlake.net ___ gtk-list mailing list gtk-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-list
Re: Reshowing Icons in a Grid (Andrew Potter)
I have 10 different icons stored in 10 files. I want to display these 10 icons in different locations in a gtk_grid_new(). It works fine once. If I gtk_widget_destroy(grid), create a new grid, and try to display these 10 icons a second time (some in different grid locations and some not) I get gtk_grid_attach: assertion `gtk_widget_get_parent (child) == NULL' failed and several gtk_grid_attach: assertion `GTK_IS_WIDGET (child)' failed However, if I re-load the icons from their files after gtk_widget_destroy(grid) it works fine the second time. Most widgets are floating on creation. Then when you add them to a container they get sinked. When you destroy the grid, it unrefs all its children before it is destroyed. If that is the only reference your icons, they are destroyed as well. You can g_object_sink_ref(your_icon) after you create them the first time, then you should be able to add them to new containers after they are destroyed. That's the ticket! Thanks. One minor change ... it should be g_object_ref_sink() rather than g_object_sink_ref(). -- Marshall Lake -- ml...@mlake.net -- http://www.mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Reshowing Icons in a Grid
I have 10 different icons stored in 10 files. I want to display these 10 icons in different locations in a gtk_grid_new(). It works fine once. If I gtk_widget_destroy(grid), create a new grid, and try to display these 10 icons a second time (some in different grid locations and some not) I get gtk_grid_attach: assertion `gtk_widget_get_parent (child) == NULL' failed and several gtk_grid_attach: assertion `GTK_IS_WIDGET (child)' failed However, if I re-load the icons from their files after gtk_widget_destroy(grid) it works fine the second time. I assume this is a referencing issue. But, shouldn't the gtk_widget_destroy(grid) destroy all references? How can I reshow the icons without reloading the files? -- Marshall Lake -- ml...@mlake.net -- http://www.mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: future of development for the desktop (C++ vs C)
Is gtk+ 3.*.* now faster than the latest gtk+-2.*.* ? If not, since even gtk+-2.*.* is slower than Qt, gtk+ loses. ... Here is another thread: http://stackoverflow.com/questions/1887070/what-should-i-choose-gtk-or-qt . FWIW, Qt now also is LGPL. I wouldn't mind giving Qt a trial but I don't do C++. I only use C. Can I use Qt with C ? Are there any toolkits besides GTK which can be used with C ? -- Marshall Lake -- ml...@mlake.net -- http://www.mlake.net ___ gtk-list mailing list gtk-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-list
Timely Display of Dialog Contents
I have an issue where the contents of a dialog (a label pic) is not always displayed in a timely manner (or at all). In the code below the dialog outline (the size of the dialog changes from pic to pic) always displays properly as it should. But the contents of the label and the pic in the gtk_image_new_from_pixbuf() call sometimes display appropriately and sometimes don't. (When the dialog content doesn't display properly the dialog outline displays but the contents are blank.) The code below is within a large loop. There's a lot of other stuff going on. The contents of the dialog (label pic) changes with each execution of the code. If I slow down execution of the entire code with sleep() I get the same results as described above. The code below is executed with a g_idle_add(). I've tried adding: while (gtk_events_pending ()) gtk_main_iteration (); after the gtk_widget_show_all() to no avail. I appreciate any insight. batterpicwin = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (batterpicwin), Batter Pic); gtk_window_set_default_size (GTK_WINDOW (batterpicwin), 200, 130); gtk_window_move (GTK_WINDOW (batterpicwin), batpicwinlocX, batpicwinlocY); gtk_signal_connect (GTK_OBJECT (batterpicwin), delete_event, GTK_SIGNAL_FUNC (donot_delete_event), 0); strcpy (work[0], Batting - ); strcat (work[0], savebattername[0]); vbox2 = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (batterpicwin)-vbox), vbox2, TRUE, TRUE, 0); label = g_object_new (GTK_TYPE_LABEL, label, work[0], NULL); gtk_box_pack_start (GTK_BOX (vbox2), label, TRUE, TRUE, 0); vbox2 = gtk_vbox_new (FALSE, 0); gtk_container_set_border_width (GTK_CONTAINER (vbox2), 8); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (batterpicwin)-vbox), vbox2, TRUE, TRUE, 0); picbox = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (picbox), gtk_image_new_from_pixbuf (pic)); gtk_box_pack_start (GTK_BOX (vbox2), picbox, TRUE, TRUE, 0); gtk_widget_show_all (batterpicwin); -- Marshall Lake -- ml...@mlake.net -- http://www.mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Application Ending Before Secondary Thread Ends
I play audio via g_thread. If the user quits the application before the thread is completed (and the user executes the application from the command line) the terminal needs reseting. It's fine if the thread ends before the user quits the application. I haven't tried but I expect I can avoid this behavior by doing a g_thread_join() and waiting for the thread to finish before exiting the application. But I don't really want to do that (some of the audio is very long). Are there any alternatives? -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Idle Function Not Getting Called
The following are the first few lines of my main() ... openlog (gtknsbclient, LOG_NDELAY, LOG_USER); if (!g_thread_supported ()) g_thread_init (NULL); gdk_threads_init (); gdk_threads_enter (); /* initialize GTK interface */ gtk_init (argc, argv); And now you pull the GDK global lock out of the hat to add to the mix! I would suspect that you are recursively, or out-of-order, locking on that, given the large number of other locks you seem to have in your program. It is difficult to use correctly. Why incidentally are you using both extra-threaded access to GTK+ with the GDK global lock and also accessing GTK+ from threads via the idle handler? You would normally do one or the other, not both. Why not drop the global lock, or drop the idle handlers (preferably the first of those)? I'll be a son-of-a-gun. Removing the gdk_* calls fixed the problem. It's something I should have known. I really appreciate your time and effort helping me. -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Idle Function Not Getting Called
The important point in looking at out-of-order locking (or other locking issues) is that the idle handler runs in the thread in which the main program loop runs, not the thread which called g_idle_add()/ g_idle_add_full(), and that it runs at a time not of that calling thread's choosing. Incidentally, to see if you have recursive locking have you tried recursive mutexes to see if that exhibits the same problem or not? If they don't your search is narrowed considerably. I've taken some time to check the mutex and locks/unlocks between the secondary thread and the idle function. All appear as it should. The locks/unlocks are being applied in an orderly fashion and as they should be, and there are no recursive locks. The program flows as it should. I still feel my problem has something to do with the secondary thread and idle function working together but at this point I'm not sure what to check next. -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Idle Function Not Getting Called
The mutex locks/unlocks are only in a secondary thread and an idle function. I assume there's no problems with idle functions using mutexes? There is no problem provided that any mutex acquired by the idle function does not block (it immediately acquires), or if it does block then it only does so transiently. If the secondary thread undertakes a lengthy operation holding a lock which the idle function may also want to acquire, then there is a bottleneck in the code. If at the same time the secondary thread is waiting for the idle handler to complete, there is a deadlock. In my case the secondary thread adds the idle function and then waits (via GCond) for it to finish. The idle function consists of a simple modal dialog. The important point in looking at out-of-order locking (or other locking issues) is that the idle handler runs in the thread in which the main program loop runs, not the thread which called g_idle_add()/ g_idle_add_full(), and that it runs at a time not of that calling thread's choosing. I don't quite understand this. Don't all idle functions run in the main program loop thread? -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Idle Function Not Getting Called
Then you must have some function blocking between your call to g_idle_add_full() and control returning to the main loop. Anything in a GTK+ signal or event handler must not block. This means in practice that nothing should block after your call to gtk_main(). After spending more time with my code I'm just not seeing it. Below is the pertinent code. AddName() is called from a drop-down menu item. Via debug code I've seen that the program flow is as it should be ... all functions are exited. The first idle function (PlayNetGame()) is added, executed, and exited as it should be. The second idle function (PlayTheGame()) is added but is never called. Does anyone see what might be blocking the call of PlayTheGame() or have any other suggestions? I have not tried to find it in the code, but as your application is multi-threaded you are showing the symptoms of a deadlock, either by recursive locking or more likely by out of order locking. Can you run the code through a deadlock checker, or if not can you by appropriate breakpoints find out if it is occurring in a mutex lock? I can't find a non-commercial deadlock checker for Linux. I agree that the multi-threaded facet of the code is causing my problem but so far I'm having trouble using breakpoints/debug code to isolate the exact cause. The mutex locks/unlocks are only in a secondary thread and an idle function. I assume there's no problems with idle functions using mutexes? -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Idle Function Not Getting Called
); gtk_dialog_add_button (GTK_DIALOG (dlgFile), Randomly Select Two Teams, 0); gtk_dialog_add_button (GTK_DIALOG (dlgFile), I'll Select the Teams, 1); gtk_widget_show (label); gtk_dialog_set_default_response (GTK_DIALOG (dlgFile), 2); x = gtk_dialog_run (GTK_DIALOG (dlgFile)); gtk_widget_destroy (dlgFile); return (x); } /* use a designated hitter? */ int SelDesignatedHitter () { gint x; GtkWidget *dlgFile, *label; dlgFile = gtk_dialog_new (); gtk_window_set_title (GTK_WINDOW (dlgFile), Use Designated Hitter?); gtk_signal_connect (GTK_OBJECT (dlgFile), delete_event, GTK_SIGNAL_FUNC (donot_delete_event), 0); label = gtk_label_new (Select One:); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlgFile)-vbox), label, TRUE, TRUE, 0); gtk_dialog_add_button (GTK_DIALOG (dlgFile), Use a Designated Hitter, 0); gtk_dialog_add_button (GTK_DIALOG (dlgFile), Do NOT Use a Designated Hitter, 1); gtk_widget_show (label); gtk_dialog_set_default_response (GTK_DIALOG (dlgFile), 2); x = gtk_dialog_run (GTK_DIALOG (dlgFile)); gtk_widget_destroy (dlgFile); return (x); } -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Idle Function Not Getting Called
What stops an idle function from being executed? ... pending events, right? I have a situation where an idle function does NOT get called with the following code: g_idle_add ((GSourceFunc) idlefunc, NULL); OR while (gtk_events_pending ()) gtk_main_iteration (); g_idle_add ((GSourceFunc) idlefunc, NULL); However, the idle function gets called fine with the following code: g_idle_add ((GSourceFunc) idlefunc, NULL); while (gtk_events_pending ()) gtk_main_iteration (); What would account for such behavior? Additionally, in the third code snippet, program flow gets stuck in the while loop until the idle function removes itself by returning FALSE. -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK threads
Just to let everyone know ... I discovered that I was having an issue with my socket logic which was the main cause of my problem outlined below. Once I resolved that issue and incorporated g_idle_add() along with GCond GMutex into my code everything is working. (When you reply, please add CC to devel mailing list, so other peoples know it's progress and may help you more). --- ml...@mlake.net wrote: From: Marshall Lake ml...@mlake.net To: Ardhan Madras aj...@knac.com Subject: Re: GTK threads Date: Wed, 8 Jul 2009 12:21:34 -0400 (EDT) Thanks for your feedback. I think what you say is likely my problem. On Wed, 8 Jul 2009, Ardhan Madras wrote: Hi, You should be aware when call GTK+ function in another thread, if you do this from another thread, GTK+ is likely not send commands to the X server. When you run a dialog in the main thread, main loop is blocked, so the dialog's window remain displayed until a response was given (eg. button was clicked). But in you code, you run the dialog outside the main loop (main thread) the main loop of course is not blocked, and it fails to show the dialog. See http://library.gnome.org/devel/gtk-faq/stable/x499.html on howto send GTK+ funcs to the main loop. Another way is to provide mechanism so you can run the dialog from the main thread by using such as condition variable (GCond). -- ajhwb --- ml...@mlake.net wrote: From: Marshall Lake ml...@mlake.net To: gtk-app-devel-list@gnome.org Subject: GTK threads Date: Wed, 8 Jul 2009 09:38:30 -0400 (EDT) I posted this on gtk-list but in the hope of catching a wider audience ... I'm developing a program(s) which runs in the client/server environment. I'm using GTK, sockets, and threads. (GTK and threads only on the client side.) I don't have very much experience using threads and this is the first time I've tried to call GTK functions within a thread, and I'm having problems. I've tried different ways of approaching the problem but can't seem to get anywhere. I suspect there's something I don't understand about thread processing or I'm under some misconception. Maybe someone can help me? Any help is much appreciated. I get the following errors when trying to run the code below (the errors show up when the program calls gtk_dialog_run() in the thread (Wait4Challenge()): src/xcb_io.c:242: process_responses: Assertion `(((long) (dpy-last_request_read) - (long) (dpy-request)) = 0)' failed. Fatal IO error 0 (Success) on X server :0.0. void * Wait4Challenge () { int wsock, x, port = 0, listensock, connected; char buffer[5000], *msg[5], challenger[50]; listensock = -1; for (x = 0; x 5; x++) msg[x] = NULL; wsock = get_connection (SOCK_STREAM, port, listensock); connected = 1; while (connected) { GtkWidget *dialog; int response; if (sock_gets (wsock, buffer[0], sizeof (buffer)) 0) { msg[0] = There is a problem with the server.\n\n; outMessage (msg); connected = 0; } if (buffer[0] == 'R') connected = 0; if (buffer[0] != 'C') continue; strcpy (challenger[0], buffer[1]); gdk_threads_enter (); dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, %s has challenged you to a game. Do you wish to play?, challenger); gtk_window_set_title (GTK_WINDOW (dialog), Play Challenger?); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); gdk_flush(); gdk_threads_leave (); if (response == GTK_RESPONSE_YES) { sock_puts (wsock, OK\n); connected = 0; } else { sock_puts (wsock, NO\n); for (x = 0; x 5; x++) msg[x] = NULL; continue; } } shutdown (wsock, SHUT_RDWR); close (wsock); return (NULL); } int main (int argc, char *argv[]) { g_thread_init (NULL); gdk_threads_init (); gtk_init (argc, argv); mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_usize (mainwin, WINSIZEX, WINSIZEY); gtk_widget_realize (mainwin); gtk_widget_add_events (mainwin, GDK_BUTTON_PRESS_MASK); gtk_signal_connect (GTK_OBJECT (mainwin), delete_event, GTK_SIGNAL_FUNC (delete_event), 0); gtk_widget_show_all (mainwin); if (!g_thread_create (Wait4Challenge, NULL, FALSE, NULL)) syslog (LOG_INFO, error trying to create new thread); gdk_threads_enter (); gtk_main (); gdk_flush(); gdk_threads_leave (); return 0; } -- Marshall Lake -- ml...@mlake.net -- http://mlake.net -- Marshall Lake -- ml...@mlake.net -- http://mlake.net
GTK threads
I posted this on gtk-list but in the hope of catching a wider audience ... I'm developing a program(s) which runs in the client/server environment. I'm using GTK, sockets, and threads. (GTK and threads only on the client side.) I don't have very much experience using threads and this is the first time I've tried to call GTK functions within a thread, and I'm having problems. I've tried different ways of approaching the problem but can't seem to get anywhere. I suspect there's something I don't understand about thread processing or I'm under some misconception. Maybe someone can help me? Any help is much appreciated. I get the following errors when trying to run the code below (the errors show up when the program calls gtk_dialog_run() in the thread (Wait4Challenge()): src/xcb_io.c:242: process_responses: Assertion `(((long) (dpy-last_request_read) - (long) (dpy-request)) = 0)' failed. Fatal IO error 0 (Success) on X server :0.0. void * Wait4Challenge () { int wsock, x, port = 0, listensock, connected; char buffer[5000], *msg[5], challenger[50]; listensock = -1; for (x = 0; x 5; x++) msg[x] = NULL; wsock = get_connection (SOCK_STREAM, port, listensock); connected = 1; while (connected) { GtkWidget *dialog; int response; if (sock_gets (wsock, buffer[0], sizeof (buffer)) 0) { msg[0] = There is a problem with the server.\n\n; outMessage (msg); connected = 0; } if (buffer[0] == 'R') connected = 0; if (buffer[0] != 'C') continue; strcpy (challenger[0], buffer[1]); gdk_threads_enter (); dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, %s has challenged you to a game. Do you wish to play?, challenger); gtk_window_set_title (GTK_WINDOW (dialog), Play Challenger?); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); gdk_flush(); gdk_threads_leave (); if (response == GTK_RESPONSE_YES) { sock_puts (wsock, OK\n); connected = 0; } else { sock_puts (wsock, NO\n); for (x = 0; x 5; x++) msg[x] = NULL; continue; } } shutdown (wsock, SHUT_RDWR); close (wsock); return (NULL); } int main (int argc, char *argv[]) { g_thread_init (NULL); gdk_threads_init (); gtk_init (argc, argv); mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_usize (mainwin, WINSIZEX, WINSIZEY); gtk_widget_realize (mainwin); gtk_widget_add_events (mainwin, GDK_BUTTON_PRESS_MASK); gtk_signal_connect (GTK_OBJECT (mainwin), delete_event, GTK_SIGNAL_FUNC (delete_event), 0); gtk_widget_show_all (mainwin); if (!g_thread_create (Wait4Challenge, NULL, FALSE, NULL)) syslog (LOG_INFO, error trying to create new thread); gdk_threads_enter (); gtk_main (); gdk_flush(); gdk_threads_leave (); return 0; } -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GTK threads
Not long ago I wrote a simple blog post on how to use threads in GTK+ applications. You can find it here: http://tadeboro.blogspot.com/2009/06/multi-threaded-gtk-applications.html After reading your blog (which is very good) and screwing around with my code a little bit I still can't solve the problem. Does anyone else have anything (my original post with code included here ...) ? I'm developing a program(s) which runs in the client/server environment. I'm using GTK, sockets, and threads. (GTK and threads only on the client side.) I don't have very much experience using threads and this is the first time I've tried to call GTK functions within a thread, and I'm having problems. I've tried different ways of approaching the problem but can't seem to get anywhere. I suspect there's something I don't understand about thread processing or I'm under some misconception. Maybe someone can help me? Any help is much appreciated. I get the following errors when trying to run the code below (the errors show up when the program calls gtk_dialog_run() in the thread (Wait4Challenge()): src/xcb_io.c:242: process_responses: Assertion `(((long) (dpy-last_request_read) - (long) (dpy-request)) = 0)' failed. Fatal IO error 0 (Success) on X server :0.0. void * Wait4Challenge () { int wsock, x, port = 0, listensock, connected; char buffer[5000], *msg[5], challenger[50]; listensock = -1; for (x = 0; x 5; x++) msg[x] = NULL; wsock = get_connection (SOCK_STREAM, port, listensock); connected = 1; while (connected) { GtkWidget *dialog; int response; if (sock_gets (wsock, buffer[0], sizeof (buffer)) 0) { msg[0] = There is a problem with the server.\n\n; outMessage (msg); connected = 0; } if (buffer[0] == 'R') connected = 0; if (buffer[0] != 'C') continue; strcpy (challenger[0], buffer[1]); gdk_threads_enter (); dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, %s has challenged you to a game. Do you wish to play?, challenger); gtk_window_set_title (GTK_WINDOW (dialog), Play Challenger?); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); gdk_flush(); gdk_threads_leave (); if (response == GTK_RESPONSE_YES) { sock_puts (wsock, OK\n); connected = 0; } else { sock_puts (wsock, NO\n); for (x = 0; x 5; x++) msg[x] = NULL; continue; } } shutdown (wsock, SHUT_RDWR); close (wsock); return (NULL); } int main (int argc, char *argv[]) { g_thread_init (NULL); gdk_threads_init (); gtk_init (argc, argv); mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_usize (mainwin, WINSIZEX, WINSIZEY); gtk_widget_realize (mainwin); gtk_widget_add_events (mainwin, GDK_BUTTON_PRESS_MASK); gtk_signal_connect (GTK_OBJECT (mainwin), delete_event, GTK_SIGNAL_FUNC (delete_event), 0); gtk_widget_show_all (mainwin); if (!g_thread_create (Wait4Challenge, NULL, FALSE, NULL)) syslog (LOG_INFO, error trying to create new thread); gdk_threads_enter (); gtk_main (); gdk_flush(); gdk_threads_leave (); return 0; } -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
GTK threads
I'm developing a program(s) which runs in the client/server environment. I'm using GTK, sockets, and threads. (GTK and threads only on the client side.) I don't have very much experience using threads and this is the first time I've tried to call GTK functions within a thread, and I'm having problems. I've tried different ways of approaching the problem but can't seem to get anywhere. I suspect there's something I don't understand about thread processing or I'm under some misconception. Maybe someone can help me? Any help is much appreciated. I get the following errors when trying to run the code below (the errors show up when the program calls gtk_dialog_run() in the thread (Wait4Challenge()): src/xcb_io.c:242: process_responses: Assertion `(((long) (dpy-last_request_read) - (long) (dpy-request)) = 0)' failed. Fatal IO error 0 (Success) on X server :0.0. void * Wait4Challenge () { int wsock, x, port = 0, listensock, connected; char buffer[5000], *msg[5], challenger[50]; listensock = -1; for (x = 0; x 5; x++) msg[x] = NULL; wsock = get_connection (SOCK_STREAM, port, listensock); connected = 1; while (connected) { GtkWidget *dialog; int response; if (sock_gets (wsock, buffer[0], sizeof (buffer)) 0) { msg[0] = There is a problem with the server.\n\n; outMessage (msg); connected = 0; } if (buffer[0] == 'R') connected = 0; if (buffer[0] != 'C') continue; strcpy (challenger[0], buffer[1]); gdk_threads_enter (); dialog = gtk_message_dialog_new (GTK_WINDOW (mainwin), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, %s has challenged you to a game. Do you wish to play?, challenger); gtk_window_set_title (GTK_WINDOW (dialog), Play Challenger?); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); gdk_flush(); gdk_threads_leave (); if (response == GTK_RESPONSE_YES) { sock_puts (wsock, OK\n); connected = 0; } else { sock_puts (wsock, NO\n); for (x = 0; x 5; x++) msg[x] = NULL; continue; } } shutdown (wsock, SHUT_RDWR); close (wsock); return (NULL); } int main (int argc, char *argv[]) { g_thread_init (NULL); gdk_threads_init (); gtk_init (argc, argv); mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_usize (mainwin, WINSIZEX, WINSIZEY); gtk_widget_realize (mainwin); gtk_widget_add_events (mainwin, GDK_BUTTON_PRESS_MASK); gtk_signal_connect (GTK_OBJECT (mainwin), delete_event, GTK_SIGNAL_FUNC (delete_event), 0); gtk_widget_show_all (mainwin); if (!g_thread_create (Wait4Challenge, NULL, FALSE, NULL)) syslog (LOG_INFO, error trying to create new thread); gdk_threads_enter (); gtk_main (); gdk_flush(); gdk_threads_leave (); return 0; } -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Full Screen mode behaves differently on two identical systems
I have 2 computers, both running Ubuntu 8.10 (kernel2.6.27-9-generic). When my gtkmm application goes to full screen mode, and the user brings up any modal dialog (which is a child of the application main window), on one system everything looks fine. On the other, I get the System menu (Applications Places System) appearing instead of the application menu. When the dialog closes, the Application menu comes back. This is somewhat disconcerting to my users *grin*. Clearly, the systems are different somehow, but I'm at a loss as to exactly where and why it would make a difference. I have multiple examples of each behavior. So far, it seems that older PCs and newer netbooks have the bad behavior, while my development laptops and some newer desktop PCs work flawlessly. The same bad/good behavior happened when all my machines were running Ubuntu 8.04 with multiple kernels. Any ideas? Are you moving executables or recompiling from machine to machine? Are the compiler versions the same across the machines? -- Marshall Lake -- ml...@mlake.net -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: treeview: seg fault When Collapsing a Row Containg a Selected Item
I have a treeview/treestore containing many top-level rows. Each top-level row contains many children. The treeview works fine except for one thing. If the user expands a top-level row, selects a child, and then collapses that row the program seg faults with the console error: gtk_tree_store_get_value: assertion `iter-stamp == GTK_TREE_STORE (tree_model)-stamp' failed gtype.c:3351: type id `0' is invalid can't peek value table for type `invalid' which is not currently referenced void TeamSelected2 (GtkTreeSelection *selection) { GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; gint sub, row_count, x; gchar *teamname, path_str[10] = ; gboolean valid; gtk_tree_selection_get_selected (selection, model, iter); The gtk_tree_selection_get_selected() api returns TRUE is something is selected. You never checked its return value! That's the ticket! I appreciate your help. -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
treeview: seg fault When Collapsing a Row Containg a Selected Item
I have a treeview/treestore containing many top-level rows. Each top-level row contains many children. The treeview works fine except for one thing. If the user expands a top-level row, selects a child, and then collapses that row the program seg faults with the console error: gtk_tree_store_get_value: assertion `iter-stamp == GTK_TREE_STORE (tree_model)-stamp' failed gtype.c:3351: type id `0' is invalid can't peek value table for type `invalid' which is not currently referenced The treeview works fine if the user never collapses the row and goes on to make another selection, either in that same top-level or a different top-level. Also, if a row is expanded and then collapsed with no child being selected it works fine. As an aside (?), I tried gtk_tree_selection_unselect_iter() on the child after it was selected and got a seg fault and the same error as noted above at the point the gtk_tree_selection_unselect_iter() was executed. Can someone tell me what might need to be done to avoid the seg fault? -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Editing a Large Amount of Data Containing Many Fields
I'm looking for a way to allow a user to edit multiple files of data. Each file contains many records/rows. And each record contains many fields/columns. I'm not deeply familiar with treeviews in GTK but from what I know it seems to me that using a treeview to facilitate editing many records containing many fields would be cumbersome for the user, especially getting from field to field. If I'm wrong please let me know. Maybe someone can point me to a GTK program which allows editing a large amount of data. If there are alternatives in GTK for editing large data please let me know. I would prefer to edit the data utilizing GTK but I'm open to any suggestions or ideas. TIA. -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Creating a Modal Dialog from a Routine Called by g_idle_add()
I've run into a problem with my current project and I'm having difficulty finding the cause. I'm sure the problem is because of a lack of understanding on my part concerning GTK. I'm hoping someone here can prod me in the right direction. I have a routine called by g_idle_add() which updates the contents of an already-existing modal dialog with data received from a server software. This routine gets called continually until the data from the server ceases. Certain data which is received causes a new modal dialog to be created which looks for user input. Things work fine until a new modal dialog needs to be created. The dialog is created fine and the user input is accepted fine, but I cannot destroy the new modal dialog. And at this point the routine is not called again by g_idle_add(). The program hangs, and the only thing I can do is kill the new modal dialog which in turn kills the whole program. Can someone clue me in to what might be going on? -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Delay in Displaying Dialog
After the text being sent to the text widget ends and process flow falls back into gtk_main() then all the other widgets within the secondary dialog appear including the first few lines of text which had been missing. This line leads me to believe that you may not be relinquishing control to the Gtk mainloop. When the text comes into the second dialog box, are you locking up the program until it is all read? Yes, I'm locking up the program until all the text is read. I haven't taken the time to test your belief but assuming you're correct (and I'm sure you are) that brings to mind a couple of questions ... Can there be more than one gtk_main() call in one program? And could that possibly help me? How does MODAL and gtk_dialog_run() work? Do they both integrate themselves with the GTK main loop behind the scenes? -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Delay in Displaying Dialog
Marshall--perhaps it would help if you could provide a little more info on the nature of the data coming into the dialog. Does it come over a socket, or a file descriptor from some type of character device, or what? I'm receiving the text via a socket. With your help and prodding I've been able to get past my problem using g_idle_add(). Using it does open up new challenges for me but I'm thankful for the helping hand. -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Delay in Displaying Dialog
I'm encountering a problem in an application I'm working on which I don't understand. It may be due to a misconception I have with GTK+ functionality. The application has a main window which comes up with program execution. Further processing is driven by events initiated by the user selecting drop-down menu items from this main window. In one menu item a dialog is displayed where the user selects certain criteria with which to proceed. Upon completion of establishing the criteria the dialog is destroyed and a new dialog is created. Within this new dialog are a couple of boxes and a couple of tables. Within one of the tables is a non-editable text widget with a vertical scrollbar. A gtk_widget_show_all() is issued for this new dialog once it's created, however the dialog is not displayed at this point. Additionally, the first dialog has not yet disappeared from the display. Immediately after creation of this new dialog, text begins to be sent on a somewhat streaming basis to the text widget. After a few seconds the first dialog disappears and the secondary dialog appears. However, the only widget within the secondary dialog which appears is the text widget. No other widgets appear. The appropriate text begins appearing and scrolling within the text widget. But missing are the first four or five lines of text which were (probably) sent to the text widget during the time it was not displayed. After the text being sent to the text widget ends and process flow falls back into gtk_main() then all the other widgets within the secondary dialog appear including the first few lines of text which had been missing. Can anyone give me an idea (or point me someplace) which will tell me what's going on? Thanks. -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list
Need Help Understanding a Compile Error
I need help in understanding a problem I'm encountering when compiling a particular GTK program. When compiling, at link time I get the following errors: /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_map_cache_clear' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_map_get_type' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_map_create_context' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_map_shutdown' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_get_type' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_lock_face' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_has_char' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_get_glyph' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_get_unknown_glyph' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_get_raw_extents' /usr/local/lib/libpangoxft-1.0.so: undefined reference to `pango_fc_font_unlock_face' In this case /usr/local/lib/libpangoxft-1.0.so is linked to /usr/local/lib/libpangoxft-1.0.so.0.501.0. If I change libpangoxft-1.0.so to be linked to /usr/local/lib/libpangoxft-1.0.so.0.200.5 the program compiles correctly. Can someone tell me why? -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Trouble Installing Pango
While trying to install pango 1.5.1 near the (seemingly) end of compilation I get the following errors: /home/mlake/pango-1.5.1/pango/.libs/libpangoft2-1.0.so: undefined reference to `g_type_instance_get_private' /home/mlake/pango-1.5.1/pango/.libs/libpangoft2-1.0.so: undefined reference to `g_type_class_add_private' /home/mlake/pango-1.5.1/pango/.libs/libpango-1.0.so: undefined reference to `g_unichar_get_mirror_char' These are GLib-2.4 things. You need GLib-2.4. I'm sure Pango README mentions this dependency. I successfully installed GLib-2.5 and I'm getting the same errors when trying to install pango 1.5.1. The GLib version doesn't have to be exactly 2.4, does it? What else could be causing the errors? -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Re: Trouble Installing Pango
[undefined references] On my system (Slackware 9), the undefined references (started with 2.4) were due to libtool adding the older versions of the libraries (in /usr/lib) in front of the newer versions (in /usr/local/lib) as part of the link command. I fiddled with ld.so.config and libtool for days with no success, so I ended up editing the *.la files by hand to get everything to link to the proper libraries. There is a newer version of libtool out that may or may not fix the problem. I installed the latest version of libtool and that didn't help. So, then I changed the pertinent .la files (actually just copied over the newer ones) and all's well. Thanks for the push in the right direction. -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Trouble Installing Pango
While trying to install pango 1.5.1 near the (seemingly) end of compilation I get the following errors: /home/mlake/pango-1.5.1/pango/.libs/libpangoft2-1.0.so: undefined reference to `g_type_instance_get_private' /home/mlake/pango-1.5.1/pango/.libs/libpangoft2-1.0.so: undefined reference to `g_type_class_add_private' /home/mlake/pango-1.5.1/pango/.libs/libpango-1.0.so: undefined reference to `g_unichar_get_mirror_char' Can anyone tell me what's going wrong and how I can correct the situation? Thanks. -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list
Problems Compiling Pango
I'm having trouble installing the current version of pango (1.4.0) on a Linux box. I installed glib 2.4.0 successfully, but when trying to make pango I get the following errors messages: /home/mlake/pango-1.4.0/pango/.libs/libpangoft2-1.0.so: undefined reference to `g_type_instance_get_private' /home/mlake/pango-1.4.0/pango/.libs/libpangoft2-1.0.so: undefined reference to `g_type_class_add_private' /home/mlake/pango-1.4.0/pango/.libs/libpango-1.0.so: undefined reference to `g_unichar_get_mirror_char' I haven't had any problems installing previous versions of glib/pango/gtk. Can someone give me a clue as to what's going wrong and how I can get around my current installation problems? -- Marshall Lake -- [EMAIL PROTECTED] -- http://mlake.net ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list