summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Mikhaylenko <alexm@gnome.org>2020-04-19 01:25:42 +0500
committerAlexander Mikhaylenko <alexm@gnome.org>2020-04-22 13:32:30 +0000
commit67f71e63b9b9dd344382d9b82d4e71915cb9b720 (patch)
tree228148f4acfdf11c048a068b637e272fd693749d
parent7426d0f1e6b190b69750b155fbf28bf0252825a0 (diff)
downloadgnome-screenshot-67f71e63b9b9dd344382d9b82d4e71915cb9b720.tar.gz
Introduce ScreenshotBackend
This interface will be used to encapsulate Shell and fallback backend implementations.
-rw-r--r--src/meson.build1
-rw-r--r--src/screenshot-backend.c44
-rw-r--r--src/screenshot-backend.h41
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