In Gtk, when is it better to use Glade/GtkBuilder than native code? - gtk

Glade helped me get started on a project quickly, but I've found it harder to maintain in the long run, and I'm thinking about switching it all to native code. In what circumstances would you choose glade, and when would you use native code?

I would personally only use native code for performance reasons. I find it much easier to work with gtkbuilder. Have you used glade or gtkbuilder? With Glade 3, gtkbuilder format is easy to use and easy to layout and design. Also, gtkbuilder is easier to load widgets from than glade was.

if by native code you mean "direct GTK calls to build ui", then i'd switch to it for several reasons:
if widgets are built dynamically depending on user preferences, etc
if i use a lot of custom widgets, esp. contained within each other (for example GDL docking panels)
to maintain backwards compatibility with older version of GTK
upd: also i'm still using glade2.x which has code generation (patched it to compile against latest gtk2). it really helps to get quickstart on "gui build from code", and works with both ancient and newer GTK versions. though i'm afraid i will have some troubles porting to gtk3 :)
and i never choose gtkbuilder over other alternatives, 'cause it is not available in (still widespread) older GTK versions.. dunno if i'll ever switch to it.. maybe when gtk3 comes out.

Related

A layout implementation such as Eclipse

I have been working on a project model and pretty much completed it. Now I must implement the view of the project. I like eclipse view layout very much and tried to implement like this but I couln't. And then download source code of eclipse but couldn't find my specific code snippet in all of the source code. I mean I want to take basic layout implementation like eclipse Coolbar,ctabfolder and events. any suggections ?
Thanks.
If you like the Eclipse look and feel and the components used, you should have a look into the technologies used with Eclipse:
SWT is the GUI toolkit. It differs from Swing in that it uses the native widgets, if possible. This makes an application using it behave more like a native application than Swing does, which has its own set of components. You will find the raw components that you mention here.
JFace is an application framework based on SWT. It provides higher level conceptual components.
Eclipse RCP is a platform for building application. It takes away some common tasks of application building but, of course, you need to learn the concepts first.
Swing has similar components, but does not use the native widgets. It draws them itself. In my opinion Swing is easier to learn and to use but the results of SWT are often nicer - you can often "feel" that a Swing application behaves not completely right. It is better if Swing applications do not try to mimic the native look and feel to avoid the uncanny valley effect. So expect your resulting application to look and feel different.
There are more documentation and third-party libraries available for Swing, for example the very nice Netbeans RCP that let's you easily build applications.
What you are looking for is a docking framework. What the best framework is is open for debate.
You might have a look at this question for a list of popular frameworks

Need Help With Gtk+ Text Editor

I am creating a GTK+ text editor called Quick-Ed Pro. It was originally designed to be a cross-platform version of Quick-Ed , a text editor I wrote in raw Win Api. But after finding the awesome capabilities of GTK+ , Quick-Ed Pro emerged as an entirely different program with advanced GUI capabilities way better than Quick-Ed. But now Im stuck with a few problems.
Problems:
1- I want to make my editor multi-tabular like notepad++ or gedit. I dont know how to do this. What widget should I use?
2- GtkTextView does not seem to have any undo / redo functions. How can I make my own? (examples appreciated)
3- Gtk+ has a long startup time, usually 2-4 seconds unlike win api which started up in less than a second, so how can I create a small popup loading bar like the one in GIMP or Code::Blocks?
4-URL of my project: http://code.google.com/p/quick-ed/
URL of the WinApi Quick-Ed : http://code.google.com/p/burningprodigy ... e&can=2&q=
Any help will be appreciated. I need contributors. Please lend me a hand.
1) Tabs: You will need to write your own widget for this. No toolkit i know has one that is flexible enough to handle what is required in a good editor. But you can start with GtkNotebook for a quick prototype.
2) Yes this is a FAQ and imho bad that it is not solved directly in GTK. If you use gtkmm you can use http://view.sourceforge.net/classes.php otherwise look into the library to see how it is implemented and port it into C. There are other implementations for example for python available on the net.
3) You have to write a small dialog using the WinAPI and show this before you call the first GTK function. Usually i wouldn't recommend to do it - after the windows file cache has the files (or you have a SSD) loading speed is okay.
You should look into http://projects.gnome.org/gtksourceview/ to get a good editor. The GtkTextView is definitely not able to work as a source code editor. I'm maintaining a commerical IDE and Editor and by the way the most code is outside the editor widget anyway.

drag and drop environment to start developing in gwt

