Re: [gnome-love] Am I doing this right?



Hi,

I looked at it briefly.  Comments below.

On Tue, 2004-06-01 at 14:36, Mikael Hallendal wrote:
ethan zimmerman wrote:

I've written a simple GNOME program using libglade, and I'm wondering if
I did it right. I would really appreciate ANY comments about the
following program (see link below). The things I'm most interested in
are "source code style" things. (written standards, unwritten rules,
variable and widget naming schemes, etc.).

You didn't provide quick access keys for your confirmation window.  If
you change the "Quit" and "Cancel" labels to "_Quit" and "_Cancel", then
gtk+ automatically transforms that into Quit and Cancel with Alt+q and
Alt+c as quick access keys.

Also, I found it somewhat strange that you end all comments at column
78.  I haven't seen any Gnome guideline against that but that might just
be because I've never seen anyone else do it.

Next, I noticed that you have the return values for functions on the
same line as the function name.  I don't know if there's a guideline for
this or not, but all the Gnome programs I am familiar with put the
return value on a separate line before the function name (at least for
definitions; for declarations they tend to be on the same line).

Took a quick look and noticed that you are not following the GNOME 
indentation scheme (8 chars). There is a document describing 
"guidelines" for GNOME code, of course in the end it's up to you but 
following those guidelines will make others feel comfortable helping out 
on your module:
 
http://developer.gnome.org/doc/guides/programming-guidelines/book1.html

Note that indentation does vary among Gnome programs, but there are two
that are the more-or-less standards.  The slightly more common one is
the one Mikael pointed out.  The other one is the Gtk+ style of
indentation (with 2 spaces), which is used by programs/libraries such as
Gtk+ (obviously) or Metacity.  So your program does follow the latter
convention.

Also, noticed:

{
 g_print("prefs \n");

 GladeXML *prefs_defs;
 GtkWidget *widget;
}

this isn't valid and you should first declare your variables in each 
block. Otherwise it seemed fine so far!

This is important to keep in mind with older compilers, but it is
actually valid C as of C99.  See, for example, 
http://www.comeaucomputing.com/techtalk/c99/#mixeddecls  (the first link
Google found for me; yes gcc supports this--see
http://gcc.gnu.org/gcc-3.3/c99status.html).


Cheers,
Elijah



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]