5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
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.
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 Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "main_status_bar.h"
32 #include "wireshark_application.h"
36 #include "ui/main_statusbar.h"
41 #define DEF_READY_MESSAGE QObject::tr(" Ready to load or capture")
43 #define DEF_READY_MESSAGE QObject::tr(" Ready to load file")
46 // XXX - The GTK+ code assigns priorities to these and pushes/pops accordingly.
56 // If we ever add support for multiple windows this will need to be replaced.
57 // See also: main_window.cpp
58 static MainStatusBar *cur_main_status_bar = NULL;
61 * Push a formatted temporary message onto the statusbar.
64 statusbar_push_temporary_msg(const gchar *msg_format, ...)
70 if (!cur_main_status_bar) return;
72 va_start(ap, msg_format);
73 msg = g_strdup_vprintf(msg_format, ap);
76 pushMsg.fromUtf8(msg);
79 cur_main_status_bar->pushTemporaryStatus(pushMsg);
83 * Update the packets statusbar to the current values
86 packets_bar_update(void)
88 QString packetsStr = QString("");
90 if (!cur_main_status_bar) return;
92 cur_main_status_bar->popPacketStatus();
94 /* Do we have any packets? */
96 packetsStr.append(QString(QObject::tr("Packets: %1 Displayed: %2 Marked: %3"))
98 .arg(cfile.displayed_count)
99 .arg(cfile.marked_count));
100 if(cfile.drops_known) {
101 packetsStr.append(QString(QObject::tr(" Dropped: %1")).arg(cfile.drops));
103 if(cfile.ignored_count > 0) {
104 packetsStr.append(QString(QObject::tr(" Ignored: %1")).arg(cfile.ignored_count));
106 if(!cfile.is_tempfile) {
107 /* Loading an existing file */
108 gulong computed_elapsed = cf_get_computed_elapsed();
109 packetsStr.append(QString(QObject::tr(" Load time: %1:%2.%3"))
110 .arg(computed_elapsed/60000)
111 .arg(computed_elapsed%60000/1000)
112 .arg(computed_elapsed%1000));
113 /*packetsStr.append(QString().sprintf(QObject::tr(" Load time: %lu:%02lu.%03lu",
114 computed_elapsed/60000,
115 computed_elapsed%60000/1000,
116 computed_elapsed%1000)));
120 packetsStr.append(QObject::tr("No Packets"));
123 cur_main_status_bar->pushPacketStatus(packetsStr);
126 MainStatusBar::MainStatusBar(QWidget *parent) :
129 QSplitter *splitter = new QSplitter(this);
130 QString readyMsg(DEF_READY_MESSAGE);
132 // XXX - Add the expert level icon
134 m_infoStatus.setTemporaryContext(STATUS_CTX_TEMPORARY);
135 splitter->addWidget(&m_infoStatus);
136 splitter->addWidget(&m_packetStatus);
137 splitter->addWidget(&m_profileStatus);
139 splitter->setStretchFactor(0, 3);
140 splitter->setStretchFactor(1, 3);
141 splitter->setStretchFactor(2, 0);
143 addWidget(splitter, 1);
145 cur_main_status_bar = this;
147 m_infoStatus.pushText(readyMsg, STATUS_CTX_MAIN);
148 packets_bar_update();
151 void MainStatusBar::pushTemporaryStatus(QString &message) {
152 m_infoStatus.pushText(message, STATUS_CTX_TEMPORARY);
155 void MainStatusBar::popTemporaryStatus() {
156 m_infoStatus.popText(STATUS_CTX_TEMPORARY);
159 void MainStatusBar::pushFileStatus(QString &message) {
160 m_infoStatus.pushText(message, STATUS_CTX_FILE);
163 void MainStatusBar::popFileStatus() {
164 m_infoStatus.popText(STATUS_CTX_FILE);
167 void MainStatusBar::pushFieldStatus(QString &message) {
168 m_infoStatus.pushText(message, STATUS_CTX_FIELD);
171 void MainStatusBar::popFieldStatus() {
172 m_infoStatus.popText(STATUS_CTX_FIELD);
175 void MainStatusBar::pushFilterStatus(QString &message) {
176 m_infoStatus.pushText(message, STATUS_CTX_FILTER);
179 void MainStatusBar::popFilterStatus() {
180 m_infoStatus.popText(STATUS_CTX_FILTER);
183 void MainStatusBar::pushPacketStatus(QString &message) {
184 m_packetStatus.pushText(message, STATUS_CTX_MAIN);
187 void MainStatusBar::popPacketStatus() {
188 m_packetStatus.popText(STATUS_CTX_MAIN);
191 void MainStatusBar::pushProfileStatus(QString &message) {
192 m_profileStatus.pushText(message, STATUS_CTX_MAIN);
195 void MainStatusBar::popProfileStatus() {
196 m_profileStatus.popText(STATUS_CTX_MAIN);