File: pps-overlay.c

package info (click to toggle)
papers 49.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 21,044 kB
  • sloc: ansic: 37,728; sh: 197; xml: 127; makefile: 113
file content (47 lines) | stat: -rw-r--r-- 1,349 bytes parent folder | download | duplicates (2)
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
// SPDX-License-Identifier: GPL-2.0-or-later
/* pps-overlay.c
 * this file is part of papers, a gnome document viewer
 *
 * Copyright (C) 2025 Lucas Baudin <lbaudin@gnome.org>
 */

#include "pps-overlay.h"

G_DEFINE_INTERFACE (PpsOverlay, pps_overlay, G_TYPE_OBJECT)

static void
pps_overlay_default_init (PpsOverlayInterface *iface)
{
	iface->get_area = NULL;
	iface->update_visibility_from_state = NULL;
}

/**
 * pps_overlay_get_area:
 * @self: a #PpsOverlay instance
 * @padding: (out): an additional padding for the overlay area (in view units)
 *
 * Gets the document area of the overlay.
 *
 * Returns: (transfer full): a #PpsRectangle that describes where the overlay shall be positioned
 */
PpsRectangle *
pps_overlay_get_area (PpsOverlay *self, gdouble *padding)
{
	g_return_val_if_fail (PPS_IS_OVERLAY (self), NULL);
	PpsOverlayInterface *iface = PPS_OVERLAY_GET_IFACE (self);
	g_return_val_if_fail (iface->get_area != NULL, NULL);
	return iface->get_area (self, padding);
}

void
pps_overlay_update_visibility_from_state (PpsOverlay *self, PpsRenderAnnotsFlags state)
{
	g_return_if_fail (PPS_IS_OVERLAY (self));
	PpsOverlayInterface *iface = PPS_OVERLAY_GET_IFACE (self);
	if (iface->update_visibility_from_state) {
		iface->update_visibility_from_state (self, state);
	} else {
		gtk_widget_set_visible (GTK_WIDGET (self), TRUE);
	}
}