Add private accessors for GntWidget minimum sizes.

Fri, 26 Apr 2019 04:22:10 -0400

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 26 Apr 2019 04:22:10 -0400
changeset 1254
4a28e30a580d
parent 1253
2a0ecf6203f6
child 1255
2610e3957206

Add private accessors for GntWidget minimum sizes.

gntbutton.c file | annotate | diff | comparison | revisions
gntcheckbox.c file | annotate | diff | comparison | revisions
gntcombobox.c file | annotate | diff | comparison | revisions
gntentry.c file | annotate | diff | comparison | revisions
gntlabel.c file | annotate | diff | comparison | revisions
gntline.c file | annotate | diff | comparison | revisions
gntprogressbar.c file | annotate | diff | comparison | revisions
gntslider.c file | annotate | diff | comparison | revisions
gnttextview.c file | annotate | diff | comparison | revisions
gnttree.c file | annotate | diff | comparison | revisions
gntwidget.c file | annotate | diff | comparison | revisions
gntwidgetprivate.h file | annotate | diff | comparison | revisions
--- a/gntbutton.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntbutton.c	Fri Apr 26 04:22:10 2019 -0400
@@ -28,6 +28,8 @@
 #include "gntstyle.h"
 #include "gntutils.h"
 
+#include "gntwidgetprivate.h"
+
 typedef struct
 {
 	gchar *text;
@@ -142,8 +144,7 @@
 {
 	GntWidget *widget = GNT_WIDGET(button);
 
-	widget->priv.minw = 4;
-	widget->priv.minh = small_button ? 1 : 3;
+	gnt_widget_set_minimum_size(widget, 4, small_button ? 1 : 3);
 	if (small_button) {
 		gnt_widget_set_has_border(widget, FALSE);
 		gnt_widget_set_has_shadow(widget, FALSE);
--- a/gntcheckbox.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntcheckbox.c	Fri Apr 26 04:22:10 2019 -0400
@@ -23,6 +23,8 @@
 #include "gntinternal.h"
 #include "gntcheckbox.h"
 
+#include "gntwidgetprivate.h"
+
 typedef struct
 {
 	gboolean checked;
@@ -123,8 +125,7 @@
 gnt_check_box_init(GntCheckBox *box)
 {
 	GntWidget *widget = GNT_WIDGET(box);
-	widget->priv.minh = 1;
-	widget->priv.minw = 4;
+	gnt_widget_set_minimum_size(widget, 4, 1);
 	gnt_widget_set_has_border(widget, FALSE);
 	gnt_widget_set_has_shadow(widget, FALSE);
 }
--- a/gntcombobox.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntcombobox.c	Fri Apr 26 04:22:10 2019 -0400
@@ -28,6 +28,8 @@
 #include "gntstyle.h"
 #include "gntutils.h"
 
+#include "gntwidgetprivate.h"
+
 #include <string.h>
 
 struct _GntComboBox
@@ -334,9 +336,7 @@
 	gnt_box_set_pad(GNT_BOX(box), 0);
 	gnt_box_add_widget(GNT_BOX(box), combo->dropdown);
 
-	widget->priv.minw = 4;
-	widget->priv.minh = 3;
-	GNTDEBUG;
+	gnt_widget_set_minimum_size(widget, 4, 3);
 }
 
 /******************************************************************************
--- a/gntentry.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntentry.c	Fri Apr 26 04:22:10 2019 -0400
@@ -30,6 +30,8 @@
 #include "gnttree.h"
 #include "gntutils.h"
 
+#include "gntwidgetprivate.h"
+
 enum
 {
 	SIG_TEXT_CHANGED,
@@ -1170,10 +1172,7 @@
 	gnt_widget_set_take_focus(widget, TRUE);
 	gnt_widget_set_grow_x(widget, TRUE);
 
-	widget->priv.minw = 3;
-	widget->priv.minh = 1;
-
-	GNTDEBUG;
+	gnt_widget_set_minimum_size(widget, 3, 1);
 }
 
 /******************************************************************************
--- a/gntlabel.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntlabel.c	Fri Apr 26 04:22:10 2019 -0400
@@ -24,6 +24,8 @@
 #include "gntlabel.h"
 #include "gntutils.h"
 
+#include "gntwidgetprivate.h"
+
 #include <string.h>
 
 struct _GntLabel
@@ -157,9 +159,7 @@
 	gnt_widget_set_has_border(widget, FALSE);
 	gnt_widget_set_has_shadow(widget, FALSE);
 	gnt_widget_set_grow_x(widget, TRUE);
-	widget->priv.minw = 3;
-	widget->priv.minh = 1;
-	GNTDEBUG;
+	gnt_widget_set_minimum_size(widget, 3, 1);
 }
 
 /******************************************************************************
--- a/gntline.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntline.c	Fri Apr 26 04:22:10 2019 -0400
@@ -23,6 +23,8 @@
 #include "gntinternal.h"
 #include "gntline.h"
 
+#include "gntwidgetprivate.h"
+
 struct _GntLine
 {
 	GntWidget parent;
@@ -139,9 +141,7 @@
 	GntWidget *widget = GNT_WIDGET(line);
 	gnt_widget_set_has_shadow(widget, FALSE);
 	gnt_widget_set_has_border(widget, FALSE);
-	widget->priv.minw = 1;
-	widget->priv.minh = 1;
-	GNTDEBUG;
+	gnt_widget_set_minimum_size(widget, 1, 1);
 }
 
 /******************************************************************************
--- a/gntprogressbar.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntprogressbar.c	Fri Apr 26 04:22:10 2019 -0400
@@ -24,6 +24,8 @@
 #include "gntprogressbar.h"
 #include "gntutils.h"
 
+#include "gntwidgetprivate.h"
+
 #include <string.h>
 
 typedef struct _GntProgressBarPrivate
@@ -109,7 +111,9 @@
 static void
 gnt_progress_bar_size_request (GntWidget *widget)
 {
-	gnt_widget_set_size (widget, widget->priv.minw, widget->priv.minh);
+	gint width, height;
+	gnt_widget_get_minimum_size(widget, &width, &height);
+	gnt_widget_set_size(widget, width, height);
 }
 
 static void
@@ -133,8 +137,7 @@
 	gnt_widget_set_has_shadow(widget, FALSE);
 	gnt_widget_set_grow_x(widget, TRUE);
 
-	widget->priv.minw = 8;
-	widget->priv.minh = 1;
+	gnt_widget_set_minimum_size(widget, 8, 1);
 
 	priv->show_value = TRUE;
 }
@@ -177,13 +180,11 @@
 			orientation == GNT_PROGRESS_RIGHT_TO_LEFT) {
 		gnt_widget_set_grow_x(widget, TRUE);
 		gnt_widget_set_grow_y(widget, FALSE);
-		widget->priv.minw = 8;
-		widget->priv.minh = 1;
+		gnt_widget_set_minimum_size(widget, 8, 1);
 	} else {
 		gnt_widget_set_grow_x(widget, FALSE);
 		gnt_widget_set_grow_y(widget, TRUE);
-		widget->priv.minw = 1;
-		widget->priv.minh = 8;
+		gnt_widget_set_minimum_size(widget, 1, 8);
 	}
 
 	if (gnt_widget_get_mapped(widget)) {
--- a/gntslider.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntslider.c	Fri Apr 26 04:22:10 2019 -0400
@@ -26,6 +26,8 @@
 #include "gntslider.h"
 #include "gntstyle.h"
 
+#include "gntwidgetprivate.h"
+
 typedef struct
 {
 	gboolean vertical;
@@ -250,9 +252,7 @@
 	gnt_widget_set_has_shadow(widget, FALSE);
 	gnt_widget_set_has_border(widget, FALSE);
 	gnt_widget_set_take_focus(widget, TRUE);
-	widget->priv.minw = 1;
-	widget->priv.minh = 1;
-	GNTDEBUG;
+	gnt_widget_set_minimum_size(widget, 1, 1);
 }
 
 /******************************************************************************
--- a/gnttextview.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gnttextview.c	Fri Apr 26 04:22:10 2019 -0400
@@ -28,6 +28,8 @@
 #include "gnttextview.h"
 #include "gntutils.h"
 
+#include "gntwidgetprivate.h"
+
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -465,8 +467,7 @@
 	gnt_widget_set_has_shadow(widget, FALSE);
 	gnt_widget_set_grow_x(widget, TRUE);
 	gnt_widget_set_grow_y(widget, TRUE);
-	widget->priv.minw = 5;
-	widget->priv.minh = 2;
+	gnt_widget_set_minimum_size(widget, 5, 2);
 	view->string = g_string_new(NULL);
 	view->list = g_list_append(view->list, line);
 
--- a/gnttree.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gnttree.c	Fri Apr 26 04:22:10 2019 -0400
@@ -25,6 +25,8 @@
 #include "gnttree.h"
 #include "gntutils.h"
 
+#include "gntwidgetprivate.h"
+
 #include <string.h>
 #include <ctype.h>
 
@@ -1223,9 +1225,7 @@
 	gnt_widget_set_grow_y(widget, TRUE);
 	gnt_widget_set_has_shadow(widget, FALSE);
 	gnt_widget_set_take_focus(widget, TRUE);
-	widget->priv.minw = 4;
-	widget->priv.minh = 1;
-	GNTDEBUG;
+	gnt_widget_set_minimum_size(widget, 4, 1);
 }
 
 /******************************************************************************
@@ -1985,12 +1985,14 @@
 void gnt_tree_set_show_title(GntTree *tree, gboolean set)
 {
 	GntTreePrivate *priv = NULL;
+	gint minw;
 
 	g_return_if_fail(GNT_IS_TREE(tree));
 	priv = gnt_tree_get_instance_private(tree);
 
 	priv->show_title = set;
-	GNT_WIDGET(tree)->priv.minh = (set ? 6 : 4);
+	gnt_widget_get_minimum_size(GNT_WIDGET(tree), &minw, NULL);
+	gnt_widget_set_minimum_size(GNT_WIDGET(tree), minw, set ? 6 : 4);
 }
 
 void gnt_tree_set_compare_func(GntTree *tree, GCompareFunc func)
--- a/gntwidget.c	Fri Apr 26 01:40:05 2019 -0400
+++ b/gntwidget.c	Fri Apr 26 04:22:10 2019 -0400
@@ -558,6 +558,28 @@
 	return ret;
 }
 
+/* Internal. */
+void
+gnt_widget_get_minimum_size(GntWidget *widget, gint *width, gint *height)
+{
+	g_return_if_fail(GNT_IS_WIDGET(widget));
+	if (width) {
+		*width = widget->priv.minw;
+	}
+	if (height) {
+		*height = widget->priv.minh;
+	}
+}
+
+/* Internal. */
+void
+gnt_widget_set_minimum_size(GntWidget *widget, gint width, gint height)
+{
+	g_return_if_fail(GNT_IS_WIDGET(widget));
+	widget->priv.minw = width;
+	widget->priv.minh = height;
+}
+
 gboolean
 gnt_widget_set_focus(GntWidget *widget, gboolean set)
 {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gntwidgetprivate.h	Fri Apr 26 04:22:10 2019 -0400
@@ -0,0 +1,37 @@
+/*
+ * GNT - The GLib Ncurses Toolkit
+ *
+ * GNT is the legal property of its developers, whose names are too numerous
+ * to list here.  Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This library 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, Boston, MA  02110-1301, USA.
+ */
+
+#ifndef GNT_WIDGET_PRIVATE_H
+#define GNT_WIDGET_PRIVATE_H
+
+#include "gnt.h"
+#include "gntwidget.h"
+
+G_BEGIN_DECLS
+
+/* Private access to some internals. Contact us if you need these. */
+void gnt_widget_get_minimum_size(GntWidget *widget, gint *width, gint *height);
+void gnt_widget_set_minimum_size(GntWidget *widget, gint width, gint height);
+
+G_END_DECLS
+
+#endif /* GNT_WIDGET_PRIVATE_H */

mercurial