getting-started-hacking.xml 27.1 KB
Newer Older
Richard Hult's avatar
Richard Hult committed
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML 4.1.2//EN "
Richard Hult's avatar
Richard Hult committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">

<book>
  <bookinfo>
    <title>Getting started on hacking Planner</title>
    <authorgroup>
      <author>
        <firstname>Mikael</firstname>
        <surname>Hallendal</surname>
        <affiliation>
          <orgname>Imendio HB</orgname>
          <address>
            <email>micke@imendio.com</email>
          </address>
        </affiliation>
      </author>
    </authorgroup>
    <releaseinfo>Version 0.4</releaseinfo>
    <copyright>
      <year>2002</year>
      <holder>Mikael Hallendal and CodeFactory AB</holder>
    </copyright>
    <legalnotice>
      <para>
        Permission is granted to copy, distribute and/or modify this document
        under the terms of the GNU Free Documentation License, Version 1.1
        or any later version published by the Free Software Foundation.
     </para>
    </legalnotice>
  </bookinfo>
  
  <chapter>
    <title>Getting started</title>
    <para>
      The first thing to do if you want to help out hacking on
      Planner is to join the Planner-devel mailing list. List
      information can be found at: 
      <ulink
      url="http://lists.codefactory.se/mailman/listinfo/planner-devel">
        http://lists.codefactory.se/mailman/listinfo/planner-devel
      </ulink>.
    </para>
    <para>
      Then read through this document to learn how we work and the
      coding style rules that should be used in Planner
      code. Finally, please join us for discussions in #planner at
      Gimpnet (irc.gnome.org).
    </para>
    <sect1>
      <title>Requirements</title>
      <sect2>
        <title>libplanner</title>
        <para>
          <table frame="none">
            <title>libplanner dependencies</title>
            <tgroup cols="2" align="left" colsep="1" rowsep="1">
              <colspec colname="Package"/>
              <colspec colname="Version"/>
              <tbody>
                <row>
                  <entry><emphasis>Package</emphasis></entry>
                  <entry><emphasis>Version</emphasis></entry>
                </row>
                <row>
                  <entry>glib</entry>
                  <entry>>=2.0.4</entry>
                </row>
                <row>
                  <entry>libxml2</entry>
                  <entry>>=2.4.7</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
        </para>
      </sect2>
      <sect2>
        <title>planner</title>
        <para>
          <table frame="none">
            <title>planner dependencies</title>
            <tgroup cols="2" align="left" colsep="1" rowsep="1">
              <colspec colname="package"/>
              <colspec colname="version"/>
              <tbody> 
                <row>
                  <entry><emphasis>Package</emphasis></entry>
                  <entry><emphasis>Version</emphasis></entry>
                </row>
                <row>
                  <entry>libplanner</entry>
                  <entry> * </entry>
                </row>
                <row>
                  <entry>gtk+</entry>
                  <entry> >= 2.0.3</entry>
                </row>
                <row>
                  <entry>libgnomecanvas</entry>
                  <entry> >= 2.0.1</entry>
                </row>
                <row>
                  <entry>libgnomeui</entry>
                  <entry> >= 2.0.1</entry>
                </row>
                <row>
                  <entry>libglade</entry>
                  <entry> >= 2.0.0</entry>
                </row>
                <row>
                  <entry>libbonoboui</entry>
                  <entry> >= 2.0.0</entry>
                </row>
              </tbody>
            </tgroup>
          </table>
        </para>
      </sect2>
    </sect1>
    <sect1>
      <title>Getting the source</title>
      <para>
        When developing on Planner we strongly recommend using the
        source from CVS. If you have a CVS account at
        cvs.gnome.org you get the source code by:
        <programlisting>
# export CVSROOT=":pserver:yourlogin@cvs.gnome.org:/cvs/gnome"
# cvs co libplanner
# cvs co planner</programlisting>
        Otherwise you can download it from our anonymous cvs with the
        following commands.
        <programlisting>
# export CVSROOT=":pserver:anonymous@anoncvs.gnome.org:/cvs/gnome"
# cvs login

(No password, just press enter.)

