Re: Drawing colored text efficiently
Dear Chad, I'm not gonna pretend that Pango isn't difficult to use from the GTK+ consumer point of view. But, GDK actually has some functions that interact with Pango and may reduce the code needed to do the things you are looking for. Check out this page in the GDK documentation, filed under Pango Interaction. http://developer.gnome.org/doc/API/2.0/gdk/gdk-Pango-Interaction.html I might also add that Cairo has some primitive text drawing facilities, and a bit of a cleaner API. However, from the looks of the way Cairo's text API is documented (in the docs, the devs call it a toy API not meant for serious text rendering), the Cairo developers want you to use Pango anyway. The example in the doc linked above contains ~80 lines of code, and ends up drawing differently-colored text in a circle. So I think it has everything you need in it. -Andrew On Mon, 2005-12-19 at 13:56 -0500, Chad Robinson wrote: I have an application that's a rewrite of an old green screen terminal application. It presents columns of data much like a table, but this information updates VERY rapidly. It's not suitable for display in a table, because rows will get deleted and added in a hurry (sometimes dozen of updates per second), and there are a LOT of rows. Tables are even worse because there's never a need for scrolling, so actually maintaining invisible rows in a table would be a waste of CPU time. The old application worked very well via ncurses by drawing strings - its math on where to put things isn't hard at all. We're just trying to move to a client/server model, and stay cross-platform. Gtk so far seems the best bet. So, the question is, how can I quickly draw text in a Gtk application? I see draw_text and draw_string functions, and they look like exactly what I need. But, they're deprecated. I see references to Pango here, but can't find a simple example of what I need to do, and Pango seems horribly obfuscated and inefficient for this type of activity. Basically, I need, on demand, to be able to draw text in location X, Y, in color C, background color B, text T. It's additionally important to know the available space to draw in. Typically I'd look to calculate the height of a monospace font, divide that into the height of the drawing area, and I'd know how many rows to draw. As the user resizes the window I could intelligently draw additional (or fewer) rows. What's the easiest and most efficient way to do this in Gtk? I'm at the end of my rope here, about to switch to something else. I just can't find a clean option. (FYI, I explored VteTerminal, but which is close but still not great.) Regards, Chad ___ 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: Change the behaviour of a button
Am Montag, den 26.12.2005, 13:15 +0300 schrieb Yury Aliaev: I'm sure there's a right way but if you're in a hurry you can do something I've used successfully. Use a table to lay out your objects, and pack two buttons into the same cell. Hide one. When you need to show the Stop button, hide the Remove button and show the Stop button. It works very well for me. Thanks. GtkTables are good. I guess I should use gtk_widget_show() and gtk_widget_hide() to hide/unhide the buttons... Naturally. You even can use GtkBox instead of GtkTable and pack all four widgets (two images and two labels) in it, and then pack this box into the button and show necessary and hide unnecessary widgets using gtk_widget_show()/gtk_widget_hide() functions. I recommend against this since it will break the GUI for people who disable images on buttons. You should rather pack both buttons into one box (hbox or vbox), use the suggested show/hide code and use a GtkSizeGroup which ensures that both always have the same size. -- Christian Neumair [EMAIL PROTECTED] ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gobject + diacanvas = i really please for help here
Hello First of all, sorry for my poor English. I want write an application. I try, but I create a monster not a program. So I decide to start once again. When I was writing first version of it, I put every object that I created to tree of widget. Purpose for that was that: if action had place and specific widget (and his children) was target, he was found in widget tree and after reading associate properties with hem I know what I can do with him. And That was Wrong way to do it. I know, I lost much time. And now I want to really understood what magic happens under the hood. I want build my application over diacanvas2 lib. I what every object on canvas has his own properties. Of course there can be one group of boxes, and another group of boxes with for the program will be complete different. I look into demo in diacanvas2 package. There is such function like add_box: add_box (DiaCanvasView *view) { DiaTool *tool = dia_placement_tool_new (DIA_TYPE_CANVAS_BOX, parent, view-canvas-root, width, 0.0, height, 0.0, bg_color, 0xFF8FFF55, NULL); g_object_set (view, tool, tool, NULL); /* First let the tool create the new item... Then unset it. */ g_signal_connect (tool, button_release_event, G_CALLBACK (cb_unset_tool), view); g_object_unref (tool); } Lets focus on the first function: dia_placement_tool_new. As we can see in dia-placement-tool.c this function use GParamSpec *pspec = g_object_class_find_property (class, name); to search given properties and set some value. From these properties: parent,width, height, bg_color (or fill_color) dia-canvas-box have the last one. I have two ways and one of them is bad. THE BAD WAY: Copy the *-box file, add add property like gchar *name; (that is working of course) The good way: Create child of widget dia-canavas-box. And here is the first place where I really need help. My widget is in attachment. But something was wrong. When I use it to create widget in diacanvas using add_box and DIA_TYPE_CANVAS_BOX_CHILD for first argument I have this warning: DiaCanvas2-WARNING **: dia-placement-tool.c:319: object class `DiaCanvasBoxChild' has no property named `fill_color', and of course he is right he doesn't have this property his parent have. The second place where I need some help is answer for that : - I want to place line, which will have size (width or height) no less or more then canvas. - I want (i like this word :) have lines or even some object which cant be resized or rotated. I think it is only about blocking some signals for that object when i created them. - I want to (again) add every created object to list or some tree when I put then on the canvas. I wrote this letter because I had bed expierence creating application in gtk without asking anybody how some things can be done in the correct way. I had read Glib object system by Mathieu Lacage but I don't understand it, i think because I only read this and never try to create my own widgets :) So this is my first try to understood gobject system. I hope anybody help me. Best regards. ps. when i have littke i will try to understand uml for diacanvas :) -- Przemysław Staniszewski ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkStatusIcon
Hi, I'm a bit confusing. I'm developing under Whitbox EL 4. I have this packages installed: gtk2-2.4.13-14 pygtk2-libglade-2.4.0-1 ... ... gtk2-devel-2.4.13-18 gtk2-engines-2.2.0-7.el4 gtk+-1.2.10-33 gtk2-2.4.13-18 As I can see in http://developer.gnome.org/doc/API/2.0/gtk/ it is recommended to use GtkProgressBar instead GtkProgress. I did without problems, and I see GtkStatusIcon in the documentation as a wrapper for eggtrayicon but I have not that .h in my include files. If I have gtkprogreesbar in /usr/include/gtk-2.0/gtk but I have not a gtkstatusicon.h. How is this possible? Am I using a wrong version of gtk? Thanks ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
is it possible to have a widget act as insensitive but look as it is sensitive?
Hi, is it possible to have a widget (a toggle button in particular) act as insensitive but look as it is sensitive. More specific is it possible to have a toggle button act as insensitive once activated but look sensitive, ie without the grey shade? Cheers. -- -- Yiannis ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gobject + diacanvas = i really please for help here
On Tue, 2005-12-27 at 13:52 +0100, Przemysław Staniszewski wrote: Hello First of all, sorry for my poor English. It is understandable. I want write an application. I try, but I create a monster not a program. So I decide to start once again. When I was writing first version of it, I put every object that I created to tree of widget. Purpose for that was that: if action had place and specific widget (and his children) was target, he was found in widget tree and after reading associate properties with hem I know what I can do with him. And That was Wrong way to do it. I know, I lost much time. And now I want to really understood what magic happens under the hood. I suggest you practice a little with some simple gtk+ or gnome programs, and use the excellent online tutorials, like http://www.gtk.org/tutorial/ and http://developer.gnome.org/doc/tutorials/ The folks on this mailing list probably do not have very much information on using diacanvas, so maybe study any code at http://diacanvas.sourceforge.net/ref/index.html for that. Good luck, let us know what you think of DiaCanvas2 after your success. // Wally -- Your eyes are weary from staring at the CRT. You feel sleepy. Notice how restful it is to watch the cursor blink. Close your eyes. The opinions stated above are yours. You cannot imagine why you ever felt otherwise. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: is it possible to have a widget act as insensitive but look as it is sensitive?
Yiannis wrote: Hi, is it possible to have a widget (a toggle button in particular) act as insensitive but look as it is sensitive. More specific is it possible to have a toggle button act as insensitive once activated but look sensitive, ie without the grey shade? Whatever you're doing, you're cheating ;-) you can: o Create a sample GtkToggleButton o Make copies of the GdkColor structs on widget-style.bg[GTK_STATE_NORMAL] (or is it ACTIVE ?), you might also want the .fg, .base .text members. you'd want to do this post gtk_rc_parse(). o Use gtk_widget_modify_bg (widget, GTK_STATE_INSENSITIVE, sensitive_bg) (and friends) to set the sensitive graphic state onto the insensitive state. o gtk_widget_set_sensitive (widget, FASLE); Cheers, -Tristan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gobject + diacanvas = i really please for help here
Hello First of all, sorry for my poor English. I want write an application. I try, but I create a monster not a program. So I decide to start once again. When I was writing first version of it, I put every object that I created to tree of widget. Purpose for that was that: if action had place and specific widget (and his children) was target, he was found in widget tree and after reading associate properties with hem I know what I can do with him. And That was Wrong way to do it. I know, I lost much time. And now I want to really understood what magic happens under the hood. I want build my application over diacanvas2 lib. I what every object on canvas has his own properties. Of course there can be one group of boxes, and another group of boxes with for the program will be complete different. I look into demo in diacanvas2 package. There is such function like add_box: add_box (DiaCanvasView *view) { DiaTool *tool = dia_placement_tool_new (DIA_TYPE_CANVAS_BOX, parent, view-canvas-root, width, 0.0, height, 0.0, bg_color, 0xFF8FFF55, NULL); g_object_set (view, tool, tool, NULL); /* First let the tool create the new item... Then unset it. */ g_signal_connect (tool, button_release_event, G_CALLBACK (cb_unset_tool), view); g_object_unref (tool); } Lets focus on the first function: dia_placement_tool_new. As we can see in dia-placement-tool.c this function use GParamSpec *pspec = g_object_class_find_property (class, name); to search given properties and set some value. From these properties: parent,width, height, bg_color (or fill_color) dia-canvas-box have the last one. I have two ways and one of them is bad. THE BAD WAY: Copy the *-box file, add add property like gchar *name; (that is working of course) The good way: Create child of widget dia-canavas-box. And here is the first place where I really need help. My widget is in attachment. But something was wrong. When I use it to create widget in diacanvas using add_box and DIA_TYPE_CANVAS_BOX_CHILD for first argument I have this warning: DiaCanvas2-WARNING **: dia-placement-tool.c:319: object class `DiaCanvasBoxChild' has no property named `fill_color', and of course he is right he doesn't have this property his parent have. The second place where I need some help is answer for that : - I want to place line, which will have size (width or height) no less or more then canvas. - I want (i like this word :) have lines or even some object which cant be resized or rotated. I think it is only about blocking some signals for that object when i created them. - I want to (again) add every created object to list or some tree when I put then on the canvas. I wrote this letter because I had bed expierence creating application in gtk without asking anybody how some things can be done in the correct way. I had read Glib object system by Mathieu Lacage but I don't understand it, i think because I only read this and never try to create my own widgets :) So this is my first try to understood gobject system. I hope anybody help me. Best regards. ps. when i have littke i will try to understand uml for diacanvas :) -- Przemys³aw Staniszewski ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list