[gtk/wip/chergert/textview-widgets: 1/2] textview: remove gtk_text_view_set_border_window_size()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/chergert/textview-widgets: 1/2] textview: remove gtk_text_view_set_border_window_size()
- Date: Tue, 17 Sep 2019 20:26:34 +0000 (UTC)
commit c9c6d56c495c311e220adbae116ea93c9e14d6e2
Author: Christian Hergert <chergert redhat com>
Date: Mon Sep 16 17:26:50 2019 -0700
textview: remove gtk_text_view_set_border_window_size()
The goal here is to use widgets for the border windows rather than
specifying there size through alternate API such as this.
gtk/gtktextview.c | 40 ++++++++++------------------
gtk/gtktextview.h | 4 ---
testsuite/reftests/textview-border-windows.c | 20 +++++++++++---
3 files changed, 30 insertions(+), 34 deletions(-)
---
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 7811fd79af..43d6a8ec48 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -369,6 +369,9 @@ static void gtk_text_view_size_allocate (GtkWidget *widget,
int width,
int height,
int baseline);
+static void gtk_text_view_set_border_window_size (GtkTextView *text_view,
+ GtkTextWindowType type,
+ gint size);
static void gtk_text_view_realize (GtkWidget *widget);
static void gtk_text_view_unrealize (GtkWidget *widget);
static void gtk_text_view_map (GtkWidget *widget);
@@ -9224,8 +9227,7 @@ gtk_text_view_get_css_node (GtkTextView *text_view,
* Converts coordinate (@buffer_x, @buffer_y) to coordinates for the window
* @win, and stores the result in (@window_x, @window_y).
*
- * Note that you can’t convert coordinates for a nonexisting window (see
- * gtk_text_view_set_border_window_size()).
+ * Note that you can’t convert coordinates for a nonexisting window.
**/
void
gtk_text_view_buffer_to_surface_coords (GtkTextView *text_view,
@@ -9295,8 +9297,7 @@ gtk_text_view_buffer_to_surface_coords (GtkTextView *text_view,
* Converts coordinates on the window identified by @win to buffer
* coordinates, storing the result in (@buffer_x,@buffer_y).
*
- * Note that you can’t convert coordinates for a nonexisting window (see
- * gtk_text_view_set_border_window_size()).
+ * Note that you can’t convert coordinates for a nonexisting window.
**/
void
gtk_text_view_window_to_buffer_coords (GtkTextView *text_view,
@@ -9381,24 +9382,10 @@ set_window_size (GtkTextView *text_view,
gtk_widget_queue_resize (GTK_WIDGET (text_view));
}
-/**
- * gtk_text_view_set_border_window_size:
- * @text_view: a #GtkTextView
- * @type: window to affect
- * @size: width or height of the window
- *
- * Sets the width of %GTK_TEXT_WINDOW_LEFT or %GTK_TEXT_WINDOW_RIGHT,
- * or the height of %GTK_TEXT_WINDOW_TOP or %GTK_TEXT_WINDOW_BOTTOM.
- * Automatically destroys the corresponding window if the size is set
- * to 0, and creates the window if the size is set to non-zero. This
- * function can only be used for the “border windows,” it doesn’t work
- * with #GTK_TEXT_WINDOW_WIDGET, #GTK_TEXT_WINDOW_TEXT, or
- * #GTK_TEXT_WINDOW_PRIVATE.
- **/
-void
-gtk_text_view_set_border_window_size (GtkTextView *text_view,
- GtkTextWindowType type,
- gint size)
+static void
+gtk_text_view_set_border_window_size (GtkTextView *text_view,
+ GtkTextWindowType type,
+ gint size)
{
GtkTextViewPrivate *priv = text_view->priv;
@@ -9431,8 +9418,7 @@ gtk_text_view_set_border_window_size (GtkTextView *text_view,
case GTK_TEXT_WINDOW_WIDGET:
case GTK_TEXT_WINDOW_TEXT:
default:
- g_warning ("Can only set size of left/right/top/bottom border windows with
gtk_text_view_set_border_window_size()");
- break;
+ g_return_if_reached ();
}
}
@@ -9441,8 +9427,10 @@ gtk_text_view_set_border_window_size (GtkTextView *text_view,
* @text_view: a #GtkTextView
* @type: window to return size from
*
- * Gets the width of the specified border window. See
- * gtk_text_view_set_border_window_size().
+ * Gets the width of the specified border window.
+ *
+ * @type must be one of %GTK_TEXT_WINDOW_LEFT, %GTK_TEXT_WINDOW_RIGHT,
+ * %GTK_TEXT_WINDOW_TOP, or %GTK_TEXT_WINDOW_BOTTOM.
*
* Returns: width of window
**/
diff --git a/gtk/gtktextview.h b/gtk/gtktextview.h
index bf666f7b81..45d452caaf 100644
--- a/gtk/gtktextview.h
+++ b/gtk/gtktextview.h
@@ -281,10 +281,6 @@ void gtk_text_view_window_to_buffer_coords (GtkTextView *text_view,
gint *buffer_y);
GDK_AVAILABLE_IN_ALL
-void gtk_text_view_set_border_window_size (GtkTextView *text_view,
- GtkTextWindowType type,
- gint size);
-GDK_AVAILABLE_IN_ALL
gint gtk_text_view_get_border_window_size (GtkTextView *text_view,
GtkTextWindowType type);
diff --git a/testsuite/reftests/textview-border-windows.c b/testsuite/reftests/textview-border-windows.c
index 019b654907..f11f60e75c 100644
--- a/testsuite/reftests/textview-border-windows.c
+++ b/testsuite/reftests/textview-border-windows.c
@@ -17,12 +17,24 @@
#include <gtk/gtk.h>
+static void
+add_border_window (GtkTextView *text_view,
+ GtkTextWindowType window_type)
+{
+ GtkWidget *box;
+
+ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_widget_set_size_request (box, 30, 30);
+ gtk_widget_set_hexpand (box, TRUE);
+ gtk_widget_set_vexpand (box, TRUE);
+ gtk_text_view_add_child_in_window (text_view, box, window_type, 0, 0);
+}
G_MODULE_EXPORT void
add_border_windows (GtkTextView *text_view)
{
- gtk_text_view_set_border_window_size (text_view, GTK_TEXT_WINDOW_LEFT, 30);
- gtk_text_view_set_border_window_size (text_view, GTK_TEXT_WINDOW_RIGHT, 30);
- gtk_text_view_set_border_window_size (text_view, GTK_TEXT_WINDOW_TOP, 30);
- gtk_text_view_set_border_window_size (text_view, GTK_TEXT_WINDOW_BOTTOM, 30);
+ add_border_window (text_view, GTK_TEXT_WINDOW_LEFT);
+ add_border_window (text_view, GTK_TEXT_WINDOW_RIGHT);
+ add_border_window (text_view, GTK_TEXT_WINDOW_TOP);
+ add_border_window (text_view, GTK_TEXT_WINDOW_BOTTOM);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]