diff options
author | Jörg Mayer <jmayer@loplof.de> | 2011-07-26 19:01:01 +0000 |
---|---|---|
committer | Jörg Mayer <jmayer@loplof.de> | 2011-07-26 19:01:01 +0000 |
commit | 68845aa77991c16c5b68cd7959b3def7892c9791 (patch) | |
tree | 1231ce936463c6fc3526a91bb54404fd87fefc6d | |
parent | 154ec7eafc818b2d4cd6fb99fc79095e695090bd (diff) |
Replace access to ...->allocation by gtk_widget_get_allocation +
using the return val - part 1
Maybe the call needs to be done more often.
Replace GTK_WIDGET_STATE by gtk_widget_get_state
svn path=/trunk/; revision=38215
-rw-r--r-- | gtk/iax2_analysis.c | 24 | ||||
-rw-r--r-- | gtk/io_stat.c | 22 | ||||
-rw-r--r-- | gtk/old-gtk-compat.h | 2 | ||||
-rw-r--r-- | gtk/rtp_analysis.c | 24 | ||||
-rw-r--r-- | gtk/sctp_byte_graph_dlg.c | 43 | ||||
-rw-r--r-- | gtk/sctp_graph_dlg.c | 50 | ||||
-rw-r--r-- | gtk/tcp_graph.c | 8 |
7 files changed, 95 insertions, 78 deletions
diff --git a/gtk/iax2_analysis.c b/gtk/iax2_analysis.c index 7951def3ea..281f557ede 100644 --- a/gtk/iax2_analysis.c +++ b/gtk/iax2_analysis.c @@ -914,6 +914,7 @@ static void dialog_graph_draw(user_data_t* user_data) int label_width_mid, label_height_mid; guint32 draw_width, draw_height; char label_string[15]; + GtkAllocation widget_alloc; cairo_t *cr; /* new variables */ @@ -969,11 +970,12 @@ static void dialog_graph_draw(user_data_t* user_data) */ cr = gdk_cairo_create (user_data->dlg.dialog_graph.pixmap); cairo_set_source_rgb (cr, 1, 1, 1); - cairo_rectangle (cr, - 0, - 0, - user_data->dlg.dialog_graph.draw_area->allocation.width, - user_data->dlg.dialog_graph.draw_area->allocation.height); + gtk_widget_get_allocation(user_data->dlg.dialog_graph.draw_area, &widget_alloc); + cairo_rectangle (cr, + 0, + 0, + widget_alloc.width, + widget_alloc.height); cairo_fill (cr); cairo_destroy (cr); @@ -1345,6 +1347,7 @@ static gboolean draw_area_expose_event(GtkWidget *widget, GdkEventExpose *event, static gboolean draw_area_configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer data) { user_data_t *user_data = data; + GtkAllocation widget_alloc; cairo_t *cr; if(user_data->dlg.dialog_graph.pixmap){ @@ -1352,15 +1355,16 @@ static gboolean draw_area_configure_event(GtkWidget *widget, GdkEventConfigure * user_data->dlg.dialog_graph.pixmap=NULL; } + gtk_widget_get_allocation(widget, &widget_alloc); user_data->dlg.dialog_graph.pixmap=gdk_pixmap_new(gtk_widget_get_window(widget), - widget->allocation.width, - widget->allocation.height, + widget_alloc.width, + widget_alloc.height, -1); - user_data->dlg.dialog_graph.pixmap_width=widget->allocation.width; - user_data->dlg.dialog_graph.pixmap_height=widget->allocation.height; + user_data->dlg.dialog_graph.pixmap_width=widget_alloc.width; + user_data->dlg.dialog_graph.pixmap_height=widget_alloc.height; cr = gdk_cairo_create (user_data->dlg.dialog_graph.pixmap); - cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height); + cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_destroy (cr); diff --git a/gtk/io_stat.c b/gtk/io_stat.c index 53c3ed9737..a3beb57df3 100644 --- a/gtk/io_stat.c +++ b/gtk/io_stat.c @@ -700,6 +700,7 @@ io_stat_draw(io_stat_t *io) int label_width, label_height; guint32 draw_width, draw_height; char label_string[45]; + GtkAllocation widget_alloc; /* new variables */ guint32 num_time_intervals; @@ -754,7 +755,8 @@ io_stat_draw(io_stat_t *io) */ cr = gdk_cairo_create (io->pixmap); cairo_set_source_rgb (cr, 1, 1, 1); - cairo_rectangle (cr, 0, 0, io->draw_area->allocation.width,io->draw_area->allocation.height); + gtk_widget_get_allocation(io->draw_area, &widget_alloc); + cairo_rectangle (cr, 0, 0, widget_alloc.width,widget_alloc.height); cairo_fill (cr); cairo_destroy (cr); /* @@ -1389,6 +1391,7 @@ draw_area_configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpoin { io_stat_t *io = user_data; GtkWidget *save_bt; + GtkAllocation widget_alloc; cairo_t *cr; if(io->pixmap){ @@ -1396,19 +1399,20 @@ draw_area_configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpoin io->pixmap=NULL; } + gtk_widget_get_allocation(widget, &widget_alloc); io->pixmap=gdk_pixmap_new(gtk_widget_get_window(widget), - widget->allocation.width, - widget->allocation.height, + widget_alloc.width, + widget_alloc.height, -1); - io->pixmap_width=widget->allocation.width; - io->pixmap_height=widget->allocation.height; + io->pixmap_width=widget_alloc.width; + io->pixmap_height=widget_alloc.height; save_bt = g_object_get_data(G_OBJECT(io->window), "save_bt"); g_object_set_data(G_OBJECT(save_bt), "pixmap", io->pixmap); gtk_widget_set_sensitive(save_bt, TRUE); cr = gdk_cairo_create (io->pixmap); - cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height); + cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_destroy (cr); @@ -1605,6 +1609,7 @@ count_type_select(GtkWidget *item, gpointer user_data) io_stat_t *io = user_data; static gboolean advanced_visible=FALSE; int i; + GtkAllocation widget_alloc; io->count_type = gtk_combo_box_get_active (GTK_COMBO_BOX(item)); @@ -1613,11 +1618,12 @@ count_type_select(GtkWidget *item, gpointer user_data) disable_graph(&io->graphs[i]); gtk_widget_show(io->graphs[i].advanced_buttons); /* redraw the entire window so the unhidden widgets show up, hopefully */ + gtk_widget_get_allocation(io->window, &widget_alloc); gtk_widget_queue_draw_area(io->window, 0, 0, - io->window->allocation.width, - io->window->allocation.height); + widget_alloc.width, + widget_alloc.height); } advanced_visible=TRUE; io_stat_redraw(io); diff --git a/gtk/old-gtk-compat.h b/gtk/old-gtk-compat.h index 844509f287..00293b098e 100644 --- a/gtk/old-gtk-compat.h +++ b/gtk/old-gtk-compat.h @@ -49,6 +49,8 @@ #if !GTK_CHECK_VERSION (2, 18, 0) # define gtk_widget_get_has_window(x) (!GTK_WIDGET_NO_WINDOW(x)) # define gtk_widget_get_visible(x) GTK_WIDGET_VISIBLE(x) +# define gtk_widget_get_state(x) GTK_WIDGET_STATE(x) +# define gtk_widget_get_allocation(x,y) (*(y) = x->allocation) #endif #if !GTK_CHECK_VERSION (2, 20, 0) diff --git a/gtk/rtp_analysis.c b/gtk/rtp_analysis.c index 7f82764ed0..2754b4bb67 100644 --- a/gtk/rtp_analysis.c +++ b/gtk/rtp_analysis.c @@ -925,6 +925,7 @@ static void dialog_graph_draw(user_data_t* user_data) int label_width_mid, label_height_mid; guint32 draw_width, draw_height; char label_string[15]; + GtkAllocation widget_alloc; cairo_t *cr; /* new variables */ @@ -980,11 +981,12 @@ static void dialog_graph_draw(user_data_t* user_data) */ cr = gdk_cairo_create (user_data->dlg.dialog_graph.pixmap); cairo_set_source_rgb (cr, 1, 1, 1); - cairo_rectangle (cr, - 0, - 0, - user_data->dlg.dialog_graph.draw_area->allocation.width, - user_data->dlg.dialog_graph.draw_area->allocation.height); + gtk_widget_get_allocation(user_data->dlg.dialog_graph.draw_area, &widget_alloc); + cairo_rectangle (cr, + 0, + 0, + widget_alloc.width, + widget_alloc.height); cairo_fill (cr); cairo_destroy (cr); @@ -1353,6 +1355,7 @@ static gint configure_event(GtkWidget *widget, GdkEventConfigure *event _U_) { user_data_t *user_data; GtkWidget *bt_save; + GtkAllocation widget_alloc; cairo_t *cr; user_data=(user_data_t *)g_object_get_data(G_OBJECT(widget), "user_data_t"); @@ -1366,19 +1369,20 @@ static gint configure_event(GtkWidget *widget, GdkEventConfigure *event _U_) user_data->dlg.dialog_graph.pixmap=NULL; } + gtk_widget_get_allocation(widget, &widget_alloc); user_data->dlg.dialog_graph.pixmap=gdk_pixmap_new(gtk_widget_get_window(widget), - widget->allocation.width, - widget->allocation.height, + widget_alloc.width, + widget_alloc.height, -1); - user_data->dlg.dialog_graph.pixmap_width=widget->allocation.width; - user_data->dlg.dialog_graph.pixmap_height=widget->allocation.height; + user_data->dlg.dialog_graph.pixmap_width=widget_alloc.width; + user_data->dlg.dialog_graph.pixmap_height=widget_alloc.height; bt_save = g_object_get_data(G_OBJECT(user_data->dlg.dialog_graph.window), "bt_save"); g_object_set_data(G_OBJECT(bt_save), "pixmap", user_data->dlg.dialog_graph.pixmap); gtk_widget_set_sensitive(bt_save, TRUE); cr = gdk_cairo_create (user_data->dlg.dialog_graph.pixmap); - cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height); + cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_destroy (cr); diff --git a/gtk/sctp_byte_graph_dlg.c b/gtk/sctp_byte_graph_dlg.c index d77841b502..f75e91cb77 100644 --- a/gtk/sctp_byte_graph_dlg.c +++ b/gtk/sctp_byte_graph_dlg.c @@ -273,6 +273,7 @@ static void sctp_graph_draw(struct sctp_udata *u_data) gfloat dis; gboolean write_label = FALSE; PangoLayout *layout; + GtkAllocation widget_alloc; cairo_t *cr; if (u_data->io->x1_tmp_sec == 0 && u_data->io->x1_tmp_usec == 0) @@ -330,11 +331,12 @@ static void sctp_graph_draw(struct sctp_udata *u_data) cr = gdk_cairo_create (u_data->io->pixmap); cairo_set_source_rgb (cr, 1, 1, 1); - cairo_rectangle (cr, - 0, - 0, - u_data->io->draw_area->allocation.width, - u_data->io->draw_area->allocation.height); + gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc); + cairo_rectangle (cr, + 0, + 0, + widget_alloc.width, + widget_alloc.height); cairo_fill (cr); cairo_destroy (cr); @@ -599,6 +601,7 @@ static void sctp_graph_draw(struct sctp_udata *u_data) static void sctp_graph_redraw(struct sctp_udata *u_data) { sctp_graph_t *ios; + GtkAllocation widget_alloc; cairo_t *cr; u_data->io->needs_redraw = TRUE; @@ -624,7 +627,8 @@ static void sctp_graph_redraw(struct sctp_udata *u_data) cr = gdk_cairo_create (gtk_widget_get_window(u_data->io->draw_area)); gdk_cairo_set_source_pixmap (cr, ios->pixmap, 0, 0); - cairo_rectangle (cr, 0, 0, u_data->io->draw_area->allocation.width, u_data->io->draw_area->allocation.height); + gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc); + cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height); cairo_fill (cr); cairo_destroy (cr); @@ -666,6 +670,7 @@ static gboolean on_configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer user_data) { struct sctp_udata *u_data = user_data; + GtkAllocation widget_alloc; cairo_t *cr; g_assert(u_data->io != NULL); @@ -675,15 +680,16 @@ on_configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer use u_data->io->pixmap = NULL; } + gtk_widget_get_allocation(widget, &widget_alloc); u_data->io->pixmap = gdk_pixmap_new(gtk_widget_get_window(widget), - widget->allocation.width, - widget->allocation.height, + widget_alloc.width, + widget_alloc.height, -1); - u_data->io->pixmap_width = widget->allocation.width; - u_data->io->pixmap_height = widget->allocation.height; + u_data->io->pixmap_width = widget_alloc.width; + u_data->io->pixmap_height = widget_alloc.height; cr = gdk_cairo_create (u_data->io->pixmap); - cairo_rectangle (cr, 0, 0, widget->allocation.width, widget->allocation.height); + cairo_rectangle (cr, 0, 0, widget_alloc.width, widget_alloc.height); cairo_set_source_rgb (cr, 1, 1, 1); cairo_fill (cr); cairo_destroy (cr); @@ -891,6 +897,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer GList *tsnlist=NULL; tsn_t *tsn, *tmptsn; PangoLayout *layout; + GtkAllocation widget_alloc; + g_snprintf(label_string, 15, "%d", 0); memcpy(label_string,(gchar *)g_locale_to_utf8(label_string, -1 , NULL, NULL, NULL), 15); layout = gtk_widget_create_pango_layout(u_data->io->draw_area, label_string); @@ -916,17 +924,14 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer ios=(sctp_graph_t *)g_object_get_data(G_OBJECT(u_data->io->draw_area), "sctp_graph_t"); g_assert(ios != NULL); + gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc); gdk_draw_pixmap(gtk_widget_get_window(u_data->io->draw_area), -#if GTK_CHECK_VERSION(2,18,0) gtk_widget_get_style(u_data->io->draw_area)->fg_gc[gtk_widget_get_state(u_data->io->draw_area)], -#else - gtk_widget_get_style(u_data->io->draw_area)->fg_gc[GTK_WIDGET_STATE(u_data->io->draw_area)], -#endif ios->pixmap, 0, 0, 0, 0, - u_data->io->draw_area->allocation.width, - u_data->io->draw_area->allocation.height); + widget_alloc.width, + widget_alloc.height); x1_tmp=(guint32) floor(u_data->io->min_x+((u_data->io->x_old-LEFT_BORDER-u_data->io->offset)*u_data->io->tmp_width/u_data->io->axis_width)); x2_tmp=(guint32) floor(u_data->io->min_x+((event->x-LEFT_BORDER-u_data->io->offset)*u_data->io->tmp_width/u_data->io->axis_width)); @@ -1057,8 +1062,8 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer ios->pixmap, 0, 0, 0, 0, - u_data->io->draw_area->allocation.width, - u_data->io->draw_area->allocation.height); + widget_alloc.width, + widget_alloc.height); } } return TRUE; diff --git a/gtk/sctp_graph_dlg.c b/gtk/sctp_graph_dlg.c index 057e3971fa..dc60f27efe 100644 --- a/gtk/sctp_graph_dlg.c +++ b/gtk/sctp_graph_dlg.c @@ -556,6 +556,7 @@ sctp_graph_draw(struct sctp_udata *u_data) gfloat dis; gboolean write_label = FALSE; PangoLayout *layout; + GtkAllocation widget_alloc; if (u_data->io->x1_tmp_sec==0 && u_data->io->x1_tmp_usec==0) u_data->io->offset=0; @@ -610,12 +611,13 @@ sctp_graph_draw(struct sctp_udata *u_data) } } + gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc); gdk_draw_rectangle(u_data->io->pixmap, gtk_widget_get_style(u_data->io->draw_area)->white_gc, TRUE, 0, 0, - u_data->io->draw_area->allocation.width, - u_data->io->draw_area->allocation.height); + widget_alloc.width, + widget_alloc.height); distance=5; /* x_axis */ @@ -870,7 +872,8 @@ updateLabels(void) static void sctp_graph_redraw(struct sctp_udata *u_data) { -sctp_graph_t *ios; + sctp_graph_t *ios; + GtkAllocation widget_alloc; u_data->io->needs_redraw=TRUE; @@ -910,17 +913,14 @@ sctp_graph_t *ios; ios=(sctp_graph_t *)g_object_get_data(G_OBJECT(u_data->io->draw_area), "sctp_graph_t"); g_assert(ios != NULL); + gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc); gdk_draw_pixmap(gtk_widget_get_window(u_data->io->draw_area), -#if GTK_CHECK_VERSION(2,18,0) gtk_widget_get_style(u_data->io->draw_area)->fg_gc[gtk_widget_get_state(u_data->io->draw_area)], -#else - gtk_widget_get_style(u_data->io->draw_area)->fg_gc[GTK_WIDGET_STATE(u_data->io->draw_area)], -#endif ios->pixmap, 0,0, 0, 0, - u_data->io->draw_area->allocation.width, - u_data->io->draw_area->allocation.height); + widget_alloc.width, + widget_alloc.height); } @@ -965,6 +965,7 @@ static gboolean configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer user_data) { struct sctp_udata *u_data = user_data; + GtkAllocation widget_alloc; g_assert(u_data->io != NULL); @@ -973,19 +974,20 @@ configure_event(GtkWidget *widget, GdkEventConfigure *event _U_, gpointer user_d u_data->io->pixmap=NULL; } + gtk_widget_get_allocation(widget, &widget_alloc); u_data->io->pixmap=gdk_pixmap_new(gtk_widget_get_window(widget), - widget->allocation.width, - widget->allocation.height, + widget_alloc.width, + widget_alloc.height, -1); - u_data->io->pixmap_width=widget->allocation.width; - u_data->io->pixmap_height=widget->allocation.height; + u_data->io->pixmap_width=widget_alloc.width; + u_data->io->pixmap_height=widget_alloc.height; gdk_draw_rectangle(u_data->io->pixmap, gtk_widget_get_style(widget)->white_gc, TRUE, 0, 0, - widget->allocation.width, - widget->allocation.height); + widget_alloc.width, + widget_alloc.height); sctp_graph_redraw(u_data); return TRUE; } @@ -1194,6 +1196,7 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer GPtrArray *tsnlist = NULL, *sacklist=NULL; struct tsn_sort *tsn, *sack=NULL; gboolean sack_found = FALSE; + GtkAllocation widget_alloc; PangoLayout *layout; g_snprintf(label_string, 15, "%d", 0); @@ -1211,6 +1214,7 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer u_data->io->rect_x_max = (gint)ceil(MAX(u_data->io->x_old,event->x)); u_data->io->rect_y_min = (gint)floor(MIN(u_data->io->y_old,event->y)); u_data->io->rect_y_max = (gint)ceil(MAX(u_data->io->y_old,event->y))+POINT_SIZE; + gtk_widget_get_allocation(u_data->io->draw_area, &widget_alloc); gdk_draw_rectangle(u_data->io->pixmap,gtk_widget_get_style(u_data->io->draw_area)->black_gc, FALSE, u_data->io->rect_x_min, u_data->io->rect_y_min, @@ -1221,16 +1225,12 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer g_assert(ios != NULL); gdk_draw_pixmap(gtk_widget_get_window(u_data->io->draw_area), -#if GTK_CHECK_VERSION(2,18,0) gtk_widget_get_style(u_data->io->draw_area)->fg_gc[gtk_widget_get_state(u_data->io->draw_area)], -#else - gtk_widget_get_style(u_data->io->draw_area)->fg_gc[GTK_WIDGET_STATE(u_data->io->draw_area)], -#endif ios->pixmap, 0, 0, 0, 0, - u_data->io->draw_area->allocation.width, - u_data->io->draw_area->allocation.height); + widget_alloc.width, + widget_alloc.height); x1_tmp=(unsigned int)floor(u_data->io->min_x+((u_data->io->x_old-LEFT_BORDER-u_data->io->offset)*u_data->io->tmp_width/u_data->io->axis_width)); x2_tmp=(unsigned int)floor(u_data->io->min_x+((event->x-LEFT_BORDER-u_data->io->offset)*u_data->io->tmp_width/u_data->io->axis_width)); @@ -1379,16 +1379,12 @@ on_button_release_event (GtkWidget *widget _U_, GdkEventButton *event, gpointer g_assert(ios != NULL); gdk_draw_pixmap(gtk_widget_get_window(u_data->io->draw_area), -#if GTK_CHECK_VERSION(2,18,0) gtk_widget_get_style(u_data->io->draw_area)->fg_gc[gtk_widget_get_state(u_data->io->draw_area)], -#else - gtk_widget_get_style(u_data->io->draw_area)->fg_gc[GTK_WIDGET_STATE(u_data->io->draw_area)], -#endif ios->pixmap, 0, 0, 0, 0, - u_data->io->draw_area->allocation.width, - u_data->io->draw_area->allocation.height); + widget_alloc.width, + widget_alloc.height); } } return TRUE; diff --git a/gtk/tcp_graph.c b/gtk/tcp_graph.c index be82a06c99..7faa0df8e9 100644 --- a/gtk/tcp_graph.c +++ b/gtk/tcp_graph.c @@ -679,6 +679,7 @@ static void create_drawing_area (struct graph *g) char window_title[WINDOW_TITLE_LENGTH]; struct segment current; struct tcpheader *thdr; + GtkAllocation widget_alloc; debug(DBS_FENTRY) puts ("create_drawing_area()"); #if 0 @@ -761,10 +762,9 @@ static void create_drawing_area (struct graph *g) gtk_widget_show (g->toplevel); /* in case we didn't get what we asked for */ - g->wp.width = GTK_WIDGET (g->drawing_area)->allocation.width - - g->wp.x - RMARGIN_WIDTH; - g->wp.height = GTK_WIDGET (g->drawing_area)->allocation.height - - g->wp.y - g->x_axis->s.height; + gtk_widget_get_allocation(GTK_WIDGET (g->drawing_area), &widget_alloc); + g->wp.width = widget_alloc.width - g->wp.x - RMARGIN_WIDTH; + g->wp.height = widget_alloc.height - g->wp.y - g->x_axis->s.height; g->font = gtk_widget_get_style(g->drawing_area)->font_desc; |