Make colors work on GTK3
authoretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 23 Aug 2011 13:49:37 +0000 (13:49 +0000)
committeretxrab <etxrab@f5534014-38df-0310-8fa8-9805f1628bb7>
Tue, 23 Aug 2011 13:49:37 +0000 (13:49 +0000)
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@38687 f5534014-38df-0310-8fa8-9805f1628bb7

gtk/io_stat.c
gtk/rtp_analysis.c
gtk/tcp_graph.c

index 0466e9d3a15b539c2a618debb9d14b54785519a4..880fa8a6bbefc7efdd713448186a4087918c3562 100644 (file)
@@ -1592,7 +1592,7 @@ scrollbar_changed(GtkWidget *widget _U_, gpointer user_data)
 }
 #if GTK_CHECK_VERSION(3,0,0)
 static gboolean
-draw_area_draw_event(GtkWidget *widget, cairo_t *cr, gpointer user_data)
+draw_area_draw(GtkWidget *widget, cairo_t *cr, gpointer user_data)
 {
        io_stat_t *io = user_data;
        GtkAllocation allocation;
@@ -1635,7 +1635,7 @@ create_draw_area(io_stat_t *io, GtkWidget *box)
 
        /* signals needed to handle backing pixmap */
 #if GTK_CHECK_VERSION(3,0,0)
-       g_signal_connect(io->draw_area, "draw", G_CALLBACK(draw_area_draw_event), io);
+       g_signal_connect(io->draw_area, "draw", G_CALLBACK(draw_area_draw), io);
 #else
        g_signal_connect(io->draw_area, "expose-event", G_CALLBACK(draw_area_expose_event), io);
 #endif
@@ -2196,7 +2196,6 @@ create_filter_box(io_stat_graph_t *gio, GtkWidget *box, int num)
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
 
 #if GTK_CHECK_VERSION(3,0,0)
-       /* Fix me: Add the GTK 3.0 equivalents */
        gtk_widget_override_color(label, GTK_STATE_NORMAL, &gio->rgba_color);
        gtk_widget_override_color(label, GTK_STATE_ACTIVE, &gio->rgba_color);
        gtk_widget_override_color(label, GTK_STATE_PRELIGHT, &gio->rgba_color);
index 8541e3a35bde38b3ec3234f31da63be23a5bde31..4f1da96b3938031d862586316228c38148d1867d 100644 (file)
@@ -145,6 +145,9 @@ typedef struct _dialog_graph_graph_t {
        gboolean display;
        GtkWidget *display_button;
        int hf_index;
+#if GTK_CHECK_VERSION(3,0,0)
+       GdkRGBA rgba_color;
+#endif
        GdkColor color;
        gchar title[100];
 } dialog_graph_graph_t;
@@ -1421,15 +1424,26 @@ static void quit(GtkWidget *widget _U_, user_data_t *user_data)
 }
 
 /****************************************************************************/
+#if GTK_CHECK_VERSION(3,0,0)
+static gboolean draw_area_draw(GtkWidget *widget, cairo_t *cr, gpointer data)
+{
+       user_data_t *user_data = data;
+       GtkAllocation allocation;
+
+       gtk_widget_get_allocation (widget, &allocation);
+
+       cairo_set_source_surface (cr, user_data->dlg.dialog_graph.surface, 0, 0); 
+       cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+       cairo_fill (cr);
+
+       return FALSE;
+}
+#else
 static gint expose_event(GtkWidget *widget, GdkEventExpose *event)
 {
-       user_data_t *user_data;
+       user_data_t *user_data = data;
        cairo_t *cr = gdk_cairo_create (gtk_widget_get_window(widget));
 
-       user_data=(user_data_t *)g_object_get_data(G_OBJECT(widget), "user_data_t");
-       if(!user_data){
-               exit(10);
-       }
 
 #if GTK_CHECK_VERSION(2,22,0)
        cairo_set_source_surface (cr, user_data->dlg.dialog_graph.surface, 0, 0); 
@@ -1443,7 +1457,7 @@ static gint expose_event(GtkWidget *widget, GdkEventExpose *event)
 
        return FALSE;
 }