# cvs -z3 co libplanner
# cvs -z3 co planner</programlisting>
      </para>

    </sect1>
    <sect1>
      <title>Building the source</title>
      <para>
        To build Planner you need to first build libplanner. Just
        execute the following commands.
        <programlisting>
# cd libplanner
# ./autogen.sh --prefix=/prefix
# make
# make install</programlisting>
        Then you can build Planner by the following set of commands.
        <programlisting>
# cd planner
# ./autogen.sh --prefix=/prefix
# make
# make install</programlisting>
      </para>
    </sect1>
    <sect1>
      <title>Creating patches</title>
      <para>
        The easiest way to create patches is by using CVS. Before you
        make the patch, make sure that you have the latest changes
        from the CVS by executing:
        <programlisting>
# cvs up -Pd</programlisting>
        Then you can create the patch with:
        <programlisting>
# cvs diff -u > file.patch</programlisting>
        Make sure you use the <emphasis>-u</emphasis> flag, that makes
        the patch easier to read.
      </para>
    </sect1>
    <sect1>
      <title>Submitting your patches</title>
180
      <para>
Richard Hult's avatar
Richard Hult committed
181 182 183 184 185 186 187 188
      Submitting patches can either be done by sending them to the
      <ulink
      url="http://lists.codefactory.se/mailman/listinfo/planner-devel">planner-devel
      mailing list</ulink>. Or by adding them as attachments to the
      issue the patch solves at the bugzilla at:
      <ulink url="http://freedom.codefactory.se/bugzilla/">
        http://freedom.codefactory.se/bugzilla/
      </ulink>.
189
      </para>
Richard Hult's avatar
Richard Hult committed
190 191 192
    </sect1>
  </chapter>
  <chapter>
193
    <title>Programming Guidelines</title>
Richard Hult's avatar
Richard Hult committed
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
    <para>
      This chapter discuss the coding guide lines that should be used in
      all Planner code. Please notice that if your code doesn't
      follow these guide lines it won't be included in Planner,
      therefor please make sure that it does before sending the
      patches. 
    </para>
    <sect1>
      <title>Naming conventions</title>
      <para>
        The naming schemes is a little different between libplanner
        and planner, this is to make it clear by looking at a
        function name to see where it belongs. The reason for a naming
        scheme is that it should be easy to find the definition and
        implementation of a function/enum/class/... by just looking at
        the name of it.
      </para>
      <sect2>
        <title>Class Names</title>
        <para>
          <itemizedlist>
            <listitem>
216
	    <para>
Richard Hult's avatar
Richard Hult committed
217 218 219
              Classes should be named with a prefix
              <emphasis>Mrp</emphasis> for classes in libplanner and
              <emphasis>Planner</emphasis> for classes in planner. 
220
	    </para>
Richard Hult's avatar
Richard Hult committed
221 222
            </listitem>
            <listitem>
223
	    <para>
Richard Hult's avatar
Richard Hult committed
224 225
              Use upper case letters as word separators, lower case
              for the rest of the word.
226
	    </para>
Richard Hult's avatar
Richard Hult committed
227 228
            </listitem>
            <listitem>
229
	    <para>
Richard Hult's avatar
Richard Hult committed
230
              No underscores ("_") in the names.
231
	    </para>
Richard Hult's avatar
Richard Hult committed
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
            </listitem>
          </itemizedlist>
         
          <example>
            <title>Class Names</title>
            <programlisting>
 class MrpTaskManager
 class PlannerResourceModel</programlisting>
          </example>
        </para>
      </sect2>
      <sect2>
        <title>File Names</title>
        <para>
          File names should be named as follows:
          <itemizedlist>
            <listitem>
249
	    <para>
Richard Hult's avatar
Richard Hult committed
250
              No upper case letters.
251
	    </para>
Richard Hult's avatar
Richard Hult committed
252 253
            </listitem>
            <listitem>
254 255 256
	    <para>
              Use a hyphen ("-") to separate words.
	    </para>
Richard Hult's avatar
Richard Hult committed
257 258
            </listitem>
            <listitem>
259
	    <para>
Richard Hult's avatar
Richard Hult committed
260 261 262
              Prefix filenames with <emphasis>mrp-</emphasis> for
              files in libplanner and <emphasis>planner-</emphasis> for
              files in planner.
