diff options
author | Alexander Mikhaylenko <alexm@gnome.org> | 2020-04-19 01:25:42 +0500 |
---|---|---|
committer | Alexander Mikhaylenko <alexm@gnome.org> | 2020-04-22 13:32:30 +0000 |
commit | 67f71e63b9b9dd344382d9b82d4e71915cb9b720 (patch) | |
tree | 228148f4acfdf11c048a068b637e272fd693749d /src | |
parent | 7426d0f1e6b190b69750b155fbf28bf0252825a0 (diff) | |
download | gnome-screenshot-67f71e63b9b9dd344382d9b82d4e71915cb9b720.tar.gz |
Introduce ScreenshotBackend
This interface will be used to encapsulate Shell and fallback backend
implementations.
Diffstat (limited to 'src')
-rw-r--r-- | src/meson.build | 1 | ||||
-rw-r--r-- | src/screenshot-backend.c | 44 | ||||
-rw-r--r-- | src/screenshot-backend.h | 41 |
3 files changed, 86 insertions, 0 deletions
diff --git a/src/meson.build b/src/meson.build index 85d68e7..6a026c3 100644 --- a/src/meson.build +++ b/src/meson.build @@ -5,6 +5,7 @@ sources = [ 'screenshot-application.c', 'screenshot-area-selection.c', + 'screenshot-backend.c', 'screenshot-config.c', 'screenshot-dialog.c', 'screenshot-filename-builder.c', diff --git a/src/screenshot-backend.c b/src/screenshot-backend.c new file mode 100644 index 0000000..73b4e5d --- /dev/null +++ b/src/screenshot-backend.c @@ -0,0 +1,44 @@ +/* screenshot-backend.c - Backend interface + * + * Copyright (C) 2020 Alexander Mikhaylenko <alexm@gnome.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + */ + +#include "config.h" + +#include "screenshot-backend.h" + +G_DEFINE_INTERFACE (ScreenshotBackend, screenshot_backend, G_TYPE_OBJECT) + +static void +screenshot_backend_default_init (ScreenshotBackendInterface *iface) +{ +} + +GdkPixbuf * +screenshot_backend_get_pixbuf (ScreenshotBackend *self, + GdkRectangle *rectangle) +{ + ScreenshotBackendInterface *iface; + + g_return_val_if_fail (SCREENSHOT_IS_BACKEND (self), NULL); + + iface = SCREENSHOT_BACKEND_GET_IFACE (self); + + g_return_val_if_fail (iface->get_pixbuf != NULL, NULL); + + return iface->get_pixbuf (self, rectangle); +} diff --git a/src/screenshot-backend.h b/src/screenshot-backend.h new file mode 100644 index 0000000..4137a0d --- /dev/null +++ b/src/screenshot-backend.h @@ -0,0 +1,41 @@ +/* screenshot-backend.h - Backend interface + * + * Copyright (C) 2020 Alexander Mikhaylenko <alexm@gnome.org> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + */ + +#pragma once + +#include <gtk/gtk.h> + +G_BEGIN_DECLS + +#define SCREENSHOT_TYPE_BACKEND (screenshot_backend_get_type ()) + +G_DECLARE_INTERFACE (ScreenshotBackend, screenshot_backend, SCREENSHOT, BACKEND, GObject) + +struct _ScreenshotBackendInterface +{ + GTypeInterface parent; + + GdkPixbuf * (*get_pixbuf) (ScreenshotBackend *self, + GdkRectangle *rectangle); +}; + +GdkPixbuf *screenshot_backend_get_pixbuf (ScreenshotBackend *self, + GdkRectangle *rectangle); + +G_END_DECLS |