-
+#endif
 /****************************************************************************/
 static gint configure_event(GtkWidget *widget, GdkEventConfigure *event _U_)
 {
@@ -1536,12 +1550,15 @@ static void create_draw_area(user_data_t* user_data, GtkWidget *box)
 {
        user_data->dlg.dialog_graph.draw_area=gtk_drawing_area_new();
        g_signal_connect(user_data->dlg.dialog_graph.draw_area, "destroy", G_CALLBACK(quit), user_data);
-       g_object_set_data(G_OBJECT(user_data->dlg.dialog_graph.draw_area), "user_data_t", user_data);
 
        gtk_widget_set_size_request(user_data->dlg.dialog_graph.draw_area, user_data->dlg.dialog_graph.surface_width, user_data->dlg.dialog_graph.surface_height);
 
        /* signals needed to handle backing pixmap */
-       g_signal_connect(user_data->dlg.dialog_graph.draw_area, "expose_event", G_CALLBACK(expose_event), NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+       g_signal_connect(user_data->dlg.dialog_graph.draw_area, "draw", G_CALLBACK(draw_area_draw), user_data);
+#else
+       g_signal_connect(user_data->dlg.dialog_graph.draw_area, "expose_event", G_CALLBACK(expose_event), user_data);
+#endif
        g_signal_connect(user_data->dlg.dialog_graph.draw_area, "configure_event", G_CALLBACK(configure_event), user_data);
 
        gtk_widget_show(user_data->dlg.dialog_graph.draw_area);
@@ -1606,7 +1623,11 @@ static void create_filter_box(dialog_graph_graph_t *dgg, GtkWidget *box, int num
        gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
 
 #if GTK_CHECK_VERSION(3,0,0)
-       /* Fix me: Add the GTK 3.0 equivalents */
+       gtk_widget_override_color(label, GTK_STATE_NORMAL, &dgg->rgba_color);
+       gtk_widget_override_color(label, GTK_STATE_ACTIVE, &dgg->rgba_color);
+       gtk_widget_override_color(label, GTK_STATE_PRELIGHT, &dgg->rgba_color);
+       gtk_widget_override_color(label, GTK_STATE_SELECTED, &dgg->rgba_color);
+       gtk_widget_override_color(label, GTK_STATE_INSENSITIVE, &dgg->rgba_color);
 #else  
        gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &dgg->color);
        gtk_widget_modify_fg(label, GTK_STATE_ACTIVE, &dgg->color);
@@ -3645,13 +3666,24 @@ void rtp_analysis(
        int fd;
        int i;
        static GdkColor col[MAX_GRAPHS] = {
-               {0,     0x0000, 0x0000, 0x0000},
-               {0,     0xffff, 0x0000, 0x0000},
-               {0,     0x0000, 0xffff, 0x0000},
-               {0,             0xdddd, 0xcccc, 0x6666},
-               {0,             0x6666, 0xcccc, 0xdddd},
-               {0,     0x0000, 0x0000, 0xffff}
+               {0,     0x0000, 0x0000, 0x0000}, /* Black */
+               {0,     0xffff, 0x0000, 0x0000}, /* Red */
+               {0,     0x0000, 0xffff, 0x0000}, /* Green */
+               {0,             0xdddd, 0xcccc, 0x6666}, /* Light amber yellow */
+               {0,             0x6666, 0xcccc, 0xdddd}, /* Light bluish cyan */
+               {0,     0x0000, 0x0000, 0xffff}  /* Blue */
+       };
+#if GTK_CHECK_VERSION(3,0,0)
+       static GdkRGBA rgba_col[MAX_GRAPHS] = {
+               {0.0,   0.0,   0.0,   1.0}, /* Black */
+               {1.0,   0.0,   0.1,   1.0}, /* Red */
+               {0.0,   1.0,   0.0,   1.0}, /* Green */
+               {0.867, 0.800, 0.400, 1.0}, /* Light amber yellow */
+               {0.400, 0.800, 0.867, 1.0}, /* Light bluish cyan */
+               {0.0,   0.0,   1.0,   1.0}, /* Blue */
        };
+#endif
+
        char *tempname;
 
        /* init */
@@ -3711,6 +3743,12 @@ void rtp_analysis(
                user_data->dlg.dialog_graph.graph[i].color.red=col[i].red;
                user_data->dlg.dialog_graph.graph[i].color.green=col[i].green;
                user_data->dlg.dialog_graph.graph[i].color.blue=col[i].blue;
+#if GTK_CHECK_VERSION(3,0,0)
+               user_data->dlg.dialog_graph.graph[i].rgba_color.red=rgba_col[i].red;
+               user_data->dlg.dialog_graph.graph[i].rgba_color.green=rgba_col[i].green;
+               user_data->dlg.dialog_graph.graph[i].rgba_color.blue=rgba_col[i].blue;
+               user_data->dlg.dialog_graph.graph[i].rgba_color.alpha=rgba_col[i].alpha;
+#endif
                user_data->dlg.dialog_graph.graph[i].display=TRUE;
                user_data->dlg.dialog_graph.graph[i].display_button=NULL;
                user_data->dlg.dialog_graph.graph[i].ud=user_data;
index d89d90b71cc5244d5307c0ac6da9eca64d5dfb81..16718e2db56d51f49edc4e37a7bc45d2ca2497f0 100644 (file)
@@ -58,6 +58,7 @@
 #include "gtk/gui_utils.h"
 #include "gtk/dlg_utils.h"
 #include "gtk/gui_stat_menu.h"
+#include "gtk/color_utils.h"
 
 #include "gtk/old-gtk-compat.h"
 
@@ -2927,8 +2928,8 @@ static int ellipse_detect_collision (struct element *e, int x, int y)
 
 static void cross_xor (struct graph *g, int x, int y)
 {
-#if GTK_CHECK_VERSION(3,0,0)
-       GdkColor color_gray15 = {0x0, 0x2626, 0x2626, 0x2626};
+//#if GTK_CHECK_VERSION(3,0,0)
+       //GdkColor color_gray15 = {0x0, 0x2626, 0x2626, 0x2626};
        cairo_t *cr;
 
        /* XXX Fix me: lines do not disapere */
@@ -2937,7 +2938,7 @@ static void cross_xor (struct graph *g, int x, int y)
                /* Draw horisontal line */
                cr = gdk_cairo_create (gtk_widget_get_window(g->drawing_area));
                cairo_set_operator (cr, CAIRO_OPERATOR_XOR);
-               gdk_cairo_set_source_color (cr, &color_gray15);
+               gdk_cairo_set_source_color (cr, &GRAY_15);
                cairo_set_line_width (cr, 1.0);
                cairo_move_to(cr,  g->wp.x, y);
                cairo_line_to(cr,  g->wp.x + g->wp.width, y);
@@ -2954,16 +2955,16 @@ static void cross_xor (struct graph *g, int x, int y)
                cairo_destroy(cr);
        }
 
-#else
-
-       if (x > g->wp.x && x < g->wp.x+g->wp.width &&
-                               y >= g->wp.y && y < g->wp.y+g->wp.height) {
-               gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, g->wp.x,
-                                               y, g->wp.x + g->wp.width, y);
-               gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, x,
-                                               g->wp.y, x, g->wp.y + g->wp.height);
-       }
-#endif
+//#else
+//
+//     if (x > g->wp.x && x < g->wp.x+g->wp.width &&
+//                             y >= g->wp.y && y < g->wp.y+g->wp.height) {
+//             gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, g->wp.x,
+//                                             y, g->wp.x + g->wp.width, y);
+//             gdk_draw_line (gtk_widget_get_window(g->drawing_area), xor_gc, x,
+//                                             g->wp.y, x, g->wp.y + g->wp.height);
+//     }
+//#endif
 }
 
 static void cross_draw (struct graph *g, int x, int y)