[gtk+/center-box: 1/7] Make GtkCenterBox public



commit 4c90d61c0597b1a8c510283cd49729792cc55d76
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jun 1 17:56:32 2017 -0700

    Make GtkCenterBox public
    
    This is functionality we used to have, and it is generally useful.

 docs/reference/gtk/gtk4-docs.xml     |    1 +
 docs/reference/gtk/gtk4-sections.txt |   20 ++++++
 gtk/gtk.h                            |    1 +
 gtk/gtkactionbar.c                   |    2 +-
 gtk/gtkcenterbox.c                   |  107 ++++++++++++++++++++++++++++++++--
 gtk/gtkcenterbox.h                   |   66 +++++++++++++++++++++
 gtk/gtkcenterboxprivate.h            |   43 --------------
 7 files changed, 190 insertions(+), 50 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-docs.xml b/docs/reference/gtk/gtk4-docs.xml
index ff1bc9c..c2f5245 100644
--- a/docs/reference/gtk/gtk4-docs.xml
+++ b/docs/reference/gtk/gtk4-docs.xml
@@ -68,6 +68,7 @@
     <chapter id="LayoutContainers">
       <title>Layout Containers</title>
       <xi:include href="xml/gtkbox.xml" />
+      <xi:include href="xml/gtkcenterbox.xml" />
       <xi:include href="xml/gtkgrid.xml" />
       <xi:include href="xml/gtkrevealer.xml" />
       <xi:include href="xml/gtklistbox.xml" />
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 28ce710..e4bffc2 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -342,6 +342,26 @@ gtk_box_get_type
 </SECTION>
 
 <SECTION>
+<FILE>gtkcenterbox</FILE>
+<TITLE>GtkCenterBox</TITLE>
+GtkCenterBox
+gtk_center_box_new
+gtk_center_box_set_start_widget
+gtk_center_box_set_center_widget
+gtk_center_box_set_end_widget
+gtk_center_box_get_start_widget
+gtk_center_box_get_center_widget
+gtk_center_box_get_end_widget
+<PRIVATE>
+GTK_TYPE_CENTER_BOX
+GTK_CENTER_BOX
+GTK_CENTER_BOX_CLASS
+GTK_IS_CENTER_BOX
+GTK_IS_CENTER_BOX_CLASS
+GTK_CENTER_BOX_GET_CLASS
+</SECTION>
+
+<SECTION>
 <FILE>gtklistbox</FILE>
 <TITLE>GtkListBox</TITLE>
 GtkListBox
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 8d13dfd..0e8b26f 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -68,6 +68,7 @@
 #include <gtk/gtkcellrenderertext.h>
 #include <gtk/gtkcellrenderertoggle.h>
 #include <gtk/gtkcellview.h>
+#include <gtk/gtkcenterbox.h>
 #include <gtk/gtkcheckbutton.h>
 #include <gtk/gtkcheckmenuitem.h>
 #include <gtk/gtkclipboard.h>
diff --git a/gtk/gtkactionbar.c b/gtk/gtkactionbar.c
index 986f51e..bf598b7 100644
--- a/gtk/gtkactionbar.c
+++ b/gtk/gtkactionbar.c
@@ -30,7 +30,7 @@
 #include "gtkwidgetprivate.h"
 #include "gtkcontainerprivate.h"
 #include "gtkprivate.h"
-#include "gtkcenterboxprivate.h"
+#include "gtkcenterbox.h"
 
 #include <string.h>
 
diff --git a/gtk/gtkcenterbox.c b/gtk/gtkcenterbox.c
index 316126c..49f8e67 100644
--- a/gtk/gtkcenterbox.c
+++ b/gtk/gtkcenterbox.c
@@ -1,5 +1,36 @@
-
-#include "gtkcenterboxprivate.h"
+/*
+ * Copyright (c) 2017 Timm Bäder <mail baedert org>
+ *
+ * This program 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 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Timm Bäder <mail baedert org>
+ */
+
+/**
+ * SECTION:gtkcenterbox
+ * @Short_description: A centering container
+ * @Title: GtkCenterBox
+ * @See_also: #GtkBox
+ *
+ * The GtkCenterBox widget will arrange three children in a horizontal
+ * or vertical arrangement, keeping the middle child centered as well
+ * as possible.
+ */
+
+#include "config.h"
+#include "gtkcenterbox.h"
 
 G_DEFINE_TYPE (GtkCenterBox, gtk_center_box, GTK_TYPE_WIDGET);
 