263
	    </para>
Richard Hult's avatar
Richard Hult committed
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
            </listitem>
          </itemizedlist>
          <example>
            <title>Filenames</title>
            <programlisting>
 mrp-task-manager.c
 mrp-task-manager.h
 planner-resource-model.c
 planner-resource-model.h</programlisting>
          </example>
        </para>
      </sect2>
      <sect2>
        <title>External Functions Names</title>
        <para>
          External functions should be named as the file names with
          every hyphen ("-") replaced by an underscore ("_").
          <example>
            <title>External function names</title>
            <programlisting>
 mrp_task_manager_get_root (...)
 planner_resource_model_get_type_string (...)</programlisting>
          </example>
        </para>
      </sect2>
      <sect2>
        <title>Static Functions Names</title>
        <para>
          This use the same scheme as external functions names but
          remove the prefix. So for example:
          <example>
            <title>Static Functions Names</title>
296
	    <para>
Richard Hult's avatar
Richard Hult committed
297 298 299 300 301 302 303 304
            An external function       
            <programlisting>
 mrp_resource_get_name (...)</programlisting>
            would become
            <programlisting>
 resource_get_name (...)</programlisting>
            if it was a static function withing
            mrp-resource.c.
305
	    </para>
Richard Hult's avatar
Richard Hult committed
306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
          </example>
        </para>
        <para>
          <emphasis>
            Notice that this scheme is currently not used in Planner 
            but we'll change to it whenever we are editing those
            files, please use this scheme for all new code.
          </emphasis>
        </para>
      </sect2>
      <sect2>
        <title>Enum/Struct Names</title>
        <para>
          Enum and structs follow the same naming convention as the
          classes.
          <example>
            <title>Enum/Struct names</title>
323
	    <para>
Richard Hult's avatar
Richard Hult committed
324 325 326 327 328 329 330
            in mrp-resource.h
            <programlisting>
 typedef enum {
   	MRP_RESOURCE_TYPE_NONE,
	MRP_RESOURCE_TYPE_WORK,
	MRP_RESOURCE_TYPE_MATERIAL
 } MrpResourceType;</programlisting>
331
	    </para>
Richard Hult's avatar
Richard Hult committed
332 333 334 335 336 337 338 339 340 341 342
          </example>
          Same goes for structures.
        </para>
      </sect2>
      <sect2>
        <title>#define and Macro Names</title>
        <para>
        #defines and macros should be named in the same way as
         functions but with uppercase letters instead of lowercase.
        <example>
          <title>#define and macro names</title>
343
	  <para>
Richard Hult's avatar
Richard Hult committed
344 345 346 347 348 349 350
          In mrp-resource.h
          <programlisting>
 #define MRP_TYPE_RESOURCE         (mrp_resource_get_type ())</programlisting>
          In planner-resource-model.h
          <programlisting>
#define PLANNER_IS_RESOURCE_MODEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), 
                                   PLANNER_TYPE_RESOURCE_MODEL))</programlisting>
351
	  </para>
Richard Hult's avatar
Richard Hult committed
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368
        </example>
        </para>
      </sect2>
    </sect1>
    <sect1>
      <title>Code Formatting</title>
      <para>
        In order to make the code more readable we here define a
        number of formatting rules that has to be followed. If
        everyone hacking on Planner uses the same code formatting
        it will be much easier to read other persons code.
      </para>
      <sect2>
        <title>Indentation</title>
        <para>
          Indentation should be done using tabs and one tab is eight
          spaces wide.
369
          <example><title>Indentation</title>
Richard Hult's avatar
Richard Hult committed
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
            <programlisting>
static void
mrp_resource_new (void)
{
        MrpResource *resource;
        
        resource = g_object_new (MRP_TYPE_RESOURCE, NULL);
        
        return resource;
}</programlisting>
          </example>
          This is the same style used by the Linux kernel and by the
          GNOME project.
        </para>
      </sect2>
      <sect2>
        <title>Braces policy</title>
        <para>
          <itemizedlist>
            <listitem>
390
	    <para>
