Re: future of development for the desktop (C++ vs C)
- Original Message - > From: Marshall Lake > To: gtk-list@gnome.org > Cc: > Sent: Saturday, May 26, 2012 4:26 PM > Subject: 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 You can write wrappers in "C" around C++ - unless what you need to do equates to making an instance of C++ template. But you'll need to understand some basic things about C++ - constructor, destructor, "placement new". Regarding the latter - start from http://en.wikipedia.org/wiki/Placement_new . If you implement "C" wrappers, you'll have an additional function call overhead. I am no promoter of C++, but gtk+ is ridiculous with its reinvented object model. ... I suggest to read this: http://www.linuxquestions.org/questions/programming-9/why-c-is-still-out-there-946286/ recent thread. Hopefully you will understand why a "C" toolkit ultimately can/should be slower than an equivalent C++ one. ... I am no C++ programmer, I code mostly in Perl/C/GNU Octave, but I'm trying to objectively see in what C++ is better than "C", and I still consider C++ to be a very convoluted language. But, alas, feature-wise it wins over "C". Regards, Sergei. ___ gtk-list mailing list gtk-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-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
Re: Textview
Hi David, On Fri, 25 May 2012 18:24:59 -0700 (PDT) you wrote: > Hi guys, > > This might be a really dumb one... > It's certainly a very common "failure to grasp a basic concept" issue. > --- code tidbits --- > > Loop: > > memset (text, 0, 100); > sprintf (text, "some very interesting data", > interesting_arguments); > textbuffer1 = gtk_text_view_get_buffer (GTK_TEXT_VIEW > (data->textview1)); > gtk_text_buffer_get_end_iter (textbuffer1, &end); > gtk_text_buffer_insert (textbuffer1, &end, text, -1); > gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (data->textview1), > &end, 0.0, FALSE, 0, 0); > > End Loop > > --- end of code --- > > Any idea what I've done wrong? > You have not understood that EVERYTHING done by Gtk (and all such tool kits) gets buffered for performance reasons. Your program is hogging the CPU doing its work, part of which is to populate the text buffer, and never letting Gtk have a chance to update the display. If you want the display to respond, you MUST let the Gtk main loop get a slot. Try re-writing your code into a form like: g_idle_add ( my_worker_callback, NULL ); Gboolean my_worker_callback(gpointer data) { do_some_small_amount_of_stuff(); sprintf (text, "some very interesting data", interesting_arguments); textbuffer1 = gtk_text_view_get_buffer (GTK_TEXT_VIEW(data->textview1)); gtk_text_buffer_get_end_iter (textbuffer1, &end); gtk_text_buffer_insert (textbuffer1, &end, text, -1); gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW (data->textview1),&end, 0.0, FALSE, 0, 0); return more_to_do_yet; } (You'll need to check the syntax details, I've only thrown together a basic shape) In other words, don't use a loop construct - instead register the contents of the loop as an idle task and let the Gtk main loop be your loop. HTH, Rob ___ gtk-list mailing list gtk-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-list