diff options
-rw-r--r-- | CMakeLists.txt | 35 | ||||
-rw-r--r-- | src/cell_explorer.c | 52 | ||||
-rw-r--r-- | src/dw-hdfsee.c | 25 |
3 files changed, 87 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 992e28f1..9e478840 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,12 +15,43 @@ find_package(GSL REQUIRED) find_package(TIFF) find_package(OpenCL) find_package(PkgConfig) + pkg_search_module(GTK gtk+-3.0) +if (NOT GTK_FOUND) + + # No GTK3. Try GTK2? + pkg_search_module(GTK gtk+-2.0) + if (GTK_FOUND) + message(STATUS "Using GTK 2") + pkg_search_module(GDK gdk-2.0) + endif () + +else () + + message(STATUS "Using GTK 3") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-deprecated-declarations") + pkg_search_module(GDK gdk-3.0) + +endif () + +# If no version of GTK was found, try for GDK +if (NOT GTK_FOUND) + message(STATUS "Looking separately for GDK") + pkg_search_module(GDK gdk-3.0) + if (NOT GDK_FOUND) + pkg_search_module(GDK gdk-2.0) + if (GDK_FOUND) + message(STATUS "Using GDK 2") + endif() + else () + message(STATUS "Using GDK 3") + endif() +endif() + pkg_search_module(CAIRO cairo) -pkg_search_module(GDK gdk-2.0) pkg_search_module(GDKPIXBUF gdk-pixbuf-2.0) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always -Wno-deprecated-declarations") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdiagnostics-color=always") include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_definitions(-DHAVE_CONFIG_H) 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); |