[gtk+/wip/matthiasc/tab-strip: 3/10] Add a simple tab class



commit 941f1ad1a649cf955527076e00a853194b4505fc
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat May 21 12:51:35 2016 -0400

    Add a simple tab class
    
    This is a very barebones subclass of GtkTab, which shows the page
    title in a label.

 gtk/Makefile.am    |    2 +
 gtk/gtk.h          |    1 +
 gtk/gtksimpletab.c |   58 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtksimpletab.h |   37 +++++++++++++++++++++++++++++++++
 4 files changed, 98 insertions(+), 0 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index c8bbf2d..a1adbf0 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -303,6 +303,7 @@ gtk_public_h_sources =              \
        gtkstyleprovider.h      \
        gtkswitch.h             \
        gtktab.h                \
+       gtksimpletab.h          \
        gtktabstrip.h           \
        gtktestutils.h          \
        gtktextattributes.h     \
@@ -903,6 +904,7 @@ gtk_base_c_sources =                \
        gtkstyleproviderprivate.c       \
        gtkswitch.c             \
        gtktab.c                \
+       gtksimpletab.c          \
        gtktabstrip.c           \
        gtktestutils.c          \
        gtktextattributes.c     \
diff --git a/gtk/gtk.h b/gtk/gtk.h
index 216eea5..9bccb68 100644
--- a/gtk/gtk.h
+++ b/gtk/gtk.h
@@ -204,6 +204,7 @@
 #include <gtk/gtkstyleprovider.h>
 #include <gtk/gtkswitch.h>
 #include <gtk/gtktab.h>
+#include <gtk/gtksimpletab.h>
 #include <gtk/gtktabstrip.h>
 #include <gtk/gtktextattributes.h>
 #include <gtk/gtktextbuffer.h>
diff --git a/gtk/gtksimpletab.c b/gtk/gtksimpletab.c
new file mode 100644
index 0000000..0937435
--- /dev/null
+++ b/gtk/gtksimpletab.c
@@ -0,0 +1,58 @@
+/* gtksimpletab.c
+ *
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include "gtksimpletab.h"
+#include "gtkintl.h"
+#include "gtkprivate.h"
+#include "gtkenums.h"
+#include "gtklabel.h"
+
+struct _GtkSimpleTab
+{
+  GtkTab parent;
+
+  GtkWidget *label;
+};
+
+typedef struct _GtkSimpleTabClass GtkSimpleTabClass;
+
+struct _GtkSimpleTabClass
+{
+  GtkTabClass parent_class;
+};
+
+G_DEFINE_TYPE (GtkSimpleTab, gtk_simple_tab, GTK_TYPE_TAB)
+
+static void
+gtk_simple_tab_class_init (GtkSimpleTabClass *klass)
+{
+}
+
+static void
+gtk_simple_tab_init (GtkSimpleTab *self)
+{
+  self->label = gtk_label_new ("");
+  gtk_widget_show (self->label);
+  gtk_widget_set_halign (self->label, GTK_ALIGN_CENTER);
+
+  gtk_tab_set_child (GTK_TAB (self), self->label);
+
+  g_object_bind_property (self, "title", self->label, "label", G_BINDING_DEFAULT);
+}
diff --git a/gtk/gtksimpletab.h b/gtk/gtksimpletab.h
new file mode 100644
index 0000000..0f97206
--- /dev/null
+++ b/gtk/gtksimpletab.h
@@ -0,0 +1,37 @@
+/* gtksimpletab.h
+ *
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * This library 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 library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GTK_SIMPLE_TAB_H__
+#define __GTK_SIMPLE_TAB_H__
+
+#include <gtk/gtktab.h>
+
+G_BEGIN_DECLS
+
+#define GTK_TYPE_SIMPLE_TAB                 (gtk_simple_tab_get_type ())
+#define GTK_SIMPLE_TAB(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_SIMPLE_TAB, 
GtkSimpleTab))
+#define GTK_IS_SIMPLE_TAB(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_SIMPLE_TAB))
+
+typedef struct _GtkSimpleTab      GtkSimpleTab;
+
+GDK_AVAILABLE_IN_3_22
+GType            gtk_simple_tab_get_type   (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif /* __GTK_SIMPLE_TAB_H__ */


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