Richard Hult's avatar
Richard Hult committed
391 392 393 394 395 396 397 398 399 400 401 402
              All if-, while-, do-, for-statements should use braces,
              even one-liners. This is because it's obvious where the
              statement starts/ends, it's also good when you want to
              put another line in the same statement and you don't
              have to make sure that you put the braces there.
              <example>
                <title>Braces used for statements</title>
                <programlisting>
if (i &gt;= 0) {
        /* do something */
}</programlisting>
              </example>
403
	    </para>
Richard Hult's avatar
Richard Hult committed
404 405
            </listitem>
            <listitem>
406
	    <para>
Richard Hult's avatar
Richard Hult committed
407 408 409 410 411 412 413 414 415 416
              For these types of statements, the open brace should be
              placed on the same line as the statement with a single
              space between the statement and the opening brace.
              <example>
                <title>One line statements</title>
                <programlisting>
for (i = 0; i &lt; len; ++i) {
        /* my one-liner */
}</programlisting>
              </example>
417
	    </para>
Richard Hult's avatar
Richard Hult committed
418 419
            </listitem>
            <listitem>
420
	    <para>
Richard Hult's avatar
Richard Hult committed
421 422 423 424 425 426 427 428 429 430 431
              For functions the opening brace should be placed
              below the function 
              <example>
                <title>Braces around function statements</title>
                <programlisting>
void static
my_function (void)
{
        /* do something */
}</programlisting>
              </example>
432
	    </para>
Richard Hult's avatar
Richard Hult committed
433 434
            </listitem>
            <listitem>
435
	    <para>
Richard Hult's avatar
Richard Hult committed
436 437 438 439 440 441 442 443 444 445 446 447 448 449
              If-elseif-else-statements should use the following
              formatting.
              <example>
                <title>If-elseif-else statement</title>
                <programlisting>
if (...) {
        /* do something */
}
else if (...) {
        /* do something else */
} else {
        /* do yet another thing */
}</programlisting>
              </example>
450
	    </para>
Richard Hult's avatar
Richard Hult committed
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
            </listitem>
          </itemizedlist>
        </para>
      </sect2>
      <sect2>
        <title>Parenthesis policy</title>
        <para>
        </para>
      </sect2>
      <sect2>
        <title>Function declarations and implementation</title>
        <para>
          A few guidelines on how to write functions.
          <itemizedlist>
            <listitem>
466
	    <para>
Richard Hult's avatar
Richard Hult committed
467 468 469 470 471 472 473 474 475 476 477
              In declaration, always put one argument per row and
              align the functions, types and arguments for easy reading.
              <example>
                <title>Function declarations</title>
                <programlisting>
void      mrp_resource_assign             (MrpResource     *resource,
		                           MrpTask         *task,
					   gint             units);

GList *   mrp_resource_get_assignments    (MrpResource     *resource);</programlisting>
              </example>
478
	    </para>
Richard Hult's avatar
Richard Hult committed
479 480
            </listitem>
            <listitem>
481
	    <para>
Richard Hult's avatar
Richard Hult committed
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503
              When implementing the function, try to fit all arguments
              on one row, if that doesn't fit in 80 chars width, split
              them up with one argument per row. Put a single space
              between the longest type and the arguments.
              <example>
                <title>Function implementation</title>
                <programlisting>
void
mrp_resource_assign (MrpResource *resource, MrpTask *task, gint units)
{
        /* ... */
}

gboolean
mrp_project_save_as (MrpProject   *project,
                     const gchar  *uri,
                     gboolean      force,
                     GError      **error)
{
        /* ... */
}</programlisting>
              </example>
504
	    </para>
Richard Hult's avatar
Richard Hult committed
505 506
            </listitem>
            <listitem>
507
	    <para>
Richard Hult's avatar
Richard Hult committed
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522
              If you have pointer arguments with * or ** they should
              be placed together with the argument, not with the
              type. Also they should be aligned as
              <example>
                <title>Align pointer arguments</title>
                <programlisting>
gboolean
mrp_project_save_as (MrpProject   *project,
                     const gchar  *uri,
                     gboolean      force,
                     GError      **error)
{
        /* ... */
}</programlisting>
              </example>
523
	    </para>
