You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to make work with plplot, i was doing the same steps as in examples.
(I have trшed it in both gtk4 and gtk-3. it is all the same):
At first i was getting hl_gtk_pixbuf_cairo_new:: Backing surface is NULL error.
I have realised, I am getting that because drawing area is created with builder, instead of hl_gtk_drawing_area_new.
In hl_gtk_drawing_area_new there is setting of backing surface: call g_object_set_data(plota, "backing-surface", isurface)
I was trying to made some setting function to mimic what hl_gtk_drawing_area_new doing, but to builder-made drawing area:
subroutine drawing_area_set(area, has_alpha, cairo_status)
type(c_ptr) :: area !pointer to existing drawing-area
integer(kind=c_int), intent(in), optional :: has_alpha
integer(kind=c_int), intent(out), optional :: cairo_status
type(c_ptr) :: isurface, cstat_cstr
integer(kind=c_int) :: mask, insert_mask
integer(kind=c_int) :: auto_add, s_type
integer(kind=c_int) ::szx, szy
type(c_ptr) :: szx_cp, szy_cp
logical :: rgba
integer(kind=c_int) :: cstat
character(len=120) :: cstat_fstr
!Not working, type mismatch int(4) to c_ptr:
!call gtk_widget_get_size_request (area, szx, szy)
!Makeshift workaround untilll get_size_request is working
szx = 300
szy = 300
if (present(has_alpha)) then
rgba = c_f_logical(has_alpha)
else
rgba = .false.
end if
if (rgba) then
s_type = CAIRO_FORMAT_ARGB32
else
s_type = CAIRO_FORMAT_RGB24
end if
isurface = cairo_image_surface_create(s_type, szx, szy)
isurface = cairo_surface_reference(isurface) ! Prevent accidental deletion
call g_object_set_data(area, "backing-surface", isurface)
if (present(cairo_status)) then
cairo_status = cairo_surface_status(isurface)
else
cstat = cairo_surface_status(isurface)
if (cstat /= CAIRO_STATUS_SUCCESS) then
cstat_cstr = cairo_status_to_string(cstat)
call c_f_string(cstat_cstr, cstat_fstr)
write(error_unit, "(A)") &
& "GTK_DRAWING_AREA_SET: Error creating backing store", &
& trim(cstat_fstr)
end if
end if
endsubroutine drawing_area_set
But it gets me no result. It is hl_gtk_pixbuf_cairo_new:: Backing surface is NULL anyway.
What am i doing wrong?
What is the correct way to use plplot with builder-made drawing area?
P.s. all examples are working, so that is all on my end.
The text was updated successfully, but these errors were encountered:
That line is in the function hl_gtk_drawing_area_cairo_new(), which contains some comments:
! Create a cairo context which will draw into the backing surface
!
! AREA | c_ptr | required | The drawing area to which we will draw.
!
! After the drawing operations, you should call `gtk_widget_queue_draw`
! to update the plot on the screen and `hl_gtk_pixbuf_cairo_destroy`
! to destroy the cairo context.
I was trying to make work with plplot, i was doing the same steps as in examples.
(I have trшed it in both gtk4 and gtk-3. it is all the same):
At first i was getting
hl_gtk_pixbuf_cairo_new:: Backing surface is NULL
error.I have realised, I am getting that because drawing area is created with builder, instead of
hl_gtk_drawing_area_new
.In
hl_gtk_drawing_area_new
there is setting of backing surface:call g_object_set_data(plota, "backing-surface", isurface)
I was trying to made some setting function to mimic what
hl_gtk_drawing_area_new
doing, but to builder-made drawing area:But it gets me no result. It is
hl_gtk_pixbuf_cairo_new:: Backing surface is NULL
anyway.What am i doing wrong?
What is the correct way to use plplot with builder-made drawing area?
P.s. all examples are working, so that is all on my end.
The text was updated successfully, but these errors were encountered: