Slow UI updates with GtkImage
Hi, I'm working on an audio player application. I currently have two elements that change on a frequent basis: a GtkHScale and a GtkImage. Whenever I update the data, I call gtk_widget_queue_draw on the widget that changed. With just the slider updating every 200ms, it works fine. If I add the GtkImage changing (by swapping out the GdkPixbuf with gtk_image_pixbuf_set) or I call gtk_widget_queue_draw on the widget, the UI waits about 2.5s in between redraws on both the slider and the image. This event happens about every 186ms. Is there something that I should be doing differently here? Is this method horribly inefficient? What should I change? Thanks, David Brigada ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: C vs C++ for GTK
Just .02 € from a programmer who's been doing it for about 40 years. I agree with most of what has been said on this thread. My thought is that object-oriented thinking is entirely different from procedural thinking. I think that one needs to settle on one paradigm or the other and stay with it. Personally, I'm using Ruby and like it very much. The reason is that it allows me to concentrate on the project at hand rather than the details of its implementation. There are occasions when a low level language like C++ is needed, but why twiddle bits when bit twiddling only gets in your way? IMHO, it is the true scientist who will use either C or C++, because of the low level of code access. The question is, Do you want to drive a car, customize a car or design a car? None is better than the others. They are different disciplines. GTK is written in C, I do believe, so the person programming in C can get up close and personal with it. My Ruby-Gnome package wraps the C code, so I can't get down and see exactly what GTK, as written, is doing, but, then, I've not needed to. Regarding the reference to euros. I'm an American living in Finland. Alan JAMES SCOTT wrote: Michael, Thanks for the feedback, it seems we are on the same page on several counts. James, - Original Message From: Michael L Torrie [EMAIL PROTECTED] To: gtk-app-devel-list@gnome.org Sent: Monday, November 26, 2007 5:32:22 PM Subject: Re: C vs C++ for GTK JAMES SCOTT wrote: To list members following this subject: I have a question - not a flame, as I try to understand the diversity of responses to this topic. How many of you who have suggested Patrick learn something other than C, know C already for yourself. Over the course of my experience I have found that learning assembler and C for a given platform has helped me better understand and use that platform. Also, knowing C make picking up or reading other languages like - python, php, perl, and many others easier. I agree to a point. C isn't going to teach you much about list processing (a la LISP), domain-specific languages, lambda closures, proper variable binding, functional programming, etc. On the other hand, C helps one learn to manage resources explicitly (even garbage collection can bite you if you don't understand how resource management works), pointers, etc. The ideal computer science program would make sure one first knows (IE is taught) C, then some assembly, then Scheme, then Python. I'm assuming that, those of you who are pointing another way - already know C! Why not let Patrick follow your well worn path through C/GLIB/GTK2, maybe he will come out afterwards to C++, Python, or some other door. Too late for that! Patrick's already well into Python. Python is a great language to learn on, in my opinion. It's as instructive as learning LISP or Scheme, but as useful as C or C++, or even Java. I get the impression that Patrick already has some C proficiency. Yes, my preference is C/GLib/Gtk+. But I use lots of other when needed. I'm coming to the opinion that a good rule of thumb is just to always use python unless specific needs dictate otherwise. Writing GUI code in a low-level, compiled language just doesn't seem to be the wisest thing to do these days. That's not to say that you're advice to learn assembly and C isn't good. In fact it's important for all computer programmers to know, in my opinion. When I have to write in C, Glib is a godsend. And of course GTK+ for the GUI. Using Glib, I wrote a very complicated data parsing program using dynamic strings, hash tables, and tree structures all with Glib and only had one very small memory leak in 10,000 lines of code and building and destroying many trees. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
printing, cairo, cups
I've been trying to get myself up to speed with state of printing support in Gtk, and I'm down to just a few conceptual questions. It looks like the general idea is to setup a callback to render with cairo one page at a time using a GtkPrintContext. From this I would speculate that on win32, a cairo GDI surface is used with the GDI device being a windows printer. On the *nix side GtkPrintContext might be using cairo post script surface, but more likely an image (memory buffer) surface is used. If the GtkPrintContext is setup correctly, then the device dependent details width, height, and dpi get used to build such a cairo memory buffer surface. I'm also betting Gtk is pulling all this from CUPS. In that case, there is then the issue of cairo's lack of support for color space beyond RGBA, as in printing, arises. Although that is a completely separate topic, and definitely something I can live with for now if all else works out. My main question is this. Somewhere the cairo RGBA color space must be mapped into a printer's device dependent color space such as CMYK. Is this mapping done inside Gtk using info resolved from cups, or is this done inside cups with filters? Any help with my understanding would be appreciated. Most of this I'm just wildly guessing about since I haven't found it documented. I really would like to spare me the time of learning CUPS, which is why I want to understand how much, and what, work Gtk is doing for me. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Slow UI updates with GtkImage
On Nov 27, 2007 6:11 AM, David Brigada [EMAIL PROTECTED] wrote: Hi, I'm working on an audio player application. I currently have two elements that change on a frequent basis: a GtkHScale and a GtkImage. Whenever I update the data, I call gtk_widget_queue_draw on the widget that changed. With just the slider updating every 200ms, it works fine. If I add the GtkImage changing (by swapping out the GdkPixbuf with gtk_image_pixbuf_set) or I call gtk_widget_queue_draw on the widget, the UI waits about 2.5s in between redraws on both the slider and the image. This event happens about every 186ms. Is there something that I should be doing differently here? Is this method horribly inefficient? What should I change? You should not have to call gtk_widget_queue_draw() at all in this case (I'm sure the gtkimage gtkscale implementations do this themselves when you update the image or adjustment values). Rather, how is your application structured ? do you use a thread for the audio or are you processing audio data for 2.5s intervals before ever returning control to the gtk+ main loop ? (are you blocking or read or write maybe ?). Even if you get it all right though, remember that you can still get resource starvation when writing a media streaming app, probably your audio processing thread is a higher priority. Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Changing a style property?
Andrew Smith a écrit : Hi Can someone tell me how to change the 'style property' (as it's called in the reference manual) of a gtkwidget? Specifically right now I'm looking to change the 'shadow-type' property of gtkmenubar, gtktoolbar, and gtkcombobox. They look like crap on vista. I tried a g_object_set() but that says 'object class gtkmenubar has no property named shadow-type'. I can't find anything in the manual describing how to work with style properties, only some vague references to themes here and there. I would prefer to not have a theme, but I will write one if I have to, in which case would you please point me to a guide or a reference? Thanks in advance, Andrew Sorry for the spam, but I just can't believe noone on the list knows how to deal with this. Does my question not make sense? I can try and rephrase. Please help, Andrew ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Strange interaction between GtkDialog and a GThread
Thanks for the reply. Interesting. Replacing sleep() with select() did return an error with errno == EINTR. If I understand you correctly, this is a clue that gtk_file_chooser_dialog_new is calling alarm() somewhere. That may indeed factor in to what I am trying to solve. But fact is, getting a thread to sleep wasn't really my goal, I just used that to make a simple example that would break. The real challenge I've been having for a couple weeks is with a thread running a blocking D-Bus server. The server works great, but if I launch a gtk_file_chooser_dialog_new, the entire app goes very weird! Below is as simple an example as I could make (without the client; I could paste that code too if wanted, but it is not needed to see the weirdness). Basically, the inconsistent results look like some kind of deadlock; usually on my system, it will not open the dialog, but if the dialog does open, it is dead. Yet normally the D-Bus thread happily continues to serve clients. But not always. Strangest to me is the backtrace; before the call to gtk_file_chooser_dialog_new, the main thread has (as one would expect) no calls to libdbus-1.so.3; after the call to gtk_file_chooser_dialog_new, the main thread is polluted with myriad calls to libdbus-1.so.3., as if it merged with the other thread. Initially, I thought this was a D-Bus problem, so I posted to the D-Bus list; then I started to think it was a GTK issue, so I've posted here. BTW, the D-Bus list did offer one interesting response about how what I see may be related to the strange code behind gtk_dialog_run, in that it re-enters the main loop. I did look at it's code, and it did mystify me. Here's the thread: [ http://lists.freedesktop.org/archives/dbus/2007-November/008968.html ] Any ideas? Thanks again! // /* Demonstration of strange gtk_file_chooser_dialog_new/dbus interaction. Compile with: gcc main.c -o HelloThreadBreaker \ `pkg-config --cflags --libs \ gtk+-2.0 gthread-2.0 dbus-1` */ #include unistd.h #include gtk/gtk.h #include dbus/dbus.h #define GNAURAL_DBUS_SERVERorg.gnaural.Server #define GNAURAL_DBUS_INTERFACE org.gnaural.Interface DBusConnection *main_remote_connection = NULL; time_t main_startime; / void GetBeatfreq (DBusMessage * msg, DBusConnection * conn) { DBusMessage *reply; DBusMessageIter args; unsigned int voice = 0; if (!dbus_message_iter_init (msg, args)) { fprintf (stderr, Message has no arguments\n); } else if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type (args)) { fprintf (stderr, Argument is not DBUS_TYPE_UINT32\n); } else { dbus_message_iter_get_basic (args, voice); } reply = dbus_message_new_method_return (msg); double result = (double) (time (NULL) - main_startime); dbus_message_iter_init_append (reply, args); if (!dbus_message_iter_append_basic (args, DBUS_TYPE_DOUBLE, result)) { fprintf (stderr, Out Of Memory\n); return; } if (!dbus_connection_send (conn, reply, NULL)) { fprintf (stderr, Out Of Memory\n); return; } dbus_connection_flush (conn); dbus_message_unref (reply); } / int main_init_connection (void) { DBusError err; int ret; dbus_error_init (err); main_remote_connection = dbus_bus_get (DBUS_BUS_SESSION, err); if (dbus_error_is_set (err)) { fprintf (stderr, Connection Error (%s)\n, err.message); dbus_error_free (err); } if (NULL == main_remote_connection) { fprintf (stderr, Connection Null\n); return 1; } ret = dbus_bus_request_name (main_remote_connection, GNAURAL_DBUS_SERVER, DBUS_NAME_FLAG_REPLACE_EXISTING, err); if (dbus_error_is_set (err)) { fprintf (stderr, Name Error (%s)\n, err.message); dbus_error_free (err); } if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { fprintf (stderr, Not Primary Owner (%d)\n, ret); return 1; } return 0; } void main_check_for_methodcall (gpointer arg) { DBusMessage *msg; if (NULL == main_remote_connection) { fprintf (stderr, Connection invalid!\n); return; } fprintf (stderr, Entering blocking loop\n); while (dbus_connection_read_write_dispatch (main_remote_connection, -1)) { msg = dbus_connection_pop_message (main_remote_connection); if (NULL == msg) { fprintf (stderr, Message == NULL\n); continue; } else { fprintf (stderr, Got Something... ); } if (dbus_message_is_method_call (msg, //DBusMessage * msg GNAURAL_DBUS_INTERFACE,//char * interface GetBeatfreq))//char * method { GetBeatfreq (msg, main_remote_connection); fprintf (stderr, Running GetBeatfreq\n); } else { fprintf (stderr, Call not recognized\n); } dbus_message_unref (msg); } fprintf (stderr, Leaving wait for methodcall loop\n); } // void *sleep_for_awhile (void *args) { time_t t1; time_t t2; g_print (Sleeping for 2 seconds\n); time (t1); sleep (1); time (t2); g_print (Slept for %d seconds\n, (int) (t2 - t1)); main_init_connection (); g_print (Blocking forever\n); main_check_for_methodcall (NULL); time (t2); g_print (Blocked for %d
Finding API documentation by function name
Hi all, I'm writing a binding generator for my language to Gtk and want the generator to be able to insert documentation into the generated code automatically. Is there any existing program/script for getting the documentation associated with a specific api function? For example: program gtk_about_dialog_new could print out the lines (as copied from devhelp): Creates a new GtkAboutDialog. Returns : a newly created GtkAboutDialog Or it could (preferably) print them out in XML, or some other structured format. I could probably fashion something myself, possibly from the files that devhelp generates, but I was wondering if anyone has already done so, or knows of any existing solution. Thanks Raja Mukherji ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Changing a style property?
You may want to look over the documentation of GtkRcStyle, resource files (.rc files for themes). The style property of a widget is a GtkStyle object. There is no shadow-type property of a widget. These are typically not used by the developer. We leave this stuff up to the theme. If we want a specific look (such as a touchscreen application) then we just write our own theme or resource file. Read more at http://library.gnome.org/devel/gtk/2.12/gtk-Resource-Files.html#GtkRcStyle - Micah Carrick Developer - http://www.micahcarrick.com GTK+ Forums - http://www.gtkforums.com Andrew Smith wrote: Andrew Smith a écrit : Hi Can someone tell me how to change the 'style property' (as it's called in the reference manual) of a gtkwidget? Specifically right now I'm looking to change the 'shadow-type' property of gtkmenubar, gtktoolbar, and gtkcombobox. They look like crap on vista. I tried a g_object_set() but that says 'object class gtkmenubar has no property named shadow-type'. I can't find anything in the manual describing how to work with style properties, only some vague references to themes here and there. I would prefer to not have a theme, but I will write one if I have to, in which case would you please point me to a guide or a reference? Thanks in advance, Andrew Sorry for the spam, but I just can't believe noone on the list knows how to deal with this. Does my question not make sense? I can try and rephrase. Please help, Andrew ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: printing, cairo, cups
Hi Thomas, On Unix, Gtk+ uses the PS backend, not the image. The image backend makes little sense for printing. On Tue, 2007-11-27 at 06:58 -0600, Thomas Stover wrote: My main question is this. Somewhere the cairo RGBA color space must be mapped into a printer's device dependent color space such as CMYK. Is this mapping done inside Gtk using info resolved from cups, or is this done inside cups with filters? That's all done in CUPS. -- behdad http://behdad.org/ Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin, 1759 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list