Richard Hult's avatar
Richard Hult committed
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556
            </listitem>
          </itemizedlist>
        </para>
      </sect2>
      <sect2>
        <title>Variable definitions</title>
        <para>
          Variables should be aligned in the same way as function
          arguments. Put one space between longest type and arguments
          and align with * and ** in the same way as for function
          arguments.
        </para>
      </sect2>
    </sect1>
    <sect1>
      <title>Structure of source files</title>
      <para>
        All source files should start with the header used in
        Planner.
        <example>
          <title></title>
          <programlisting>
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2002 Your name &lt;your@email&gt;
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
557
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Richard Hult's avatar
Richard Hult committed
558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */</programlisting>
        </example>
        The first row is to make sure that everyone using Emacs gets
        the correct tab-width and programming mode. 
      </para>
      <sect2>
        <title>Header Files</title>
        <para>
          Header files is built up as follows.
          <example>
            <title>Commented header file</title>
            <programlisting>
/* Header as described above */

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2001-2002 CodeFactory AB
 * Copyright (C) 2001-2002 Richard Hult &lt;rhult@codefactory.se&gt;
 * Copyright (C) 2001-2002 Mikael Hallendal &lt;micke@codefactory.se&gt;
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
591
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Richard Hult's avatar
Richard Hult committed
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/* 
 * include guards, these are to make sure that the same header only
 * gets included once. 
 */
#ifndef __MRP_ASSIGNMENT_H__
#define __MRP_ASSIGNMENT_H__

/* 
 * Includes needed by this header, put as much includes as possible in
 * the C-file rather than the header file. 
 */
#include &lt;planner/mrp-object.h&gt;
#include &lt;planner/mrp-time.h&gt;
#include &lt;planner/mrp-types.h&gt;

/*
 * If it is a class you are defining you need this convenience macros,
 * they should come directly after the includes.
 */
#define MRP_TYPE_ASSIGNMENT         (mrp_assignment_get_type ())
#define MRP_ASSIGNMENT(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), 
                                     MRP_TYPE_ASSIGNMENT, MrpAssignment))
#define MRP_ASSIGNMENT_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), 
                                     MRP_TYPE_ASSIGNMENT, MrpAssignmentClass))
#define MRP_IS_ASSIGNMENT(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), 
                                     MRP_TYPE_ASSIGNMENT))
#define MRP_IS_ASSIGNMENT_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), 
                                     MRP_TYPE_ASSIGNMENT))
#define MRP_ASSIGNMENT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), 
                                     MRP_TYPE_ASSIGNMENT, MrpAssignmentClass))

/*
 * Defining the class structures
 */
typedef struct _MrpAssignmentClass MrpAssignmentClass;
typedef struct _MrpAssignmentPriv  MrpAssignmentPriv;

struct _MrpAssignment {
        MrpObject          parent;

        MrpAssignmentPriv *priv;
};

struct _MrpAssignmentClass {
        MrpObjectClass parent_class;
};

/* Function declarations */
GType              mrp_assignment_get_type     (void) G_GNUC_CONST;

MrpAssignment     *mrp_assignment_new          (void);

MrpTimeInterval   *mrp_assignment_get_interval (MrpAssignment *assignment);

MrpTask           *mrp_assignment_get_task     (MrpAssignment *assignment);
MrpResource       *mrp_assignment_get_resource (MrpAssignment *assignment);
gint               mrp_assignment_get_units    (MrpAssignment *assignemnt);

/* End of the include guard */
#endif /* __MRP_ASSIGNMENT_H__ */</programlisting>
          </example>
        </para>
      </sect2>
      <sect2>
        <title>C Files</title>
        <para>
          <example>
            <title>Commented C file</title>
            <programlisting>
/* Same header as in the header file */

/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
 * Copyright (C) 2001-2002 CodeFactory AB
 * Copyright (C) 2001-2002 Richard Hult &lt;rhult@codefactory.se&gt;
 * Copyright (C) 2001-2002 Mikael Hallendal &lt;micke@codefactory.se&gt;
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
684
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Richard Hult's avatar
Richard Hult committed
685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

/*
 * Declarations of private structures and enums, the should come
 * before the internal functions since some of the internal functions
 * might need these structures/enums.
 */
