Re: GTK+ 2.0/3.0 Windows runtimes
John, I am maintaining several gtk2 applications for windows that I'm cross compiling from Linux. I'm using Fedora for the cross compilation and the way I'm working is as follows: - Install the necessary mingw64 packages through dnf - Install mingw32-nsis for the generation of a windows Installer for your application on Linux. Compile with the cross compilation environment of your choice. E.g. you can use automake through the script mingw64-configure . Personally I'm using scons where I manually set up all the compilation and linkage environments, etc. For an example see my image viewer giv at https://github.com/dov/giv/blob/master/SConstruct . Regarding gtk3 and gtk2, nobody is removing gtk2 for the foreseeable future, and you can continue using it as long as you see fit. One of the "big" cross platform gtk applications, inkscape, is still using gtk2. On the other hand if you want the new functionality of gtk3, go ahead and port, and you can cross compile for Windows in the same method. Regards, On Tue, Oct 23, 2018 at 10:26 AM John Mills wrote: > Hello list > > If this question should be raised on another list, please let me know. > > I have been developing a C-language GTK+ 2.0 application for MS Windows 10 > using mingw > cross-compilation on Linux, and deploying it by installing the Windows > GTK+ 2.0 runtime > bundle on the Windows machine. > http://ftp.gnome.org/pub/gnome/binaries/win32/ > > The procedure was: on Linux development machine, unzip the gtk Windows > bundle in a directory > with the C source, set up a Makefile with the appropriate CFLAGS and > LDFLAGS, 'make mingw' > and deploy the EXE. This procedure suited my development style. > > Do I now need to port to GTK+ 3? > Is MSYS2 now the best/only way to deploy the dependencies to Windows? > Using the binaries available through MSYS2/pacman, can I still develop on > Linux and deploy > mingw executables to Windows? > Can anyone point me to a guide for doing that? > > Thank you > John Mills > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: IDE to develop app with GTK3 on windows using MSYS2
Why don't you cross compile from Linux to Windows? I have for years maintained several gtk based applications, including the building of installers for windows through make-nsis, and done everything from Linux. Regards, Dov On Mon, May 7, 2018 at 10:30 AM, arkkimedewrote: > Hi! > I need an advice: > I written apps on Linux with GTK3 using essentially vi and Makefile to > build the project splitten in multiple C files with the corresponding H > file. > > Now I would migrate on WIndows 10 by means of MSYS2. > > There is an IDE (better if open source) that I can use instean to follow to > use vi? > I tried Code Blocks but the wizard to build project with GTK support only > GTK2. > I asked support and I received suggestions but at the moment I'm not able > to using C::B to build an app with GTK3 on WIndows 10. > Thank you for any advice and suggestion. > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Re-drawing GtkDrawingArea surface on motion-notify-event
The key is to not draw directly, but to invalidate one or more rectangles needed to for changing the image from the old to the new one. I worked on this problem some years ago and I think my solution is very relevant to your question. See the gtk3 branch at: https://github.com/dov/dovtk-lasso . Regards, Dov On Mon, Mar 20, 2017 at 9:25 PM, Marcin Kolnywrote: > Hi everyone, > I'd like to write very simple application for drawing lines. > 1) User press button - app saves x and y coordinates > 2) User moves the mouse - app dynamically draws potential line on each > mouse move event > 3) User releases button - app "saves" the line on the canvas. > > I've tried to modify slightly the GTK example drawing application [1]. > 1) On button press event I paint the current state to the "base_surface" > surface. > 2) On each mouse move I paint to the "tmp_surface" surface "base_surface" > and after that the actual line, so I avoid multiple lines on mouse move. > 3) On mouse release event I paint "tmp_surface" surface to "base_surface". > > This works, and full code can be found on my gist [2]. However, I don't > think it's the right approach, since I have to re-paint a whole image for > each mouse-move, and latter on, on "draw" event application is doing almost > the same, so I'm doing the re-paint twice per each mouse move. I'm afraid > that for huge surfaces it might be very inefficient. > > Do you know what would be the right approach to solve this sort of > problems? > > Thank you for help, > Marcin > > [1] https://developer.gnome.org/gtk3/stable/ch01s05.html > [2] https://gist.github.com/loganek/156b6b9ce2333fd7d389f74c093a92b4 > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Re[4]: Compiling for Windows [Was: argv revisited]
Note that if you are using fedora (and possibly other Linux distributions) it comes with lots of win32 packages precompiled. E.g. all you need to do to get gtk2 and its dependencies is to do: dnf install mingw32-gtk2 You can then compile your gtk programs for windows through cross compilation and generate a windows install file for your application through nsis. All your grandma then needs to do on windows is to run the installer. I have been doing this for several applications for several years, and the process is so smooth and reliable that I only do the testing on Linux before compiling and distributing for Windows. Regards, Dov On Thu, May 5, 2016 at 8:30 PM, Andrew Robinsonwrote: > On 5/5/2016 at 10:23 AM, Lucas Levrel wrote: > >Le 5 mai 2016, Andrew Robinson a écrit : > > > >> So if I don't want to make my on copy of the GTK+ libraries, > > > >Why wouldn't you want to build your static libs for future inclusion in > >your software? Where "build" is for "let the Makefile of MXE do all the > >work needed to build". > > 1) Because there are between 40 to 120Mb worth of libraries or their > dependencies I would have to post on my website. > > 2) You could get under 40Mb, if you are only going to use one function from > one or two libraries, and you don't want the user to have any features like > skinning. > > (I am going to reference Allegro here, only just for comparison sake) > > 3) If I do compile GTK myself, I will have to maintain all that huge > amount of > source code on my website, per the licensing agreement. If I use Allegro, > I do > nothing else unless I customize the source code, only then will I have to > post > source code. > > 4) Furthermore, I would have to answer questions on why users couldn't > compile > the source code for making GTK+ for Win32 on Windows7 (or 8 or 10 or XP), > something the GTK community has been unwilling to do itself. With Allegro, > I > literally simply download DevC++ for Windows7, select DevPak to download > Allegro, compile, and you are done! Compare that to GTK: Downgrade your > Visual > Studio to version 2013, install GIT if you don't already have it, clone the > GTK repository, install a minimalistic Linux environment like MSYS2, > install > MinGW, spend a few days trying to get to know these things, try compiling a > Win32 version of GTK+ using half-arse written instructions, if that doesn't > work try installing and using MXE, if that doesn't work follow the terse > instructions posted on an almost hidden website at Nachos blog, if you are > still having problems, go to the GTK developer forum where they won't give > you > any help, ... etc > > The setting up the development environment for GTK relies on lots and lots > of > esoteric command line parameters, and it seems like no two computers use > the > same exact parameters. Developing on Windows for Windows is super easy and > user friendly, whereas developing on Windows for GTK is not. Windows forums > are not really friendly either, but they are much more friendly than the > Linux > forums are, and anyways I can avoid the forums because there is so much > code > and advice posted on the Internet for Windows, that it is hard not to find > what you are looking for, no matter how esoteric your needs are. > > >> I must tell grandma and grandpa to get their own copy of MSYS2 and MXE, > >(not Msys2, MXE will do all the needed download) > >> and provide make their own copy of GTK+ for Win32. Wouldn't that be easy > >> and fun? > > > >All the more as they would have to install Linux beforehand! > > That attitude is one of the reasons I chose to abandon Windows ... you > sound > just like Satya Nadella trying to pawn Windows 10 off to the world. If > Linux > was so great, people would already be using it in droves, instead of barely > mustering 3% of the entire market. > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Compiling for Windows [Was: argv revisited]
Another equivalent scons-based way of compiling for windows with gcc is shown in my program giv. See: https://github.com/dov/giv/blob/master/SConstruct SCons uses the Sconstruct files to do the cross-compilation and also calls out to nsis to create a windows installer. The complete gtk run time is only about 20MB in size (at least for gtk2) which with todays hard disk sizes really is negligable, so I agree that there is no reason to try to create a common gtk runtime. I still remember the frustration back in the days when there was a common run environment and installing glade would make inkscape or gimp fail, or vice verse. Individual run time environments is really the way to go! For a peak into the bad old days, see e.g. the following thread: http://comments.gmane.org/gmane.comp.gnome.gtk%2B.general/16828 Regards, Dov On Tue, May 3, 2016 at 7:44 PM, Allin Cottrellwrote: > On Tue, 3 May 2016, Dave Howorth wrote: > > On 2016-05-03 16:57, Florian Pelz wrote: >> >>> I'd like to have one standard GTK+ installer for the GTK+ DLLs etc. that >>> can be downloaded and installed from other installers, so there is just >>> one GTK+ installed on Windows instead of one copy of perhaps different >>> versions of GTK+ for each application. >>> >> >> That's been a longstanding desire of many people. The other side of the >> argument of course is that all the applications have to be compatible with >> that particular version of the libraries, which has sometimes proven to be >> problematic even when the libraries ship with Windows. Expecting every >> application to be updated every time there is a library update is not >> realistic. It's not like a linux distro where the distro can update and >> recompile all the dependencies itself. >> > > Yep, Florian's desire is a "natural" one from the point of view of anyone > used to Linux but unfortunately it's totally impractical on MS Windows. > It's a real No-No for any third-party package to install DLLs into system > directories on Windows; this would likely break all sorts of things. > > It may seem like a terrible waste of disk space to install multiple > per-application copies of GTK, but you just have to get over it. Basically > the same on Mac OS X. > > (I might note: even on Linux, GTK updates are not necessarily harmless. > For example, updating from GTK 3.18 to 3.20 breaks emacs and gnumeric; they > still run, but they're damaged.) > > Allin Cottrell > > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Output Widgets
Please define what you mean with an output widget. All widgets are output widgets in a sense, but e.g. GtkLabel is an output label for text messages (and images). On Mon, Oct 7, 2013 at 12:44 PM, Mahesh Chaudhari mahesh.chaudh...@ymail.com wrote: Are there any output widgets available with GTK+-2.0 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Mouse events on a Cairo Context
There is another solution that I have used extensively, which is to draw the cairo commands twice. Once for the actual drawing, and once again in an offline image (called label image), with the following differences: 1. Use solid colors corresponding to labels of the different graphical components. 2. Turn off anti-aliasing. When the user clicks on the image, the x,y of the event is referenced in the label image. The label is then used as a lookup to the component which can be modified. You can see an example of how to do this at https://github.com/dov/dovtk-lasso . Note that there is a special gtk3 branch. Regards, Dov On Mon, Jul 1, 2013 at 7:54 PM, Stefan Salewski m...@ssalewski.de wrote: On Mon, 2013-07-01 at 17:42 +0200, Borja Mon Serrano wrote: The problem with (4) is dragdrop. I think it could be very difficult to deal with it, so I'm going to try the third solution, with goocanvasmm. Do you know any example of use of goocanvasmm? Yes, dragdrop may be not very easy. And zooming and panning/scrolling for a plain (cairo) drawing area may be not really trivial, when you need to grab objects with the mouse. I did try it two years ago from Ruby -- not really difficult, but it takes some time to get the math right. Have not found time to clean it up yet. ( http://www.ssalewski.de/PetEd.html.en) Of course, if you do C++ and have not much experience in GTK already you may try https://qt-project.org/doc/qt-4.8/graphicsview.html I have never find time and motivation to test that. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Fulscreen mode
You just need to use gtk_widget_hide() on the widget and it and its child widgets will not be shown. On Sun, Jun 16, 2013 at 4:28 AM, John Coppens j...@jcoppens.com wrote: Hi... I created a program with three elements in an HBox (gtk2): two treeviews and a GtkGlExt drawing area. I'd like to toggle the drawing area fullscreen/normal. Ie., not show the treeviews (or any other element - such as menus) while in fullscreen mode. Is that possible somehow? Thanks for any suggestion... John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Copy full path when hovering over a file?
Is there any keybinding that allows copying into the clip-board the full path of a filename that you hover over in the file chooser dialog? E.g. when looking at the Recent file menu, there is a tooltip popup of the full path of a file. Is it possible to copy the contents of this tooltip so that you can later paste it as text? Thanks! Dov ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: pango or any other way to format text
See http://developer.gnome.org/pango/stable/PangoMarkupFormat.html for the syntax for subscripts and superscripts. Regards, Dov On Mon, May 14, 2012 at 3:38 PM, David Nečas y...@physics.muni.cz wrote: On Mon, May 14, 2012 at 08:20:26PM +0800, Rudra Banerjee wrote: Can anybody please take some time to show me simple way of implementing pango formatting to get greek letters, subscripts and superscripts in gtk2+? What do you mean by ‘implementing Pango formatting'? I suppose you are not writing a Pango backend, i.e. you are not *implementing* any text rendering yourself. If you just want to use Pango to render Greek text, subscripts, superscripts, Cyrillic, math symbols or whatever, use UTF-8: GtkWidget *label = gtk_label_new(ἀπὸ τοῦ ἡλίου μετάστηθι); or GtkWidget *label = gtk_label_new(a² + b² = c²); That's it. Function gtk_label_set_markup() with Pango markup http://developer.gnome.org/pango/stable/PangoMarkupFormat.html can be used for more complex indexes and exponents and other stuff in labels. Yeti ___ 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: GtkButton bg color
The following, though a bit old and referring to perl, might still help: http://gtk2-perl.sourceforge.net/doc/yapc-2004-perl-gtk2/slides.html Regards, Dov On Sun, Apr 29, 2012 at 20:41, Steve iteratio...@gmail.com wrote: I'm using linux. I've tried dozens of different methods and a few examples which seem to suggest that they will change the background but noting works. I scrapped all that code and started over from scratch. I can change the fg color with no problems but i can't seem to get anything to work with the bg color Any chance you can provide an example of a button with a background color? Steve ___ 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: GtkTextView and bidi text
Sorry for not being clear. I actually meant that it should be controllable by the programmer. Looking at the documentation for GtkTextTag I realized that there is a property direction, that by default has the value GTK_TEXT_DIR_NONE . What happens if you change it to GTK_TEXT_DIR_LTR? Will it not override the automatic calculation of the base direction? If not, it is a bug that can easily be fixed. I can think of no other use for this property that makes sense. And you are never helpless as long as you have the source. Of course you have a complexity barrier and learning curve. But it is much better than the being blindfolded. ;-) Regards, Dov On Tue, Apr 24, 2012 at 23:36, Ferdinand Ramirez ramirez.ferdin...@yahoo.com wrote: --- On Mon, 4/23/12, Dov Grobgeld dov.grobg...@gmail.com wrote: Lots of years ago we spoke about having a direction override as a paragraph attribute, but we never got around to implementing it. I think it is a good idea to give control to the programmer rather than make it automatic. Making everything automatic and making the programmer feel helpless is the Microsoft way. There, now that I've insulted you, I am sure you will consider adding this feature. :-) Seriously, this should not even be at the paragraph level, but in the complete control of the programmer. The programmer should be able to set the direction and this should hold until it is set again. Even if the automatic direction detection exists, there should be the ability to override it. -Ferdinand ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkTextView and bidi text
Indeed there is no higher level override determine the text direction. You have to change the buffer contents to get what you want. The easiest way of doing this is by inserting the character zero-width character LRM (U+200E) before your first RTL character. Lots of years ago we spoke about having a direction override as a paragraph attribute, but we never got around to implementing it. Regards, Dov On Tue, Apr 24, 2012 at 01:33, Ferdinand Ramirez ramirez.ferdin...@yahoo.com wrote: How can I force GtkTextView object to use left to right rendering when I type in a character which has the default behavior of being from a RTL language? I need this behavior when I mix some RTL characters with LTR characters and the first character on a line is of RTL type. The following lines seem to have no impact. GtkTextView *view; ... gtk_widget_set_direction(view, GTK_TEXT_DIR_LTR); gtk_widget_set_default_direction(GTK_TEXT_DIR_LTR); -Ferdinand ___ 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: porting Xlib/Motif apps to GTK+
On Wed, Feb 29, 2012 at 01:17, Roger Davis r...@soest.hawaii.edu wrote: [stuff deleted] Does Cairo have a way of mimicking an X11 XOR-op GC for doing low-overhead ephemeral drawing ops of rubberband-lines, etc.? I have over the years been intrigued of how to do flicker free rubberband selection with gtk/cairo. My current solution may be seen here: https://github.com/dov/dovtk-lasso Feel free to poke me if you need more explanations and more documentation of how it works. Regards, Dov ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Simple Html-View widget
Just use gtk_label_set_markup(). Regards, Dov On Sat, Sep 10, 2011 at 20:35, Craig craigbakal...@verizon.net wrote: Hi, I am not expert on this issue, but isn't Pango the way to go. I think you should look up the Pango functions or how gtk deals with the Pango thing. Craig Bakalian Hello, in my application I store some Text data in xml files. Some nodes are displayed via a gtk-label or an gtk-entry, others are displayed via a gtk text-view. Now I want to extend the text-view (and storage) with the capability to handle some formated text. I just need things like bold text, linefeed, maybe headers and colors. Since I don't want to create a own text storage format and I am using already xml for text storing html would be nearby. Is there some Gtk-Widget like the textview/buffer which can render simple HTML Tags? If not, what is your recommendation for my problem. regards Arne ___ 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: GTK+INSTALLATION IN WINDOWS
One way of doing this is as follows: - Cross compile for windows from Linux. E.g. on Fedora, this may be done by installing the mingw32* packages. - Install the cross compiled makensis package to create an installer for Windows under Linux. - Run the installer under Windows installing your application and all the gtk packages. You can refer to the SConstruct file and the nsis file of my program giv at: http://git.gnome.org/browse/giv Too see how I do it. Regards, Dov On Tue, Apr 26, 2011 at 00:39, AKSHAT MALTARE akshat.malt...@gmail.comwrote: RESPECTED SIR,MADAM, I am using gtk+ in my c,c++ code to develop a cross platform application and have created my gui using gtk+ in linux and now i just want to test those codes for windows.I had been trying to install gtk on windows from last two days but due to lack of details abt installation process i am unable to install it as I do not have much experience of using commands of windows so it would be very helpfull if you could tell us the step by step procedure of installing packages or reffer us some website where we could find it. thankyou ___ 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: Program Files folder
There is no such thing as default folder under Linux/Unix. The user might want to install an application in her home directory, or in /opt, or in /usr/bin depending on permissions or the visibility of the application. Perhaps you meant to ask if it is possible to know where the application was run from? In that case just check argv[0]. Regards, Dov On Thu, Apr 21, 2011 at 11:00, John Emmas john...@tiscali.co.uk wrote: I know that glib offers a function called g_get_home_dir() which returns the user's home folder on the relevant platform. Is there any similar function that will give me the default folder for installing applications? For example, on Windows this would return C:\Program Files. On Linux it might be /bin or /usr/bin or /usr/local/bin etc. And on OS-X it would be /Applications. John ___ 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: Loading postscript file
As far as I know (but perhaps someone else knows better) the only freely available postscript interpreter is ghostscript (which is used by gv). Ghostscript is distributed under the GPL license which prevents Gtk, which is distributed under the LGPL, to depend on it. The easiest way round this is simply to run system() ghostscript as a subprocess and have it output a raster file, e.g. in the pnm format, and then load this file into your gtk program. Here is the command line I've been using for this in the past: gs -q -dNOPAUSE -g100x200 -r75x75 -sDEVICE=ppmraw -sOutputFile=foo.pgm trans.ps myfile.ps quit.ps where trans.ps encodes of the shift and rotation of the file myfile.ps Hope this helps. Regards, Dov On Mon, Dec 27, 2010 at 05:10, tengfei tfco...@gmail.com wrote: Hello all. I want to render a postscript file (as gv does) in a Gtk+ program. I tried the image widget by the function gtk_image_new_from_file, but it didn't work. Can anyone help regarding this? Regards, Colin ___ 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: GTK Error handling..
If all you want is a popup, then you might as well create a new process instead of a new thread. There is no advantage of using a thread as it does not seem like you want to pass any info between the window and the monitoring loop. Further, the way you described it, if more than one event occurs, then you will be spawning two threads that does calls into GUI. This is a big no-no as gtk is not multi-threaded, and only a single thread may do graphics related calls. Regards, Dov On Wed, Nov 24, 2010 at 15:01, Jaroslav Šmíd jardas...@gmail.com wrote: GTK is not smart toolkit and is unable to work without X display and is not even able to reconnect to different display (or to the same later) when the connection get lost. This is with all X based toolkits I know of - it just seems easier for developers to just call exit() then to install like timer to event loop which would try to reconnect. This way it works on Windows - GUI applications are able to work without GUI subsystem being active (e.g. when it crashes because of driver failure). When the GUI subsystem is restarted (either with the same driver or geeric vesa driver), GUI applications still works, because WindowsAPI takes care of this. GTK on X-based systems does not, even if that is not too much work (just catch X server error, discard all X id's for every top level windows, pixmaps, ..., and then when it gets reconnected, create them again and in the meanwhile use stubs). On 11/24/2010 03:41 AM, Champ Clark III [Softwink] wrote: Hello all! I have a multi-threaded application written in C that I'm a bit stumped on. It's not the 'multithreaded' portion of the code I'm having issues with. That seems to be functional. It's the GTK error and warning handling. The application is constantly processing data (syslog). When a rule is 'satisfied', a thread is spawned which builds a simple GTK window (popup) with the information about the 'event.' So far, so good. However, I'm not sure how to handle certain error events. For example, let's say I'm sending 'popups' to a workstation across a network. The remote workstation goes off line (the user leaves, powers it down, whatever). My application, of course, won't be able to send the GTK 'popup'. I'll likely get the error: Gtk-WARNING **: cannot open display: 10.10.10.10:0.0 Here's my problem. This error/warning causes termination of the over all application. Even though the 'error/warning' gets generated from within my 'GTK thread', it terminates the whole application. That's not good. Is there any way I could intercept or use a callback with the warnings/errors? That is, I'd like to log the warnings/errors, but I don't want termination of my software due to a GTK/X11 problem. Basically, some method to let me deal with the GTK/X11 errors the way I see fit. I hope this makes sense. Let me know if you have any questions. ___ 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: large performance difference between gtktextview and gtksourceview
Last time I checked (which was a long time ago) gtksourceview did not support BiDi and possibly other i18n issues. But this per se is no explanation for it being slower. And yes, performance can always be improved. Regards, Dov On Thu, Nov 4, 2010 at 18:12, Olivier Sessink oliviersess...@gmail.comwrote: Hi all, loading 1Mb of UTF-8 encoded text into a gtk text view seems to take much more time than loading the same buffer into gtksourceview. Since gtksourceview has all of the functionality of gtktextview and more, where is this difference coming from? And does this mean that we can improve the performance of gtktextview? regards, Olivier ___ 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: gtk 2 or 3
For an example of how to do it without having a secondary thread do any gtk commands, see my example program in: http://www.mail-archive.com/gtk-app-devel-list@gnome.org/msg14213.html Basically the work thread, that is taking a long time doing its thing, requests the gui thread to update the GUI by sending it requests through g_idle_add(). The GUI thread will then, when idle, attend to the routine and update the gui. Syncronization is handled by mutexes, etc. In my example I wanted a reply from the GUI thread (should I abort?) therefore the worker threads blocks until released by the main thread. Regards, Dov On Thu, Nov 4, 2010 at 12:18, Michael T. mys...@seznam.cz wrote: So GIMP is a single threaded software? No, but... There's never GTK+ multithreaded activity? Indeed. If I may ask, what is the main technical problem (deeper explanation) with using GTK+ from multiple threads? It is probably very application specific. For instance, in my measurement application an extra thread is started that takes care of data acquisition. I need to update a GTK progress bar while measuring, but since data are acquired extremely fast I do it from the measuring thread. The main thread, where GTK is running is of course blocked until the measurement is finished. This is obviously using GTK from multiple threads, but so far works perfectly. (Although, sometimes I get an occasional warning during execution) But this is probably due to the fact, that the main thread is blocked so the only thing that can be done is the progress bar update that is being taken care of from the measurement thread. myso ___ 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: Creating own stock image library
I use gdk-pixbuf-csource in my build system to generate c-files from my icons that I then insert into the source list of programs. Let me know if you need more examples. Regards, Dov On Sun, Oct 10, 2010 at 17:46, Arne Pagel a...@pagelnet.de wrote: Hello, I created some special icons for my application. Now I want to reduce the files needed by the application, and therefore I want to compile the needed images in the binary output. What would be the best way to do that? How is this done with the gtk-stock-images? regards Arne ___ 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: Linking the buttons to gtk app
I might be missing something but it seems like this is a Linux kernel question and doesn't have much to do with Gtk. Unless I'm missing something you need to write a device driver for your kernel than makes your hardware buttons appear as keyboard key-presses, e.g. F1-F10, and then use standard Gtk keypressevent to catch these. Regards, Dov On Mon, Aug 30, 2010 at 07:59, Guruprasad Bhat guruprasad...@gmail.comwrote: Yes it has got linux kernnel, on the user space application will run. Inorder to operate user will press buttons GTK has got button click/press event handler. Pressing should reach GTK from hardware. How it can be linked. *Regards,* * Guruprasad Bhat.* On Fri, Aug 27, 2010 at 3:59 PM, dhk dhk...@optonline.net wrote: On 08/27/2010 01:27 AM, Guruprasad Bhat wrote: Hello, I have developed a GUI application for ARM based product. It has 10 buttons, so I want to link button press to GTK. How can I start to do this? In which level/layer I have work to get it done? *Regards,* * Guruprasad Bhat.* ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list This is a little off the subject, but how do you get you application on the ARM device especially when it's got an OS like Windows CE or something like that? dhk ___ 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: porting gdk - cairo
I took the bait and coded my solution that I (in lack of anything better called) dovtk-lasso . I'm including it below including a test program. I think this solution is even simpler than your old xor solution. All you need to do is to create the draw_callback fuction that uses whatever cairo painting you want to draw your overlay. Note that this function is called twice, once to extract where you are drawing, and once to do the drawing. During the first time the do_mask variable is on. In this case you should choose a thicker pen and draw in black, to make sure that everything is included. Note that there is one constraint that I have not been able to solve. The expose-event callback that is doing the actual drawing of your graphics have to return FALSE. I would be happy to receive a solution for it. I promise to put this code into git-hub as soon as possible. //== // test-gtk-lasso.c - This example is in the public domain // // Dov Grobgeld dov.grobg...@gmail.com // Mon Aug 16 09:09:56 2010 //-- #include stdlib.h #include gtk/gtk.h #include math.h #include dovtk-lasso.h DovtkLasso *lasso = NULL; int start_x, start_y, end_x, end_y; int cb_expose(GtkWidget *widget, GdkEventExpose *event, gpointeruser_data) { cairo_t *cr; cr = gdk_cairo_create(widget-window); cairo_rectangle(cr, event-area.x, event-area.y, event-area.width, event-area.height); cairo_clip(cr); // Just draw anything in the widget double x, y; x = widget-allocation.x + widget-allocation.width / 2; y = widget-allocation.y + widget-allocation.height / 2; double radius; radius = MIN (widget-allocation.width / 2, widget-allocation.height / 2) - 5; cairo_set_source_rgb(cr, 0,0,0); cairo_arc (cr, x, y, radius, 0, 2 * M_PI); cairo_stroke(cr); cairo_destroy(cr); return FALSE; } /** * Draw whatever overlay you want on the image. If the do_mask * is on, then you should paint in black and with a pen that * is thicker than the drawing. */ void my_lasso_draw(cairo_t *cr, gboolean do_mask, // output DovtkLassoRectangleList **rect_list) { int min_x = MIN(start_x, end_x); int min_y = MIN(start_y, end_y); if (!do_mask) { cairo_set_source_rgb(cr, 1,0,0); cairo_set_line_width(cr,1); } else cairo_set_line_width(cr, 5); cairo_set_line_cap(cr, CAIRO_LINE_CAP_ROUND); // Draw a rectangle cairo_rectangle(cr, min_x, min_y, abs(end_x-start_x), abs(end_y-start_y)); cairo_stroke(cr); } int cb_button_press(GtkWidget *widget, GdkEventButton *event, gpointeruser_data) { lasso = dovtk_lasso_create(widget, my_lasso_draw, TRUE); start_x = event-x; start_y = event-y; return FALSE; } int cb_button_release(GtkWidget *widget, GdkEventButton *event, gpointeruser_data) { dovtk_lasso_destroy(lasso); lasso = NULL; return FALSE; } int cb_motion_notify(GtkWidget *widget, GdkEventMotion *event, gpointeruser_data) { //printf(button motion\n); end_x = event-x; end_y = event-y; dovtk_lasso_update(lasso); return FALSE; } int main(int argc, char *argv[]) { gtk_init(argc, argv); GtkWidget *w_top = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(w_top), delete-event, G_CALLBACK(gtk_main_quit), NULL); GtkWidget *w_draw = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(w_top), w_draw); gtk_widget_set_size_request(w_draw, 500,500); g_signal_connect(G_OBJECT(w_draw), expose-event, G_CALLBACK(cb_expose), NULL); // TBD - set up events for lasso gtk_widget_add_events(w_draw, GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); g_signal_connect(G_OBJECT(w_draw), button-press-event, G_CALLBACK(cb_button_press), NULL); g_signal_connect(G_OBJECT(w_draw), button-release-event, G_CALLBACK(cb_button_release), NULL); g_signal_connect(G_OBJECT(w_draw), motion-notify-event, G_CALLBACK(cb_motion_notify), NULL); gtk_widget_show_all(w_top); gtk_main(); return 0; } /** * dovtk-lasso.h * * A solution for drawing overlays on a gtk widget. * * This code is relased under the LGPL
Re: porting gdk - cairo
I don't know if you noticed it in another thread, but I created a working example of the approach that I described in my earlier email. See: http://github.com/dov/dovtk-lasso See the program test-dovtk-lasso.c for an example of how to use it. Please let me know if you need more explanations. The source code isn't very well documented yet. Regards, Dov On Wed, Aug 11, 2010 at 20:12, Allin Cottrell cottr...@wfu.edu wrote: On Wed, 11 Aug 2010 jcup...@gmail.com wrote: On 11 August 2010 02:14, Allin Cottrell cottr...@wfu.edu wrote: rid of GdkGC. I'd imagine that the effect I'm after is something that many GTP apps have need of, and it's trivial to achieve with the GDK API. I've found that XOR rubber banding is quite hard to do reliably in gdk. The problem I think is that you are using the screen pixels to store part of the state, and that gets hard to coordinate between the various things that can affect the display. I had mouse movements triggering rect moves, mouse moves with a button held down causing background scrolling of the canvas, and mouse moves over other screen objects triggering highlight effects. With all these things going on at once it became very difficult to get XOR rubber bands to not leave annoying trails as they moved. I switched to an update-model / invalidate-widget / redraw-on-idle scheme as Dov suggests and I got prettier updates with less complication. Since input and output are decoupled, it'll scale more gracefully between slower and faster machines as well, which is nice. My drawing case may be simpler than yours -- there's nothing scrollable in the vicinity -- but I've found that rubber-banding using GDK_INVERT to undraw the last box works flawlessly at low programming cost. But can you suggest a good example to look at for the alternative approach? Thanks. Allin Cottrell ___ 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: porting gdk - cairo
The following solution does the job though it causes flickering. - If there is a previous backing store (see below) then restore it to the underlying image. - Define the rectangle to draw by the button-press and the motion-notify-events. - Copy the four edges of below the rectangle to four GdkPixmaps, that I call backing store. - Draw the rectangle. The following more complex solution should take care of flickering: Preparation: - Create an expose handle that is called after the default expose handle which uses cairo to draw a rectangle in coordinates determined by structure R (see below). Note that this expose handle will be called up to eight times every time a motion notify event occurs. - Create a fifo buffer containing up to eight CairoRectangles to be exposed. During motion: - Define the new rectangle to draw by button-press and motion-notify events and store it in the structure R available by the expose handle. - Push four areas corresponding to the four edges of the rectangles to the fifo buffer. - Expose the eight areas in the fifo buffer. - Pop off the first four areas of the fifo buffer. This solution relies on the underlying expose handle. If that expose handle is slow (e.g. complex vector graphics), the solution may be made faster by initiating the process (e.g. at button-press) by copying the entire widget window to an off screen pixmap, and then block the underlying expose handle. I'd be interested if there is a more compact solution. Regards, Dov On Tue, Aug 10, 2010 at 17:16, Allin Cottrell cottr...@wfu.edu wrote: I gather from recent discussion on the gtk-devel list that a good deal of the old GDK drawing API may be removed for GTK 3 in favor of use of cairo: in particular GdkGC seems likely to disappear. There appear to be good arguments for this, but it means some extra work for people trying to get their apps GTK3-ready. Benjamin Otte has some notes on porting at http://blogs.gnome.org/otte/2010/07/27/rendering-cleanup/ but there's one piece of GDK code I've been using for which I can't figure out the cairo equivalent and I wonder if anyone can help. The context is zooming to a selected portion of a graphic displayed in a GTK window. If the user selects a Zoom menu item she can then drag out a rectangular outline on the current image, and when the mouse button is released the view snaps to the chosen rectangle. The tricky part is avoiding a horrible mess as the user drags the rectangle. This is achieved via a cycle of draw-display-erase as the mouse pointer moves. In GDK, the erase part is done by redrawing the last-shown rectangle using an inverted GdkGC: gdk_gc_set_function(gc, GDK_INVERT); How would you do this in cairo? Thanks. -- Allin Cottrell Department of Economics Wake Forest University ___ 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: text on a curved baseline?
What do you mean with drawing text? Through the text property of the label widget? Then the answer is indeed no. But you can always create a drawing area and draw whatever you want with cairo in the expose event. You will then have no problem drawing in a circle as you can loop over each character and draw it separately. I believe that Behdad wrote an example for this in the pango example directory. Regards, Dov On Thu, Jul 15, 2010 at 12:55, N James Bridge ja...@xmas.demon.co.ukwrote: Hi this is a beginner's question... can you make text follow a curved baseline? Looks like no. James ___ 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: Grid Based Canvas
Why don't you just draw a grid with lines on the canvas, and then whenever you select a square you create a canvas rectangle item and put it in the grid between the grid lines? When you unselect, you just destroy the canvas item. You will still need 2 items, which might still be too much... Another approach which uses a lot less memory but requires more work on your part is to use my GtkImageViewer widget which is a hybrid between an image viewer and a canvas. (In spite of its name it does not necessarily display images). The widget handles zooming, but you have to redraw the contents yourself on exposure events. See: http://giv.sourceforge.net/gtk-image-viewer/ Regards, Dov On Tue, May 25, 2010 at 22:02, Asad Jibran Ahmed surfer...@gmail.comwrote: On Mon, 2010-05-24 at 23:21 -0400, Liam R E Quin wrote: On Tue, 2010-05-25 at 05:04 +0500, Asad Jibran Ahmed wrote: [...] The canvas will have grids, much like a graph paper. Whenever the user clicks on one of the grid squares, that square will become selected and the selection will be shown by highlighting the square. It sounds like you really have a grid of squares, even if the user doesn't think of it that way. I think all of the canvas APIs support scrolling and zooming. Or take a peek at e.g. the minesweeper game? Liam Liam, Thanks for the info. I checked out the crcanvas widget and I think that it may just be what I need. I do however have one issue with the square approach that you have suggested. The grid I am trying to make needs to be quite large (1x1), and the memory requirements of keeping track of this large a number of rectangles is very problematic. Any advice on how to proceed from here? Again, thanks for your earlier reply. Thanks -- JB :: http://www.asadjb.com ___ 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: GtkPlot
Attached below is a simple example. Something that you should keep in mind is that gtkplot expects you to keep the data around as long as the plot is displayed, i.e. it accepts a pointer to the data, but it does not copy it. Presumably for perfomance reasons. Regards, Dov #include gtk/gtk.h #include gtkextra/gtkextra.h #include math.h GtkWidget *w_top; GtkPlotData *dataset; void build_example1(GtkWidget *plot) { GdkColor color; static gdouble px1[]={0., 0.2, 0.4, 0.6, 0.8, 1.0}; static gdouble py1[]={.2, .4, .5, .35, .10, .40}; dataset = GTK_PLOT_DATA(gtk_plot_data_new()); gtk_plot_data_set_points(dataset, px1, py1, NULL, NULL, 6); gdk_color_parse(red, color); gtk_plot_data_set_symbol(dataset, GTK_PLOT_SYMBOL_DIAMOND, GTK_PLOT_SYMBOL_EMPTY, 10, 2, color, color); gtk_plot_data_set_line_attributes(dataset, GTK_PLOT_LINE_SOLID, (GdkCapStyle)0, (GdkJoinStyle)0, 2, color); gtk_plot_data_set_connector(dataset, GTK_PLOT_CONNECT_STRAIGHT); gtk_plot_data_hide_legend(dataset); gtk_plot_add_data(GTK_PLOT(plot), dataset); gtk_widget_show(GTK_WIDGET(dataset)); } // This signal handler resizes the graph if its allocation was changed int plot_expose_event(GtkWidget *canvas, GdkEventConfigure *event, gpointer user_data) { int width = canvas-allocation.width; int height = canvas-allocation.height; if (width != GTK_PLOT_CANVAS(canvas)-width || height != GTK_PLOT_CANVAS(canvas)-height) { gtk_plot_canvas_set_size(GTK_PLOT_CANVAS(canvas), width, height); gtk_plot_canvas_paint(GTK_PLOT_CANVAS(canvas)); } return 0; } GtkWidget *create_plot() { GtkWidget *w_plot_canvas, *w_plot; GtkPlotCanvasChild *child; GtkPlotAxis *x_axis, *y_axis; w_plot_canvas = gtk_plot_canvas_new(500,300,1.0); // Do this in order to have auto resize of plot with window. GTK_PLOT_CANVAS_UNSET_FLAGS (GTK_PLOT_CANVAS (w_plot_canvas), GTK_PLOT_CANVAS_DND_FLAGS); GTK_PLOT_CANVAS_SET_FLAGS (GTK_PLOT_CANVAS (w_plot_canvas), GTK_PLOT_CANVAS_CAN_RESIZE); w_plot = gtk_plot_new(NULL); gtk_plot_set_range(GTK_PLOT(w_plot), 0, 1., -1., 1.4); gtk_plot_axis_set_ticks(gtk_plot_get_axis(GTK_PLOT(w_plot), GTK_PLOT_AXIS_LEFT), 0.5,5); child = gtk_plot_canvas_plot_new(GTK_PLOT(w_plot)); gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(w_plot_canvas), child, .10, .1, .9, .85); // Setup the axis gtk_plot_set_legends_border(GTK_PLOT(w_plot), (GtkPlotBorderStyle)0, 0); gtk_plot_axis_set_visible(gtk_plot_get_axis(GTK_PLOT(w_plot), GTK_PLOT_AXIS_TOP), FALSE); gtk_plot_axis_set_visible(gtk_plot_get_axis(GTK_PLOT(w_plot), GTK_PLOT_AXIS_RIGHT), FALSE); x_axis = gtk_plot_get_axis(GTK_PLOT(w_plot), GTK_PLOT_AXIS_BOTTOM); y_axis = gtk_plot_get_axis(GTK_PLOT(w_plot), GTK_PLOT_AXIS_LEFT); gtk_plot_axis_set_title(x_axis, Time [t]); gtk_plot_axis_hide_title(y_axis); gtk_plot_x0_set_visible(GTK_PLOT(w_plot), TRUE); gtk_plot_y0_set_visible(GTK_PLOT(w_plot), TRUE); gtk_plot_canvas_put_child(GTK_PLOT_CANVAS(w_plot_canvas), gtk_plot_canvas_text_new(Helvetica, 12, 0, NULL, NULL, FALSE, GTK_JUSTIFY_CENTER, Intensity ), .10, .1, .20, .20); // Build data and put it in plot build_example1(w_plot); gtk_widget_show(GTK_WIDGET(w_plot)); g_signal_connect(G_OBJECT(w_plot_canvas), expose-event, G_CALLBACK(plot_expose_event), NULL); return w_plot_canvas; } // This is an example of how to update the data displayed in the // widget. For more examples, see testrealtime.c. void cb_change_dataset(GtkWidget *button, gpointer user_data ) { GtkWidget *canvas = GTK_WIDGET(user_data); static gdouble px1[]={0., 0.2, 0.4, 0.6, 0.8, 1.0}; static gdouble py1[]={.35, .30, .40, .2, .4, .5 }; gtk_plot_data_set_points(dataset, px1, py1, NULL, NULL, 6); gtk_plot_canvas_paint(GTK_PLOT_CANVAS(canvas)); gtk_widget_queue_draw(canvas); } void create_widgets() {
Re: Widget for drawing plot
I've been using GtkPlot for real time plots for a number of years. It basically does the job, though its feature set is quite limited. In case you will be using PyGtk then there is no doubt that you should be using MatPlotLib which has vastly more options. I have often wished that there was a C port of it. There is of course also the option of embedding a python interpreter and matplotlib and then grab its output and display it as an image. But that is a bit more complex. Regards, Dov On Wed, Mar 17, 2010 at 18:25, Salvatore De Paolis iw...@claws-mail.orgwrote: Hi, I was searching a good way to draw plots in Gtk+. Surfing a little bit a found Gtkdatabox and GtkPlot. Which is worth to use or there's anything else? regards Salvatore ___ 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; iimg_width*img_height; i++) { float gl = src_buf[i]; if (gl min) min = gl; else if (gl max) max = gl; } // Rescale for (int row_idx=0; row_idximg_height; row_idx++) { guint *dst_row = src_buf + row_stride; for (int col_idx=0; col_idximg_height; col_idx++) { float src_gl = src_buf[row_idx*img_width + col_idx]; float dst_gl = (src_gl - min) / (max-min) * 255; // clip if (dst_gl 0) dst_gl = 0; else if (dst_gl 255) dst_gl = 255; // Assign to rgb for (int i=0; i3; 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 gora...@mst-india.com wrote: On Wed, Feb 3, 2010 at 08:41, Gorav gora...@mst-india.com 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 Wirzeniusl...@liw.fi 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: about main event loop
No, you don't create threads to handle events. Instead you connect to callbacks through g_signal_connect(). But in order to get an intelligent reply from this list, you should provide a complete compilable program that exhibit the problem that you experience. Regards, Dov On Tue, Jan 12, 2010 at 11:02, Zhang Wei zwi...@gmail.com wrote: hello, I don't know how to deal with the signal when I clicked the icon on taskbar with right button of the mouse the program runs ok, but it gives the warnings in the console: GLib-WARNING **: g_main_context_prepare() called recursively from within a source's check() or prepare() member. GLib-WARNING **: g_main_context_check() called recursively from within a source's check() or prepare() member. should i use a callback function to deal with the signal button_press_eventor create a thread to run in the idle time? ___ 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: how to set language for non-unicode text
No, don't use gtk-i18n-list and don't cross post. gtk-app-devel-list is just fine. Gtk works only with unicode in utf8 encoding internally, so if you want a different format on the disk you will have to convert your text on input and output. Regards, Dov On Mon, Dec 28, 2009 at 19:59, Han keepsim...@gmail.com wrote: Hi, I wrote my first linux GUI app using GTK+, which seems to be a very nice tool. One question I had is: how can I set the language for non-unicode text in my application? I tried to use iconv(), but did not work out. The iconv_open call returned error ENOENT (2). Not sure if i am in the correct direction. thanks for any help. ___ 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: Howto make a gtkbutton send a changed signal?
I don't really understand what you mean with emiting a changed event. You mean that someone is doing something like: gtk_label_set_text(GTK_LABEL(gtk_container_get_child(GTK_CONTAINER(my_button)), new text) or something simar (e.g. changing the image shown on the image)? One way of doing it would be to do the following: - Derive a new widget inheriting from GtkButton. - Add a new signal changed to it. - Add a new accessor function to the widget that changes the contents and emits the new signal. - Change the calls for changing button contents so that it uses the new function. - Connect to the new signal. Regards, Dov You can get the effect that you want by deriving a new widget On Tue, Dec 1, 2009 at 10:59, Till Harbaum li...@harbaum.org wrote: Hi, i am changing the UI of an existing app for mobile usage in a way that i replace some gtkentry's with some gtkbuttons which the use some alternate input method. I want to keep as much of the application as it is and one of the things the app expects is that this particular widget emits a changed event whenever its contents changes. So i'd like to enable my gtkbutton to emit a changed event, but i don't find any examples on how to achieve that. How do i attach a new signal to an existing widget type? Thanks, Till ___ 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: Capture console app output into texview?
Here's my solution to the problem. It runs the external command in an external thread. This is probably an overkill for the problem at hand, on the other hand it is a good demo for how to create a worker thread and capture its output in the GUI. This currently does not work with windows at it is using popen() and g_io_channel_unix_new() but it should be trivial to fix and is left as an exercise for the reader. Compile with: gcc -o stdout-to-textview `pkg-config --cflags --libs gtk+-2.0 gthread-2.0` stdout-to-textview.c //== // stdout-to-textview.c // // An example how to place stdout from a an external process // into a text view buffer by running the process in a separate // thread. // // This program is released under the LGPL v3.0. // // Dov Grobgeld dov.grobg...@gmail.com // Fri Nov 20 09:22:39 2009 //-- #include stdio.h #include stdlib.h #include gtk/gtk.h // This structure contains all the thread info for the job. typedef struct { GMutex *update_mutex; GCond *update_cond; GMutex *mutex_to_run; gchar *cmd; gchar *info; } JobData; // Sorry, out of laziness I made the widgets global. GtkWidget *w_text_view = NULL; GtkWidget *w_entry_cmd = NULL; GMutex *mutex_one_job_at_a_time = NULL; // Create the data for a job JobData *job_data_new(const char *cmd, GMutex *mutex_to_run) { JobData *job_data = g_new0(JobData, 1); job_data-cmd = g_strdup(cmd); job_data-update_mutex = g_mutex_new(); job_data-update_cond = g_cond_new(); job_data-mutex_to_run = mutex_to_run; return job_data; } // free the data from a job void job_data_free(JobData *job_data) { g_free(job_data-cmd); g_mutex_free(job_data-update_mutex); g_cond_free(job_data-update_cond); g_free(job_data); } // This function receives a requst from a worker thread asking to // update the gui with the required info. gboolean cb_update_job(JobData *job_data) { if (job_data-info) { GtkTextBuffer *text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(w_text_view)); GtkTextIter end_iter; gtk_text_buffer_get_end_iter(text_buffer, end_iter); gtk_text_buffer_insert(text_buffer, end_iter, job_data-info, -1); gtk_text_view_scroll_to_iter (GTK_TEXT_VIEW(w_text_view), end_iter, 0.0, TRUE, 0.0, 0.5); g_free(job_data-info); job_data-info = NULL; } // Indicate that the update is done g_mutex_lock(job_data-update_mutex); g_cond_signal(job_data-update_cond); g_mutex_unlock(job_data-update_mutex); return FALSE; } // A helper function run in the job thread receiving the string that // should be displayed in the textview. void job_add_to_text_viewer(JobData *job_data, const char *info) { job_data-info = g_strdup(info); // Lock mutex to make sure that we will receive the condition signal g_mutex_lock(job_data-update_mutex); g_idle_add((GSourceFunc)cb_update_job, job_data); // Wait for cb_update_job to tell me that the update is done g_cond_wait(job_data-update_cond, job_data-update_mutex); g_mutex_unlock(job_data-update_mutex); } // The thread entry point. It will do the job, send the data to the // GUI and self destruct when it is done. static gpointer thread_worker(JobData *job_data) { FILE *fh = popen(job_data-cmd,r); printf(thread_worker running %s\n, job_data-cmd); GIOChannel *gh = g_io_channel_unix_new(fileno(fh)); GIOStatus status; GError *error = NULL; gsize length; gsize terminator_pos; gchar *str_return; while( (status = g_io_channel_read_line(gh, str_return, length, terminator_pos, error)) == G_IO_STATUS_NORMAL) { job_add_to_text_viewer(job_data, str_return); g_free(str_return); } g_io_channel_unref(gh); pclose(fh); job_add_to_text_viewer(job_data, Job done!); g_mutex_unlock(job_data-mutex_to_run); g_thread_exit(NULL); if (job_data) job_data_free(job_data); return NULL; } // Callback for the run button void cb_clicked_run(GtkWidget *widget, gpointer user_data) { const gchar *cmd = gtk_entry_get_text(GTK_ENTRY(w_entry_cmd)); GError *error = NULL; printf(Run %s\n, cmd); // create a thread that will run the external command // tbd... JobData *job_data = job_data_new(cmd, mutex_one_job_at_a_time); g_thread_create((GThreadFunc)thread_worker
Re: GDK + GLib main loop
You don't manually loop for events, but instead set up your drawing in the expose handle of the drawing widget. You then connect to this handle through: g_signal_connect(drawing_area, expose-event, G_CALLBACK(my_expose_handler), user_data); See the simple.c example in the gtkglarea source archive. Regards, Dov 2009/7/23 Mihai Draghicioiu mihai.draghici...@gmail.com Hi all! I'm making an OpenGL application based on GDK + GtkGLArea. My code so far works, but it has two issues: 1. It does not handle events in a blocking fashion. 2. Somehow the window does not receive an Expose event. I was told that for blocking until an event arrives, I'd have to use GLib main loop. I have looked at the GLib main loop reference page, but I have no idea how to make the this work. So I need some hints here. And for the GDK_EXPOSE event thing, I even set the all events mask, and there was still no expose event. I went around this by drawing outside the event switch, after each event is processed. This is not so important, but I'm curious why it happens. With Xlib programs, an Expose event is received when the window pops up, and every time it is 'made dirty' by other windows or dragging on-screen from off-screen or whatever. Here is my code: // g++ *gdkgl.cpp* `pkg-config gdk-2.0 gtkglext-1.0 --libs --cflags` -ogdkgl #include stdlib.h #include gdk/gdk.h #include gdk/gdkgl.h #include GL/gl.h int main(int argc, char **argv) { gdk_init(argc, argv); gdk_gl_init(argc, argv); int config_attributes[] = { GDK_GL_DOUBLEBUFFER, GDK_GL_RGBA, GDK_GL_RED_SIZE,1, GDK_GL_GREEN_SIZE, 1, GDK_GL_BLUE_SIZE, 1, GDK_GL_DEPTH_SIZE, 12, GDK_GL_ATTRIB_LIST_NONE }; GdkGLConfig *glc = gdk_gl_config_new(config_attributes); GdkWindowAttr attr; attr.title = argv[0]; attr.event_mask = GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK | GDK_EXPOSURE_MASK; attr.window_type = GDK_WINDOW_TOPLEVEL; attr.wclass = GDK_INPUT_OUTPUT; attr.width = 800; attr.height = 600; GdkWindow *win = gdk_window_new(NULL, attr, 0); gdk_window_show(win); GdkGLWindow *glwin = NULL; GdkGLContext *glcontext = NULL; glwin = gdk_window_set_gl_capability(win, glc, NULL); glcontext = gdk_gl_context_new(GDK_GL_DRAWABLE(glwin), NULL, true, GDK_GL_RGBA_TYPE); bool done = false; while(!done) { GdkEvent *ev = gdk_event_get(); if(ev) { switch(ev-type) { case GDK_MAP: break; case GDK_DELETE: done = true; break; case GDK_KEY_PRESS: printf(key pressed\n); break; case GDK_EXPOSE: printf(got expose\n); break; case GDK_CONFIGURE: if(gdk_gl_drawable_gl_begin(gdk_window_get_gl_drawable(win), glcontext)) { glViewport(0, 0, ev-configure.width, ev-configure.height); if(gdk_gl_drawable_is_double_buffered(gdk_window_get_gl_drawable(win))) { gdk_gl_drawable_swap_buffers(gdk_window_get_gl_drawable(win)); } else glFlush(); gdk_gl_drawable_gl_end(gdk_window_get_gl_drawable(win)); } break; } if(gdk_gl_drawable_gl_begin(gdk_window_get_gl_drawable(win), glcontext)) { glClearColor(1.0, .5, .2, 1.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, 800, 600, 0, -1, 1); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glBegin(GL_QUADS); glVertex2i(100, 100); glVertex2i(400, 100); glVertex2i(400, 500); glVertex2i(100, 500); glEnd();
Re: flow control question
Here are two programs that implement through the text viewer widget what you are asking for: - The Python console in gimp - GemTcl - a tcl interpreter The way I set up the interaction is to listen to both the key-press-event and the insert-text events of the text-viewer. The key-press-event signals to the insert-event handler that it is supposed to enter eval mode: if (!(event-state GDK_SHIFT_MASK)) { switch(event-keyval) { case GDK_Return: do_eval = true; break; } } and the insert-event catches this before the newline is inserted into the buffer, runs the eval and inserts the result into the buffer: if (do_eval) { // Extract the text between the prompt and the end of the line output = eval(command); gtk_text_buffer_insert(text_buffer, output); } Have a look in GemTcl:gemtcl.cc cb_insert_text() and cb_key_press_command() for details. Hope this helps, Regards, Dov 2009/7/21 Allin Cottrell cottr...@wfu.edu In the context of my gtk app I have an optional console -- not a real shell, but a means of sending commands to the app besides point-and-click. It's working OK, but for various reasons I'd like to reformulate it so that I have a loop like this: while (command != quit) { get_a_command(); do_stuff(); } I'm having trouble with get_a_command(). The criterion for a command being entered is that Return is pressed in a certain GtkTextView, to which I have a pointer. But how does the get_a_command() function know that this has happened? I've implemented this via a static int, command_entered (a file-scope global), which is set to 1 by Return and is monitored by the function in question: void get_a_command () { while (!command_entered) { if (gtk_events_pending()) { gtk_main_iteration(); } } command_entered = 0; } This works, but not surprisingly it uses a lot of CPU running around its tight loop waiting for Return. I then tried adding g_usleep(1) into the loop on while (!command_entered). That brought CPU usage down to a sane level, but of course it made the whole GUI quite gummy. It seems there must be a smarter way of doing this, probably using some of the g_main* apparatus or g_threads, which I'm not really familiar with, and at my current level of ignorance looking at the API docs leaves me guessing. Any pointers to get me started would be very helpful. Allin Cottrell ___ 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: Best practice for bundling GTK with an windows application?
Oops. Make that: http://ftp.gnome.org/pub/gnome/binaries/win32/ Regards, Dov 2009/7/11 Dov Grobgeld dov.grobg...@gmail.com I've been doing cross platform development and windows installer during the last few years of lots of C/C++ programs. Here is an outline of my practices: - Build done through scons. - Special scons rules for doing cross compilation for Windows from Linux. - Use NSIS for Windows installer deployment. (cross compiled mingw32 version of nsis used). - The Windows installer is self contained, i.e. it is not dependent on the installation of a separate gtk installation. - The windows binaries are the standard compiled binaries from ftp.gtk.org - Testing done through a WinXP installation under VirtualBox. See the SConstruct and NSIS files of my two programs giv and gemtcl for examples of how to do the above. Regards, Dov 2009/7/11 Hartmut Goebel h.goe...@goebel-consult.de Hi, I'm currently working to make setting up a Python application (www.tryton.org) easier for Windows users. Meanwhile I'm totally confused about which package of bundle to use and what to put into the installer package. Now GTK for Windows comes in quite a lot of flavours. Since Tryton uses pygtk Co., we only need the runtime environment, no developer files. But there are still some options left: - zipped runtime bundle including 3rd-party dependencies. - zipped archives for individual packages (glib, gtk+, pango, ...) - installer from glade-win32 somewhat outdated, but including librsvg http://sourceforge.net/projects/gladewin32/files/ - installer from http://gtk-win.sourceforge.net/: much more up to date but missing librsvg and libbz2 Which one should I use? Is there some agreed best practice? I'm currently tending to this solution: * use the installer from gtk-win for the development environment * put additional .dlls (e.g. librsvg) into the development directory * include the whole gtk-win installer into the Tryton installer. Any comments or suggestions anyone? -- Schönen Gruß - Regards Hartmut Goebel Dipl.-Informatiker (univ.), CISSP, CSSLP Goebel Consult Spezialist für IT-Sicherheit in komplexen Umgebungen http://www.goebel-consult.de ___ 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: Best practice for bundling GTK with an windows application?
I've been doing cross platform development and windows installer during the last few years of lots of C/C++ programs. Here is an outline of my practices: - Build done through scons. - Special scons rules for doing cross compilation for Windows from Linux. - Use NSIS for Windows installer deployment. (cross compiled mingw32 version of nsis used). - The Windows installer is self contained, i.e. it is not dependent on the installation of a separate gtk installation. - The windows binaries are the standard compiled binaries from ftp.gtk.org - Testing done through a WinXP installation under VirtualBox. See the SConstruct and NSIS files of my two programs giv and gemtcl for examples of how to do the above. Regards, Dov 2009/7/11 Hartmut Goebel h.goe...@goebel-consult.de Hi, I'm currently working to make setting up a Python application (www.tryton.org) easier for Windows users. Meanwhile I'm totally confused about which package of bundle to use and what to put into the installer package. Now GTK for Windows comes in quite a lot of flavours. Since Tryton uses pygtk Co., we only need the runtime environment, no developer files. But there are still some options left: - zipped runtime bundle including 3rd-party dependencies. - zipped archives for individual packages (glib, gtk+, pango, ...) - installer from glade-win32 somewhat outdated, but including librsvg http://sourceforge.net/projects/gladewin32/files/ - installer from http://gtk-win.sourceforge.net/: much more up to date but missing librsvg and libbz2 Which one should I use? Is there some agreed best practice? I'm currently tending to this solution: * use the installer from gtk-win for the development environment * put additional .dlls (e.g. librsvg) into the development directory * include the whole gtk-win installer into the Tryton installer. Any comments or suggestions anyone? -- Schönen Gruß - Regards Hartmut Goebel Dipl.-Informatiker (univ.), CISSP, CSSLP Goebel Consult Spezialist für IT-Sicherheit in komplexen Umgebungen http://www.goebel-consult.de ___ 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: Pass more widgets as gpointer.
As I've said in he past, I believe the best thing is to sub-class GtkWindow and then make all the pointers you want to pass around members of your new class. Conceptually this looks like: class MyWindow : GtkWindow { GtkWidget *w_label; GtkWidget *w_button; GtkWidget *w_tooltip; } : MyWindow *w_window = my_window_new(); g_signal_connect(w_button, clicked, G_CALLBACK(cb_button), w_window); : int cb_button(GtkWidget *widget, GtkButtonEvent *event, gpointer userdata) { MyWindow *self = (MyWindow*)self; gtk_tool_tip...(self-w_tooltip, ...); gtk_label_set_text(self-w_label, foo); } I hope you get the idea. The problem with this approach though is that it is a bit of an effort quite to subclass Gtk in C, (in contrast to gtkmm, perl, python, javascript in which it has been nicely mapped to the native objects, not to talk about vala where a GObject is native). That's why I'm using gob2 whenever I'm writing C. It makes this technique as natural as in any other language that I mentioned. Regards, Dov 2009/4/22 Vlad Volodin vest...@gmail.com Hi, Jens Yes, your way is good (thank you for a small code, maybe I will use it in my projects). But, are you sure your way is safe? You don't know the size of array (at the first), where do you free the array of pointers itself (try g_malloc and g_free, because it is GLIB :) ) (at the second). And I think, your way isn't type-safe (at the third), because you won't be sure that your element's type is needed. Well, of course I have many questions and now answers :) I think, in small projects your way is good (but you can also easily forget the order of the elements). Maybe HashTables, or STL sets will be more applicable. What do you think about all of this? Good luck in GTK programming :), Vlad Volodin 2009/4/22 Jens Hansen jensh...@gmail.com: Hi All. Thanks for all ideas, to this problem. I figured out how to pass more widgets in an array, which is IMHO the best way to do it. Just for reference, the following snippet. Packing the widgets pointers in the array GtkWidget * *data; data = malloc(sizeof(GtkWidget *)*3); data[0]=spinbutton; data[1]=combobox; data[2]=check_hidden And unpacking them GtkWidget * *array=(GtkWidget **)data; Then you just need to type cast the elements of the array: for instance gtk_combo_box_get_active((GtkComboBox *)array[1]) ___ 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: method to erase a drawing area
Hello Frederico, What you are doing is basically hit detection. What I wonder is why you are doing it the hard way. Why don't you use one of the canvas widgets, e.g. goocanvas? It allows you to tie events to specific geometric objects. If you want to do it on your own I first of all suggest that you use cairo, using gdk_draw_* is considered obsolete. Second you can use the idea of keeping a second non-visible image as a label image. I've described this multiple times on the net: - http://www.mail-archive.com/gtk-perl-l...@gnome.org/msg01428.html - http://www.mail-archive.com/gtk-l...@gnome.org/msg27934.html Regarding your approach you can still salvage it by instead of checking for if((GPOINTER_TO_INT(desenho-parray-pdata[x1]) == x) (GPOINTER_TO_INT(desenho-parray-pdata[x1+1]) == y)) you check for int xp = GPOINTER_TO_INT(desenho-parray-pdata[x1]); int yp = GPOINTER_TO_INT(desenho-parray-pdata[x1+1]); int posH = GPOINTER_TO_INT(desenho-parray-pdata[x1+2]); int posV = GPOINTER_TO_INT(desenho-parray-pdata[x1+3]); if (abs(xp-x)posH abs(yp-y)posV) ... Regards, Dov 2009/4/17 frederico schardong frede@gmail.com Hi, I have a drawing area, and a window with 2 gtk_range, and them variable form 1 to 10, and this values go to posH and posV. I'm doing this to can draw a rectangular with my specification.. max width: 10, min: 1, max henght:10, min: 1. This event is called when drawing area is clicked: static gboolean button_pressed (GtkWidget *a, GdkEventButton *event) { gint x = event-x, y = event-y, x1, y1; for(x1 = (0-posH); x1 posH; x1++) { for(y1 = (0-posV); y1 posV; y1++) { gdk_draw_point(desenho-drawingArea-window, desenho-drawingArea-style-fg_gc[GTK_WIDGET_STATE(desenho-drawingArea)], x+x1, y+y1); } } g_print(\ndrawing x: %d y: %d tamH: %d tamV: %d, x, y, posH, posV); g_ptr_array_add(desenho-parray, GINT_TO_POINTER(x)); g_ptr_array_add(desenho-parray, GINT_TO_POINTER(y)); g_ptr_array_add(desenho-parray, GINT_TO_POINTER(posH)); g_ptr_array_add(desenho-parray, GINT_TO_POINTER(posV)); } But now I must do a eraser function... I do a simple for: gint x1, x = event-x, y = event-y; for (x1 = 0; x1 desenho-parray-len; x1 = x1 + 4) { if((GPOINTER_TO_INT(desenho-parray-pdata[x1]) == x) (GPOINTER_TO_INT(desenho-parray-pdata[x1+1]) == y)) { g_print(\nta no lugar certo mano!); g_ptr_array_remove_index(desenho-parray, x1); g_ptr_array_remove_index(desenho-parray, x1); g_ptr_array_remove_index(desenho-parray, x1); g_ptr_array_remove_index(desenho-parray, x1); } it's work, but not fine... it's only work when i click exactly where I clicked before to draw this point... but I need to delete from GPtrArray when I click on somewhere of this rectangle area... not only center... Can help me 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: Rendering lines
gdk_draw_line() is deprecated. Use cairo instead. Regards, Dov 2009/4/13 Paolo pra...@gmail.com Hi! I'm drawing lines into GtkDrawingArea through gdk_draw_line function. The results is good, but not enough. How can I increase the rendering? ___ 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: Rendering lines
Slow or fast is obviously application dependent. The original poster didn't complain about speed... The most important thing is never to send to the rendering pipeline data that will not be shown. E.g. in a GIS system if you are zoomed out you don't want to draw small features. And you don't want to send features to be rendered that you know will be clipped. So you may want to use some kind of quadtree to save the relevant features at each zoom level. That said, I also found cairo too slow for my liking in my image and vector viewer giv, and found that agg was faster.See my tutorial at: http://giv.sourceforge.net/gtk-image-viewer/gtkimageviewer_tutorial.html for an example of how to use agg with gtk. Regards, Dov 2009/4/13 Jose Hevia jose.francisco.he...@gmail.com 2009/4/13 Dov Grobgeld dov.grobg...@gmail.com: gdk_draw_line() is deprecated. Use cairo instead. And the problem with cairo is that is going to be far slower than gdk, although it provides better output, and could be hardware accelerated. http://cairographics.org/FAQ/ Read Clipping should only make things faster, right? That's my main problem with cairo. I use my own raster because cairo is slw, and only want to update the region I change. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Drawingarea in a scrolled window
I know this is not answering your question, but you can get the same effect of the drawing area by using my GtkImageViewer widget, without an image. See the tutorial at: http://giv.sourceforge.net/gtk-image-viewer/gtkimageviewer_tutorial.html for an example. Regards, Dov 2009/4/12 Paolo pra...@gmail.com hi! I've put a drawing area into the scrolled window. My drawing are is bigger than the scrolled window and there're problems about the refresh. How can I fix that? Please help me!! ___ 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: slowness in getting events
Since hex characters only has an alphabet of 16 characters, you can draw these once into separate pixbufs, and then use gdk_pixbuf_copy_area() to draw the prerendered characters to the screen. If you have the memory you can e.g. create 256 two-nibble precomposed glyphs. I'm not sure how much more efficient this is compared to the gtk/pango/freetype caching of text, but it is worth a try. An additional option is to only update your screen at some reasonable interval, e.g. 5-10 times a second. Higher than that is hardly going to be seen by the user anyhow. And if you are looking for exceptional behaviour you may want to use other approaches like coloring the cells to indicate that. Regards, Dov 2009/4/6 Efraim Yawitz efraim.yaw...@gmail.com On Mon, Apr 6, 2009 at 2:00 PM, Michael Torrie wrote: You might want to implement this hex dump display as a GtkTreeView widget, which does lend itself better to displaying tabular data. The MVC mechanism by which the TreeView works means that the view automatically updates itself as the model (your hex data) changes and emits signals. You an even have multiple views of the same data if you need it. There are also a number of custom widgets that implement spreadsheet-style grids you can search for. Some more testing has made it clear to me that the problem I am having is not that I am not getting the events, but that gdk_draw_layout(), which I am calling many times per update, is too slow. I found some posts from a few years ago that this was hundreds of times slower than XDrawString(), and I have verified that it is much slower. Of course, XDrawString is much harder to use. Does anyone have any ways of dealing with this? ___ 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: goocanvas vs crcanvas,which better?
Hi Chen, For the application that you described, using a canvas doesn't give you much and you can just as well create a cairo context and draw on the image directly. But there are a few things that you should be aware of: - Drawing overlays on av full realtime speed is going to take a lot of CPU no matter how fast you do it. - You should make sure to prepare all the data offline before you ship it off to the screen. Thus don't put the data from the frame grabber on the screen until after you have annotated it. - If the annotation is static, it certainly faster to prepare a transparent pixbuf and draw the annotation on the pixbuf and then simply merge the data from the frame grabber with the overlay mostly transparent pixbuf, and then ship the result of to display. - If you want the user to be able to interactively zoom the resulting pixbuf, you may want to have a look at my GtkImageViewer that creates such a zoomable interface for you. See the tutorial at: http://giv.sourceforge.net/gtk-image-viewer/ Regards, Dov 2009/3/26 chen zhixin thexin1...@gmail.com Program need to draw realtime lines on per frame,first time i use cairo_surface_create_similar and draw surface on the frame. (frame draw on GtkDrawingArea),this make fast on my pc and the Machine(use slitaz system),but when i use ubuntu on the machine,the Xorg process take 100% cpu,this make me craze,i still don't kown why. I want to use canvas to change this,there are some cairo canvas,goocanvas can be found in lib.gnome.org,it will be a part of gnome? goocanvas vs crcanvas ,which should i use? or somebody have a good method to do these. software do these: 1. capture frame from TV card by V4L2,and then change fmt from yuyv to gray. 2. draw gray frame to GtkDrawingarea by gdk_draw_gray to a GdkPixmap. 3. do some other things on the GdkPixmap,such as draw pixbuf and text,and then gdk_draw_drawable. 4. measure on the drawingarea.such as line,circle,ellipse,polygon,arrow,draw results on the frame. 5. do other things ,such as zoom,save as image,video. there are some problems: 1. can create cairo surface on GRAY picture,then i can draw something on it ? ___ 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: goocanvas vs crcanvas,which better?
The following does it: int img_width = gdk_pixbuf_get_width(pixbuf); int img_height = gdk_pixbuf_get_height(pixbuf); cairo_surface_t *surface = cairo_image_surface_create_for_data(gdk_pixbuf_get_pixels(pixbuf), CAIRO_FORMAT_ARGB32, img_width, img_height, gdk_pixbuf_get_rowstride(pixbuf)); You will have to swap R and B in calls to: cairo_set_source_rgba (cr, 0,0,1.0,0.5); when drawing though, as cairo and gdk_pixbuf have different ideas about their order. (These examples are copied from the GtkImageViewer tutorial.) Regards, Dov 2009/3/26 Alexander b3n...@yandex.ru Hi, Dov. On Thursday 26 March 2009, Dov Grobgeld wrote: - If the annotation is static, it certainly faster to prepare a transparent pixbuf and draw the annotation on the pixbuf and then simply merge the data from the frame grabber with the overlay mostly transparent pixbuf, and then ship the result of to display. Is there standard facility for creating cairo context for pixbuf? Like gdk_cairo_create() for drawables. ___ 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: How to get GtkImage resize of widget container?
No, doing it for the GtkImage is enough. Manually resizing or maximizing is one and the same. Regards, Dov 2009/3/15 Luis Gonzalez ghempr...@hotmail.com Hi, I have do this in size-request event of the GtkViewport?, Does it works if the user maximize the window? Thanks. No, GtkImage doesn't resize the pixbuf automatically for you. You will have to do it manually whenever you get a resize event. Thus you will need to store your original image in an off screen GdkPixbuf, and on an resize event create a resized copy through gdk_pixbuf_scale_simple() that you then provide to the GtkImage. Don't forget to unref the rescaled pixbuf after you pass it to GtkImage so you won't get a memory leak. Hope this helps. Regards, Dov Hi, I have a GtkImage inside GtkViewport. I want that GTKImage resize with the width/height of the widget container. I try to use gtk_widget_size_request method of the widget but it hasn't the actually width. Anyway to get GtkImage automatically fit width/heigth to adjust to widget container? _ Drag n’ drop—Get easy photo sharing with Windows Live™ Photos. http://www.microsoft.com/windows/windowslive/products/photos.aspx ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to get GtkImage resize of widget container?
No, GtkImage doesn't resize the pixbuf automatically for you. You will have to do it manually whenever you get a resize event. Thus you will need to store your original image in an off screen GdkPixbuf, and on an resize event create a resized copy through gdk_pixbuf_scale_simple() that you then provide to the GtkImage. Don't forget to unref the rescaled pixbuf after you pass it to GtkImage so you won't get a memory leak. Hope this helps. Regards, Dov 2009/3/14 Luis Gonzalez ghempr...@hotmail.com Hi, I have a GtkImage inside GtkViewport. I want that GTKImage resize with the width/height of the widget container. I try to use gtk_widget_size_request method of the widget but it hasn't the actually width. Anyway to get GtkImage automatically fit width/heigth to adjust to widget container? _ More than messages–check out the rest of the Windows Live™. http://www.microsoft.com/windows/windowslive/ ___ 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: newbie question
Hi Frederico, (Copied from my own post from Mar 23, 2006 12:31:00 pm) Here are four additional possibilities: 1. Use global variables for your widgets. 2. Create a struct containing pointers to all your widgets and use the userdata field to pass this struct around in all callbacks. 3. Use the g_object_set_data() method to attach miscellaneous pointers to your widgets. I.e. in the widget construction do: GtkWidget *w_tree_view, *w_button; w_tree_view = gtk_tree_view_new(...); : w_button = gtk_button_new(); g_object_set_data(G_OBJECT(w_button), tree_view, w_tree_view); g_signal_connect(G_OBJECT(w_button), clicked, G_CALLBACK(cb_button_clicked), NULL); and in the callback cb_button_clicked() do: GtkWidget *w_tree_view = GTK_WIDGET(g_object_get_data(G_OBJECT(widget), tree_view)); This method is similar to what glade is doing. 4. Create your own container widget, e.g. by gob2 or vala and put all your widgets in it. This is a fancy way of doing the struct callback I mentioned above. Hope this helps. Regards, Dov 2009/3/11 Tadej Borovšak tadeb...@gmail.com 2009/3/11 frederico schardong frede@gmail.com: void my_callback_function (GtkButton *widget, gpointer user_ptr); ... g_signal_connect( G_OBJECT( widget), clicked, G_CALLBACK( my_callback_function), user_ptr ); void my_callback_function (GtkButton *widget, gpointer user_ptr) { ... } http://library.gnome.org/devel/gtk/unstable/GtkButton.html but how I can pass to my_callback_function the gtk_drawing_area? I know about the g_signal_connect.. but I not know how pass another widget, without the widget being passed the first parameter of function.. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list Hello. Just pass your drawing area as a last parameter to g_signal_connect function. Simple code would look like: -- CODE --- int main( int argc, char **argv ) { GtkWidget *button = gtk_button_new(); GtkWidget *draw = gtk_drawing_area_new(); g_signal_connect( G_OBJECT( button ), clicked, G_CALLBACK( cb_clicked ), draw ); /* More code here */ } /* Callback function */ static void cb_clicked( GtkButton *button, GtkWidget *draw ) { /* Code here to save your work */ } --- /CODE -- -- Tadej Borovšak 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 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: 2. Re: General tips about GTK+ programming
First of all, since C++ is basically a superset of C, you can add as much or little C++ as you want to your C-program. In another word, you can program in C++, but use the C-api for widget creation, etc. That is what I have been doing e.g. in my projects GemTCL and giv. In contrast to what was said in this thread, I am subclassing GtkWindow and adding private members to it, and am doing it in C. But, as I also find the C-syntax very tough and verbose for object inheritance, I have been using gob2 for this. gob2 is a preprocessor written for extending and dealing with GObjects. It may be claimed that gob2 has become deprecated with the emergance of Vala, which is a new language that compiles to C/H-code for GObjects. But then you are no longer writing in C or C++ at all, for good and for bad. It's pluses is that its syntax is much nicer for GObjects. Its minuses is that you need to create extra glue interfaces in order to refer to other C and C++ classes. Hope this helps. Regards, Dov 2009/3/5 dhk dhk...@optonline.net Ali Abdallah wrote: -- Message: 1 Date: Tue, 3 Mar 2009 09:39:51 -0300 From: Tomaz Canabrava tum...@gmail.com Subject: Re: General tips about GTK+ programming To: Vlad Volodin vest...@gmail.com Cc: gtk-app-devel-list@gnome.org Message-ID: 7ebbb4b50903030439k5e4bc73asff21305eefd84...@mail.gmail.com Content-Type: text/plain; charset=ISO-8859-1 from what I'v been into, it's better to write object oriented software using object oriented programming languages. I know some in this list dislikes c++ , but it's more sane than use pointers and simulations of classes. you will not learn how to program better by converting your gtkmm code to gtk, your code will be larger and will do the same thing. I think what he was saying about learning more when converting his program to GTK is valid, since in C you deal with lower level programming than C++ , also you know Gtk+ is written in C, so when he gets used of C/Gtk/GObject programming he could easily understand the way Gtk+ is done. My 2 cents. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list Is there a way to start adding C++ code to an existing C GTK program? How would you start to convert a GTK program written in C to a GTK program in C++? Thanks, dave ___ 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: RE : RE : drawing and erasing text
Hi Dominique, Do yourself a favour and take the time to get rid of the use of XOR for drawing and erasing. You'll have to keep a backing store of your data and restore it when erasing. I've done the same thing for creating a rubber band distance measuring tool in my image viewer giv. (Look at giv-backstore.cc and giv-backstore.h(*)). Even better use of existing canvas frameworks, e.g. goocanvas, that does all the job for you. The only reason I can think of for not using the canvas is if you have huge data sets and you can't afford the time and space overhead of the canvas frameworks. Regarding XOR, besides being ugly, you'll suffer because you can't use cairo and pango for a modern anti-aliasing, as well as easy exporting and printing. (*) The backstore class is still suffering from flickering because it erases the old rubber band line by restoring the background, and only after the background has been restored, does it paint the new rubberband line. I've been planning to take care of this, but never got around to it. Regards, Dov 2009/2/24 POULAIN DOMINIQUE (AREVA TA) dominique.poula...@areva.com Hello Tor, I know that the gdk_font family functions and gdk_draw_string are deprecated, I use them because it was easier for me when I translate my XWindows plotting part on my sotfware to Gdk (in order to port the entire software from Linux to Windows). Using Pango layout and gtk_draw_layout leads to same problem : the text is not drawn in Xor mode (we can see also that the colour is not the same for the lines and text). The Xor mode is a smart and easy way to erase some drawing (more than saving and restoring the original plot under each text notes, each axe's tics... we must calculate the involved region, and what to do when a note to erase is near a another one we want to keep). I will be sorry if I dont find a solution ! The CbExpose callback was called repeated over and over by the use in the sample program of gtk_widget_modify_bg. I replace it by gdk_window_set_background that doesn't change the background ! and at last I use gtk_draw_rectangle to paint the entire drawing area in the background colour I want. In the XWindows, I use a XChangeWindowAttributes to set the backing store which prevents to have to redraw the plot when another window comes over a part of the drawing. With the backing store, no expose event is send in these cases. Is there a way to obtain the same beahivior with Gdk ? If not, I will use a pixmap to save and restore quickly the plot rather than redrawing billion of points on each expose event. The use of setlocale is for trying to have the buttons from stock in French. In fact, the problem is when I distribute my software on Windows, Gtk seems to not find the .../share/locale/fr/LC_MESSAGES/gtk20.mo and the button are in English. Is there a path to set ? The last problem is about the tree view with multiple selection. On Windows, when I use Ctrl or Shift keys and left click to select multiple items, it works fine until I select three or four items : suddenly the tree is collapsed. It seems to be the same with demo program of GTK. Thank you for your answer. -Message d'origine- De : tlillqv...@gmail.com [mailto:tlillqv...@gmail.com] De la part de Tor Lillqvist Envoyé : lundi 23 février 2009 15:59 À : POULAIN DOMINIQUE (AREVA TA) Cc : gtk-app-devel-list@gnome.org Objet : Re: RE : drawing and erasing text Hmm, do you know that the gdk_font_* and gdk_draw_string() APIs are deprecated and de facto unmaintained? Whether some aspect of it works fully or not on Windows is hardly interesting at this point. When I run your program both in Linux and Windows, the CbExpose callback is called repeatedly over and over. Does that happen for you, too? I wonder why that happens. By the way, the XLFD you pass to gdk_font_load_for_display, -adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1 is way too specific and probably works only on the distro and combination of package versions you happen to be using. No matching font was found on openSUSE 11.1, for instance. (Instead, I just used -*-fixed-medium-r-normal--*-100-*-*-c-*-iso8859-1) (But as I said, using the XLFD-based font API is deprecated anyway.) You call setlocale(LC_ALL, fr). Note that the setlocale() function in the Microsoft C library used on Windows in general does not accept locale names in the form commonly used on Unixes, using ISO639 language codes and ISO3166 country codes. But just out of luck, for fr it happens to work apparently, but not in general for locale codes like fr_CA, sv or de for instance. --tml ___ 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
Re: GTK warning
The message means exactly what it sais, that you try to reduce the ref count of an object that doesn't exist. If it is a C-program the way to trace this is to rerun the program with the flag g-fatal-warnings in which case the program will exit such that if you run the program in a debugger, the error will be caught and you can examine the stack and the reason for the error. But since the example you give is in Python this probably means that there is an error in the python binding. You should try to create a minimum example that triggers the problem and try to create a bug report. Regards, Dov 2009/2/21 Jeffrey Barish jeff_bar...@earthlink.net I hate the warning messages that GTK provides because they rarely help me find the problem. What does this one mean? /myprogram.py:118: Warning: g_object_unref: assertion `object-ref_count 0' failed self['myimage'].set_from_pixbuf(mypb) What object is producing the warning? I suppose it must be myimage. What am I supposed to do? If I exit the program and run it again, 9 times out of 10 I don't get the warning. -- Jeffrey Barish ___ 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: GUI quickly?
Here are a couple of options: - Parse your variable list through regular expressions and dynamically build your interface. - Offline generate a glade (or GtkBuilder file) based on the same parsing. The syntax of glade and GtkBuilder is very straight forward. Regarding the callback, the question is if you really want to get a callback for each of the four characters 3,.,1 and 4. After all you are not likely to use them until you press some [Go] button, or at least leave the widget. In any case it will help you in this case to use the g_object_set_data() function to attach the name of the data to the entry or ComboBox widgets. If you instead use the [Go] button approach, then you can save all your widgets in a list and in the [Go] clicked signal handle, query them all for their current values. This latter approach is how I do it now, after having used the callback on each keypress in the beginning of my Gtk days. (Which is closer to how Perl/Tk works). Regards, Dov 2009/2/10 Juhana Sadeharju kou...@nic.funet.fi This is related to open source free project, please help. I have described variables this way: NPC / Weight, float NPC / AI Data / Mood, list of choices here What are possibilities for creating GUI with minimal work? I may group variables to groups, one per window. I may group variables to subgroups, one per tab. I may add widget type IDs if that is not clear. But, using Glade to built the windows is too time-consuming. Of course, when a value has been edited in GUI, I should receive message: NPC / Weight changed to 3.14, etc. Juhana ___ 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: GtkImage
In glade, try erasing the size. There is almost never any need to set the size of a widget in glade. Instead the size of a widget should be the size of its contained widgets. Regards, Dov 2009/1/29 frederico schardong frede@gmail.com 2009/1/29 Dov Grobgeld dov.grobg...@gmail.com: The GtkImage will change its size automatically according to the size of the image that you load. If you want to change the image size, then you should load it into a GdkPixbuf, resize it, and then set it with gtk_image_set_from_pixbuf(). Btw, please keep CC:ing the mailing list, as there might be others with similar questions. Regards, Dov 2009/1/29 frederico schardong frede@gmail.com Hi, But I must resize the image to the size of space of GtkImagem on .glade.. how I do it? But GtkImage don't change its size.. On glade I defined the size of GtkImage, that is not preventing it to resize? Thanks ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkImage
If you use glade, then after loading the interface, the widget has already been created for you. There is therefore no need to generate another image widget through a call to gtk_image_new_from_file() and you should use gtk_image_set_from_file instead: GtkWidget *image = ...*get widget pointer from libglade* ...(); gtk_image_set_from_file(image, image.bmp) How to get the widget pointer from libglade is left as an exercise for the reader. (A bad excuse for saying that I am too lazy to look it up. :-) Regards, Dov 2009/1/27 frederico schardong frede@gmail.com Hello, I was created a space for image on glade-3, and I'm trying to link some imagem to this space. GtkWidget space; space = gtk_image_new_from_file(image.bmp); only this? the image will rezise itself to the space dimensions? ___ 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: Using GdkPixbuf buffers with GraphicsMagick
The data of a GdkPixbuf is layed out as a continous allocated chunk of memory in one of the following format RGBRGBRGB for 24-bit images, or RGBARGBARGBA, for 32-bit images, where R,G,B,A stands for the red, green, blue, and alpha components respectively. Lines may be also padded to row_stride bytes. Since you don't describe what GraphicsMagic() expects and how you extracts the relevent info from the pixbuf, it is impossible to say what went wrong. In any case you can use any library, e.g. cairo, agg, OpenCV, or access the pixels straight in the GdkPixbuf. Regards, Dov 2009/1/6 Luka Napotnik luka.napot...@gmail.com Hello. I'm trying to use GraphicsMagic (the successor of ImageMagick) to manipulate a GdkPixbuf image buffer. The problem is that the program segfaults, probably due to the raw nature of the buffer which the Magick API doesn't handle very good. I'm opening the image buffer with MagickReadImageBlob() and then apply some filters. Does anyone have experiences using GdkPixbuf together with GraphicsMagick or can anyone suggest alternatives to GraphicsMagick which works well with GdkPixbuf? Greets, Luka ___ 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: Accessing PixBuf pixels
It is almost correct except the fact that the rows of a pixbuf may be padded. You are therefore supposed to use gdk_pixbuf_get_rowstride(pixbuf) to get the distance between the rows. Here is e.g. an example of vertically flip an image: guint8 *buf = gdk_pixbuf_get_pixels(img); gint w = gdk_pixbuf_get_width(img); gint h = gdk_pixbuf_get_height(img); gint rs = gdk_pixbuf_get_rowstride(img); gint row_idx, col_idx; for (row_idx=0; row_idxh/2; row_idx++) { guint8 *ptr1 = buf+rs * row_idx; guint8 *ptr2 = buf+rs * (h-row_idx-1); for (col_idx=0; col_idxw; col_idx++) { guint8 tmp_r = *ptr1; guint8 tmp_g = *(ptr1+1); guint8 tmp_b = *(ptr1+2); guint8 tmp_alpha = *(ptr1+3); *ptr1++ = *ptr2; *ptr1++ = *(ptr2+1); *ptr1++ = *(ptr2+2); *ptr1++ = *(ptr2+3); *ptr2++ = tmp_r; *ptr2++ = tmp_g; *ptr2++ = tmp_b; *ptr2++ = tmp_alpha; } } Hope this helps. Regads, 2008/12/18 Luka Napotnik luka.napot...@gmail.com Hello. I have some difficulties with manipulation of pixels in the GdkPixbuf data buffer. I use the following loop to iterate thought each pixel: --- n_channels = gdk_pixbuf_get_n_channels(pixbuf); guchar *pixel; guchar *data = gdk_pixbuf_get_pixels(pixbuf); for (i = 0; i width*height; i++) { pixel = buffer + i * n_channels; pixel[0] = 100; /* Red channel */ pixel[1] = 100; /* Green channel */ pixel[2] = 100; /* Blue channel */ pixel[3] = 100; /* Alpha channel */ } --- Is this the right way to handle a RGBA buffer? Greets, Luka ___ 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: gdk-pixbuf
Just loop over the pixels and calculate a gray level through a linear combination of R, G, and B. For example ppmtopgm uses: grey = .299 r + .587 g + .114 b Then assign the resulting gray to the red, green, and blue components, and voila! You've got yourself a gray scale image. See my previous post for an example of how to loop over a GdkPixbuf. Regards, Dov 2008/12/18 frederico schardong frede@gmail.com I need some API, which has the power to transform any RGB image to grayscale (8-bit) and I can map the image, creating a vast array[height in pixels][width in pixels] in which each cell has a value from 0 to 255, corresponding to the values of the pixels. With gdk-pixbuf can I do that? ___ 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: Problems when (cross)compiling a gtk app on linux for windows
I just tested your compilation line and except from the fact that I needed to add: -I$MINGW/lib/gtk-2.0/include to the include flags, I had no problem compiling with it. So either the download at gtk is broken or you made some mistake when downloading it. Btw, you might be interested in checking out the cross compilation environment that I have set up in the SConstruct file of the project giv at http://giv.sf.net/giv . I do all my development including the construction of a install package from from Linux. Regards, Dov 2008/10/26 [EMAIL PROTECTED] Hi everyone, I am trying to compile my application for windows on a Linux system using i486-mingw-gcc without having to run Windows itself. I obtained the cross compiler, including the winapi headers etc., through the packaging system of the distribution I use which is Archlinux. I already succeeded in compiling some other applications of mine, including SDL applications, so the crosscompiler itself, including the winapi references etc., works fine/should be properly configured. Before I started compiling my gtk app, I downloaded all the devel and bin packages from http://www.gtk.org/download-windows.html which that site told me I need and extracted them all into the sub folder ./gtk/ (relative to my source code files). Then I did pkg-config --cflags --libs gtk+-2.0 to obtain the package names and linker flags I need, and changed all the paths from it so it points all to ./gtk/ which resulted in the following command: i486-mingw32-gcc -o LPHirc.exe ./lphirc_main.c -mwindows -lws2_32 -I./gtk/include/gtk-2.0 -I./gtk/include/gtk-2.0/gtk -I./gtk/include/gtk-2.0/gdk -I./gtk/include/atk-1.0 -I./gtk/include/cairo -I./gtk/include/pango-1.0 -I./gtk/include/glib-2.0 -I./gtk/lib/glib-2.0/include -I./gtk/include/freetype2 -I./gtk/include/libpng12 -I./gtk/include/pixman-1 -L./gtk/bin -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0 When attempting to compile, I get the following errors: In file included from ./gtk/include/gtk-2.0/gtk/gtkwindow.h:35, from ./gtk/include/gtk-2.0/gtk/gtkdialog.h:36, from ./gtk/include/gtk-2.0/gtk/gtkaboutdialog.h:32, from ./gtk/include/gtk-2.0/gtk/gtk.h:33, from lphirc_gtk.h:17, from lphirc.h:78, from lphirc_main.c:17: ./gtk/include/gtk-2.0/gtk/gtkaccelgroup.h:77: warning: parameter names (without types) in function declaration ./gtk/include/gtk-2.0/gtk/gtkaccelgroup.h:77: error: field 'GSEAL' declared as a function ./gtk/include/gtk-2.0/gtk/gtkaccelgroup.h:78: warning: parameter names (without types) in function declaration ./gtk/include/gtk-2.0/gtk/gtkaccelgroup.h:78: error: field 'GSEAL' declared as a function I have no idea what's going wrong, maybe some includes or linker flags missing? Thanks, Jonas Schon gehört? Bei WEB.DE gibt' s viele kostenlose Spiele: http://games.entertainment.web.de/de/entertainment/games/free/index.html ___ 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: How to center vbox inside full screen window
Both GtkImage and GtkLabel are subclasses of GtkMisc, which means that you can set their alignments through the GtkMisc methods. Thus after after packing them together, set the yalignment of the image to 1.0 and the yalignment of the label to 0.0 (default for both are 0.5) and you should be ok. Search for GtkMisc in the GtkLabel and GtkImage documentations. Another option is to create another non-filled GtkVBox into which you place the image and the label, and then place this vbox in your outer filled vbox. Hope this helps, Dov 2008/8/30 Christian Smith [EMAIL PROTECTED] Hi All, I have a very simple GTK program (in C) that creates a full screen window. Inside the full screen window I am placing a vbox with two elements inside: and image and a label. For the life of me I cannot figure out how to get the contents of the vbox to be packed together. I.e. I want the image + label touching each other and centered on the screen. Currently the height of the vbox seems to fill the height of the screen with the image and label distributed inside (and not touching). Any help is appreciated! Thanks, Christian ___ 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: How to set the font's size of the GtkLabel?
Hi Lazy (great name), The way to do it is to set the name of the label through: gtk_widget_set_name(label, foo); and then define a style for the name foo, that includes a font specification: gtk_rc_parse_string(style \foo\ {\n font = \Serif 32\\n }\n ); Hope this helps, Dov 2008/8/28 Lazy Fox [EMAIL PROTECTED] I wrote the following statememts to set a GtkLabel's font size. But it seems don't work? I'm not good at Pango, can anybody help me? +--- | PangoAttrList *pg_attr_list = pango_attr_list_new(); | PangoAttribute *pg_attr = pango_attr_size_new(10); | | label = gtk_label_new(This is a label); | pango_attr_list_change(pg_attr_list, pg_attr); | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list); +-- ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to set the font's size of the GtkLabel?
Hi Tomas, You are certainly right The style method is more suited when you want to change additional properties like background color, etc. I stand corrected. Regards, Dov 2008/8/28 Tomas Carnecky [EMAIL PROTECTED] Dov Grobgeld wrote: Hi Lazy (great name), The way to do it is to set the name of the label through: gtk_widget_set_name(label, foo); and then define a style for the name foo, that includes a font specification: gtk_rc_parse_string(style \foo\ {\n font = \Serif 32\\n }\n ); Ugh, that's complicated. An easier way is: GtkLabel *label = gtk_label_new(); gtk_label_set_markup(label, span font_desc=\10.0\This is a label/span); See http://library.gnome.org/devel/pango/stable/PangoMarkupFormat.html how to use the pango markup language. 2008/8/28 Lazy Fox [EMAIL PROTECTED] I wrote the following statememts to set a GtkLabel's font size. But it seems don't work? I'm not good at Pango, can anybody help me? +--- | PangoAttrList *pg_attr_list = pango_attr_list_new(); | PangoAttribute *pg_attr = pango_attr_size_new(10); | | label = gtk_label_new(This is a label); | pango_attr_list_change(pg_attr_list, pg_attr); | gtk_label_set_attributes(GTK_LABEL(label), pg_attr_list); +-- ___ gtk-list mailing list [EMAIL PROTECTED] http://mail.gnome.org/mailman/listinfo/gtk-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: When packing widgets, what is the difference between box and table
Box is one dimensional, either horizontal (hbox) or vertical (vbox) and the widgets are packed in the beginning or the end of them. Table is two dimensional and widgets are packed by specifying the coordinates of the four sides to which the widget is to be attached. You can also get two dimensions by recursively packing several boxes inside one another, but it is not the same as a table, as the constraints of a table is that all cells belonging to a column have the same width AND all the cells belonging to a row have the same height. Regards, Dov On 7/4/06, chao yeaj [EMAIL PROTECTED] wrote: Hello, everyone First ,i am sorry for my terrible English. When packing widgets ,we can use the box widget or the table widget,but what is the difference ? when many widgets packed to the box or table,how to modify the tab order of those packed widgets ? Any hint would be much appreciated ,thank you in advance ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk themes
Just do: gtk_rc_parse_string(include \/usr/share/themes/Bumblebee\\n) and you will use the Bumblebee theme. Regards, Dov On Wed, May 11, 2005 at 07:41:52AM +0100, abhi rocks wrote: hi Well i couldnt change my gtk theme using the .gtkrc file in my home directory. Is there anyway i can change the theme using code. I know my gtk themes are in /usr/share/themes. Is there any function which could implement a theme on runtime. Thank You Abhishek Samuel ___ Yahoo! Messenger - want a free and easy way to contact your friends online? http://uk.messenger.yahoo.com ___ gtk-list mailing list gtk-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list