is there any drag and drop environment to work with GWT widgets.
or any user friendly IDE or plugin on IDE's
i remember using some thing like MyEclips for developing Hibernate was better then working with .xml files.
The Eclipse-based WindowBuilder Pro supports GWT and is now free, courtesy of Google.
I tried GWT Designer, http://code.google.com/webtoolkit/tools/gwtdesigner/index.html, but I think for now I'll stick to code the guis myself by hand.
The main reasons are:
Sometimes, it takes a little while (longer than I can wait) to load the design mode.
Sometimes it breaks after you modify code underneath.
Sometimes, does not do what you expect it to do.
I would suggest you giving it a try and see if it works out for your needs.
In my opinion, the experience using it has been frustrating than encouraging.

How can I enhance the look of the Perl/TK GUI under Perl 5.004?

I have an application that is built to work on Windows, Linux, and Solaris that uses the Perl/TK GUI. Due to constraints, we are limited to Perl/TK only. Moreover, we are limited to an old Perl/Tk version, 5.00404.
I'd like to work within these limitations to make the GUI look as nice and modern as possible.
Are there any web-resources that have TK design schemes (for buttons, frames, colors, etc) that could assist me in this endeavor?
I am also looking for modernization advices like the one that I found here:
If you're finding that your Tk apps look a little ugly on X-based systems, try adding the following lines to the top of your script:
$mw->optionAdd("*font", "-*-arial-normal-r-*-*-*-120-*-*-*-*-*-*");
$mw->optionAdd("*borderWidth", 1);
Try using images instead of button elements, then you can have whatever style you like and the fonts can be baked in. This will work for pretty much any element where the contents are not dynamic - including backgrounds on panes and such. Granted it's more work but it does solve your problem, especially if you have a competent artist in your project group.
You could use the Tk theme engine to give your app better looks.
Using optionAdd to tweak defaults through the option database
is a reasonable start. A thread about this can be found at:
http://tcl.projectforum.com/tk/221
Download griffin.kit from there, use the sdx tool to unwrap it and locate
griffin.tcl to get a good set of option settings.
http://wiki.tcl.tk/3411 for the sdx tool.
Since in Linux the background of Tk::Entry and Tk::Text is grey i would also use the following two lines.
$mw->optionAdd( '*Entry.background', 'snow1' );
$mw->optionAdd( '*Text.background', 'snow1' );
Replace 'snow1' with a color of your choice. You can also use the hex representation(RGB) of the colors like '#ff9696'.
The Tile themeable engine for Tk makes it look much prettier. However, Perl/Tk has lagged far behind Tk's development, and can't take advantage of Tile and other advancements.
You should investigate whether Tkx is an option for you. It's not completely compatible with Perl/Tk, but the API is pretty close. It's a bridge between Perl and Tcl/Tk, so it can use all of the modern Tcl/Tk features (like Tile) while still having application logic coded in Perl. Quite a few of ActiveState's own graphical utilities use Tkx, with fairly good-looking results.
(source: activestate.com)
Perl 5.00404 is incredibly ancient, though. The Tkx dist claims to depend on Perl≥5.008... I don't have an old enough Perl to see how accurate that is.

Graphically laying out wx app

Being really new to wx, I'm wondering if there is an IDE (especially for Linux) which would help me lay out a frame or dialog or whatever just to help me see what I'm doing. That means also creating the code for those changes.
I remember way back when using resource compilers for OS/2 and Windows that produced binaries that would then create the window, and was hoping for something similar (though obviously not binary if wx doesn't support that).
I use wxFormBuilder. It is written in wxWidgets, so it works on Linux quite well. It can generate C++ code or XRC files. Make sure you understand its philosophy, and use it like this:
generate C++ code for the GUI
don't edit the code wxFormBuilder generated, but create new files
in new files, derive new classes from the classes it generated
implement event handlers in you own class (wxFB creates virtual function for each event handler you wish to use)
I usually name the wxFormBuilder generated classes/files like, for example, MainFrameGUI, and one with implementation (derived one in which I write all my code) would be just MainFrame. This enables you to change the visual layout and regenerate C++ files from wxFB at any time without overwriting your code.
DialogBlocks works quite well for me, although sometimes you need to edit the code to fix errors manually. It has a property editor that seems advanced enough.
Just another options is wxGlade. It does not have the that much features as the others mentioned seem to have, but it works just good enough for me to not daring to switch.
I use Code::Blocks IDE from http://www.codeblocks.org which has
- built-in GUI editor
- Cross compilable, so you can use it under Linux, OSX and Windows.
But I still use wxFormBuilder with it instead of built-in wxSmith editor. But they are compatible with internal wxSmith.
For windows you've got "wx-devcpp" which is Blodsheed Dev C++ with some addons providing what you looking for
Here is project page
http://wxdsgn.sourceforge.net/