summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-rw-r--r--ui/gtk/capture_file_dlg.c2
-rw-r--r--ui/gtk/color_dlg.c2
-rw-r--r--ui/gtk/color_utils.c22
-rw-r--r--ui/gtk/color_utils.h34
-rw-r--r--ui/gtk/main.c6
-rw-r--r--ui/qt/color_utils.cpp15
-rw-r--r--ui/qt/coloring_rules_dialog.cpp23
-rw-r--r--ui/qt/main_window_slots.cpp2
-rw-r--r--ui/qt/wireshark_application.cpp2
-rw-r--r--ui/ui_util.h1
-rw-r--r--ui/win32/file_dlg_win32.c2
11 files changed, 55 insertions, 56 deletions
diff --git a/ui/gtk/capture_file_dlg.c b/ui/gtk/capture_file_dlg.c
index bf4a7ecc99..b1cf035f5e 100644
--- a/ui/gtk/capture_file_dlg.c
+++ b/ui/gtk/capture_file_dlg.c
@@ -2277,7 +2277,7 @@ file_color_import_cmd_cb(GtkWidget *color_filters, gpointer filter_list _U_)
}
/* Try to open the color filter file. */
- if (!color_filters_import(cf_name, color_filters, &err_msg, initialize_color, color_filter_add_cb)) {
+ if (!color_filters_import(cf_name, color_filters, &err_msg, color_filter_add_cb)) {
/* 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,
diff --git a/ui/gtk/color_dlg.c b/ui/gtk/color_dlg.c
index edb6c6da13..ed016b5ee0 100644
--- a/ui/gtk/color_dlg.c
+++ b/ui/gtk/color_dlg.c
@@ -963,7 +963,7 @@ color_clear_cmd(GtkWidget *widget)
}
/* try to read the global filters */
- if (!color_filters_read_globals(color_filters, &err_msg, initialize_color, color_filter_add_cb))
+ if (!color_filters_read_globals(color_filters, &err_msg, color_filter_add_cb))
{
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
diff --git a/ui/gtk/color_utils.c b/ui/gtk/color_utils.c
index 65889a2fbf..de34afc395 100644
--- a/ui/gtk/color_utils.c
+++ b/ui/gtk/color_utils.c
@@ -1,5 +1,5 @@
/* color_utils.c
- * Toolkit-dependent implementations of routines to handle colors.
+ * GTK+ color conversion routines.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
@@ -28,25 +28,6 @@
#include "ui/gtk/color_utils.h"
-/*
- * Initialize a color with R, G, and B values, including any toolkit-dependent
- * work that needs to be done.
- * Returns TRUE if it succeeds, FALSE if it fails.
- */
-gboolean
-initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue)
-{
- GdkColor gdk_color;
-
- gdk_color.pixel = 0;
- gdk_color.red = red;
- gdk_color.green = green;
- gdk_color.blue = blue;
-
- gdkcolor_to_color_t(color, &gdk_color);
- return TRUE;
-}
-
void
color_t_to_gdkcolor(GdkColor *target, const color_t *source)
{
@@ -64,6 +45,7 @@ color_t_to_gdkRGBAcolor(GdkRGBA *target, const color_t *source)
target->green = source->green / 65535.0;
target->blue = source->blue / 65535.0;
}
+
void
gdkcolor_to_color_t(color_t *target, const GdkColor *source)
{
diff --git a/ui/gtk/color_utils.h b/ui/gtk/color_utils.h
index 1f8fcf2ec9..15c4953b62 100644
--- a/ui/gtk/color_utils.h
+++ b/ui/gtk/color_utils.h
@@ -1,5 +1,5 @@
-/* colors.h
- * Definitions for color structures and routines
+/* color_utils.h
+ * Definitions for GTK+ color conversion routines.
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
@@ -20,8 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef __COLORS_H__
-#define __COLORS_H__
+#ifndef __COLOR_UTILS_H__
+#define __COLOR_UTILS_H__
#include "ui/gtk/gui_utils.h"
#include <epan/color_filters.h>
@@ -36,15 +36,39 @@
* @param source the source color_t
*/
void color_t_to_gdkcolor(GdkColor *target, const color_t *source);
+
+/** Convert color_t to GdkRGBA.
+ *
+ * @param target the GdkRGBA to be filled
+ * @param source the source color_t
+ */
void color_t_to_gdkRGBAcolor(GdkRGBA *target, const color_t *source);
+
/** Convert GdkColor to color_t.
*
* @param target the source color_t
* @param source the GdkColor to be filled
*/
void gdkcolor_to_color_t(color_t *target, const GdkColor *source);
+
+/** Convert GdkRGBA to color_t.
+ *
+ * @param target the source color_t
+ * @param source the GdkRGBA to be filled
+ */
void gdkRGBAcolor_to_color_t(color_t *target, const GdkRGBA *source);
+/** Convert GdkColor to GdkRGBA.
+ *
+ * @param target the source GdkColor
+ * @param source the GdkRGBA to be filled
+ */
void GdkColor_to_GdkRGBA(GdkRGBA *target, const GdkColor *source);
+
+/** Convert GdkRGBA to GdkColor.
+ *
+ * @param target the source GdkColor
+ * @param source the GdkRGBA to be filled
+ */
void gdkRGBAcolor_to_GdkColor(GdkColor *target, const GdkRGBA *source);
-#endif /* __COLORS_H__ */
+#endif /* __COLOR_UTILS_H__ */
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index 78fdf27188..afac29a273 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -3177,7 +3177,7 @@ main(int argc, char *argv[])
dnd_init(top_level);
- if (!color_filters_init(&err_msg, initialize_color, color_filter_add_cb)) {
+ if (!color_filters_init(&err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
}
@@ -3963,7 +3963,7 @@ void change_configuration_profile (const gchar *profile_name)
}
/* Reload color filters */
- if (!color_filters_reload(&err_msg, initialize_color, color_filter_add_cb)) {
+ if (!color_filters_reload(&err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
}
@@ -3989,7 +3989,7 @@ main_fields_changed (void)
gchar* err_msg = NULL;
/* Reload color filters */
- if (!color_filters_reload(&err_msg, initialize_color, color_filter_add_cb)) {
+ if (!color_filters_reload(&err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
}
diff --git a/ui/qt/color_utils.cpp b/ui/qt/color_utils.cpp
index e6576b0938..204aa59f80 100644
--- a/ui/qt/color_utils.cpp
+++ b/ui/qt/color_utils.cpp
@@ -54,8 +54,21 @@ ColorUtils::ColorUtils(QObject *parent) :
{
}
+//
+// A color_t has RGB values in [0,65535].
+// Qt RGB colors have RGB values in [0,255].
+//
+// 65535/255 = 257 = 0x0101, so converting from [0,255] to
+// [0,65535] involves just shifting the 8-bit value left 8 bits
+// and ORing them together.
+//
+// Converting from [0,65535] to [0,255] without rounding involves
+// just shifting the 16-bit value right 8 bits; I guess you could
+// round them by adding 0x80 to the value before shifting.
+//
QColor ColorUtils::fromColorT (const color_t *color) {
if (!color) return QColor();
+ // Convert [0,65535] values to [0,255] values
return QColor(color->red >> 8, color->green >> 8, color->blue >> 8);
}
@@ -67,6 +80,8 @@ QColor ColorUtils::fromColorT(color_t color)
const color_t ColorUtils::toColorT(const QColor color)
{
color_t colort;
+
+ // Convert [0,255] values to [0,65535] values
colort.red = (color.red() << 8) | color.red();
colort.green = (color.green() << 8) | color.green();
colort.blue = (color.blue() << 8) | color.blue();
diff --git a/ui/qt/coloring_rules_dialog.cpp b/ui/qt/coloring_rules_dialog.cpp
index 264cda04d8..5ba48a91a6 100644
--- a/ui/qt/coloring_rules_dialog.cpp
+++ b/ui/qt/coloring_rules_dialog.cpp
@@ -324,7 +324,7 @@ void ColoringRulesDialog::on_buttonBox_clicked(QAbstractButton *button)
QString file_name = QFileDialog::getOpenFileName(this, wsApp->windowTitleString(tr("Import Coloring Rules")),
wsApp->lastOpenDir().path());
gchar* err_msg = NULL;
- if (!color_filters_import(file_name.toUtf8().constData(), this, &err_msg, initialize_color, color_filter_add_cb)) {
+ if (!color_filters_import(file_name.toUtf8().constData(), this, &err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
}
@@ -436,27 +436,6 @@ void ColoringRulesTreeDelegate::ruleNameChanged(const QString name)
}
-/*
- * Initialize a color with R, G, and B values, including any toolkit-dependent
- * work that needs to be done.
- */
-gboolean
-initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue)
-{
- QColor qc;
-
- // color_t uses 16-bit components to match Gtk+. Qt use 8.
- qc.setRgb(red>>8, green>>8, blue>>8);
- if (!qc.isValid())
- return FALSE;
-
- // Match what color_filters.c does.
- color->red = red;
- color->green = green;
- color->blue = blue;
- return TRUE;
-}
-
// Callback for color_filters_clone.
void
color_filter_add_cb(color_filter_t *colorf, gpointer user_data)
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index c396236eb2..2cc5755626 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -1398,7 +1398,7 @@ void MainWindow::checkDisplayFilter()
void MainWindow::fieldsChanged()
{
gchar *err_msg = NULL;
- if (!color_filters_reload(&err_msg, initialize_color, color_filter_add_cb)) {
+ if (!color_filters_reload(&err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
}
diff --git a/ui/qt/wireshark_application.cpp b/ui/qt/wireshark_application.cpp
index ec648a56fc..2ba9cfdcfd 100644
--- a/ui/qt/wireshark_application.cpp
+++ b/ui/qt/wireshark_application.cpp
@@ -394,7 +394,7 @@ void WiresharkApplication::setConfigurationProfile(const gchar *profile_name)
}
/* Reload color filters */
- if (!color_filters_reload(&err_msg, initialize_color, color_filter_add_cb)) {
+ if (!color_filters_reload(&err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
}
diff --git a/ui/ui_util.h b/ui/ui_util.h
index fd5f1daedb..e973549849 100644
--- a/ui/ui_util.h
+++ b/ui/ui_util.h
@@ -89,7 +89,6 @@ void packet_list_resize_column(gint col);
files
Function names make it clear where they are coming from
*/
-gboolean initialize_color(color_t *color, guint16 red, guint16 green, guint16 blue);
void color_filter_add_cb(color_filter_t *colorf, gpointer user_data);
#ifdef __cplusplus
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index 747819024b..3b8c0614df 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -978,7 +978,7 @@ win32_import_color_file(HWND h_wnd, gpointer color_filters) {
/* XXX - Support export limited to selected filters */
if (GetOpenFileName(ofn)) {
g_free( (void *) ofn);
- if (!color_filters_import(utf_16to8(file_name), color_filters, &err_msg, initialize_color, color_filter_add_cb)) {
+ if (!color_filters_import(utf_16to8(file_name), color_filters, &err_msg, color_filter_add_cb)) {
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_msg);
g_free(err_msg);
return;