[gnome-screenshot/wip/exalm/refactor: 1/12] Introduce ScreenshotBackend



commit c0f8509517a9150c41c8bf68e31d9520efe72895
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Sun Apr 19 01:25:42 2020 +0500

    Introduce ScreenshotBackend
    
    This interface will be used to encapsulate Shell and fallback backend
    implementations.

 src/meson.build          |  1 +
 src/screenshot-backend.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 src/screenshot-backend.h | 41 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)
---
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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]