[gdl] Add GObject Introspection Support.



commit 03c4817dbd83d50a4dbcbd184be256d23b17c6c0
Author: Maxim Ermilov <zaspire rambler ru>
Date:   Sat Apr 17 18:49:58 2010 +0400

    Add GObject Introspection Support.
    
    Also add JS example.
    https://bugzilla.gnome.org/show_bug.cgi?id=598911

 Makefile.am           |    6 +-
 configure.in          |    7 ++-
 gdl/Makefile.am       |   23 ++++++
 gdl/gdl-dock-item.c   |    2 +-
 gdl/gdl-dock-object.c |    7 ++
 gdl/test-dock.js      |  190 +++++++++++++++++++++++++++++++++++++++++++++++++
 m4/introspection.m4   |   94 ++++++++++++++++++++++++
 7 files changed, 324 insertions(+), 5 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 77a86ab..3d98828 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,7 @@
 SUBDIRS = gdl docs po
 
-DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
+ACLOCAL_AMFLAGS = -I m4
+DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc --enable-introspection
 
 EXTRA_DIST = 			\
 	MAINTAINERS		\
@@ -8,7 +9,8 @@ EXTRA_DIST = 			\
 	gdl.spec.in		\
 	intltool-extract.in	\
 	intltool-merge.in	\
-	intltool-update.in
+	intltool-update.in	\
+	m4/introspection.m4
 
 pkgconfigdir = $(libdir)/pkgconfig
 pkgconfig_DATA = gdl-1.0.pc 
diff --git a/configure.in b/configure.in
index 656e7c2..98a40a7 100644
--- a/configure.in
+++ b/configure.in
@@ -5,7 +5,8 @@ dnl it too, or it will never make it into the spec file!
 dnl
 dnl ==========================================================================
 
-AC_PREREQ(2.53)
+AC_PREREQ(2.62)
+AC_CONFIG_MACRO_DIR([m4])
 AC_INIT(gdl)
 AM_CONFIG_HEADER(config.h)
 
@@ -32,7 +33,7 @@ AC_SUBST(GDL_AGE)
 PACKAGE=gdl
 GDL_VERSION=$GDL_MAJOR_VERSION.$GDL_MINOR_VERSION.$GDL_MICRO_VERSION
 
-AM_INIT_AUTOMAKE($PACKAGE, $GDL_VERSION)
+AM_INIT_AUTOMAKE($PACKAGE, $GDL_VERSION, [-Wno-portability])
 
 dnl with higher autotools, we can set ACLOCAL_AMFLAGS instead, which is
 dnl the better solution; this does the trick for automake-1.4
@@ -140,6 +141,8 @@ AC_SUBST(gdl_images_dir)
 # check for gtk-doc
 GTK_DOC_CHECK(1.4)
 
