aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2012-07-19 21:49:52 +0000
committerGerald Combs <gerald@wireshark.org>2012-07-19 21:49:52 +0000
commit0da59a005829eb5daf49c6477219a35ac4e73ab3 (patch)
tree0890e6704f36a03fa1d444d4ad8e25411ec36f34 /ui
parentbdb0898ff8fccc3a7fba48bd36c8a13899745177 (diff)
Pass {delayed_}create_progress_dlg a pointer the top level window
so that we can properly associate a widget with create, update, and destroy events. Only used by Qt so far but it should be easy enough to add to GTK+. Rename ui/qt/progress_dialog.{h,cpp} to progress_bar.{h,cpp}. Show a progress bar in the status bar of the main window instead of creating a separate dialog. Note that we still need to add a "cancel" mechanism and display the task and item titles somewhere. Thus began the War Against Gratuitous Dialogs. svn path=/trunk/; revision=43833
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/funnel_stat.c2
-rw-r--r--ui/gtk/iax2_analysis.c2
-rw-r--r--ui/gtk/packet_list_store.c3
-rw-r--r--ui/gtk/packet_list_store.h2
-rw-r--r--ui/gtk/progress_dlg.c20
-rw-r--r--ui/gtk/rtp_analysis.c2
-rw-r--r--ui/progress_dlg.h38
-rw-r--r--ui/qt/QtShark.pro8
-rw-r--r--ui/qt/main_status_bar.cpp19
-rw-r--r--ui/qt/main_status_bar.h10
-rw-r--r--ui/qt/main_window.cpp7
-rw-r--r--ui/qt/main_window.h4
-rw-r--r--ui/qt/progress_bar.cpp145
-rw-r--r--ui/qt/progress_bar.h (renamed from ui/qt/progress_dialog.h)34
-rw-r--r--ui/qt/progress_dialog.cpp196
15 files changed, 244 insertions, 248 deletions
diff --git a/ui/gtk/funnel_stat.c b/ui/gtk/funnel_stat.c
index b8d4f97771..b4f63350b3 100644
--- a/ui/gtk/funnel_stat.c
+++ b/ui/gtk/funnel_stat.c
@@ -547,7 +547,7 @@ static gboolean funnel_open_file(const char* fname, const char* filter, const ch
typedef struct progdlg _funnel_progress_window_t;
static funnel_progress_window_t* funnel_new_progress_window(const gchar* label, const gchar* task, gboolean terminate_is_stop, gboolean *stop_flag) {
- return (funnel_progress_window_t*)create_progress_dlg(label, task, terminate_is_stop, stop_flag);
+ return (funnel_progress_window_t*)create_progress_dlg(top_level, label, task, terminate_is_stop, stop_flag);
}
static void funnel_update_progress(funnel_progress_window_t* win, float pr, const gchar* task) {
diff --git a/ui/gtk/iax2_analysis.c b/ui/gtk/iax2_analysis.c
index 3149b40b11..3fbc73dc8d 100644
--- a/ui/gtk/iax2_analysis.c
+++ b/ui/gtk/iax2_analysis.c
@@ -2318,7 +2318,7 @@ static gboolean copy_file(gchar *dest, gint channels, gint format, user_data_t *
return FALSE;
}
- progbar = create_progress_dlg("Saving voice in a file", dest, TRUE, &stop_flag);
+ progbar = create_progress_dlg(top_level, "Saving voice in a file", dest, TRUE, &stop_flag);
if (format == SAVE_AU_FORMAT) /* au format */
{
diff --git a/ui/gtk/packet_list_store.c b/ui/gtk/packet_list_store.c
index 0c82fb4b25..5036b5d6aa 100644
--- a/ui/gtk/packet_list_store.c
+++ b/ui/gtk/packet_list_store.c
@@ -839,7 +839,8 @@ packet_list_dissect_and_cache_all(PacketList *packet_list)
/* allow certain "interupts" to happen during this code. */
/* (Note that the progress_dlg window is set to "modal" */
/* so that clicking on other windows is disabled). */
- progbar = delayed_create_progress_dlg("Construct", "Columns",
+ progbar = delayed_create_progress_dlg(gtk_widget_get_window(packet_list->view),
+ "Construct", "Columns",
TRUE, &progbar_stop_flag,
&progbar_start_time, progbar_val);
diff --git a/ui/gtk/packet_list_store.h b/ui/gtk/packet_list_store.h
index 34ce0dfa94..4c5120e3a9 100644
--- a/ui/gtk/packet_list_store.h
+++ b/ui/gtk/packet_list_store.h
@@ -93,7 +93,7 @@ struct _PacketList
gint n_columns;
/**< Note: We need one extra column to store the entire PacketListRecord */
GType column_types[NUM_COL_FMTS+1];
- GtkWidget *view; /**< @todo XXX - Does this really belong here?? */
+ GtkWidget *view;
gint sort_id;
GtkSortType sort_order;
diff --git a/ui/gtk/progress_dlg.c b/ui/gtk/progress_dlg.c
index 8725948001..bb40c21034 100644
--- a/ui/gtk/progress_dlg.c
+++ b/ui/gtk/progress_dlg.c
@@ -49,7 +49,7 @@ struct progdlg {
GtkWidget *dlg_w; /* top-level window widget */
GTimeVal start_time;
GTimeVal last_time; /* last time it was updated */
-
+
GtkLabel *status_lb;
GtkLabel *elapsed_lb;
GtkLabel *time_left_lb;
@@ -83,7 +83,7 @@ struct progdlg {
* be read.
*/
progdlg_t *
-create_progress_dlg(const gchar *task_title, const gchar *item_title,
+create_progress_dlg(const gpointer top_level_window _U_, const gchar *task_title, const gchar *item_title,
gboolean terminate_is_stop, gboolean *stop_flag)
{
progdlg_t *dlg;
@@ -231,9 +231,9 @@ create_progress_dlg(const gchar *task_title, const gchar *item_title,
}
progdlg_t *
-delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title,
- gboolean terminate_is_stop, gboolean *stop_flag,
- const GTimeVal *start_time, gfloat progress)
+delayed_create_progress_dlg(const gpointer top_level_window, const gchar *task_title,
+ const gchar *item_title, gboolean terminate_is_stop,
+ gboolean *stop_flag, const GTimeVal *start_time, gfloat progress)
{
GTimeVal time_now;
gdouble delta_time;
@@ -289,7 +289,7 @@ delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title,
if (progress >= (delta_time / (delta_time + min_display)))
return NULL;
- dlg = create_progress_dlg(task_title, item_title, terminate_is_stop,
+ dlg = create_progress_dlg(top_level_window, task_title, item_title, terminate_is_stop,
stop_flag);
/*
@@ -351,21 +351,21 @@ update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status)
/* calculate some timing values */
g_get_current_time(&time_now);
-
+
delta_time = (time_now.tv_sec - dlg->last_time.tv_sec) * 1e6 +
time_now.tv_usec - dlg->last_time.tv_usec;
/* after the first time don't update more than every 100ms */
- if (dlg->last_time.tv_sec && delta_time < 100*1000)
+ if (dlg->last_time.tv_sec && delta_time < 100*1000)
return;
dlg->last_time = time_now;
delta_time = (time_now.tv_sec - dlg->start_time.tv_sec) * 1e6 +
time_now.tv_usec - dlg->start_time.tv_usec;
-
+
ul_percentage = (gulong) (percentage * 100);
ul_elapsed = (gulong) (delta_time / 1000 / 1000);
-
+
/* update labels */
g_snprintf(tmp, sizeof(tmp), "%lu%% of %s", ul_percentage, dlg->title);
gtk_window_set_title(GTK_WINDOW(dlg_w), tmp);
diff --git a/ui/gtk/rtp_analysis.c b/ui/gtk/rtp_analysis.c
index d987090f34..6733735465 100644
--- a/ui/gtk/rtp_analysis.c
+++ b/ui/gtk/rtp_analysis.c
@@ -2392,7 +2392,7 @@ static gboolean copy_file(gchar *dest, gint channels, gint format, user_data_t *
return FALSE;
}
- progbar = create_progress_dlg("Saving voice in a file", dest, TRUE, &stop_flag);
+ progbar = create_progress_dlg(top_level, "Saving voice in a file", dest, TRUE, &stop_flag);
if (format == SAVE_AU_FORMAT) /* au format */
{
diff --git a/ui/progress_dlg.h b/ui/progress_dlg.h
index d145750dd8..4531ade197 100644
--- a/ui/progress_dlg.h
+++ b/ui/progress_dlg.h
@@ -46,52 +46,56 @@ typedef struct progdlg progdlg_t;
* needs in order to manipulate the dialog, and return a pointer to
* it.
*
- * @param task_title the task to do, e.g. "Loading"
- * @param item_title the item to do, e.g. "capture.cap"
+ * @param widget UI widget to associate with the progress dialog, e.g.
+ * the main window.
+ * @param task_title The task to do, e.g. "Loading"
+ * @param item_title The item to do, e.g. "capture.cap"
* @param terminate_is_stop TRUE if the operation can't be cancelled, just
* stopped (i.e., it has a "Stop" button and clicking it doesn't undo
* anything already done), FALSE if it can
- * @param stop_flag a pointer to a Boolean variable that will be
+ * @param stop_flag A pointer to a Boolean variable that will be
* set to TRUE if the user hits that button
- * @return the newly created progress dialog
+ * @return The newly created progress dialog
*/
-progdlg_t *create_progress_dlg(const gchar *task_title, const gchar *item_title,
+progdlg_t *create_progress_dlg(const gpointer top_level_window, const gchar *task_title, const gchar *item_title,
gboolean terminate_is_stop, gboolean *stop_flag);
/**
* Create a progress dialog, but only if it's not likely to disappear
* immediately. This can be disconcerting for the user.
*
- * @param task_title the task to do, e.g. "Loading"
- * @param item_title the item to do, e.g. "capture.cap"
+ * @param top_level The top-level window associated with the progress update.
+ * May be NULL.
+ * @param task_title The task to do, e.g. "Loading"
+ * @param item_title The item to do, e.g. "capture.cap"
* @param terminate_is_stop TRUE if the operation can't be cancelled, just
* stopped (i.e., it has a "Stop" button and clicking it doesn't undo
* anything already done), FALSE if it can
- * @param stop_flag a pointer to a Boolean variable that will be
+ * @param stop_flag A pointer to a Boolean variable that will be
* set to TRUE if the user hits that button
- * @param start_time a pointer to a GTimeVal structure which holds
+ * @param start_time A pointer to a GTimeVal structure which holds
* the time at which the caller started to process the data
- * @param progress the current progress (0..1)
- * @return the newly created progress dialog
+ * @param progress The current progress (0..1)
+ * @return The newly created progress dialog
*/
progdlg_t *
-delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title,
+delayed_create_progress_dlg(const gpointer top_level_window, const gchar *task_title, const gchar *item_title,
gboolean terminate_is_stop, gboolean *stop_flag,
const GTimeVal *start_time, gfloat progress);
/**
* Update the progress information of the progress dialog box.
*
- * @param dlg the progress dialog from create_progress_dlg()
- * @param percentage the current percentage value (0..1)
- * @param status the new status string to show, e.g. "3000KB of 6000KB"
+ * @param dlg The progress dialog from create_progress_dlg()
+ * @param percentage The current percentage value (0..1)
+ * @param status the New status string to show, e.g. "3000KB of 6000KB"
*/
void update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status);
/**
- * Destroy the progress bar.
+ * Destroy or hide the progress bar.
*
- * @param dlg the progress dialog from create_progress_dlg()
+ * @param dlg The progress dialog from create_progress_dlg()
*/
void destroy_progress_dlg(progdlg_t *dlg);
diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro
index 7a527743c9..5ea86e92ff 100644
--- a/ui/qt/QtShark.pro
+++ b/ui/qt/QtShark.pro
@@ -86,7 +86,6 @@ win32:INCLUDEPATH += \
# Is there any way to do this automatically?
SOURCES_WS_C = \
../../airpcap_loader.c \
- ../../ui/alert_box.c \
../../capture-pcap-util.c \
../../capture.c \
../../capture_ifinfo.c \
@@ -147,7 +146,7 @@ SOURCES_QT_CPP = \
packet_list.cpp \
packet_list_model.cpp \
packet_list_record.cpp \
- progress_dialog.cpp \
+ progress_bar.cpp \
proto_tree.cpp \
qt_ui_utils.cpp \
recent_file_status.cpp \
@@ -178,7 +177,7 @@ HEADERS_QT_CPP = \
packet_list.h \
packet_list_model.h \
packet_list_record.h \
- progress_dialog.h \
+ progress_bar.h \
proto_tree.h \
qt_ui_utils.h \
qt_ui_utils.h \
@@ -311,3 +310,6 @@ TRANSLATIONS = \
ICON = ../../packaging/macosx/Resources/Wireshark.icns
win32: QMAKE_CLEAN += *.pdb
+
+
+
diff --git a/ui/qt/main_status_bar.cpp b/ui/qt/main_status_bar.cpp
index babe9ac01b..ae335e2652 100644
--- a/ui/qt/main_status_bar.cpp
+++ b/ui/qt/main_status_bar.cpp
@@ -36,6 +36,7 @@
#include "ui/main_statusbar.h"
#include <QSplitter>
+#include <QHBoxLayout>
#ifdef HAVE_LIBPCAP
#define DEF_READY_MESSAGE QObject::tr(" Ready to load or capture")
@@ -128,11 +129,25 @@ MainStatusBar::MainStatusBar(QWidget *parent) :
{
QSplitter *splitter = new QSplitter(this);
QString readyMsg(DEF_READY_MESSAGE);
-
+ QWidget *infoProgress = new QWidget(this);
+ QHBoxLayout *infoProgressHB = new QHBoxLayout(infoProgress);
+ int pbMargin = infoProgressHB->contentsMargins().left();
+
+ infoProgressHB->setMargin(0);
+ infoProgressHB->setContentsMargins(0, 0, 0, 0);
+ m_progressBar.setStyleSheet(QString(
+ "ProgressBar {"
+// " margin-left: %1px;"
+ " max-width: 8em;"
+ "}")
+ .arg(pbMargin)
+ );
// XXX - Add the expert level icon
m_infoStatus.setTemporaryContext(STATUS_CTX_TEMPORARY);
- splitter->addWidget(&m_infoStatus);
+ infoProgressHB->addWidget(&m_infoStatus);
+ infoProgressHB->addWidget(&m_progressBar);
+ splitter->addWidget(infoProgress);
splitter->addWidget(&m_packetStatus);
splitter->addWidget(&m_profileStatus);
diff --git a/ui/qt/main_status_bar.h b/ui/qt/main_status_bar.h
index 505078257d..0545f659fe 100644
--- a/ui/qt/main_status_bar.h
+++ b/ui/qt/main_status_bar.h
@@ -1,4 +1,4 @@
-/* mainStatus_bar.h
+/* main_status_bar.h
*
* $Id$
*
@@ -21,10 +21,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef MAINStatus_BAR_H
-#define MAINStatus_BAR_H
+#ifndef MAIN_STATUS_BAR_H
+#define MAIN_STATUS_BAR_H
#include "label_stack.h"
+#include "progress_bar.h"
#include <QStatusBar>
@@ -36,6 +37,7 @@ public:
private:
LabelStack m_infoStatus;
+ ProgressBar m_progressBar;
LabelStack m_packetStatus;
LabelStack m_profileStatus;
@@ -56,4 +58,4 @@ public slots:
void popProfileStatus();
};
-#endif // MAINStatus_BAR_H
+#endif // MAIN_STATUS_BAR_H
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 2cfa31038d..ecd93648dc 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -322,9 +322,9 @@ void MainWindow::openCaptureFile(QString &cfPath)
/* Try to open the capture file. */
if (cf_open(&cfile, cfPath.toUtf8().constData(), FALSE, &err) != CF_OK) {
/* We couldn't open it; don't dismiss the open dialog box,
- just leave it around so that the user can, after they
- dismiss the alert box popped up for the open error,
- try again. */
+ just leave it around so that the user can, after they
+ dismiss the alert box popped up for the open error,
+ try again. */
if (rfcode != NULL)
dfilter_free(rfcode);
cfPath.clear();
@@ -332,6 +332,7 @@ void MainWindow::openCaptureFile(QString &cfPath)
}
capFile = &cfile;
+ cfile.window = this;
switch (cf_read(&cfile, FALSE)) {
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index a624d5b0a5..39edf4ebe9 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -36,6 +36,7 @@
#include <QSplitter>
#include "main_welcome.h"
#include "display_filter_combo.h"
+#include "progress_bar.h"
class QAction;
@@ -62,6 +63,9 @@ private:
DisplayFilterCombo *dfComboBox;
capture_file *capFile;
+signals:
+ void showProgress(progdlg_t **dlg_p, bool animate, const QString message, bool terminate_is_stop, bool *stop_flag, float pct);
+
public slots:
void captureFileReadStarted(const capture_file *cf);
void captureFileReadFinished(const capture_file *cf);
diff --git a/ui/qt/progress_bar.cpp b/ui/qt/progress_bar.cpp
new file mode 100644
index 0000000000..9c2c003640
--- /dev/null
+++ b/ui/qt/progress_bar.cpp
@@ -0,0 +1,145 @@
+/* progress_bar.cpp
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "progress_bar.h"
+
+#include "wireshark_application.h"
+
+#include <QPropertyAnimation>
+
+static progdlg_t *
+common_create_progress_dlg(bool animate, const gpointer top_level_window,
+ gboolean terminate_is_stop, gboolean *stop_flag,
+ int value)
+{
+ ProgressBar *pb;
+ QWidget *main_window;
+
+ g_warning("ccpd %d %p", animate, top_level_window);
+ if (!top_level_window) {
+ return NULL;
+ }
+
+ g_warning("got tlw");
+ main_window = qobject_cast<QWidget *>((QObject *)top_level_window);
+
+ if (!main_window) {
+ return NULL;
+ }
+
+ g_warning("got mw");
+ pb = main_window->findChild<ProgressBar *>();
+
+ if (!pb) {
+ return NULL;
+ }
+ g_warning("got pb");
+ return pb->show(animate, terminate_is_stop, stop_flag, value);
+}
+
+progdlg_t *
+create_progress_dlg(const gpointer top_level_window, const gchar *task_title, const gchar *item_title,
+ gboolean terminate_is_stop, gboolean *stop_flag,
+ const GTimeVal *start_time, gfloat progress)
+{
+ Q_UNUSED(task_title);
+ Q_UNUSED(item_title);
+ Q_UNUSED(start_time);
+
+ return common_create_progress_dlg(false, top_level_window, terminate_is_stop, stop_flag, progress * 100);
+}
+
+progdlg_t *
+delayed_create_progress_dlg(const gpointer top_level_window, const gchar *task_title, const gchar *item_title,
+ gboolean terminate_is_stop, gboolean *stop_flag,
+ const GTimeVal *start_time, gfloat progress)
+{
+ Q_UNUSED(task_title);
+ Q_UNUSED(item_title);
+ Q_UNUSED(start_time);
+
+ return common_create_progress_dlg(true, top_level_window, terminate_is_stop, stop_flag, progress * 100);
+}
+
+/*
+ * Update the progress information of the progress bar box.
+ */
+void
+update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status)
+{
+ Q_UNUSED(status);
+// GtkWidget *dlg_w = dlg->dlg_w;
+// GtkWidget *prog_bar;
+
+ dlg->progressBar->setValue(percentage * 100);
+
+ /*
+ * Flush out the update and process any input events.
+ */
+ WiresharkApplication::processEvents();
+}
+
+/*
+ * Destroy the progress bar.
+ */
+void
+destroy_progress_dlg(progdlg_t *dlg)
+{
+ dlg->progressBar->hide();
+}
+
+// XXX - Add a "stop what you're doing this instant" button.
+// XXX - We need to show the task and item titles. Maybe as a tooltip or popped
+// into our sibling status message?
+ProgressBar::ProgressBar(QWidget *parent) :
+ QProgressBar(parent)
+{
+ m_dlg.progressBar = this;
+ m_dlg.topLevelWindow = window();
+ hide();
+}
+
+progdlg_t * ProgressBar::show(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value) {
+
+ m_terminate_is_stop = terminate_is_stop;
+ m_stop_flag = stop_flag;
+
+ setValue(value);
+
+ // http://stackoverflow.com/questions/3930904/how-to-animate-widget-transparency-in-qt4
+ if (animate) {
+ QPropertyAnimation animate = new QPropertyAnimation(this, "windowOpacity", this);
+
+ animate.setDuration(2 * 1000);
+ animate.setStartValue(1);
+ animate.setEndValue(0);
+ animate.start();
+ }
+ QProgressBar::show();
+
+ return &m_dlg;
+}
diff --git a/ui/qt/progress_dialog.h b/ui/qt/progress_bar.h
index 89d1aa2534..1195c588a9 100644
--- a/ui/qt/progress_dialog.h
+++ b/ui/qt/progress_bar.h
@@ -1,4 +1,4 @@
-/* progress_dialog.h
+/* progress_bar.h
*
* $Id$
*
@@ -21,21 +21,39 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef PROGRESS_DIALOG_H
-#define PROGRESS_DIALOG_H
+#ifndef PROGRESS_BAR_H
+#define PROGRESS_BAR_H
-#include <QProgressDialog>
+#include <glib.h>
-class ProgressDialog : public QProgressDialog
+#include "ui/progress_dlg.h"
+
+#include <QProgressBar>
+
+class ProgressBar;
+
+// Define the structure describing a progress dialog.
+struct progdlg {
+ ProgressBar *progressBar; // This progress bar
+ QWidget *topLevelWindow; // Top-level window widget
+};
+
+class ProgressBar : public QProgressBar
{
Q_OBJECT
public:
- explicit ProgressDialog(QWidget *parent = 0);
+ explicit ProgressBar(QWidget *parent = 0);
+ progdlg_t *show(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value);
-signals:
+private:
+ progdlg_t m_dlg;
+ QString m_message;
+ QString m_status;
+ bool m_terminate_is_stop;
+ gboolean *m_stop_flag;
public slots:
};
-#endif // PROGRESS_DIALOG_H
+#endif // PROGRESS_BAR_H
diff --git a/ui/qt/progress_dialog.cpp b/ui/qt/progress_dialog.cpp
deleted file mode 100644
index 1c2f70ae32..0000000000
--- a/ui/qt/progress_dialog.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/* progress_dialog.cpp
- *
- * $Id$
- *
- * Wireshark - Network traffic analyzer
- * By Gerald Combs <gerald@wireshark.org>
- * Copyright 1998 Gerald Combs
- *
- * 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
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <glib.h>
-
-#include "progress_dialog.h"
-
-#include "ui/progress_dlg.h"
-
-#include "wireshark_application.h"
-
-progdlg_t *
-delayed_create_progress_dlg(const gchar *task_title, const gchar *item_title,
- gboolean terminate_is_stop, gboolean *stop_flag,
- const GTimeVal *start_time, gfloat progress)
-{
- GTimeVal time_now;
- gdouble delta_time;
- gdouble min_display;
- progdlg_t *dlg = NULL;
-
-#define INIT_DELAY 0.1 * 1e6
-#define MIN_DISPLAY_DEFAULT 2.0 * 1e6
-
- /* Create a progress dialog, but only if it's not likely to disappear
- * immediately, which can be disconcerting for the user.
- *
- * Arguments are as for create_progress_dlg(), plus:
- *
- * (a) A pointer to a GTimeVal structure which holds the time at which
- * the caller started to process the data.
- * (b) The current progress as a real number between 0 and 1.
- */
-
- g_get_current_time(&time_now);
-
- /* Get the time elapsed since the caller started processing the data */
-
- delta_time = (time_now.tv_sec - start_time->tv_sec) * 1e6 +
- time_now.tv_usec - start_time->tv_usec;
-
- /* Do nothing for the first INIT_DELAY microseconds */
-
- if (delta_time < INIT_DELAY)
- return NULL;
-
- /* If we create the progress dialog we want it to be displayed for a
- * minimum of MIN_DISPLAY_DEFAULT microseconds. However, if we
- * previously estimated that the progress dialog didn't need to be
- * created and the caller's processing is slowing down (perhaps due
- * to the action of the operating system's scheduler on a compute-
- * intensive task), we tail off the minimum display time such that
- * the progress dialog will always be created after
- * 2*MIN_DISPLAY_DEFAULT microseconds.
- */
-
- if (delta_time <= INIT_DELAY + MIN_DISPLAY_DEFAULT)
- min_display = MIN_DISPLAY_DEFAULT;
- else
- min_display = 2 * MIN_DISPLAY_DEFAULT - delta_time;
- /* = MIN_DISPLAY_DEFAULT - (delta_time - MIN_DISPLAY_DEFAULT) */
-
- /* Assuming the progress increases linearly, see if the progress
- * dialog would be displayed for at least min_display microseconds if
- * we created it now.
- */
-
- if (progress >= (delta_time / (delta_time + min_display)))
- return NULL;
-
- g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: delayed_create_progress_dlg tt: %s it: %s", task_title, item_title);
-// dlg = create_progress_dlg(task_title, item_title, terminate_is_stop,
-// stop_flag);
-
- /*
- * Flush out the dialog so we don't see an "empty" one until first update.
- */
- //WiresharkApplication::processEvents();
-
- /* set dialog start_time to the start of processing, not box creation */
-// dlg->start_time = *start_time;
-
- return dlg;
-}
-
-/*
- * Update the progress information of the progress dialog box.
- */
-void
-update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status)
-{
-// GtkWidget *dlg_w = dlg->dlg_w;
-// GtkWidget *prog_bar;
- GTimeVal time_now;
- gdouble delta_time;
- gulong ul_left;
- gulong ul_elapsed;
- gulong ul_percentage;
- gchar tmp[100];
-
-
- /* calculate some timing values */
- g_get_current_time(&time_now);
-
-// delta_time = (time_now.tv_sec - dlg->last_time.tv_sec) * 1e6 +
-// time_now.tv_usec - dlg->last_time.tv_usec;
-
- g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: update_progress_dlg: %0.2f %s", percentage, status);
-
-// /* after the first time don't update more than every 100ms */
-// if (dlg->last_time.tv_sec && delta_time < 100*1000)
-// return;
-
-// dlg->last_time = time_now;
-// delta_time = (time_now.tv_sec - dlg->start_time.tv_sec) * 1e6 +
-// time_now.tv_usec - dlg->start_time.tv_usec;
-
-// ul_percentage = (gulong) (percentage * 100);
-// ul_elapsed = (gulong) (delta_time / 1000 / 1000);
-
-// /* update labels */
-// g_snprintf(tmp, sizeof(tmp), "%lu%% of %s", ul_percentage, dlg->title);
-// gtk_window_set_title(GTK_WINDOW(dlg_w), tmp);
-
-// gtk_label_set_text(dlg->status_lb, status);
-
-// g_snprintf(tmp, sizeof(tmp), "%lu%%", ul_percentage);
-// gtk_label_set_text(dlg->percentage_lb, tmp);
-
-// g_snprintf(tmp, sizeof(tmp), "%02lu:%02lu", ul_elapsed / 60,
-// ul_elapsed % 60);
-// gtk_label_set_text(dlg->elapsed_lb, tmp);
-
-// /* show "Time Left" only,
-// * if at least 5% and 3 seconds running (to get a useful estimation) */
-// if (ul_percentage >= 5 && delta_time >= 3 * 1e6) {
-// ul_left = (gulong) ((delta_time / percentage - delta_time) / 1000 / 1000);
-
-// g_snprintf(tmp, sizeof(tmp), "%02lu:%02lu", ul_left / 60,
-// ul_left % 60);
-// gtk_label_set_text(dlg->time_left_lb, tmp);
-// }
-
-// /* update progress bar */
-// prog_bar = g_object_get_data(G_OBJECT(dlg_w), PROG_BAR_KEY);
-// gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(prog_bar), percentage);
-
- /*
- * Flush out the update and process any input events.
- */
- WiresharkApplication::processEvents();
- }
-
-/*
- * Destroy the progress dialog.
- */
-void
-destroy_progress_dlg(progdlg_t *dlg)
-{
-// GtkWidget *dlg_w = dlg->dlg_w;
-
- g_log(NULL, G_LOG_LEVEL_DEBUG, "FIX: destroy_progress_dlg");
-// window_destroy(GTK_WIDGET(dlg_w));
-// g_free(dlg->title);
-// g_free(dlg);
-}
-
-
-ProgressDialog::ProgressDialog(QWidget *parent) :
- QProgressDialog(parent)
-{
-}