@@ -76,8 +107,7 @@ gtk_center_box_size_allocate (GtkWidget     *widget,
 
   GTK_WIDGET_CLASS (gtk_center_box_parent_class)->size_allocate (widget, allocation);
 
-
-  // TODO: Allocate natural sizes if possible?
+  /* TODO: Allocate natural sizes if possible? */
 
   /* Start Box */
   gtk_widget_measure (self->start_widget, GTK_ORIENTATION_HORIZONTAL,
@@ -93,7 +123,6 @@ gtk_center_box_size_allocate (GtkWidget     *widget,
   gdk_rectangle_union (&clip, &clip, &child_clip);
   start_size = child_allocation.width;
 
-
   /* End Box */
   gtk_widget_measure (self->end_widget, GTK_ORIENTATION_HORIZONTAL,
                       allocation->height,
@@ -165,12 +194,30 @@ gtk_center_box_init (GtkCenterBox *self)
   self->end_widget = NULL;
 }
 
+/**
+ * gtk_center_box_new:
+ *
+ * Creates a new #GtkCenterBox.
+ *
+ * Returns: the new #GtkCenterBox.
+ *
+ * Since: 3.92
+ */
 GtkWidget *
 gtk_center_box_new (void)
 {
   return GTK_WIDGET (g_object_new (GTK_TYPE_CENTER_BOX, NULL));
 }
 
+/**
+ * gtk_center_box_set_start_widget:
+ * @self: a #GtkCenterBox
+ * @child: the child
+ *
+ * Sets the start widget.
+ *
+ * Since: 3.92
+ */
 void
 gtk_center_box_set_start_widget (GtkCenterBox *self,
                                  GtkWidget    *child)
@@ -183,9 +230,18 @@ gtk_center_box_set_start_widget (GtkCenterBox *self,
     gtk_widget_set_parent (child, GTK_WIDGET (self));
 }
 
+/**
+ * gtk_center_box_set_center_widget:
+ * @self: a #GtkCenterBox
+ * @child: the child
+ *
+ * Sets the center widget.
+ *
+ * Since: 3.92
+ */
 void
 gtk_center_box_set_center_widget (GtkCenterBox *self,
-                                 GtkWidget    *child)
+                                 GtkWidget     *child)
 {
   if (self->center_widget)
     gtk_widget_unparent (self->center_widget);
@@ -195,6 +251,15 @@ gtk_center_box_set_center_widget (GtkCenterBox *self,
     gtk_widget_set_parent (child, GTK_WIDGET (self));
 }
 
+/**
+ * gtk_center_box_set_end_widget:
+ * @self: a #GtkCenterBox
+ * @child: the child
+ *
+ * Sets the end widget.
+ *
+ * Since: 3.92
+ */
 void
 gtk_center_box_set_end_widget (GtkCenterBox *self,
                                GtkWidget    *child)
@@ -207,18 +272,48 @@ gtk_center_box_set_end_widget (GtkCenterBox *self,
     gtk_widget_set_parent (child, GTK_WIDGET (self));
 }
 
+/**
+ * gtk_center_box_get_start_widget:
+ * @self: a #GtkCenterBox
+ *
+ * Gets the start widget.
+ *
+ * Returns: the start widget.
+ *
+ * Since: 3.92
+ */
 GtkWidget *
 gtk_center_box_get_start_widget (GtkCenterBox *self)
 {
   return self->start_widget;
 }
 
+/**
+ * gtk_center_box_get_center_widget:
+ * @self: a #GtkCenterBox
+ *
+ * Gets the center widget.
+ *
+ * Returns: the center widget.
+ *
+ * Since: 3.92
+ */
 GtkWidget *
 gtk_center_box_get_center_widget (GtkCenterBox *self)
 {
   return self->center_widget;
 }
 
+/**
+ * gtk_center_box_get_end_widget:
+ * @self: a #GtkCenterBox
+ *
+ * Gets the end widget.
+ *
+ * Returns: the end widget.
+ *
+ * Since: 3.92
+ */
 GtkWidget *
 gtk_center_box_get_end_widget (GtkCenterBox *self)
 {
diff --git a/gtk/gtkcenterbox.h b/gtk/gtkcenterbox.h
new file mode 100644
index 0000000..c18845c
--- /dev/null
+++ b/gtk/gtkcenterbox.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2017 Timm Bäder <mail baedert org>
+ *
+ * This program 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 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 Lesser General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ * Author: Timm Bäder <mail baedert org>
+ *
+ */
+
+#ifndef __GTK_CENTER_BOX_H__
+#define __GTK_CENTER_BOX_H__
+
+#include "gtkwidget.h"
+
+#define GTK_TYPE_CENTER_BOX                 (gtk_center_box_get_type ())
+#define GTK_CENTER_BOX(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_CENTER_BOX, 
GtkCenterBox))
+#define GTK_CENTER_BOX_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_CENTER_BOX, 
GtkCenterBoxClass))
+#define GTK_IS_CENTER_BOX(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_CENTER_BOX))
+#define GTK_IS_CENTER_BOX_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_CENTER_BOX))
+#define GTK_CENTER_BOX_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_CENTER_BOX, 
GtkCenterBoxClass))
+
+typedef struct _GtkCenterBox             GtkCenterBox;
+typedef struct _GtkCenterBoxClass        GtkCenterBoxClass;
+
+struct _GtkCenterBox
+{
+  GtkWidget parent_instance;
+
+  GtkWidget *start_widget;
+  GtkWidget *center_widget;
+  GtkWidget *end_widget;
+};
+
+struct _GtkCenterBoxClass
+{
+  GtkWidgetClass parent_class;
+};
+
+GType      gtk_center_box_get_type (void) G_GNUC_CONST;
+
+GtkWidget *gtk_center_box_new (void);
+void       gtk_center_box_set_start_widget   (GtkCenterBox *self,
+                                              GtkWidget    *child);
+void       gtk_center_box_set_center_widget  (GtkCenterBox *self,
+                                              GtkWidget    *child);
+void       gtk_center_box_set_end_widget     (GtkCenterBox *self,
+                                              GtkWidget    *child);
+
+GtkWidget * gtk_center_box_get_start_widget  (GtkCenterBox *self);
+GtkWidget * gtk_center_box_get_center_widget (GtkCenterBox *self);
+GtkWidget * gtk_center_box_get_end_widget    (GtkCenterBox *self);
+
+
+#endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]