+GOBJECT_INTROSPECTION_CHECK([0.6.7])
+
 AC_OUTPUT([
 Makefile
 gdl/Makefile
diff --git a/gdl/Makefile.am b/gdl/Makefile.am
index 553467d..1d30490 100644
--- a/gdl/Makefile.am
+++ b/gdl/Makefile.am
@@ -133,3 +133,26 @@ libgdlmarshal.c: libgdlmarshal.h
 	&& cp xgen-gmc $(@F) \
 	&& rm -f xgen-gmc
 
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir)
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir)
+
+if HAVE_INTROSPECTION
+introspection_sources = $(libgdl_1_la_SOURCES)
+
+Gdl- GDL_CURRENT@.gir: libgdl-1.la
+Gdl_ GDL_CURRENT@_gir_INCLUDES = GObject-2.0 Gtk-2.0
+Gdl_ GDL_CURRENT@_gir_CFLAGS = $(INCLUDES)
+Gdl_ GDL_CURRENT@_gir_LIBS = libgdl-1.la
+Gdl_ GDL_CURRENT@_gir_FILES = $(addprefix $(srcdir)/,$(introspection_sources))
+INTROSPECTION_GIRS += Gdl- GDL_CURRENT@.gir
+
+girdir = $(datadir)/gir-1.0
+dist_gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(dist_gir_DATA) $(typelib_DATA)
+endif
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index 0136119..bbfab61 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -1669,7 +1669,7 @@ gdl_dock_item_new_with_stock (const gchar         *name,
 /**
  * gdl_dock_item_dock_to:
  * @item: The dock item that will be relocated to the dock position.
- * @target: The dock item that will be used as the point of reference.
+ * @target: (allow-none): The dock item that will be used as the point of reference.
  * @position: The position to dock #item, relative to #target.
  * @docking_param: This value is unused, and will be ignored.
  * 
diff --git a/gdl/gdl-dock-object.c b/gdl/gdl-dock-object.c
index dc36288..7e8db49 100644
--- a/gdl/gdl-dock-object.c
+++ b/gdl/gdl-dock-object.c
@@ -559,6 +559,13 @@ gdl_dock_object_dock_request (GdlDockObject  *object,
                                           FALSE);
 }
 
+/**
+ * gdl_dock_object_dock:
+ * @object:
+ * @requestor:
+ * @position:
+ * @other_data: (allow-none):
+ **/
 void
 gdl_dock_object_dock (GdlDockObject    *object,
                       GdlDockObject    *requestor,
diff --git a/gdl/test-dock.js b/gdl/test-dock.js
new file mode 100755
index 0000000..49e23f0
--- /dev/null
+++ b/gdl/test-dock.js
@@ -0,0 +1,190 @@
+#!/usr/bin/env seed
+
+Gtk = imports.gi.Gtk;
+Gdl = imports.gi.Gdl;
+
+Gtk.init (Seed.argv);
+
+function create_item (button_title) {
+	vbox1 = new Gtk.VBox.c_new (false, 0);
+
+	button1 = new Gtk.Button.with_label (button_title);
+	vbox1.pack_start (button1, true, true, 0);
+	vbox1.show_all ();
+
+	return vbox1;
+}
+
+function create_text_item () {
+	vbox1 = new Gtk.VBox.c_new (false, 0);
+	scrolledwindow1 = new Gtk.ScrolledWindow.c_new (null, null);
+
+	vbox1.pack_start (scrolledwindow1, true, true, 0);
+	scrolledwindow1.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
+	scrolledwindow1.set_shadow_type (Gtk.ShadowType.ETCHED_IN);
+
+	text = new Gtk.TextView ({ "wrap-mode": Gtk.WrapMode.WORD });
+	scrolledwindow1.add (text);
+
+	vbox1.show_all ();
+	return vbox1;
+}
+
+function create_styles_item (dock) {
+	function create_style_button (dock, box, group, style, style_text) {
+		current_style = dock.master.switcher_style;
+		button1 = new Gtk.RadioButton.with_label_from_widget (group, style_text);
+		button1.show ();
+		button1.__style_id = style;
+		if (current_style == style) {
+	    		button1.set_active (true);
+		}
+		button1.signal.toggled.connect (function (button, dock) {
+			style = button.__style_id;
+			active = button.get_active ();
+			if (active) {
+			    dock.master.switcher_style = style;
+			}
+		}, dock);
+
+		box.pack_start (button1, false, false, 0);
+		return button1;
+	}
+
+	vbox1 = new Gtk.VBox.c_new (false, 0);
+	vbox1.show ();
+
+	group = create_style_button (dock, vbox1, null,
+				     Gdl.SwitcherStyle.ICON, "Only icon");
+	group = create_style_button (dock, vbox1, group,
+				     Gdl.SwitcherStyle.TEXT, "Only text");
+	group = create_style_button (dock, vbox1, group,
+				     Gdl.SwitcherStyle.BOTH, "Both icons and texts");
+	group = create_style_button (dock, vbox1, group,
+				     Gdl.SwitcherStyle.TOOLBAR, "Desktop toolbar style");
+	group = create_style_button (dock, vbox1, group,
+				     Gdl.SwitcherStyle.TABS, "Notebook tabs");
+	group = create_style_button (dock, vbox1, group,
+				     Gdl.SwitcherStyle.NONE, "None of the above");
+	return vbox1;
+}
+
+
+win = new Gtk.Window ({ "title": "Docking widget test", "default-width": 400, "default-height": 400 });
+win.signal.delete_event.connect (function () {
+	Gtk.main_quit ();
+	return true;
+});
+
+table = new Gtk.VBox.c_new (false, 5);
+win.add (table);
+
+dock = new Gdl.Dock ();
+
+layout = new Gdl.DockLayout (dock);
+dockbar = new Gdl.DockBar (dock);
+dockbar.docbar_style = Gdl.DockBarStyle.TEXT;
+
+box = new Gtk.HBox.c_new (false, 5);
+table.pack_start (box, true, true, 0);
+
+box.pack_start (dockbar, false, false, 0);
+box.pack_end (dock, true, true);
+
+item1 = new Gdl.DockItem.c_new ("item1", "Item #1", Gdl.DockItemBehavior.LOCKED);
+item1.add (create_text_item ());
+
+dock.add_item (item1, Gdl.DockPlacement.TOP);
+item1.show ();
+
+item2 = new Gdl.DockItem.with_stock ("item2", "Item #2: Select the switcher style for notebooks",
+					Gtk.STOCK_EXECUTE, Gdl.DockItemBehavior.NORMAL);
+item2.resize = false;
+item2.add (create_styles_item (dock));
+
+dock.add_item (item2, Gdl.DockPlacement.RIGHT);
+item2.show_all ();
+
+item3 = new Gdl.DockItem.with_stock ("item3", "Item #3 has accented characters (áéíóúñ)",
+				Gtk.STOCK_CONVERT, Gdl.DockItemBehavior.NORMAL |
+					      Gdl.DockItemBehavior.CANT_CLOSE);
+item3.add (create_item ("Button 3"));
+dock.add_item (item3, Gdl.DockPlacement.BOTTOM);
+item3.show ();
+
+items = new Array (3);
+items [0] = new Gdl.DockItem.with_stock ("Item #4", "Item #4", Gtk.STOCK_JUSTIFY_FILL,
+						  Gdl.DockItemBehavior.NORMAL |
+						  Gdl.DockItemBehavior.CANT_ICONIFY);
+items [0].add (create_text_item ());
+items [0].show ();
+dock.add_item (items [0], Gdl.DockPlacement.BOTTOM);
+for (i = 1; i < 3; i++) {
+	name = "Item #" + (i + 4);
+	items [i] = new Gdl.DockItem.with_stock (name, name, Gtk.STOCK_NEW,
+						      Gdl.DockItemBehavior.NORMAL);
+	items [i].add (create_text_item ());
+	items [i].show ();
+
+	items [0].dock (items [i], Gdl.DockPlacement.CENTER, null);
+};
+
+item3.dock_to (item1, Gdl.DockPlacement.TOP, -1);
+
+item2.dock_to (item3, Gdl.DockPlacement.RIGHT, -1);
+
+item2.dock_to (item3, Gdl.DockPlacement.LEFT, -1);
+
+item2.dock_to (null, Gdl.DockPlacement.FLOATING, -1);
+
+box = new Gtk.HBox.c_new (true, 5);
+table.pack_end (box, false, false, 0);
+
+button = new Gtk.Button.from_stock (Gtk.STOCK_SAVE);
+button.signal.clicked.connect (function (w, layout) {
+	dialog = new Gtk.Dialog ({title: "New Layout"});
+	dialog.flags = Gtk.DialogFlags.MODAL | Gtk.DialogFlags.DESTROY_WITH_PARENT;
+	dialog.add_button (Gtk.STOCK_OK, Gtk.ResponseType.OK);
+
+	hbox = new Gtk.HBox.c_new (false, 8);
+	hbox.set_border_width (8);
+	dialog.get_content_area ().pack_start (hbox, false, false, 0);
+
+	label = new Gtk.Label.c_new ("Name:");
+	hbox.pack_start (label, false, false, 0);
+	
+	entry = new Gtk.Entry.c_new ();
+	hbox.pack_start (entry, true, true, 0);
+
+	hbox.show_all ();
+	response = dialog.run ();
+
+	if (response == Gtk.ResponseType.OK) {
+		name = entry.get_text ();
+		layout.save_layout (name);
+	}
+	dialog.destroy ();
+}, layout);
+
+box.pack_end (button, false, true, 0);
+
+button = new Gtk.Button.with_label ("Layout Manager");
+button.signal.clicked.connect (function (w, layout) {
+	layout.run_manager (layout);
+}, layout);
+box.pack_end (button, false, true, 0);
+	
+button = new Gtk.Button.with_label ("Dump XML");
+button.signal.clicked.connect (function (w, layout) {
+	layout.save_to_file ("layout.xml");
+} , layout);
+box.pack_end (button, false, true, 0);
+	
+win.show_all ();
+
+new Gdl.DockPlaceholder.c_new ("ph1", dock, Gdl.DockPlacement.TOP, false);
+new Gdl.DockPlaceholder.c_new ("ph2", dock, Gdl.DockPlacement.BOTTOM, false);
+new Gdl.DockPlaceholder.c_new ("ph3", dock, Gdl.DockPlacement.LEFT, false);
+new Gdl.DockPlaceholder.c_new ("ph4", dock, Gdl.DockPlacement.RIGHT, false);
+
+Gtk.main ();
diff --git a/m4/introspection.m4 b/m4/introspection.m4
new file mode 100644
index 0000000..525d22a
--- /dev/null
+++ b/m4/introspection.m4
@@ -0,0 +1,94 @@
+dnl -*- mode: autoconf -*-
+dnl Copyright 2009 Johan Dahlin
+dnl
+dnl This file is free software; the author(s) gives unlimited
+dnl permission to copy and/or distribute it, with or without
+dnl modifications, as long as this notice is preserved.
+dnl
+
+# serial 1
+
+m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL],
+[
+    AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
+    AC_BEFORE([LT_INIT],[$0])dnl setup libtool first
+
+    dnl enable/disable introspection
+    m4_if([$2], [require],
+    [dnl
+        enable_introspection=yes
+    ],[dnl
+        AC_ARG_ENABLE(introspection,
+                  AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]],
+                                 [Enable introspection for this build]),, 
+                                 [enable_introspection=auto])
+    ])dnl
+
+    AC_MSG_CHECKING([for gobject-introspection])
+
+    dnl presence/version checking
+    AS_CASE([$enable_introspection],
+    [no], [dnl
+        found_introspection="no (disabled, use --enable-introspection to enable)"
+    ],dnl
+    [yes],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0],,
+                         AC_MSG_ERROR([gobject-introspection-1.0 is not installed]))
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1],
+                         found_introspection=yes,
+                         AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed]))
+    ],dnl
+    [auto],[dnl
+        PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no)
+    ],dnl
+    [dnl	
+        AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@])
+    ])dnl
+
+    AC_MSG_RESULT([$found_introspection])
+
+    INTROSPECTION_SCANNER=
+    INTROSPECTION_COMPILER=
+    INTROSPECTION_GENERATE=
+    INTROSPECTION_GIRDIR=
+    INTROSPECTION_TYPELIBDIR=
+    if test "x$found_introspection" = "xyes"; then
+       INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0`
+       INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0`
+       INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0`
+       INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0`
+       INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)"
+       INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0`
+       INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0`
+       INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection
+    fi
+    AC_SUBST(INTROSPECTION_SCANNER)
+    AC_SUBST(INTROSPECTION_COMPILER)
+    AC_SUBST(INTROSPECTION_GENERATE)
+    AC_SUBST(INTROSPECTION_GIRDIR)
+    AC_SUBST(INTROSPECTION_TYPELIBDIR)
+    AC_SUBST(INTROSPECTION_CFLAGS)
+    AC_SUBST(INTROSPECTION_LIBS)
+    AC_SUBST(INTROSPECTION_MAKEFILE)
+
+    AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes")
+])
+
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version])
+
+AC_DEFUN([GOBJECT_INTROSPECTION_CHECK],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1])
+])
+
+dnl Usage:
+dnl   GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version])
+
+
+AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE],
+[
+  _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require])
+])



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