~jan-hrdina/ubuntu/quantal/xfce4-places-plugin/1.4.0-upstream-import

« back to all changes in this revision

Viewing changes to panel-plugin/model.c

  • Committer: Bazaar Package Importer
  • Author(s): Gauvain Pocentek
  • Date: 2007-04-22 08:55:28 UTC
  • Revision ID: james.westby@ubuntu.com-20070422085528-ijr73vydcqg5l830
Tags: upstream-0.2.0
ImportĀ upstreamĀ versionĀ 0.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  xfce4-places-plugin
 
2
 *
 
3
 *  Copyright (c) 2007 Diego Ongaro <ongardie@gmail.com>
 
4
 *
 
5
 *  This program is free software; you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation; either version 2 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU Library General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 */
 
19
 
 
20
#ifdef HAVE_CONFIG_H
 
21
#  include <config.h>
 
22
#endif
 
23
 
 
24
#include "model.h"
 
25
#include "model_system.h"
 
26
#include "model_volumes.h"
 
27
#include "model_user.h"
 
28
 
 
29
#include <libxfce4util/libxfce4util.h>
 
30
 
 
31
struct _Bookmarks
 
32
{
 
33
    BookmarksSystem  *system;
 
34
    BookmarksVolumes *volumes;
 
35
    BookmarksUser    *user;
 
36
};
 
37
 
 
38
Bookmarks*
 
39
places_bookmarks_init()
 
40
{
 
41
    DBG("initializing model");
 
42
 
 
43
    Bookmarks *b = g_new0(Bookmarks, 1);
 
44
 
 
45
    b->system = places_bookmarks_system_init();
 
46
    b->volumes = places_bookmarks_volumes_init();
 
47
    b->user = places_bookmarks_user_init(b->system); // user depends on system for 
 
48
                                                     // places_bookmarks_system_bi_system_mod().
 
49
                                                     // It's a sucky aspect of this design...
 
50
 
 
51
    return b;
 
52
}
 
53
 
 
54
void
 
55
places_bookmarks_visit(Bookmarks *b,
 
56
                       BookmarksVisitor *visitor)
 
57
{
 
58
    places_bookmarks_system_visit  (b->system,  visitor);
 
59
    places_bookmarks_volumes_visit (b->volumes, visitor);
 
60
    visitor->separator             (visitor->pass_thru);
 
61
    places_bookmarks_user_visit    (b->user,    visitor);
 
62
}
 
63
 
 
64
gboolean
 
65
places_bookmarks_changed(Bookmarks *b)
 
66
{
 
67
    // try to avoid short-circuit of || since changed() has side-effects
 
68
    gboolean changed = FALSE;
 
69
    changed = places_bookmarks_system_changed(b->system)    || changed;
 
70
    changed = places_bookmarks_volumes_changed(b->volumes)  || changed;
 
71
    changed = places_bookmarks_user_changed(b->user)        || changed;
 
72
    return changed;
 
73
}
 
74
 
 
75
void
 
76
places_bookmarks_finalize(Bookmarks *b)
 
77
{
 
78
    places_bookmarks_system_finalize(b->system);
 
79
    b->system = NULL;
 
80
    
 
81
    places_bookmarks_volumes_finalize(b->volumes);
 
82
    b->volumes = NULL;
 
83
    
 
84
    places_bookmarks_user_finalize(b->user);
 
85
    b->user = NULL;
 
86
 
 
87
    g_free(b);
 
88
}
 
89
 
 
90
// vim: ai et tabstop=4