diff options
author | Thomas White <taw@physics.org> | 2018-07-06 15:15:32 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2018-07-06 15:15:32 +0200 |
commit | 177af3bd9f28821f153b1ed4e447b696242a8923 (patch) | |
tree | 314c08802865c27a7119e0c8b5d71ecdb0a50cc0 /src | |
parent | a845d3061d5251c530fdaa4185ebf3059d433943 (diff) |
Use either GTK2 or GTK3
Diffstat (limited to 'src')
-rw-r--r-- | src/cell_explorer.c | 52 | ||||
-rw-r--r-- | src/dw-hdfsee.c | 25 |
2 files changed, 54 insertions, 23 deletions
diff --git a/src/cell_explorer.c b/src/cell_explorer.c index b6756c8f..f58423c7 100644 --- a/src/cell_explorer.c +++ b/src/cell_explorer.c @@ -315,20 +315,17 @@ static void draw_label(cairo_t *cr, HistoBox *b, int width, int height) } -static gboolean draw_sig(GtkWidget *da, GdkEventExpose *event, HistoBox *b) +static gboolean draw_sig(GtkWidget *da, cairo_t *cr, HistoBox *b) { int width, height; int i, max; double h_height; - cairo_t *cr; double gstep; int *data_p, *data_a, *data_b, *data_c, *data_i, *data_f; int *data_r, *data_h, *data_excl; int start, stop; GtkAllocation allocation; - cr = gdk_cairo_create(gtk_widget_get_window(da)); - gtk_widget_get_allocation(da, &allocation); width = allocation.width; height = allocation.height; @@ -480,8 +477,16 @@ static gboolean draw_sig(GtkWidget *da, GdkEventExpose *event, HistoBox *b) draw_axis(cr, b, width, height); draw_label(cr, b, width, height); - cairo_destroy(cr); + return FALSE; +} + +static gboolean expose_sig(GtkWidget *da, GdkEventExpose *event, HistoBox *b) +{ + cairo_t *cr; + cr = gdk_cairo_create(gtk_widget_get_window(da)); + draw_sig(da, cr, b); + cairo_destroy(cr); return FALSE; } @@ -538,15 +543,12 @@ static gint keyclick_sig(GtkWidget *widget, GdkEventButton *event, -static gboolean keydraw_sig(GtkWidget *da, GdkEventExpose *event, CellWindow *w) +static gboolean keydraw_sig(GtkWidget *da, cairo_t *cr, CellWindow *w) { int width, height; - cairo_t *cr; double x; GtkAllocation allocation; - cr = gdk_cairo_create(gtk_widget_get_window(da)); - gtk_widget_get_allocation(da, &allocation); width = allocation.width; height = allocation.height; @@ -608,6 +610,17 @@ static gboolean keydraw_sig(GtkWidget *da, GdkEventExpose *event, CellWindow *w) } +static gboolean keyexpose_sig(GtkWidget *da, GdkEventExpose *event, + CellWindow *w) +{ + cairo_t *cr; + cr = gdk_cairo_create(gtk_widget_get_window(da)); + keydraw_sig(da, cr, w); + cairo_destroy(cr); + return FALSE; +} + + static int check_exclude(HistoBox *h, double v) { double min, max; @@ -1428,8 +1441,14 @@ static HistoBox *histobox_new(CellWindow *w, const char *units, const char *n) | GDK_SCROLL_MASK | GDK_KEY_PRESS_MASK); - g_signal_connect(G_OBJECT(h->da), "expose_event", G_CALLBACK(draw_sig), - h); + if ( g_signal_lookup("draw", GTK_TYPE_DRAWING_AREA) ) { + g_signal_connect(G_OBJECT(h->da), "draw", + G_CALLBACK(draw_sig), h); + } else { + g_signal_connect(G_OBJECT(h->da), "expose-event", + G_CALLBACK(expose_sig), h); + } + g_signal_connect(G_OBJECT(h->da), "button-press-event", G_CALLBACK(press_sig), h); g_signal_connect(G_OBJECT(h->da), "button-release-event", @@ -1475,8 +1494,15 @@ static void indexing_method_list(CellWindow *w, GtkWidget *vbox) key = gtk_drawing_area_new(); gtk_box_pack_end(GTK_BOX(w->indmlist), key, FALSE, FALSE, 5.0); gtk_widget_add_events(GTK_WIDGET(key), GDK_BUTTON_PRESS_MASK); - g_signal_connect(G_OBJECT(key), "expose_event", G_CALLBACK(keydraw_sig), - w); + + if ( g_signal_lookup("draw", GTK_TYPE_DRAWING_AREA) ) { + g_signal_connect(G_OBJECT(key), "draw", + G_CALLBACK(keydraw_sig), w); + } else { + g_signal_connect(G_OBJECT(key), "expose-event", + G_CALLBACK(keyexpose_sig), w); + } + g_signal_connect(G_OBJECT(key), "configure-event", G_CALLBACK(keyconf_sig), w); g_signal_connect(G_OBJECT(key), "button-press-event", diff --git a/src/dw-hdfsee.c b/src/dw-hdfsee.c index 39e18de7..cfadda90 100644 --- a/src/dw-hdfsee.c +++ b/src/dw-hdfsee.c @@ -613,20 +613,20 @@ static void displaywindow_update(DisplayWindow *dw) } +static gboolean displaywindow_draw(GtkWidget *da, cairo_t *cr, DisplayWindow *dw) +{ + cairo_set_source_surface(cr, dw->surf, 0.0, 0.0); + cairo_paint(cr); +} + + static gboolean displaywindow_expose(GtkWidget *da, GdkEventExpose *event, DisplayWindow *dw) { cairo_t *cr; - cr = gdk_cairo_create(gtk_widget_get_window(da)); - - cairo_set_source_surface(cr, dw->surf, 0.0, 0.0); - cairo_rectangle(cr, event->area.x, event->area.y, - event->area.width, event->area.height); - cairo_fill(cr); - + displaywindow_draw(da, cr, dw); cairo_destroy(cr); - return FALSE; } @@ -3136,8 +3136,13 @@ DisplayWindow *displaywindow_open(char *filename, char *geom_filename, dw->drawingarea); gtk_box_pack_start(GTK_BOX(vbox), dw->scrollarea, TRUE, TRUE, 0); - g_signal_connect(G_OBJECT(dw->drawingarea), "expose-event", - G_CALLBACK(displaywindow_expose), dw); + if ( g_signal_lookup("draw", GTK_TYPE_DRAWING_AREA) ) { + g_signal_connect(G_OBJECT(dw->drawingarea), "draw", + G_CALLBACK(displaywindow_draw), dw); + } else { + g_signal_connect(G_OBJECT(dw->drawingarea), "expose-event", + G_CALLBACK(displaywindow_expose), dw); + } gtk_window_set_resizable(GTK_WINDOW(dw->window), TRUE); gtk_widget_show_all(dw->window); |