1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
// gutter_renderer.rs
//
// Copyright 2019 Christopher Davis <brainblasted@disroot.org>
//
// This file is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This file is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// SPDX-License-Identifier: LGPL-2.1-or-later
use crate::GutterRenderer;
use crate::GutterRendererState;
use glib::object::IsA;
use glib::translate::*;
pub trait GutterRendererExtManual: 'static {
fn begin(
&self,
cr: &mut cairo::Context,
background_area: &mut gdk::Rectangle,
cell_area: &mut gdk::Rectangle,
start: &mut gtk::TextIter,
end: &mut gtk::TextIter,
);
fn draw(
&self,
cr: &mut cairo::Context,
background_area: &mut gdk::Rectangle,
cell_area: &mut gdk::Rectangle,
start: &mut gtk::TextIter,
end: &mut gtk::TextIter,
state: GutterRendererState,
);
}
impl<O: IsA<GutterRenderer>> GutterRendererExtManual for O {
fn begin(
&self,
cr: &mut cairo::Context,
background_area: &mut gdk::Rectangle,
cell_area: &mut gdk::Rectangle,
start: &mut gtk::TextIter,
end: &mut gtk::TextIter,
) {
unsafe {
ffi::gtk_source_gutter_renderer_begin(
self.as_ref().to_glib_none().0,
cr.to_raw_none(),
background_area.to_glib_none_mut().0,
cell_area.to_glib_none_mut().0,
start.to_glib_none_mut().0,
end.to_glib_none_mut().0,
);
}
}
fn draw(
&self,
cr: &mut cairo::Context,
background_area: &mut gdk::Rectangle,
cell_area: &mut gdk::Rectangle,
start: &mut gtk::TextIter,
end: &mut gtk::TextIter,
state: GutterRendererState,
) {
unsafe {
ffi::gtk_source_gutter_renderer_draw(
self.as_ref().to_glib_none().0,
cr.to_raw_none(),
background_area.to_glib_none_mut().0,
cell_area.to_glib_none_mut().0,
start.to_glib_none_mut().0,
end.to_glib_none_mut().0,
state.into_glib(),
);
}
}
}