[gnome-builder] build: more introspection work
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] build: more introspection work
- Date: Wed, 30 Sep 2015 02:56:29 +0000 (UTC)
commit 569e2e9358fe13478d1afbb0f9fab5b016e78a65
Author: Christian Hergert <christian hergert me>
Date: Tue Sep 29 19:16:25 2015 -0700
build: more introspection work
- Add GbViewGrid to introspection classes
- Start breaking out enums into their own headers
- generate enums using glib-mkenums
src/Makefile.am | 13 ++++++++-
src/gb-enums.c.in | 41 +++++++++++++++++++++++++++++
src/gb-enums.h.in | 24 +++++++++++++++++
src/gnome-builder.h | 4 +++
src/views/gb-view-grid.c | 52 ++++++++++++++++++++-----------------
src/views/gb-view-grid.h | 13 +--------
src/views/gb-view-stack-actions.c | 4 +-
src/views/gb-view-stack-split.h | 46 ++++++++++++++++++++++++++++++++
src/views/gb-view-stack.c | 2 +
9 files changed, 160 insertions(+), 39 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index ae502fc..7109766 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,6 +34,8 @@ libgnome_builder_public_sources = \
views/gb-view.h \
views/gb-view-stack.c \
views/gb-view-stack.h \
+ views/gb-view-grid.c \
+ views/gb-view-grid.h \
workbench/gb-workbench.c \
workbench/gb-workbench.h \
$(NULL)
@@ -166,8 +168,6 @@ libgnome_builder_la_SOURCES = \
util/gb-string.h \
util/gb-widget.c \
util/gb-widget.h \
- views/gb-view-grid.c \
- views/gb-view-grid.h \
views/gb-view-stack-actions.c \
views/gb-view-stack-actions.h \
views/gb-view-stack-private.h \
@@ -187,7 +187,16 @@ libgnome_builder_la_SOURCES = \
css/gb-css-provider.h \
util/gb-settings.c \
util/gb-settings.h \
+ gb-enums.c \
+ gb-enums.h \
+ $(NULL)
+
+glib_enum_h = gb-enums.h
+glib_enum_c = gb-enums.c
+glib_enum_headers = \
+ views/gb-view-stack-split.h \
$(NULL)
+include $(top_srcdir)/build/autotools/Makefile.am.enums
nodist_libgnome_builder_la_SOURCES = \
resources/gb-resources.c \
diff --git a/src/gb-enums.c.in b/src/gb-enums.c.in
new file mode 100644
index 0000000..f4df828
--- /dev/null
+++ b/src/gb-enums.c.in
@@ -0,0 +1,41 @@
+/*** BEGIN file-header ***/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "ide-enums.h"
+
+#include "gb-view-stack-split.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+ enum_name@_get_type (void)
+{
+ static GType etype = 0;
+ if (G_UNLIKELY(etype == 0)) {
+ static const G Type@Value values[] = {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ etype = g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+ }
+ return etype;
+}
+
+/*** END value-tail ***/
+
+/*** BEGIN file-tail ***/
+
+/*** END file-tail ***/
diff --git a/src/gb-enums.h.in b/src/gb-enums.h.in
new file mode 100644
index 0000000..416f9e8
--- /dev/null
+++ b/src/gb-enums.h.in
@@ -0,0 +1,24 @@
+/*** BEGIN file-header ***/
+#ifndef __GB_ENUMS_H__
+#define __GB_ENUMS_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from "@filename@" */
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType @enum_name _get_type (void);
+#define @ENUMPREFIX _TYPE_@ENUMSHORT@ (@enum_name _get_type ())
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __GB_ENUMS_H__ */
+/*** END file-tail ***/
diff --git a/src/gnome-builder.h b/src/gnome-builder.h
index 3004a41..59c5f18 100644
--- a/src/gnome-builder.h
+++ b/src/gnome-builder.h
@@ -30,7 +30,11 @@
#include "tree/gb-tree-node.h"
#include "tree/gb-tree-types.h"
#include "views/gb-view.h"
+#include "views/gb-view-grid.h"
#include "views/gb-view-stack.h"
+#include "views/gb-view-stack-split.h"
#include "workbench/gb-workbench.h"
+#include "gb-enums.h"
+
#endif /* GNOME_BUILDER_H */
diff --git a/src/views/gb-view-grid.c b/src/views/gb-view-grid.c
index 7016362..c773a0e 100644
--- a/src/views/gb-view-grid.c
+++ b/src/views/gb-view-grid.c
@@ -286,7 +286,7 @@ gb_view_grid_stack_split (GbViewGrid *self,
gb_view_stack_focus_document (GB_VIEW_STACK (target), document);
break;
- case GB_VIEW_GRID_MOVE_LEFT:
+ case GB_VIEW_GRID_SPLIT_MOVE_LEFT:
target = gb_view_grid_get_stack_before (self, stack);
if (target == NULL)
target = gb_view_grid_add_stack_before (self, stack);
@@ -306,7 +306,7 @@ gb_view_grid_stack_split (GbViewGrid *self,
gb_view_stack_focus_document (GB_VIEW_STACK (target), document);
break;
- case GB_VIEW_GRID_MOVE_RIGHT:
+ case GB_VIEW_GRID_SPLIT_MOVE_RIGHT:
target = gb_view_grid_get_stack_after (self, stack);
if (target == NULL)
target = gb_view_grid_add_stack_after (self, stack);
@@ -437,6 +437,11 @@ gb_view_grid_get_stacks (GbViewGrid *self)
return list;
}
+/**
+ * gb_view_grid_add_stack_before:
+ *
+ * Returns: (transfer none) (type Builder.ViewStack): The new view stack.
+ */
GtkWidget *
gb_view_grid_add_stack_before (GbViewGrid *self,
GbViewStack *stack)
@@ -490,6 +495,11 @@ gb_view_grid_add_stack_before (GbViewGrid *self,
return GTK_WIDGET (new_stack);
}
+/**
+ * gb_view_grid_add_stack_after:
+ *
+ * Returns: (transfer none) (type Builder.ViewStack): The new view stack.
+ */
GtkWidget *
gb_view_grid_add_stack_after (GbViewGrid *self,
GbViewStack *stack)
@@ -541,6 +551,11 @@ gb_view_grid_add_stack_after (GbViewGrid *self,
return GTK_WIDGET (new_stack);
}
+/**
+ * gb_view_grid_get_stack_before:
+ *
+ * Returns: (nullable) (transfer none) (type Builder.ViewStack): The view stack.
+ */
GtkWidget *
gb_view_grid_get_stack_before (GbViewGrid *self,
GbViewStack *stack)
@@ -562,6 +577,11 @@ gb_view_grid_get_stack_before (GbViewGrid *self,
return NULL;
}
+/**
+ * gb_view_grid_get_stack_after:
+ *
+ * Returns: (nullable) (transfer none) (type Builder.ViewStack): The view stack.
+ */
GtkWidget *
gb_view_grid_get_stack_after (GbViewGrid *self,
GbViewStack *stack)
@@ -855,28 +875,12 @@ gb_view_grid_init (GbViewGrid *self)
gtk_widget_insert_action_group (GTK_WIDGET (self), "view-grid", G_ACTION_GROUP (actions));
}
-GType
-gb_view_grid_split_get_type (void)
-{
- static gsize type_id;
-
- if (g_once_init_enter (&type_id))
- {
- static const GEnumValue values[] = {
- { GB_VIEW_GRID_SPLIT_LEFT, "GB_VIEW_GRID_SPLIT_LEFT", "split-left" },
- { GB_VIEW_GRID_SPLIT_RIGHT, "GB_VIEW_GRID_SPLIT_RIGHT", "split-right" },
- { GB_VIEW_GRID_MOVE_LEFT, "GB_VIEW_GRID_MOVE_LEFT", "move-left" },
- { GB_VIEW_GRID_MOVE_RIGHT, "GB_VIEW_GRID_MOVE_RIGHT", "move-right" },
- };
- gsize _type_id;
-
- _type_id = g_enum_register_static ("GbViewGridSplit", values);
- g_once_init_leave (&type_id, _type_id);
- }
-
- return type_id;
-}
-
+/**
+ * gb_view_grid_find_document_typed:
+ *
+ * Returns: (transfer none) (nullable): The first document
+ * matching @document_type or %NULL.
+ */
GbDocument *
gb_view_grid_find_document_typed (GbViewGrid *self,
GType document_type)
diff --git a/src/views/gb-view-grid.h b/src/views/gb-view-grid.h
index 57541d6..53501bc 100644
--- a/src/views/gb-view-grid.h
+++ b/src/views/gb-view-grid.h
@@ -23,23 +23,14 @@
#include "gb-document.h"
#include "gb-view-stack.h"
+#include "gb-view-stack-split.h"
G_BEGIN_DECLS
-#define GB_TYPE_VIEW_GRID (gb_view_grid_get_type())
-#define GB_TYPE_VIEW_GRID_SPLIT (gb_view_grid_split_get_type())
+#define GB_TYPE_VIEW_GRID (gb_view_grid_get_type())
G_DECLARE_FINAL_TYPE (GbViewGrid, gb_view_grid, GB, VIEW_GRID, GtkBin)
-typedef enum
-{
- GB_VIEW_GRID_SPLIT_LEFT,
- GB_VIEW_GRID_SPLIT_RIGHT,
- GB_VIEW_GRID_MOVE_LEFT,
- GB_VIEW_GRID_MOVE_RIGHT,
-} GbViewGridSplit;
-
-GType gb_view_grid_split_get_type (void);
GtkWidget *gb_view_grid_new (void);
GtkWidget *gb_view_grid_add_stack_after (GbViewGrid *grid,
GbViewStack *stack);
diff --git a/src/views/gb-view-stack-actions.c b/src/views/gb-view-stack-actions.c
index e2f6649..e32a70c 100644
--- a/src/views/gb-view-stack-actions.c
+++ b/src/views/gb-view-stack-actions.c
@@ -85,7 +85,7 @@ gb_view_stack_actions_move_left (GSimpleAction *action,
if (active_view == NULL || !GB_IS_VIEW (active_view))
return;
- g_signal_emit_by_name (self, "split", active_view, GB_VIEW_GRID_MOVE_LEFT);
+ g_signal_emit_by_name (self, "split", active_view, GB_VIEW_GRID_SPLIT_MOVE_LEFT);
}
static void
@@ -102,7 +102,7 @@ gb_view_stack_actions_move_right (GSimpleAction *action,
if (active_view == NULL || !GB_IS_VIEW (active_view))
return;
- g_signal_emit_by_name (self, "split", active_view, GB_VIEW_GRID_MOVE_RIGHT);
+ g_signal_emit_by_name (self, "split", active_view, GB_VIEW_GRID_SPLIT_MOVE_RIGHT);
}
static void
diff --git a/src/views/gb-view-stack-split.h b/src/views/gb-view-stack-split.h
new file mode 100644
index 0000000..e4bae37
--- /dev/null
+++ b/src/views/gb-view-stack-split.h
@@ -0,0 +1,46 @@
+/* gb-view-stack-split.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This program 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GB_VIEW_STACK_SPLIT_H
+#define GB_VIEW_STACK_SPLIT_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+/**
+ * GbViewGridSplit:
+ * %GB_VIEW_GRID_SPLIT_LEFT:
+ * %GB_VIEW_GRID_SPLIT_RIGHT:
+ * %GB_VIEW_GRID_SPLIT_MOVE_LEFT:
+ * %GB_VIEW_GRID_SPLIT_MOVE_RIGHT:
+ *
+ */
+typedef enum
+{
+ GB_VIEW_GRID_SPLIT_LEFT = 1,
+ GB_VIEW_GRID_SPLIT_RIGHT = 2,
+ GB_VIEW_GRID_SPLIT_MOVE_LEFT = 3,
+ GB_VIEW_GRID_SPLIT_MOVE_RIGHT = 4,
+} GbViewGridSplit;
+
+GType gb_view_stack_split_get_type (void);
+
+G_END_DECLS
+
+#endif /* GB_VIEW_STACK_SPLIT_H */
diff --git a/src/views/gb-view-stack.c b/src/views/gb-view-stack.c
index 82d614b..41b6f6d 100644
--- a/src/views/gb-view-stack.c
+++ b/src/views/gb-view-stack.c
@@ -20,11 +20,13 @@
#include <ide.h>
#include "gb-document.h"
+#include "gb-enums.h"
#include "gb-view.h"
#include "gb-view-grid.h"
#include "gb-view-stack.h"
#include "gb-view-stack-actions.h"
#include "gb-view-stack-private.h"
+#include "gb-view-stack-split.h"
#include "gb-widget.h"
#include "gb-workbench.h"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]