struct _MrpAssignmentPriv {
	MrpTask     *task;
	MrpResource *resource;

	gint         units;
};

/* Properties */
enum {
        PROP_0,
        PROP_TASK,
        PROP_RESOURCE,
        PROP_UNITS
};

/* Declaration of internal functions */
static void mpa_class_init        (MrpAssignmentClass *klass);
static void mpa_init              (MrpAssignment      *assignment);
static void mpa_finalize          (GObject            *object);
static void mpa_set_property      (GObject            *object,
				   guint               prop_id,
				   const GValue       *value,
				   GParamSpec         *pspec);
static void mpa_get_property      (GObject            *object,
				   guint               prop_id,
				   GValue             *value,
				   GParamSpec         *pspec);


/*
 * Declaration of internal file global variables
 * NOTE! Try to not use file global variables and instead put them in
 *       a privat structure as in this example
 */
static MrpObjectClass *parent_class;

/* 
 * Put the get_type function as the first function implementation.
 */
GType
mrp_assignment_get_type (void)
{
        /* ... */
}

/* 
 * It should be directly followed by the static variables 
 * (in the same order as they were defined).
 */
static void
mpa_class_init (MrpAssignmentClass *klass)
{
      /* &lt;snip&gt; */
}
 
/* After the internal functions you put the implementations of the
 * external functions.
 * (These too in the same order as they were declared).
 */</programlisting>
          </example>
          The reason I'm nagging about putting the implementations
          in the same order as the declarations is that it's much
          easier to find a function if you do.
        </para>
      </sect2>
      <sect2>
        <title>Use of private structures</title>
        <para>
          We strongly suggest that you use private structures as where
          done in the code example above. This makes the code better
          object oriented and makes sure that you are not using the
          internal variables directly.
        </para>
       </sect2>
    </sect1>
  </chapter>
  <chapter>
    <title>Design of Planner</title>
    <sect1>
      <title>Directory structure</title>
      <sect2>
        <title>libplanner</title>
        <programlisting>
libplanner
 |
 +- docs              All documentation
 |   |
|   +- design        Design documentation
 |
 |
 +- planner         The exported libplanner
 |
 |
 +- po                Translation files.
 |
 |
 +- storage-modules   Storage modules that can be used from Planner
 |   |
 |   +- mpx           MPX loader (Microsoft Project eXchange format)
 |   |
 |   +- planner-1   The old Planner 0.5 file format
 |   |
 |   +- xml           The new XML-based format (currently not used).
 |
 |
 +- tests             Various tests to check that the library does what it's 
                      supposed to do.</programlisting>
      </sect2>
      <sect2>
        <title>planner</title>
        <programlisting>
planner
 |
 +- data                   Extra data files.
 |   |
 |   +- icons              Icon files for the GUI and the desktop.
 |   |
 |   +- mime               Mime-type information for .planner files.
 |
 |
 +- docs                   Documentation about Planner
 |   |
 |   +- design             Design documents
 |   |
 |   +- user-guide         Planner User Guide
 |
 |  
 +- po                     Translation files.
 |
 |
 +- src                    The source code for Planner.
     |
     +- app                Main application files. 
     |                     (including the planner binary).
     |  
     +- cell-renderers     Various GtkTreeView cell renderers
     |
     +- dialogs            The dialogs used in Planner (the more 
     |   |                 complicated).
     |   |
     |   +- task-dialog    The Task Dialog (used to edit task properties)
     |
     +- models             GtkTreeView storage modules.
     |
     +- util               Utility functions and marshal definitions used
     |                     throughout the entire Planner
     |
     +- widgets            Own defined widgets.
     |   |
     |   +- sidebar        The Sidebar used in Planner, we have our own 
     |                     now instead of using the one from GAL.
     |
     +- views              The various views (displayed in the sidebar).
         |
         +- gantt          The Gantt view and the Task table views. Put 
         |                 together because they have very much in common 
         |                 and depend on each other.
         |
        +- resources      Resource view and Group dialog (should probably 
                           be moved to dialogs/group-dialog).</programlisting>
      </sect2>
    </sect1>
  </chapter>
</book>