Re: locale, gui vs command line question?
On Mon, 1 Feb 2010, Freddie Unpenstein wrote: > > On Sun, 31 Jan 2010, james morris wrote: > >> Why is store/change/restore of locale bad? > > > There's nothing at all wrong with it in the context you > > specified -- i.e. you want to ensure that floating-point > > values written to and read from file always use '.' as the > > decimal separator. I do that in my app, gretl (also for > > reasons of portability). > > The problem would be the potential that the library may have > cached locale features under a different locale, wouldn't it? A bigger problem is that setlocale() is non-local hence it breaks anything asynchronous, namely threads. It may not matter in a single-threaded program but it's something you should never do in a library. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: locale, gui vs command line question?
On 1/2/2010, "Freddie Unpenstein" wrote: >> There's nothing at all wrong with it in the context you specified >> -- i.e. you want to ensure that floating-point values written to >> and read from file always use '.' as the decimal separator. I do >> that in my app, gretl (also for reasons of portability). > >The problem would be the potential that the library may have cached locale >features under a different locale, wouldn't it? That could lead to either >uninitialised bytes, or buffer overrun. > So what's the point of having a setlocale function which can tell you the locale in use and/or set a new locale to use if this stuff is going to be stored in cache and read/write of locale settings is going to break the library and your program? Or are you saying the libraries (gtk/mpfr/stdc) I'm using may be caching the locale and may not heed my changes? >From personal experience; I've first-use-allocated strings with all the >thousands characters, and an array of byte offsets at which to put the higher >portions of numbers, and then used a regular floating point format to write >the last thousand (sprintf comes to mind). If the locale were to unexpectedly >change to one that uses a multi-byte decimal point, a buffer overrun would >certainly occur. In the opposing case, that same function would likely write >out a null character following the number. > Are you talking about a change from outside the program? Say, whichever X environment changes locale settings (do running programs take notice then?). Cheers, James. >Could cause quite some stress. > > >Fredderic > > >Best Weight Loss Program - Click Here! >Weight Loss Program >http://tagline.excite.com/c?cp=vXYG-fGF-EFlsgtFzMFtVgAAKZSqLQhMVy_O-FcGiDoF0G0BAAYAAADNAAAEUkg= > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: locale, gui vs command line question?
On Tue, Feb 02, 2010 at 09:58:27AM +, james morris wrote: > > So what's the point of having a setlocale function which can tell you > the locale in use and/or set a new locale to use if this stuff is going > to be stored in cache and read/write of locale settings is going to > break the library and your program? > > Or are you saying the libraries (gtk/mpfr/stdc) I'm using may be caching > the locale and may not heed my changes? Since Gtk+ does not have any mechanism to rebuild the UI when a locale category changes, either you implement such mechanism or, more often, put up with it and accept the locale does not change. Then, of course, caching is not a problem. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: locale, gui vs command line question?
On 2/2/2010, "David Nečas" wrote: >On Mon, 1 Feb 2010, Freddie Unpenstein wrote: >> > On Sun, 31 Jan 2010, james morris wrote: >> >> Why is store/change/restore of locale bad? >> >> > There's nothing at all wrong with it in the context you >> > specified -- i.e. you want to ensure that floating-point >> > values written to and read from file always use '.' as the >> > decimal separator. I do that in my app, gretl (also for >> > reasons of portability). >> >> The problem would be the potential that the library may have >> cached locale features under a different locale, wouldn't it? > >A bigger problem is that setlocale() is non-local hence it breaks >anything asynchronous, namely threads. > >It may not matter in a single-threaded program but it's something you >should never do in a library. I was about ask something along similar lines. Presumably, if the X environment changes locale it will be GTK which deals with it and as GTK is not threaded, and, my code which stores/restores locale only operates within the GTK thread (my code is multi-threaded) then GTK will only deal with the locale change when it is doing it's internal stuff and not going about my code? James. >Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Image manipulation and Scaling
Hi I need to do some image manipulation using GTK, and I want to view some proprietary image formats. So, I can prepare RGB data. But, which widget and API to be use to draw pixels on screen. I used GtkImage using Pixbuf, but it supports only 8 bits per sample. Then I used GtkDrawing area, and use "gdk_draw_rgb_image" function to draw rgb data. I wanted to know that is DrawingArea widget is well for me. As, I need to do scaling also. I also need to know how to perform scaling of images. Please help. Thanks Gorav ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Gtk+: multi-threaded or not ?
Hi all, Reading this list, I see some questions which talk about "threads": main thread, event thread, and so on. I was not conscious Gtk+ was multithreaded. I'm conscious of asynchronous code with the mail loop and idle function (which are rather in Glib, I believe ?), but really not of multithread. So is Gtk multithreaded, or not ? Because if it is, I will have to deal with mutex, semaphores and all the usual soup!! Thanks in advance Regards Pierre ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Gtk+: multi-threaded or not ?
On Tue, Feb 2, 2010 at 5:56 PM, Pierre Wieser wrote: > Hi all, > > Reading this list, I see some questions which talk about "threads": main > thread, event thread, and so on. > > I was not conscious Gtk+ was multithreaded. I'm conscious of asynchronous > code with the mail loop and idle function (which are rather in Glib, I > believe ?), but really not of multithread. > > So is Gtk multithreaded, or not ? > > Because if it is, I will have to deal with mutex, semaphores and all the > usual soup!! > > Gtk+ is single threaded library In order to confirm you can run the standard hello world gtk program and look up in the /proc//status | grep Threads #field for the number of threads but if you want the thread support in your application it would be possible with gthreads CMIIAW Regards, Sid > Thanks in advance > Regards > Pierre > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > -- Regards, ~Sid~ I have never met a man so ignorant that i couldn't learn something from him ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GdkPixbuf animation
Hi all, I have noticed that there is a way to load an animation using gdk_pixbuf_animation_new_from_file. But is there a way to save already loaded/created animation to a file? For example GdkPixbuf has a method gdk_pixbuf_save Thanks in advance, Tomas Soltys ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Gtk+: multi-threaded or not ?
On Tue, Feb 02, 2010 at 06:14:18PM +0530, Siddu wrote: > On Tue, Feb 2, 2010 at 5:56 PM, Pierre Wieser wrote: > > > Reading this list, I see some questions which talk about "threads": main > > thread, event thread, and so on. > > > > I was not conscious Gtk+ was multithreaded. I'm conscious of asynchronous > > code with the mail loop and idle function (which are rather in Glib, I > > believe ?), but really not of multithread. > > > > So is Gtk multithreaded, or not ? > > > > Because if it is, I will have to deal with mutex, semaphores and all the > > usual soup!! > > > Gtk+ is single threaded library This is a bit too simplistic view. Gtk+ is a thread-aware library. This means if the application does not use threads neither does Gtk+ so you don't need to care about mutexes and stuff at all. However, Gtk+ knows about threads and goes to some length to be usable in a multithreaded application by protecting its internal state by locking (if threading is enabled). Note that the only portable use of threads with Gtk+ is to let only the thread running gtk_main() to actually touch the GUI. So Gtk+ is neither single-threaded nor multi-threaded in the usual sense of these terms. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Making a Python/GTK CheckMenuItem, when clicked, not close the menu
On Fri, 2010-01-29 at 00:27 -0500, Freddie Unpenstein wrote: > > Using Python and PyGTK I've got a GtkMenu with various GtkCheckMenuItems > > in it. When the user clicks one of the checkboxes the menu closes. I'd > > like for the user to be able to check a series of checkboxes without the > > menu closing each time. > > I looked into this myself a while back, and gave up. More important things > to do, and so forth. This seems to be my likely course of action too. > One thing did occur to me, though. It's kind of annoying when you click a > check menu item, and the menu doesn't go away. And having some that do, and > some that don't, would probably drive my balmy. My scenario, however, is a tray icon with a bunch of preferences for network interfaces and I'd like it so that you go into the submenu for the NIC and then tick a series of boxes to configure it. In this case having the menu not disappear makes some sense IMO. > [...] > Back to the original question; the "better" way, would probably be to use a > dialog box in this instance, to allow these options to be changed without > having to go back to the menu all the time. Perhaps depending on usage, an > Options menu item as well as the individual options, which brings them up in > a dialog for when you need to change multiple options. Dialog box looks the way forward. Maybe tabbed or something. Many thanks for your input, David ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Image manipulation and Scaling
On Tue, 2010-02-02 at 17:25 +0530, Gorav wrote: > Hi > > > I need to do some image manipulation using GTK, and I want to view some > proprietary image formats. So, I can prepare RGB data. But, which widget > and API to be use to draw pixels on screen. > > > I used GtkImage using Pixbuf, but it supports only 8 bits per sample. Have you looked at GdkPixbuf for holding the image data? You may need to write converter plugins to load and store images from files for your proprietary formats, but after that, all the in-memory stuff should work fine. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: locale, gui vs command line question?
>> Or are you saying the libraries (gtk/mpfr/stdc) I'm using may be caching >> the locale and may not heed my changes? > Since Gtk+ does not have any mechanism to rebuild the UI when a locale > category changes, either you implement such mechanism or, more often, > put up with it and accept the locale does not change. Then, of course, > caching is not a problem. That's pretty much how I understood it to be. I was kind of getting a little worried I might have been wrong. I have seen some applications that seem to change when the desktop locale settings are changed. So I'm assuming there is a mechanism there that your application can use to find out about locale changes, it's just not propogated into the application at all. So my applications that continue to cache locale bits and pieces will continue to work, libraries shouldn't change locale info ever unless they're guaranteed to be initialised first, and the rest of the world can change locales as much as it wants, the application won't care until it's next started. I'm hoping that about sums it up, and I haven't misread anything. Fredderic Click to find great rates on medical insurance, save big, shop here. Medical Insurance http://tagline.excite.com/c?cp=EUy_Tkl4rz1GWIyhDqxWrwAAKZSlMmZOmLoSxr7IH9qxTEOrAAYAAADNAAAQVgA= ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Image manipulation and Scaling
Even if your image has more than eight bits you can always convert it to 8-bit according to a user setting defining the grey level max and min to be used for the convertion (known as window and level in the medical image community). That's exactly how I do it in my image viewer giv. The image is held in a GivImage that is overloaded for various bit integer or floating widths and is then converted according to the user level setting before being displayed. Btw, if you would like to have interactive zooming of the image being displayed you may want to consider using my GtkImageViewer instead of GtkImage. (There is also the GtkImageView by Björn Lindquist with similar and different functionality.) See: http://giv.sourceforge.net/gtk-image-viewer/ Regards, Dov On Wed, Feb 3, 2010 at 04:19, Lars Wirzenius wrote: > On Tue, 2010-02-02 at 17:25 +0530, Gorav wrote: > > Hi > > > > > > I need to do some image manipulation using GTK, and I want to view some > > proprietary image formats. So, I can prepare RGB data. But, which widget > > and API to be use to draw pixels on screen. > > > > > > I used GtkImage using Pixbuf, but it supports only 8 bits per sample. > > Have you looked at GdkPixbuf for holding the image data? You may need to > write converter plugins to load and store images from files for your > proprietary formats, but after that, all the in-memory stuff should work > fine. > > > ___ > 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: Image manipulation and Scaling
Thanks for reply. Can you please elaborate more on Converting More than 8bit image to 8 bit image. And, apart from GtkImageView, is there no other way of image scaling? Thanks Gorav On 02/03/2010 12:02 PM, Dov Grobgeld wrote: Even if your image has more than eight bits you can always convert it to 8-bit according to a user setting defining the grey level max and min to be used for the convertion (known as window and level in the medical image community). That's exactly how I do it in my image viewer giv. The image is held in a GivImage that is overloaded for various bit integer or floating widths and is then converted according to the user level setting before being displayed. Btw, if you would like to have interactive zooming of the image being displayed you may want to consider using my GtkImageViewer instead of GtkImage. (There is also the GtkImageView by Björn Lindquist with similar and different functionality.) See: http://giv.sourceforge.net/gtk-image-viewer/ Regards, Dov On Wed, Feb 3, 2010 at 04:19, Lars Wirzenius wrote: On Tue, 2010-02-02 at 17:25 +0530, Gorav wrote: Hi I need to do some image manipulation using GTK, and I want to view some proprietary image formats. So, I can prepare RGB data. But, which widget and API to be use to draw pixels on screen. I used GtkImage using Pixbuf, but it supports only 8 bits per sample. Have you looked at GdkPixbuf for holding the image data? You may need to write converter plugins to load and store images from files for your proprietary formats, but after that, all the in-memory stuff should work fine. ___ 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 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Image manipulation and Scaling
The following code does it: // your original data assumed to be in a continous structure of gray. // Preferably in a structure. float *src_buf; int img_width = 256; int img_height = 256; // You destination GdkPixbuf *dst = gdk_pixbuf_new(...); guint8 *dst_buf = gdk_pixbuf_get_data(); guint src_stride = gdk_pixbuf_get_row_stride(dst); // Find min and max unless you have user min and user max float min = HUGE; float max = -HUGE; for (int i=0; i max) max = gl; } // Rescale for (int row_idx=0; row_idx 255) dst_gl = 255; // Assign to rgb for (int i=0; i<3; i++) { dst_row[col_idx*3+i] = dst_gl; } } Changing to support user min and max and source RGB image is left as an exercise to the reader. And regarding whether you can support zoom without GtkImageView or GtkImageViewer, obviously yes since these are written based on lower level gtk structures. The trivial (and memory wasteful way) is to rescale the image based on zoom level and show it in a view port. Regards, Dov Wed, Feb 3, 2010 at 08:41, Gorav wrote: On Wed, Feb 3, 2010 at 08:41, Gorav wrote: Thanks for reply. > > > Can you please elaborate more on Converting More than 8bit image to 8 bit > image. > > And, apart from GtkImageView, is there no other way of image scaling? > > > Thanks > Gorav > > > On 02/03/2010 12:02 PM, Dov Grobgeld wrote: > >> Even if your image has more than eight bits you can always convert it to >> 8-bit according to a user setting defining the grey level max and min to >> be >> used for the convertion (known as window and level in the medical image >> community). That's exactly how I do it in my image viewer giv. The image >> is >> held in a GivImage that is overloaded for various bit integer or floating >> widths and is then converted according to the user level setting before >> being displayed. >> >> Btw, if you would like to have interactive zooming of the image being >> displayed you may want to consider using my GtkImageViewer instead of >> GtkImage. (There is also the GtkImageView by Björn Lindquist with similar >> and different functionality.) >> >> See: http://giv.sourceforge.net/gtk-image-viewer/ >> >> Regards, >> Dov >> >> On Wed, Feb 3, 2010 at 04:19, Lars Wirzenius wrote: >> >> >> >>> On Tue, 2010-02-02 at 17:25 +0530, Gorav wrote: >>> >>> Hi I need to do some image manipulation using GTK, and I want to view some proprietary image formats. So, I can prepare RGB data. But, which widget and API to be use to draw pixels on screen. I used GtkImage using Pixbuf, but it supports only 8 bits per sample. >>> Have you looked at GdkPixbuf for holding the image data? You may need to >>> write converter plugins to load and store images from files for your >>> proprietary formats, but after that, all the in-memory stuff should work >>> fine. >>> >>> >>> ___ >>> 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 >> >> > > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list