~ubuntu-branches/ubuntu/natty/gnome-chemistry-utils/natty

« back to all changes in this revision

Viewing changes to libs/gcu/dialog-owner.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Mailänder
  • Date: 2009-12-19 11:00:02 UTC
  • mfrom: (1.1.5 upstream) (2.1.6 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091219110002-el6iiqb23qoh8uxf
Tags: 0.10.9-1ubuntu1
* manual merge from Debian testing, fixes LP: #233963
  * gcu-plugin.dirs, gcu-plugin.links: iceweasel → firefox; iceape → seamonkey
  * debian/control: added MOTU, iceweasel → firefox

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- C++ -*-
 
2
 
 
3
/* 
 
4
 * Gnome Chemistry Utils
 
5
 * gcu/dialog-owner.h
 
6
 *
 
7
 * Copyright (C) 2005-2007 Jean Bréfort <jean.brefort@normalesup.org>
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or 
 
10
 * modify it under the terms of the GNU General Public License as 
 
11
 * published by the Free Software Foundation; either version 2 of the
 
12
 * License, or (at your option) any later version.
 
13
 *
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 *
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program; if not, write to the Free Software
 
21
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 
22
 * USA
 
23
 */
 
24
 
 
25
#include "config.h"
 
26
#include "dialog-owner.h"
 
27
#include "dialog.h"
 
28
 
 
29
using namespace std;
 
30
 
 
31
namespace gcu
 
32
{
 
33
 
 
34
DialogOwner::DialogOwner ()
 
35
{
 
36
}
 
37
 
 
38
DialogOwner::~DialogOwner ()
 
39
{
 
40
        ClearDialogs ();
 
41
}
 
42
 
 
43
Dialog *DialogOwner::GetDialog (string name)
 
44
{
 
45
        map <string, Dialog *>::iterator i = Dialogs.find (name);
 
46
        return (i != Dialogs.end ())? (*i).second: NULL;
 
47
}
 
48
 
 
49
bool DialogOwner::AddDialog (string name, Dialog *dialog) 
 
50
{
 
51
        if (Dialogs[name]) {
 
52
                Dialogs[name]->Present ();
 
53
                return false;
 
54
        }
 
55
        Dialogs[name] = dialog;
 
56
        return true;
 
57
}
 
58
 
 
59
void DialogOwner::ClearDialogs ()
 
60
{
 
61
        map <string, Dialog *>::iterator i;
 
62
        while (!Dialogs.empty ()) {
 
63
                i = Dialogs.begin ();
 
64
                if ((*i).second)
 
65
                        (*i).second->Destroy ();
 
66
                else
 
67
                        Dialogs.erase (i);
 
68
        }
 
69
}
 
70
 
 
71
}       //      namespace gcu