Re: Application with XML parsing
Depending on your specific needs, you might want to keep your eye on my project (http://www.weldae.org). I haven't posted the source yet, but I'm trying very hard to get the first release with source out soon. I'm building something very similar to what your asking for. Nothing is hard coded into my application and all the structure of the application is downloaded as XML from a web server. Events and data are passed back and forth between the client and the server giving the impression of a thick client application. Sort of like Ajax for GTK. Unlike libglade, my XML is much simpler and is designed to work with any widget set, not just GTK. You also have the ability to bind events to client side actions or server side code directly in the XML. The downside is that there are limitations to the interfaces that can be built with it given that it is a subset of what GTK offers. On Mon, 2006-02-06 at 16:29, Mark Richardson wrote: I am playing with the idea of an application with a main window that is blank. Then you can load views which are saved XML files that are parsed and the main window is populated with this dynamic gui. What I was thinking was taking the XML loading/parsing routines from glade-2 and putting them into my own app. I would guess others have done this or there is something that suits my needs - but I can't find anything (I found a few related questions, but either no answer or nobody knows). Thanks in advance for your help, Mark ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: combo rant
I am pretty negative about the combo as a control, not just the GTK combo. Widget sets don't have much of a choice but to include it since it's considered a core control, but as a developer, I try to avoid it if I can. As has been discussed previously, the problem with the combo as a control is that if you have just a few items then your better off displaying them as radio buttons. If you have more than say 20 items or you want to display multiple columns or you want to allow multiple selection, then your better off displaying a custom screen that allows the user to easily resize/sort/select items. So essentially, combo controls are good for very simple lists that aren't too short. Say a single column of data between 4 and 50 unique items. On Fri, 2005-11-25 at 02:19, control H wrote: I'm not that negative about a combo control. After all, a good combo like the Windows one lets me select the item I want quickly and simple (enough), and in an acceptable style. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: combo rant
My current project requires that I write wrappers around all common GTK and Win32 .NET controls to give them a common functionality set. Sort of like what wxWindows would do but much much more simple with much less functionality. I mention this because with the exception of the GtkComboBox control, GTK flat out embarrasses the .NET widgets. Most of the time I'm struggling to make the .NET controls do something simple while scaling the GTK functionality back dramatically. It isn't so much that the GTK combo is bad, but way to complex. I would say the Win32 combo is much better, but at least it's simple. To be fair, I've worked with combo controls from at least 4 different widget sets and they all were horrible. Win32, GTK, Web, Borland, Java, they all suck. I think as a control, the combo control is just a bad concept. I will probably create my own combo type control in addition to the native Win32/GTK combo box controls. It will basically be a text field with a button directly to the right of it. When the button is clicked a separate window will be opened with a grid inside it. This allows me to bypass all the horrible problems with combos on each platform. It will be a little slower for a user to use than a combo, but the ease of use should be better since the user/developer can resize the grid, etc if needed. On Wed, 2005-11-23 at 13:55, control H wrote: [I already posted this to the gtk-list, I'm not sure which list I should use] I'll start with apologies for upcoming rant. In general I like Gtk: I'm programming with it for a couple of years now and it's easy to learn, reasonably fast, has many bindings, runs on windows, and is highly themable. However, an ever returning frustration for me is the lack of a decent combobox. With every release of Gtk I hoped for a better combo, but to be fair, GtkCombo is in some ways still a better option than GtkComboBox. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: Efficient use of GDK Graphic contexts
A reasonable chunk, but then by the time a GtkWidget gets all its signal bindings, extra data, and other stuff, a GC probably isn't all that much extra. ;) Thanks for both of you that responded. Sounds like I don't need to worry much based on the fact that it sounds like I can't switch a GC between windows. This pretty much forces me to have one GC per window and if this is the case, I'm sure GCs are designed to have hundreds active at any given time. I've already got a structure that holds all the data associated with each widget, so adding a GC per widget isn't a big deal at all. The designer part is a small part of my application so I can just build the GCs only if in design mode and not worry about memory or anything. I was just worried about having thousands of GCs per form and looking like an idiot when someone looked at the code. I thought maybe they were like tooltips or pango font objects where you build one then share it with everything on the form. Just seemed wasteful since each GC will be exactly the same. Thanks ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Efficient use of GDK Graphic contexts
Thanks Tor for the helpful response. This seems a lot more sane to me. More comments follow: The manpage for XCreateGC() says The GC can be used with any destination drawable having the same root and depth as the specified drawable. Just to clarify, root is root X window? So I could theoretically have one GC that I use between windows of the same application? Depth must mean Color Depth and not window recurrsion depth. Guess my brain is wired weird, because that's what I thought the first time I read it. The documentation for gdk_gc_new() says The created GC must always be used with drawables of the same depth as this one. *blush*. Sorry, missed that. Should teach me to read all the documentation, including the param comments and not just the main description. (A Win32 DC, which has a similar function as an X11 GC, *is* specific to the window or bitmap (pixmap) specified at its creation, though. GDK hides this detail, you can use the same GdkGC with any GdkDrawable also on Win32. GDK creates and destroys Win32 DCs on the fly.) I guess the way I'm currently doing my GCs is fine too since this is what probably happens on Win32. I'll still move over to one global GC just because it's cleaner. Thanks! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Displaying intermediate button images.
This is just a guess since I'm not in front of my development workstation. You need to call the main GTK loop while you sleep. Invalidated regions of the screen get painted by the idle handler in the main loop. From the looks of it you sleep function doesn't call the main loop before it sleeps. Given that your sleeping for a total of 2 seconds, which is an eternity from a UI standpoint. I would probably setup some main loop timmer callbacks to update the button. Look at: http://developer.gnome.org/doc/API/2.0/glib/glib-The-Main-Event-Loop.html#g-timeout-add If you don't want to use the built in main loop timers, try calling gdk_window_process_updates () before you sleep. I have a button. When it's clicked, I want to toggle the image that's displayed as the label on the button. I want to toggle it four times, pausing for half a second between each toggle. The trouble is only the final image is being shown. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Displaying intermediate button images.
Okay, I've read this web page and for the life of me, I can't see a way to write a simple/elegant routine that does this, within the context of my larger application. Setup a event timer to call a function every 0.5 seconds. Inside this function you toggle all the pieces that will be effected by the current move. The 4th time this function is called, it will disable itself by disabling the event timer. Inside your click callback event, you just enable the event timer. You'll need to keep the event ID somewhere you can easily get to it, but this shouldn't be much of a problem. void reve_sleep(unsigned x) /* Suspend execution for interval in microseconds. */ { struct timeval st_delay; while (gtk_events_pending()) { gtk_main_iteration(); } st_delay.tv_usec = x; st_delay.tv_sec = 0; select(32, NULL, NULL, NULL, st_delay); } This should also work, and has he somewhat good side effect of locking your UI so the user can't issue additional commands until the turn is finished. Depending on how your game works, this may be good or bad. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Efficient use of GDK Graphic contexts
I'm building a form designer application and need to draw a grab border around widgets when the user selects them. This part seems straight forward and I've already got the border drawing working from the expose event. My question is how do do this in an efficient manner since GCs seem to be tied to windows. Currently I'm just building and destroying a new GC each time the expose() event fires. I know this isn't efficient at all, and I only did it this was to test that I could actually draw a border. GCs are tied to windows, so it would seem I'll need a GC for each widget on my form or can I have one GC and use it for all the widgets? I guess I'm asking what sort of overhead is involved in: 1) Creating a GC 2) Destroying a GC 3) Switching the window a GC is connected to 4) Memory overhead of each GC Thanks for any help or suggestions. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: gtk_key_snooper_install() example
On Mon, 2005-08-29 at 01:42, Olexiy Avramchenko wrote: 1. Use typecast (GtkKeySnoopFunc) to get rid of compiler warning. This did the trick. I didn't think to try just type casting it. I was thinking too complex, along the lines that there was a magic GTK cast function like GTK_WIDGET(). 2. Place 'return' with value to snooper_event - without it key events will disappear randomly. Ah, left that off the return in the code I posted, but in my real code I was returning FALSE just like your example. Interesting to know that not returning a gint will result in random missed keys. Thanks for the quick response! ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
gtk_key_snooper_install() example
I've seen this asked before a while back with no response, so I thought I'd give it a try. Google hasn't been any help at all. I'm trying to install a snooper and it's working just fine, but I get a compiler type warning on the first arg of gtk_key_snooper_install() and I'm sure I don't have it quite right. An example of how to use this function would help a lot. Below is what I'm trying. Thanks for any/all help. static gint snooper_event(GtkWidget*,GdkEventKey*,AE_APPLICATION*); gtk_key_snooper_install(snooper_event, form-parent); static gint snooper_event (GtkWidget *widget, GdkEventKey *event, AE_APPLICATION *app){ printf(Event: %i\n, event-keyval); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Partially disable checkbox
Disregard this question. Apparently a treeview without a model doesn't emit the button-press-event. I can live with that, just have to re-factor my code a bit. On Wed, 2005-08-24 at 09:13, Greg Breland wrote: I also have a problem detecting a mouse click on a treeview control. I'm currently trying the widget event button-press-event, but that doesn't seem to fire. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Partially disable checkbox
I also have a problem detecting a mouse click on a treeview control. I'm currently trying the widget event button-press-event, but that doesn't seem to fire. On Wed, 2005-08-24 at 00:51, Greg Breland wrote: I need to partially disable a checkbox control. I don't want the checkbox to toggle when a user clicks on it but I want the click event or something similar to fire. Something similar to the editable property on a text control. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: creating a entry mask
Thanks for this link. I too have been looking for something like this. For some reason the configure script requires GTK 2.6.8. FC4 only ships with 2.6.7, so this is a pretty steep requirement. I hacked the configure script to only require 2.6.7 and it worked fine. I also was able to get it to compile on my FC2 box with GTK 2.4.0 by just replacing the 2.6.0 convenience function combobox_get_active_text() with a couple lines of code to grab the active text from the model. I'm going to send the change in as a patch, but anyone who wants the diff, drop me an email. On Wed, 2005-08-24 at 16:22, Luca Cavalli wrote: such a widget was already developed. Here is the link: http://saettaz.altervista.org/software/gtkmaskedentry.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Partially disable checkbox
I need to partially disable a checkbox control. I don't want the checkbox to toggle when a user clicks on it but I want the click event or something similar to fire. Something similar to the editable property on a text control. I've thought about using the click event to just toggle the control back, but figured there was probably a better solution since this would cause a lot of complications for my program. I need to do this because I creating a simple form design app and when the user clicks on a control the properties for that control are displayed in another panel, but I don't want to the checkbox to toggle. If I toggle the checkbox back in the click event then I have to have a way to know that that click event was user based and not done by the user setting the state property via the control panel. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Web Queries through GTK
On Fri, 2005-08-05 at 02:30, Bhatnagar Achindra wrote: I need to make http: Get/Post queries through my GTK application, I'm using libcurl with great success. I use it on Win32 and Linux with no problems at all. libcurl is much faster than the normal .Net methods by a long shot. By faster I'm mainly referring to the startup time and not the transfer speed. libcurl has lots of great examples, but just to give you an idea how easy it is, here is a section of my code where I send some XML back to the server using post. The CurlWriteMemoryCallback receives the response from the server and I just use the example from the libcurl site so nothing special there. struct curl_httppost *formpost=NULL; struct curl_httppost *lastptr=NULL; xml = some xml curl_handle = curl_easy_init(); curl_formadd(formpost, lastptr, CURLFORM_COPYNAME, ae_xml, CURLFORM_COPYCONTENTS, xml, CURLFORM_END); curl_easy_setopt(curl_post, CURLOPT_HTTPPOST, formpost); curl_easy_setopt(curl_post, CURLOPT_WRITEFUNCTION, CurlWriteMemoryCallback); curl_easy_setopt(curl_post, CURLOPT_URL, url); curl_easy_setopt(curl_post, CURLOPT_FILE, (void *)data); curl_easy_perform(curl_post); curl_formfree(formpost); ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: I don't think I need a custom widget
On Wed, 2005-08-03 at 13:24, Tristan Van Berkom wrote: Maybe you should write one custom GtkContainer for each type of container you need to put those widgets in. The problem is really about the container widget and the allocation it gives to its child, also what child properties are involved (like attatch coordinates in a GtkTable, or position coordinates in a GtkFixed). The container can then easily add an event handler for all of its child handlers and return FALSE if it didn't resize anything. This sounds like a workable idea as long as it won't alter the allocation request of the child widget. Since most widgets have their own window, I can't draw to my custom container unless it is larger than the child widget? Again, all this can probably be worked around but I'd be interested to hear any thoughts about this. The other issue is that is would double my widget count. I am REALLY not worried about this since an event box probably doesn't have much overhead, but if anyone knows different I'd appreciate feedback. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: calling gtk_menu_popup from a button's clicked signal
On Mon, 2005-07-25 at 11:53, Tristan Van Berkom wrote: I suppose generating the arguments for gtk_menu_popup() is no big deal but why would you want to use a GtkButton to create a context menu ? First, I'm 100% with you on this issue. The product I support does this and it confuses the users 100% of the time. However, I can't say I could offer a better option where I have seen this interface used. I blame it on how terrible combo boxes are on all platforms. The places I've seen it used are when the user is entering very generic data. The dialog allows the user to save the data or to cancel. If the user wishes to save, the program has to know where/how to save the data. For example, our product helps users keep track of customers and what they've done for these customers. When our user's phone rings, they instantly hit F6 which is an activity dialog that lets them pick the customer and enter in free form notes. The user is only given the option to save or cancel. When the user clicks save they get a context menu where they can pick what to do with the data. There are about ~13 options on the menu. Here are a couple of examples: 1) Save as Note 2) Save as Completed Phone Call 3) Save as Completed Phone Call with Followup 4) Etc. Until the user has been using that screen for a few days, it confuses the mess out of them. There are only maybe 5 places that technique is used in the product thank goodness. Having a required combo box where the user chooses the type of record to create would slow the user down or so the thinking went by the developer. The only other option would have been to make the combo change save the form, but that would have been even worse. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: calling gtk_menu_popup from a button's clicked signal
This is the best suggestion I've ever heard as a replacement for the horrible button menu hack. Maybe this will keep the parent poster from adding this hack to yet another piece of software. The only downside I could see is if the list is very long. I think for short lists, say 20 then the treelist vs the context menu works about the same. More than that and the context menu is better because of scree real estate issues. However after a certain point the treelist would work better because long context lists are unusable. On Mon, 2005-07-25 at 14:51, Tristan Van Berkom wrote: Maybe you could have a GtkTreeView + GtkListStore in a scrolled window on the same page with Save / Cancel, just make sure that the Save button is insensitive untill the selection in the list store is made. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Simple GtkRange Problem
I must be missing something very obvious, but for the life of me I can't find it. I'm using a GtkVscale widget with FC2 GTK2.4 like so: control = gtk_vscale_new(NULL); gtk_scale_set_digits(GTK_SCALE(control), 0); gtk_range_set_range(GTK_RANGE(control), 0, 100); gtk_range_set_increments(GTK_RANGE(control), 1, 10); The step always works as expected when using the up/down arrow keys. However, the page is always double what I set. In the case above, Page Up/Down results in the value changing by 20. I did see someone in the past have problems on Mac with the page increment event being called twice, could this be my problem? Does GtkRange use Pango units or something? If no one has a quick idea about what my problem might be, I'll create a minimum test script tomorrow. Any help is appreciated. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Window shape and back_pixmap
The expose event wouldn't work for me either unless, as you did, I returned TRUE. I even tried calling _after all the other expose events with no luck. I ended up having to set the background pixmap on show of the window. I have no way of knowing if it will work on Windows though. On Fri, 2005-02-18 at 05:32, Carlo wrote: In order to see what were happening, I tried to hook the window expose event: gboolean on_winmain_expose_event (GtkWidget * widget, GdkEventExpose * event, gpointer user_data) return TRUE; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Window with background Image
Thanks Brian, you've gotten me very close to solving this problem. When I use window-window instead of getting the root window, I now see my background image for short periods of time when portions of the window are newly exposed such as during resize and when other windows are moved over it just like Russell's email suggested. Just wondering, where did you find the window-window property? I looked through the entire widget hierarchy (GtkBin, GtkContainer, GtkWidget, etc.) and didn't see this property. I'm using FC2/Gnome with the default WM MetaCity. I hooked up the style-set event on the window, both normal and _after, but this doesn't seem to be helping. I also tried the realize and show events with no luck. You can see the source as it stands after your advice at: http://home.atlee.net/background.c On Sun, 2005-02-06 at 00:11, Brian J. Tarricone wrote: You're trying to set the bg pixmap of the screen's root window. You want to set it on the GdkWindow of the widget itself: gdk_window_set_back_pixmap(window-window, pixmap, FALSE); Note that gtk themes that have pixmap window backgrounds set may override this, so you'd want to connect to the GtkWindow's style-set signal, and re-set the bg pixmap in that signal handler. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Window with background Image
I got despirate and hooded up the expose-event to reset the BG image and this works. Seems a bit excessive, surely there's a better event to use? FWIW, I'm using the regular expose the gets called before the default handler. On Sun, 2005-02-06 at 01:12, Greg Breland wrote: I'm using FC2/Gnome with the default WM MetaCity. I hooked up the style-set event on the window, both normal and _after, but this doesn't seem to be helping. I also tried the realize and show events with no luck. You can see the source as it stands after your advice at: http://home.atlee.net/background.c ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list