[gnome-flashback] add screencast and screenshot (not implemented yet)
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-flashback] add screencast and screenshot (not implemented yet)
- Date: Fri, 27 Mar 2015 12:28:38 +0000 (UTC)
commit 9762d9c4bace5e7db346ada1b7bbea75efeba55c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Fri Mar 27 14:27:38 2015 +0200
add screencast and screenshot (not implemented yet)
configure.ac | 10 +
data/org.gnome.gnome-flashback.gschema.xml.in.in | 10 +
gnome-flashback/Makefile.am | 4 +
gnome-flashback/flashback-application.c | 28 +++
gnome-flashback/libscreencast/Makefile.am | 37 ++++
.../libscreencast/flashback-screencast.c | 155 ++++++++++++++++
.../libscreencast/flashback-screencast.h | 33 ++++
.../libscreencast/org.gnome.Shell.Screencast.xml | 95 ++++++++++
gnome-flashback/libscreenshot/Makefile.am | 37 ++++
.../libscreenshot/flashback-screenshot.c | 191 ++++++++++++++++++++
.../libscreenshot/flashback-screenshot.h | 33 ++++
.../libscreenshot/org.gnome.Shell.Screenshot.xml | 128 +++++++++++++
12 files changed, 761 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c5e6b03..b5dca72 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,6 +53,14 @@ PKG_CHECK_MODULES(DISPLAY_CONFIG, gtk+-3.0 >= $GTK_REQUIRED glib-2.0 >= $GLIB_RE
AC_SUBST(DISPLAY_CONFIG_CFLAGS)
AC_SUBST(DISPLAY_CONFIG_LIBS)
+PKG_CHECK_MODULES(SCREENCAST, gtk+-3.0 >= $GTK_REQUIRED)
+AC_SUBST(SCREENCAST_CFLAGS)
+AC_SUBST(SCREENCAST_LIBS)
+
+PKG_CHECK_MODULES(SCREENSHOT, gtk+-3.0 >= $GTK_REQUIRED)
+AC_SUBST(SCREENSHOT_CFLAGS)
+AC_SUBST(SCREENSHOT_LIBS)
+
PKG_CHECK_MODULES(SHELL, gtk+-3.0 >= $GTK_REQUIRED x11)
AC_SUBST(SHELL_CFLAGS)
AC_SUBST(SHELL_LIBS)
@@ -72,6 +80,8 @@ gnome-flashback/libautomount-manager/Makefile
gnome-flashback/libdesktop-background/Makefile
gnome-flashback/libdisplay-config/Makefile
gnome-flashback/libend-session-dialog/Makefile
+gnome-flashback/libscreencast/Makefile
+gnome-flashback/libscreenshot/Makefile
gnome-flashback/libshell/Makefile
gnome-flashback/libsound-applet/Makefile
gnome-flashback/libsound-applet/gvc/Makefile
diff --git a/data/org.gnome.gnome-flashback.gschema.xml.in.in
b/data/org.gnome.gnome-flashback.gschema.xml.in.in
index 217ee35..20bbfa1 100644
--- a/data/org.gnome.gnome-flashback.gschema.xml.in.in
+++ b/data/org.gnome.gnome-flashback.gschema.xml.in.in
@@ -20,6 +20,16 @@
<_summary>End session dialog</_summary>
<_description>If set to true, then GNOME Flashback application will be used to show
end session dialog.</_description>
</key>
+ <key name="screencast" type="b">
+ <default>true</default>
+ <_summary>Screencast</_summary>
+ <_description>If set to true, then GNOME Flashback application will be used to record
screen.</_description>
+ </key>
+ <key name="screenshot" type="b">
+ <default>true</default>
+ <_summary>Screenshot</_summary>
+ <_description>If set to true, then GNOME Flashback application will be used to take
screenshot.</_description>
+ </key>
<key name="shell" type="b">
<default>true</default>
<_summary>Shell</_summary>
diff --git a/gnome-flashback/Makefile.am b/gnome-flashback/Makefile.am
index 47f2aa6..eacd19f 100644
--- a/gnome-flashback/Makefile.am
+++ b/gnome-flashback/Makefile.am
@@ -3,6 +3,8 @@ SUBDIRS = \
libdesktop-background \
libdisplay-config \
libend-session-dialog \
+ libscreencast \
+ libscreenshot \
libshell \
libsound-applet
@@ -27,6 +29,8 @@ gnome_flashback_LDADD = \
$(top_builddir)/gnome-flashback/libdesktop-background/libdesktop-background.la \
$(top_builddir)/gnome-flashback/libdisplay-config/libdisplay-config.la \
$(top_builddir)/gnome-flashback/libend-session-dialog/libend-session-dialog.la \
+ $(top_builddir)/gnome-flashback/libscreencast/libscreencast.la \
+ $(top_builddir)/gnome-flashback/libscreenshot/libscreenshot.la \
$(top_builddir)/gnome-flashback/libshell/libshell.la \
$(top_builddir)/gnome-flashback/libsound-applet/libsound-applet.la
diff --git a/gnome-flashback/flashback-application.c b/gnome-flashback/flashback-application.c
index 59ae945..308bf3f 100644
--- a/gnome-flashback/flashback-application.c
+++ b/gnome-flashback/flashback-application.c
@@ -23,6 +23,8 @@
#include "libdesktop-background/desktop-background.h"
#include "libdisplay-config/flashback-display-config.h"
#include "libend-session-dialog/flashback-end-session-dialog.h"
+#include "libscreencast/flashback-screencast.h"
+#include "libscreenshot/flashback-screenshot.h"
#include "libshell/flashback-shell.h"
#include "libsound-applet/gvc-applet.h"
@@ -31,6 +33,8 @@
#define KEY_DESKTOP_BACKGROUND "desktop-background"
#define KEY_DISPLAY_CONFIG "display-config"
#define KEY_END_SESSION_DIALOG "end-session-dialog"
+#define KEY_SCREENCAST "screencast"
+#define KEY_SCREENSHOT "screenshot"
#define KEY_SHELL "shell"
#define KEY_SOUND_APPLET "sound-applet"
@@ -40,6 +44,8 @@ struct _FlashbackApplicationPrivate {
DesktopBackground *background;
FlashbackDisplayConfig *config;
FlashbackEndSessionDialog *dialog;
+ FlashbackScreencast *screencast;
+ FlashbackScreenshot *screenshot;
FlashbackShell *shell;
GvcApplet *applet;
@@ -95,6 +101,26 @@ flashback_application_settings_changed (GSettings *settings,
}
}
+ if (key == NULL || g_strcmp0 (key, KEY_SCREENCAST) == 0) {
+ if (g_settings_get_boolean (settings, KEY_SCREENCAST)) {
+ if (app->priv->screencast == NULL) {
+ app->priv->screencast = flashback_screencast_new ();
+ }
+ } else {
+ g_clear_object (&app->priv->screencast);
+ }
+ }
+
+ if (key == NULL || g_strcmp0 (key, KEY_SCREENSHOT) == 0) {
+ if (g_settings_get_boolean (settings, KEY_SCREENSHOT)) {
+ if (app->priv->screenshot == NULL) {
+ app->priv->screenshot = flashback_screenshot_new ();
+ }
+ } else {
+ g_clear_object (&app->priv->screenshot);
+ }
+ }
+
if (key == NULL || g_strcmp0 (key, KEY_SHELL) == 0) {
if (g_settings_get_boolean (settings, KEY_SHELL)) {
if (app->priv->shell == NULL) {
@@ -130,6 +156,8 @@ flashback_application_finalize (GObject *object)
g_clear_object (&app->priv->background);
g_clear_object (&app->priv->config);
g_clear_object (&app->priv->dialog);
+ g_clear_object (&app->priv->screencast);
+ g_clear_object (&app->priv->screenshot);
g_clear_object (&app->priv->shell);
g_clear_object (&app->priv->applet);
g_clear_object (&app->priv->settings);
diff --git a/gnome-flashback/libscreencast/Makefile.am b/gnome-flashback/libscreencast/Makefile.am
new file mode 100644
index 0000000..836cc1f
--- /dev/null
+++ b/gnome-flashback/libscreencast/Makefile.am
@@ -0,0 +1,37 @@
+noinst_LTLIBRARIES = \
+ libscreencast.la
+
+AM_CPPFLAGS = \
+ $(SCREENCAST_CFLAGS) \
+ -I$(top_builddir)/gnome-flashback/libscreencast
+
+libscreencast_la_SOURCES = \
+ flashback-dbus-screencast.c \
+ flashback-dbus-screencast.h \
+ flashback-screencast.c \
+ flashback-screencast.h
+
+libscreencast_la_LIBADD = \
+ $(SCREENCAST_LIBS)
+
+flashback-dbus-screencast.h:
+flashback-dbus-screencast.c: org.gnome.Shell.Screencast.xml
+ $(AM_V_GEN) gdbus-codegen \
+ --interface-prefix org.gnome.Shell. \
+ --c-namespace Flashback \
+ --generate-c-code flashback-dbus-screencast \
+ --annotate "org.gnome.Shell.Screencast" \
+ "org.gtk.GDBus.C.Name" DBusScreencast \
+ $(srcdir)/org.gnome.Shell.Screencast.xml
+
+BUILT_SOURCES = \
+ flashback-dbus-screencast.c \
+ flashback-dbus-screencast.h
+
+EXTRA_DIST = \
+ org.gnome.Shell.Screencast.xml
+
+CLEANFILES = \
+ $(BUILT_SOURCES)
+
+-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/libscreencast/flashback-screencast.c
b/gnome-flashback/libscreencast/flashback-screencast.c
new file mode 100644
index 0000000..f36ddb4
--- /dev/null
+++ b/gnome-flashback/libscreencast/flashback-screencast.c
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2015 Alberts Muktupāvels
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include "flashback-dbus-screencast.h"
+#include "flashback-screencast.h"
+
+#define SHELL_DBUS_NAME "org.gnome.Shell"
+#define SCREENCAST_DBUS_PATH "/org/gnome/Shell/Screencast"
+
+struct _FlashbackScreencast
+{
+ GObject parent;
+
+ gint bus_name;
+ GDBusInterfaceSkeleton *iface;
+};
+
+G_DEFINE_TYPE (FlashbackScreencast, flashback_screencast, G_TYPE_OBJECT)
+
+static gboolean
+handle_screencast (FlashbackDBusScreencast *dbus_screencast,
+ GDBusMethodInvocation *invocation,
+ const gchar *file_template,
+ GVariant *options,
+ gpointer user_data)
+{
+ g_warning ("screencast: screencast");
+ flashback_dbus_screencast_complete_screencast (dbus_screencast, invocation,
+ FALSE, "");
+
+ return TRUE;
+}
+
+static gboolean
+handle_screencast_area (FlashbackDBusScreencast *dbus_screencast,
+ GDBusMethodInvocation *invocation,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ const gchar *file_template,
+ GVariant *options,
+ gpointer user_data)
+{
+ g_warning ("screencast: screencast-area");
+ flashback_dbus_screencast_complete_screencast_area (dbus_screencast, invocation,
+ FALSE, "");
+
+ return TRUE;
+}
+
+static gboolean
+handle_stop_screencast (FlashbackDBusScreencast *dbus_screencast,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ g_warning ("screencast: stop-screencast");
+ flashback_dbus_screencast_complete_stop_screencast (dbus_screencast, invocation,
+ TRUE);
+
+ return TRUE;
+}
+
+static void
+name_appeared_handler (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ FlashbackScreencast *screencast;
+ FlashbackDBusScreencast *skeleton;
+ GError *error;
+
+ screencast = FLASHBACK_SCREENCAST (user_data);
+ skeleton = flashback_dbus_screencast_skeleton_new ();
+
+ g_signal_connect (skeleton, "handle-screencast",
+ G_CALLBACK (handle_screencast), screencast);
+ g_signal_connect (skeleton, "handle-screencast-area",
+ G_CALLBACK (handle_screencast_area), screencast);
+ g_signal_connect (skeleton, "handle-stop-screencast",
+ G_CALLBACK (handle_stop_screencast), screencast);
+
+ error = NULL;
+ screencast->iface = G_DBUS_INTERFACE_SKELETON (skeleton);
+
+ if (!g_dbus_interface_skeleton_export (screencast->iface, connection,
+ SCREENCAST_DBUS_PATH,
+ &error))
+ {
+ g_warning ("Failed to export interface: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+}
+
+static void
+flashback_screencast_finalize (GObject *object)
+{
+ FlashbackScreencast *screencast;
+
+ screencast = FLASHBACK_SCREENCAST (object);
+
+ if (screencast->bus_name)
+ {
+ g_bus_unwatch_name (screencast->bus_name);
+ screencast->bus_name = 0;
+ }
+
+ G_OBJECT_CLASS (flashback_screencast_parent_class)->finalize (object);
+}
+
+static void
+flashback_screencast_class_init (FlashbackScreencastClass *screencast_class)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (screencast_class);
+
+ object_class->finalize = flashback_screencast_finalize;
+}
+
+static void
+flashback_screencast_init (FlashbackScreencast *screencast)
+{
+ screencast->bus_name = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ SHELL_DBUS_NAME,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ name_appeared_handler,
+ NULL,
+ screencast,
+ NULL);
+}
+
+FlashbackScreencast *
+flashback_screencast_new (void)
+{
+ return g_object_new (FLASHBACK_TYPE_SCREENCAST, NULL);
+}
diff --git a/gnome-flashback/libscreencast/flashback-screencast.h
b/gnome-flashback/libscreencast/flashback-screencast.h
new file mode 100644
index 0000000..51daf57
--- /dev/null
+++ b/gnome-flashback/libscreencast/flashback-screencast.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2015 Alberts Muktupāvels
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FLASHBACK_SCREENCAST_H
+#define FLASHBACK_SCREENCAST_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define FLASHBACK_TYPE_SCREENCAST flashback_screencast_get_type ()
+G_DECLARE_FINAL_TYPE (FlashbackScreencast, flashback_screencast,
+ FLASHBACK, SCREENCAST, GObject)
+
+FlashbackScreencast *flashback_screencast_new (void);
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/libscreencast/org.gnome.Shell.Screencast.xml
b/gnome-flashback/libscreencast/org.gnome.Shell.Screencast.xml
new file mode 100644
index 0000000..f188cf7
--- /dev/null
+++ b/gnome-flashback/libscreencast/org.gnome.Shell.Screencast.xml
@@ -0,0 +1,95 @@
+<!DOCTYPE node PUBLIC
+'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
+'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
+<node>
+
+ <!--
+ org.gnome.Shell.Screencast:
+ @short_description: Screencast interface
+
+ The interface used to record screen contents.
+ -->
+ <interface name="org.gnome.Shell.Screencast">
+
+ <!--
+ Screencast:
+ @file_template: the template for the filename to use
+ @options: a dictionary of optional parameters
+ @success: whether the screencast was started successfully
+ @filename_used: the file where the screencast is being saved
+
+ Records a screencast of the whole screen and saves it
+ (by default) as webm video under a filename derived from
+ @file_template. The template is either a relative or absolute
+ filename which may contain some escape sequences - %d and %t
+ will be replaced by the start date and time of the recording.
+ If a relative name is used, the screencast will be saved in the
+ $XDG_VIDEOS_DIR if it exists, or the home directory otherwise.
+ The actual filename of the saved video is returned in @filename_used.
+ The set of optional parameters in @options currently consists of:
+ 'draw-cursor'(b): whether the cursor should be included in the
+ recording (true)
+ 'framerate'(i): the number of frames per second that should be
+ recorded if possible (30)
+ 'pipeline'(s): the GStreamer pipeline used to encode recordings
+ in gst-launch format; if not specified, the
+ recorder will produce vp8 (webm) video (unset)
+ -->
+ <method name="Screencast">
+ <arg type="s" direction="in" name="file_template"/>
+ <arg type="a{sv}" direction="in" name="options"/>
+ <arg type="b" direction="out" name="success"/>
+ <arg type="s" direction="out" name="filename_used"/>
+ </method>
+
+ <!--
+ ScreencastArea:
+ @x: the X coordinate of the area to capture
+ @y: the Y coordinate of the area to capture
+ @width: the width of the area to capture
+ @height: the height of the area to capture
+ @file_template: the template for the filename to use
+ @options: a dictionary of optional parameters
+ @success: whether the screencast was started successfully
+ @filename_used: the file where the screencast is being saved
+
+ Records a screencast of the passed in area and saves it
+ (by default) as webm video under a filename derived from
+ @file_template. The template is either a relative or absolute
+ filename which may contain some escape sequences - %d and %t
+ will be replaced by the start date and time of the recording.
+ If a relative name is used, the screencast will be saved in the
+ $XDG_VIDEOS_DIR if it exists, or the home directory otherwise.
+ The actual filename of the saved video is returned in @filename_used.
+ The set of optional parameters in @options currently consists of:
+ 'draw-cursor'(b): whether the cursor should be included in the
+ recording (true)
+ 'framerate'(i): the number of frames per second that should be
+ recorded if possible (30)
+ 'pipeline'(s): the GStreamer pipeline used to encode recordings
+ in gst-launch format; if not specified, the
+ recorder will produce vp8 (webm) video (unset)
+ -->
+ <method name="ScreencastArea">
+ <arg type="i" direction="in" name="x"/>
+ <arg type="i" direction="in" name="y"/>
+ <arg type="i" direction="in" name="width"/>
+ <arg type="i" direction="in" name="height"/>
+ <arg type="s" direction="in" name="file_template"/>
+ <arg type="a{sv}" direction="in" name="options"/>
+ <arg type="b" direction="out" name="success"/>
+ <arg type="s" direction="out" name="filename_used"/>
+ </method>
+
+ <!--
+ StopScreencast:
+ @success: whether stopping the recording was successful
+
+ Stop the recording started by either Screencast or ScreencastArea.
+ -->
+ <method name="StopScreencast">
+ <arg type="b" direction="out" name="success"/>
+ </method>
+
+ </interface>
+</node>
diff --git a/gnome-flashback/libscreenshot/Makefile.am b/gnome-flashback/libscreenshot/Makefile.am
new file mode 100644
index 0000000..5eb38ca
--- /dev/null
+++ b/gnome-flashback/libscreenshot/Makefile.am
@@ -0,0 +1,37 @@
+noinst_LTLIBRARIES = \
+ libscreenshot.la
+
+AM_CPPFLAGS = \
+ $(SCREENSHOT_CFLAGS) \
+ -I$(top_builddir)/gnome-flashback/libscreenshot
+
+libscreenshot_la_SOURCES = \
+ flashback-dbus-screenshot.c \
+ flashback-dbus-screenshot.h \
+ flashback-screenshot.c \
+ flashback-screenshot.h
+
+libscreenshot_la_LIBADD = \
+ $(SCREENSHOT_LIBS)
+
+flashback-dbus-screenshot.h:
+flashback-dbus-screenshot.c: org.gnome.Shell.Screenshot.xml
+ $(AM_V_GEN) gdbus-codegen \
+ --interface-prefix org.gnome.Shell. \
+ --c-namespace Flashback \
+ --generate-c-code flashback-dbus-screenshot \
+ --annotate "org.gnome.Shell.Screenshot" \
+ "org.gtk.GDBus.C.Name" DBusScreenshot \
+ $(srcdir)/org.gnome.Shell.Screenshot.xml
+
+BUILT_SOURCES = \
+ flashback-dbus-screenshot.c \
+ flashback-dbus-screenshot.h
+
+EXTRA_DIST = \
+ org.gnome.Shell.Screenshot.xml
+
+CLEANFILES = \
+ $(BUILT_SOURCES)
+
+-include $(top_srcdir)/git.mk
diff --git a/gnome-flashback/libscreenshot/flashback-screenshot.c
b/gnome-flashback/libscreenshot/flashback-screenshot.c
new file mode 100644
index 0000000..61395ae
--- /dev/null
+++ b/gnome-flashback/libscreenshot/flashback-screenshot.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2015 Alberts Muktupāvels
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include "flashback-dbus-screenshot.h"
+#include "flashback-screenshot.h"
+
+#define SHELL_DBUS_NAME "org.gnome.Shell"
+#define SCREENSHOT_DBUS_PATH "/org/gnome/Shell/Screenshot"
+
+struct _FlashbackScreenshot
+{
+ GObject parent;
+
+ gint bus_name;
+ GDBusInterfaceSkeleton *iface;
+};
+
+G_DEFINE_TYPE (FlashbackScreenshot, flashback_screenshot, G_TYPE_OBJECT)
+
+static gboolean
+handle_screenshot (FlashbackDBusScreenshot *dbus_screenshot,
+ GDBusMethodInvocation *invocation,
+ gboolean include_cursor,
+ gboolean flash,
+ const gchar *filename,
+ gpointer user_data)
+{
+ g_warning ("screenshot: screenshot");
+ flashback_dbus_screenshot_complete_screenshot (dbus_screenshot, invocation,
+ FALSE, "");
+
+ return TRUE;
+}
+
+static gboolean
+handle_screenshot_window (FlashbackDBusScreenshot *dbus_screenshot,
+ GDBusMethodInvocation *invocation,
+ gboolean include_frame,
+ gboolean include_cursor,
+ gboolean flash,
+ const gchar *filename,
+ gpointer user_data)
+{
+ g_warning ("screenshot: screenshot-window");
+ flashback_dbus_screenshot_complete_screenshot_window (dbus_screenshot, invocation,
+ FALSE, "");
+
+ return TRUE;
+}
+
+static gboolean
+handle_screenshot_area (FlashbackDBusScreenshot *dbus_screenshot,
+ GDBusMethodInvocation *invocation,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ const gchar *file_template,
+ GVariant *options,
+ gpointer user_data)
+{
+ g_warning ("screenshot: screenshot-area");
+ flashback_dbus_screenshot_complete_screenshot_area (dbus_screenshot, invocation,
+ FALSE, "");
+
+ return TRUE;
+}
+
+static gboolean
+handle_flash_area (FlashbackDBusScreenshot *dbus_screenshot,
+ GDBusMethodInvocation *invocation,
+ gint x,
+ gint y,
+ gint width,
+ gint height,
+ gpointer user_data)
+{
+ g_warning ("screenshot: flash-area");
+ flashback_dbus_screenshot_complete_flash_area (dbus_screenshot, invocation);
+
+ return TRUE;
+}
+
+static gboolean
+handle_select_area (FlashbackDBusScreenshot *dbus_screenshot,
+ GDBusMethodInvocation *invocation,
+ gpointer user_data)
+{
+ g_warning ("screenshot: select-area");
+ flashback_dbus_screenshot_complete_select_area (dbus_screenshot, invocation,
+ 0, 0, 0, 0);
+
+ return TRUE;
+}
+
+static void
+name_appeared_handler (GDBusConnection *connection,
+ const gchar *name,
+ const gchar *name_owner,
+ gpointer user_data)
+{
+ FlashbackScreenshot *screenshot;
+ FlashbackDBusScreenshot *skeleton;
+ GError *error;
+
+ screenshot = FLASHBACK_SCREENSHOT (user_data);
+ skeleton = flashback_dbus_screenshot_skeleton_new ();
+
+ g_signal_connect (skeleton, "handle-screenshot",
+ G_CALLBACK (handle_screenshot), screenshot);
+ g_signal_connect (skeleton, "handle-screenshot-window",
+ G_CALLBACK (handle_screenshot_window), screenshot);
+ g_signal_connect (skeleton, "handle-screenshot-area",
+ G_CALLBACK (handle_screenshot_area), screenshot);
+ g_signal_connect (skeleton, "handle-flash-area",
+ G_CALLBACK (handle_flash_area), screenshot);
+ g_signal_connect (skeleton, "handle-select-area",
+ G_CALLBACK (handle_select_area), screenshot);
+
+ error = NULL;
+ screenshot->iface = G_DBUS_INTERFACE_SKELETON (skeleton);
+
+ if (!g_dbus_interface_skeleton_export (screenshot->iface, connection,
+ SCREENSHOT_DBUS_PATH,
+ &error))
+ {
+ g_warning ("Failed to export interface: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+}
+
+static void
+flashback_screenshot_finalize (GObject *object)
+{
+ FlashbackScreenshot *screenshot;
+
+ screenshot = FLASHBACK_SCREENSHOT (object);
+
+ if (screenshot->bus_name)
+ {
+ g_bus_unwatch_name (screenshot->bus_name);
+ screenshot->bus_name = 0;
+ }
+
+ G_OBJECT_CLASS (flashback_screenshot_parent_class)->finalize (object);
+}
+
+static void
+flashback_screenshot_class_init (FlashbackScreenshotClass *screenshot_class)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (screenshot_class);
+
+ object_class->finalize = flashback_screenshot_finalize;
+}
+
+static void
+flashback_screenshot_init (FlashbackScreenshot *screenshot)
+{
+ screenshot->bus_name = g_bus_watch_name (G_BUS_TYPE_SESSION,
+ SHELL_DBUS_NAME,
+ G_BUS_NAME_WATCHER_FLAGS_NONE,
+ name_appeared_handler,
+ NULL,
+ screenshot,
+ NULL);
+}
+
+FlashbackScreenshot *
+flashback_screenshot_new (void)
+{
+ return g_object_new (FLASHBACK_TYPE_SCREENSHOT, NULL);
+}
diff --git a/gnome-flashback/libscreenshot/flashback-screenshot.h
b/gnome-flashback/libscreenshot/flashback-screenshot.h
new file mode 100644
index 0000000..2a1a0fe
--- /dev/null
+++ b/gnome-flashback/libscreenshot/flashback-screenshot.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2015 Alberts Muktupāvels
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef FLASHBACK_SCREENSHOT_H
+#define FLASHBACK_SCREENSHOT_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define FLASHBACK_TYPE_SCREENSHOT flashback_screenshot_get_type ()
+G_DECLARE_FINAL_TYPE (FlashbackScreenshot, flashback_screenshot,
+ FLASHBACK, SCREENSHOT, GObject)
+
+FlashbackScreenshot *flashback_screenshot_new (void);
+
+G_END_DECLS
+
+#endif
diff --git a/gnome-flashback/libscreenshot/org.gnome.Shell.Screenshot.xml
b/gnome-flashback/libscreenshot/org.gnome.Shell.Screenshot.xml
new file mode 100644
index 0000000..9ffa5f6
--- /dev/null
+++ b/gnome-flashback/libscreenshot/org.gnome.Shell.Screenshot.xml
@@ -0,0 +1,128 @@
+<!DOCTYPE node PUBLIC
+'-//freedesktop//DTD D-BUS Object Introspection 1.0//EN'
+'http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd'>
+<node>
+
+ <!--
+ org.gnome.Shell.Screenshot:
+ @short_description: Screenshot interface
+
+ The interface used to capture pictures of the screen contents.
+ -->
+ <interface name="org.gnome.Shell.Screenshot">
+
+ <!--
+ Screenshot:
+ @filename: The filename for the screenshot
+ @include_cursor: Whether to include the cursor image or not
+ @flash: Whether to flash the screen or not
+ @success: whether the screenshot was captured
+ @filename_used: the file where the screenshot was saved
+
+ Takes a screenshot of the whole screen and saves it
+ in @filename as png image, it returns a boolean
+ indicating whether the operation was successful or not.
+ @filename can either be an absolute path or a basename, in
+ which case the screenshot will be saved in the $XDG_PICTURES_DIR
+ or the home directory if it doesn't exist. The filename used
+ to save the screenshot will be returned in @filename_used.
+ -->
+ <method name="Screenshot">
+ <arg type="b" direction="in" name="include_cursor"/>
+ <arg type="b" direction="in" name="flash"/>
+ <arg type="s" direction="in" name="filename"/>
+ <arg type="b" direction="out" name="success"/>
+ <arg type="s" direction="out" name="filename_used"/>
+ </method>
+
+ <!--
+ ScreenshotWindow:
+ @include_frame: Whether to include the frame or not
+ @include_cursor: Whether to include the cursor image or not
+ @flash: Whether to flash the window area or not
+ @filename: The filename for the screenshot
+ @success: whether the screenshot was captured
+ @filename_used: the file where the screenshot was saved
+
+ Takes a screenshot of the focused window (optionally omitting the frame)
+ and saves it in @filename as png image, it returns a boolean
+ indicating whether the operation was successful or not.
+ @filename can either be an absolute path or a basename, in
+ which case the screenshot will be saved in the $XDG_PICTURES_DIR
+ or the home directory if it doesn't exist. The filename used
+ to save the screenshot will be returned in @filename_used.
+ -->
+ <method name="ScreenshotWindow">
+ <arg type="b" direction="in" name="include_frame"/>
+ <arg type="b" direction="in" name="include_cursor"/>
+ <arg type="b" direction="in" name="flash"/>
+ <arg type="s" direction="in" name="filename"/>
+ <arg type="b" direction="out" name="success"/>
+ <arg type="s" direction="out" name="filename_used"/>
+ </method>
+
+ <!--
+ ScreenshotArea:
+ @x: the X coordinate of the area to capture
+ @y: the Y coordinate of the area to capture
+ @width: the width of the area to capture
+ @height: the height of the area to capture
+ @flash: whether to flash the area or not
+ @filename: the filename for the screenshot
+ @success: whether the screenshot was captured
+ @filename_used: the file where the screenshot was saved
+
+ Takes a screenshot of the passed in area and saves it
+ in @filename as png image, it returns a boolean
+ indicating whether the operation was successful or not.
+ @filename can either be an absolute path or a basename, in
+ which case the screenshot will be saved in the $XDG_PICTURES_DIR
+ or the home directory if it doesn't exist. The filename used
+ to save the screenshot will be returned in @filename_used.
+ -->
+ <method name="ScreenshotArea">
+ <arg type="i" direction="in" name="x"/>
+ <arg type="i" direction="in" name="y"/>
+ <arg type="i" direction="in" name="width"/>
+ <arg type="i" direction="in" name="height"/>
+ <arg type="b" direction="in" name="flash"/>
+ <arg type="s" direction="in" name="filename"/>
+ <arg type="b" direction="out" name="success"/>
+ <arg type="s" direction="out" name="filename_used"/>
+ </method>
+
+ <!--
+ FlashArea:
+ @x: the X coordinate of the area to flash
+ @y: the Y coordinate of the area to flash
+ @width: the width of the area to flash
+ @height: the height of the area to flash
+
+ Renders a flash spot effect in the specified rectangle of the screen.
+ -->
+ <method name="FlashArea">
+ <arg type="i" direction="in" name="x"/>
+ <arg type="i" direction="in" name="y"/>
+ <arg type="i" direction="in" name="width"/>
+ <arg type="i" direction="in" name="height"/>
+ </method>
+
+ <!--
+ SelectArea:
+ @x: the X coordinate of the selected area
+ @y: the Y coordinate of the selected area
+ @width: the width of the selected area
+ @height: the height of the selected area
+
+ Interactively allows the user to select a rectangular area of
+ the screen, and returns its coordinates.
+ -->
+ <method name="SelectArea">
+ <arg type="i" direction="out" name="x"/>
+ <arg type="i" direction="out" name="y"/>
+ <arg type="i" direction="out" name="width"/>
+ <arg type="i" direction="out" name="height"/>
+ </method>
+
+ </interface>
+</node>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]