[gitg] Add a platform support method to get a stream from a fd
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Add a platform support method to get a stream from a fd
- Date: Mon, 21 Dec 2015 13:54:48 +0000 (UTC)
commit 4fc83c3a13fabe69558623ffca397e7c2f41158d
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Dec 21 14:53:33 2015 +0100
Add a platform support method to get a stream from a fd
libgitg/gitg-hook.vala | 6 +-----
libgitg/gitg-platform-support-osx.c | 8 ++++++++
libgitg/gitg-platform-support-win32.c | 9 +++++++++
libgitg/gitg-platform-support.c | 9 +++++++++
libgitg/gitg-platform-support.h | 3 +++
vapi/gitg-platform-support.vapi | 2 ++
6 files changed, 32 insertions(+), 5 deletions(-)
---
diff --git a/libgitg/gitg-hook.vala b/libgitg/gitg-hook.vala
index fe64e85..f4b9607 100644
--- a/libgitg/gitg-hook.vala
+++ b/libgitg/gitg-hook.vala
@@ -101,11 +101,7 @@ public class Hook : Object
private void read_from_fd(int fd)
{
-#if G_OS_WIN32
- var stream = new Win32InputStream(fd, true);
-#else
- var stream = new UnixInputStream(fd, true);
-#endif
+ var stream = PlatformSupport.new_input_stream_from_fd(fd, true);
var dstream = new DataInputStream(stream);
stream_read_async(dstream);
diff --git a/libgitg/gitg-platform-support-osx.c b/libgitg/gitg-platform-support-osx.c
index d105cce..31a8e95 100644
--- a/libgitg/gitg-platform-support-osx.c
+++ b/libgitg/gitg-platform-support-osx.c
@@ -20,6 +20,7 @@
#include "gitg-platform-support.h"
#include <gdk/gdkquartz.h>
+#include <gio/gunixinputstream.h>
gboolean
gitg_platform_support_use_native_window_controls (GdkDisplay *display)
@@ -159,4 +160,11 @@ gitg_platform_support_create_cursor_surface (GdkDisplay *display,
return target;
}
+GInputStream *
+gitg_platform_support_new_input_stream_from_fd (gint fd,
+ gboolean close_fd)
+{
+ return g_unix_input_stream_new (fd, close_fd);
+}
+
// ex:ts=4 noet
diff --git a/libgitg/gitg-platform-support-win32.c b/libgitg/gitg-platform-support-win32.c
index f80c72b..ac39775 100644
--- a/libgitg/gitg-platform-support-win32.c
+++ b/libgitg/gitg-platform-support-win32.c
@@ -19,6 +19,8 @@
#include "gitg-platform-support.h"
+#include <gio/gwin32inputstream.h>
+
gboolean
gitg_platform_support_use_native_window_controls (GdkDisplay *display)
{
@@ -52,4 +54,11 @@ gitg_platform_support_create_cursor_surface (GdkDisplay *display,
return NULL;
}
+GInputStream *
+gitg_platform_support_new_input_stream_from_fd (gint fd,
+ gboolean close_fd)
+{
+ return g_win32_input_stream_new ((void *)fd, close_fd);
+}
+
// ex:ts=4 noet
diff --git a/libgitg/gitg-platform-support.c b/libgitg/gitg-platform-support.c
index 77c0227..2b2ff57 100644
--- a/libgitg/gitg-platform-support.c
+++ b/libgitg/gitg-platform-support.c
@@ -19,6 +19,8 @@
#include "gitg-platform-support.h"
+#include <gio/gunixinputstream.h>
+
gboolean
gitg_platform_support_use_native_window_controls (GdkDisplay *display)
{
@@ -86,4 +88,11 @@ gitg_platform_support_create_cursor_surface (GdkDisplay *display,
return surface;
}
+GInputStream *
+gitg_platform_support_new_input_stream_from_fd (gint fd,
+ gboolean close_fd)
+{
+ return g_unix_input_stream_new (fd, close_fd);
+}
+
// ex:ts=4 noet
diff --git a/libgitg/gitg-platform-support.h b/libgitg/gitg-platform-support.h
index ea502bb..6906282 100644
--- a/libgitg/gitg-platform-support.h
+++ b/libgitg/gitg-platform-support.h
@@ -41,6 +41,9 @@ cairo_surface_t *gitg_platform_support_create_cursor_surface (GdkDisplay *dis
gint *width,
gint *height);
+GInputStream *gitg_platform_support_new_input_stream_from_fd (gint fd,
+ gboolean close_fd);
+
#endif /* __GITG_PLATFORM_SUPPORT_H__ */
// ex:ts=4 noet
diff --git a/vapi/gitg-platform-support.vapi b/vapi/gitg-platform-support.vapi
index 50b1b99..d00f05a 100644
--- a/vapi/gitg-platform-support.vapi
+++ b/vapi/gitg-platform-support.vapi
@@ -12,5 +12,7 @@ namespace Gitg
out int hot_y = null,
out int width = null,
out int height = null);
+
+ public static GLib.InputStream new_input_stream_from_fd(int fd, bool close_fd);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]