~ubuntu-branches/ubuntu/oneiric/bbmail/oneiric

« back to all changes in this revision

Viewing changes to mailboxmenu.cc

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2002-02-02 18:49:55 UTC
  • Revision ID: james.westby@ubuntu.com-20020202184955-a0zs49k8711frhqc
Tags: upstream-0.8.2
ImportĀ upstreamĀ versionĀ 0.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// mailboxmenu.cc for bbmail - an tool for display the mail in X11.
 
2
//
 
3
//  Copyright (c) 1998-2000 by John Kennis, jkennis@chello.nl
 
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 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., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
//
 
19
// (See the included file COPYING / GPL-2.0)
 
20
//
 
21
#include "mailboxmenu.hh"
 
22
 
 
23
Mailboxmenu::Mailboxmenu(ToolWindow *toolwindow) :
 
24
                Basemenu(toolwindow)
 
25
{
 
26
        int i;
 
27
        bbtool=toolwindow;
 
28
 
 
29
        setTitleVisibility(False);
 
30
        setMovable(False);
 
31
        setHidable(False);
 
32
        setAlignment(AlignBottom);
 
33
        defaultMenu();
 
34
 
 
35
        word_length = new int [bbtool->getResource()->report.number_of_spoolfiles];
 
36
        for (i=0;i<bbtool->getResource()->report.number_of_spoolfiles;i++) {
 
37
                insert(&bbtool->getResource()->spoolfile[i].name);
 
38
                word_length[i]=strlen(bbtool->getResource()->spoolfile[i].name);
 
39
        }
 
40
        insert("Reconfigure");
 
41
        insert("Close");
 
42
}
 
43
 
 
44
 
 
45
Mailboxmenu::~Mailboxmenu(void)
 
46
{
 
47
        delete [] word_length;
 
48
}
 
49
 
 
50
void Mailboxmenu::ClearMenu()
 
51
{
 
52
        int i;
 
53
 
 
54
        for (i=0;i<=bbtool->getResource()->report.number_of_spoolfiles;i++)
 
55
                remove(0);
 
56
        remove(0);
 
57
        remove(0);
 
58
        delete [] word_length;
 
59
}
 
60
 
 
61
void Mailboxmenu::Reconfigure()
 
62
{
 
63
        int i;
 
64
 
 
65
        word_length = new int [bbtool->getResource()->report.number_of_spoolfiles];
 
66
        for (i=0;i<bbtool->getResource()->report.number_of_spoolfiles;i++) {
 
67
                insert(&bbtool->getResource()->spoolfile[i].name);
 
68
                word_length[i]=strlen(bbtool->getResource()->spoolfile[i].name);
 
69
        }
 
70
        insert("Reconfigure");
 
71
        insert("Close");
 
72
        Basemenu::reconfigure();
 
73
}
 
74
 
 
75
 
 
76
void Mailboxmenu::Move(int x, int y, bool withdrawn)
 
77
{
 
78
        if (!withdrawn) {
 
79
                int y_old=y;
 
80
                y= y - getHeight() -1;
 
81
                if ((x+getWidth())>bbtool->getCurrentScreenInfo()->getWidth())
 
82
                        x=bbtool->getCurrentScreenInfo()->getWidth()-getWidth();
 
83
                if (y<0)
 
84
                        y=y_old+bbtool->Frame().height;
 
85
                Basemenu::move(x, y);
 
86
        } else {
 
87
                x= x - getWidth() - 6;
 
88
                if (x<0)
 
89
                        x=x + getWidth() + 12;
 
90
                if (y<0)
 
91
                        y=0;
 
92
                if (y+getHeight()>bbtool->getCurrentScreenInfo()->getHeight())
 
93
                        y=bbtool->getCurrentScreenInfo()->getHeight()-getHeight();
 
94
                Basemenu::move(x, y);
 
95
        }
 
96
}
 
97
 
 
98
/* quick and dirty */
 
99
void Mailboxmenu::UpdateNumbers(int newmail, int totalmail,int spoolno)
 
100
{
 
101
        char dummy[15];
 
102
 
 
103
        bbtool->getResource()->spoolfile[spoolno].name[word_length[spoolno]]='\0';
 
104
        sprintf(dummy," (%u/%u)",newmail,totalmail);
 
105
        strcat(bbtool->getResource()->spoolfile[spoolno].name,dummy);
 
106
        if (newmail>0)
 
107
                setHighlight(spoolno);
 
108
        Basemenu::reconfigure();
 
109
}
 
110
 
 
111
void Mailboxmenu::Update()
 
112
{
 
113
        wait_for_update=False;
 
114
        Basemenu::update();
 
115
}
 
116
 
 
117
void Mailboxmenu::itemSelected(int button, int index)
 
118
{
 
119
        if (button == 1) {
 
120
                if (index < bbtool->getResource()->report.number_of_spoolfiles) {
 
121
                        system(bbtool->getResource()->spoolfile[index].runCommand);
 
122
                } else if (index == bbtool->getResource()->report.number_of_spoolfiles) {
 
123
                        bbtool->reconfigure();
 
124
                } else if (index == bbtool->getResource()->report.number_of_spoolfiles+1) {
 
125
                        bbtool->shutdown();
 
126
                }
 
127
                hide();
 
128
                bbtool->EnvelopePushed(False);
 
129
                bbtool->Redraw(False);
 
130
        }
 
131
}
 
132
 
 
133
void Mailboxmenu::show(void)
 
134
{
 
135
        XRaiseWindow(bbtool->getXDisplay(), getWindowID());
 
136
        Basemenu::show();
 
137
}