[tepl] View: add new_with_buffer()
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tepl] View: add new_with_buffer()
- Date: Sat, 18 Apr 2020 17:17:40 +0000 (UTC)
commit e9da8fe022021c90a7dd7af67782aaf2d768b838
Author: Sébastien Wilmet <swilmet gnome org>
Date: Sat Apr 11 15:44:56 2020 +0200
View: add new_with_buffer()
It's possible to use TeplView without using TeplBuffer, just a
GtkSourceBuffer. It will ease porting apps that don't use TeplBuffer
yet.
tepl_view_new_with_buffer() was in any case missing, it will be used in
gCSVedit (at least as a transition to use more Tepl features).
TeplView doesn't depend on TeplBuffer. If in the future TeplView depends
on TeplBuffer, then the API will need to be broken.
docs/reference/tepl-sections.txt | 1 +
tepl/tepl-view.c | 30 +++++++++++++++++++++++++++++-
tepl/tepl-view.h | 4 +++-
3 files changed, 33 insertions(+), 2 deletions(-)
---
diff --git a/docs/reference/tepl-sections.txt b/docs/reference/tepl-sections.txt
index 863e1dc..1e3e816 100644
--- a/docs/reference/tepl-sections.txt
+++ b/docs/reference/tepl-sections.txt
@@ -428,6 +428,7 @@ tepl_utils_show_warning_dialog
<FILE>view</FILE>
TeplView
tepl_view_new
+tepl_view_new_with_buffer
tepl_view_cut_clipboard
tepl_view_copy_clipboard
tepl_view_paste_clipboard
diff --git a/tepl/tepl-view.c b/tepl/tepl-view.c
index 943884c..873799f 100644
--- a/tepl/tepl-view.c
+++ b/tepl/tepl-view.c
@@ -6,7 +6,7 @@
* Copyright 2000, 2002 - Chema Celorio, Paolo Maggi
* Copyright 2003-2005 - Paolo Maggi
*
- * Copyright 2016 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright 2016-2020 - Sébastien Wilmet <swilmet gnome org>
*
* Tepl is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -60,6 +60,15 @@ tepl_view_init (TeplView *view)
/**
* tepl_view_new:
*
+ * Creates a new #TeplView.
+ *
+ * By default, an empty #TeplBuffer will be lazily created and can be retrieved
+ * with gtk_text_view_get_buffer().
+ *
+ * If you want to specify your own buffer, either override the
+ * #GtkTextViewClass create_buffer factory method, or use
+ * tepl_view_new_with_buffer().
+ *
* Returns: a new #TeplView.
* Since: 1.0
*/
@@ -69,6 +78,25 @@ tepl_view_new (void)
return g_object_new (TEPL_TYPE_VIEW, NULL);
}
+/**
+ * tepl_view_new_with_buffer:
+ * @buffer: a #GtkSourceBuffer or a subclass of it.
+ *
+ * Creates a new #TeplView widget displaying the buffer @buffer.
+ *
+ * Returns: a new #TeplView.
+ * Since: 5.0
+ */
+GtkWidget *
+tepl_view_new_with_buffer (GtkSourceBuffer *buffer)
+{
+ g_return_val_if_fail (GTK_SOURCE_IS_BUFFER (buffer), NULL);
+
+ return g_object_new (TEPL_TYPE_VIEW,
+ "buffer", buffer,
+ NULL);
+}
+
/**
* tepl_view_cut_clipboard:
* @view: a #TeplView.
diff --git a/tepl/tepl-view.h b/tepl/tepl-view.h
index a67c845..c631614 100644
--- a/tepl/tepl-view.h
+++ b/tepl/tepl-view.h
@@ -1,7 +1,7 @@
/*
* This file is part of Tepl, a text editor library.
*
- * Copyright 2016 - Sébastien Wilmet <swilmet gnome org>
+ * Copyright 2016-2020 - Sébastien Wilmet <swilmet gnome org>
*
* Tepl is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
@@ -42,6 +42,8 @@ struct _TeplViewClass
GtkWidget * tepl_view_new (void);
+GtkWidget * tepl_view_new_with_buffer (GtkSourceBuffer *buffer);
+
void tepl_view_cut_clipboard (TeplView *view);
void tepl_view_copy_clipboard (TeplView *view);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]