[anjuta] project-wizard: Added GtkApplication wizard (non-working currently)



commit b37011b2bc96ae731384e7a3039d2c8c3d1e92cc
Author: Johannes Schmid <jhs gnome org>
Date:   Fri Dec 3 15:59:01 2010 +0100

    project-wizard: Added GtkApplication wizard (non-working currently)

 configure.ac                                       |    3 +
 plugins/project-wizard/druid.c                     |    9 ++-
 plugins/project-wizard/templates/Makefile.am       |    3 +-
 .../project-wizard/templates/gtkapplication.wiz.in |   91 +++++++++++++++++
 .../templates/gtkapplication/Makefile.am           |    4 +
 .../templates/gtkapplication/po/Makefile.am        |    5 +
 .../templates/gtkapplication/po/POTFILES.in        |    6 +
 .../templates/gtkapplication/src/Makefile.am       |    5 +
 .../templates/gtkapplication/src/Makefile.am.tpl   |   36 +++++++
 .../templates/gtkapplication/src/application.c     |  106 ++++++++++++++++++++
 .../templates/gtkapplication/src/application.h     |   45 ++++++++
 .../templates/gtkapplication/src/main.c            |   44 ++++++++
 .../templates/gtkapplication/src/project.ui        |   15 +++
 13 files changed, 370 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 320e229..64f9dec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -876,6 +876,9 @@ plugins/project-wizard/templates/cpp/po/Makefile
 plugins/project-wizard/templates/gtk/Makefile
 plugins/project-wizard/templates/gtk/src/Makefile
 plugins/project-wizard/templates/gtk/po/Makefile
+plugins/project-wizard/templates/gtkapplication/Makefile
+plugins/project-wizard/templates/gtkapplication/src/Makefile
+plugins/project-wizard/templates/gtkapplication/po/Makefile
 plugins/project-wizard/templates/anjuta-plugin/Makefile
 plugins/project-wizard/templates/anjuta-plugin/src/Makefile
 plugins/project-wizard/templates/anjuta-plugin/po/Makefile
diff --git a/plugins/project-wizard/druid.c b/plugins/project-wizard/druid.c
index 61f97c3..b23c660 100644
--- a/plugins/project-wizard/druid.c
+++ b/plugins/project-wizard/druid.c
@@ -805,9 +805,16 @@ on_druid_get_new_page (NPWAutogen* gen, gpointer data)
 static void
 on_druid_parse_page (const gchar* output, gpointer data)
 {
+	GError *error = NULL;
 	NPWPageParser* parser = (NPWPageParser*)data;
 	
-	npw_page_parser_parse (parser, output, strlen (output), NULL);
+	npw_page_parser_parse (parser, output, strlen (output), &error);
+
+	if (error)
+	{
+		g_warning ("Parser error: %s", error->message);
+		g_error_free (error);
+	}
 }
 
 static void
diff --git a/plugins/project-wizard/templates/Makefile.am b/plugins/project-wizard/templates/Makefile.am
index 1ec0e57..fb6cbad 100644
--- a/plugins/project-wizard/templates/Makefile.am
+++ b/plugins/project-wizard/templates/Makefile.am
@@ -1,5 +1,5 @@
 
-SUBDIRS = minimal terminal cpp gtk anjuta-plugin \
+SUBDIRS = minimal terminal cpp gtk gtkapplication anjuta-plugin \
 	gtkmm wxwin xlib xlib-dock gcj java pygtk \
 	python mkfile sdl library directory licenses m4 js_minimal
 
@@ -9,6 +9,7 @@ template_in_files = \
 	cpp.wiz.in \
 	django.wiz.in \
 	gtk.wiz.in \
+	gtkapplication.wiz.in \
 	anjuta-plugin.wiz.in \
 	gtkmm.wiz.in \
 	wxwin.wiz.in \
diff --git a/plugins/project-wizard/templates/gtkapplication.wiz.in b/plugins/project-wizard/templates/gtkapplication.wiz.in
new file mode 100644
index 0000000..788200c
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication.wiz.in
@@ -0,0 +1,91 @@
+<project-template>
+	<project-wizard>
+		<_name>GTK+ (Application)</_name>
+		<_description>Full features Gtk+ Application with file handling</_description>
+		<icon>gtk-logo.png</icon>
+		<category>C</category>
+		<required-program>automake</required-program>
+		<required-program>autoconf</required-program>
+		<required-program>make</required-program>
+		<required-package>gtk+-3.0 >= 2.90.3</required-package>
+	</project-wizard>
+	
+	<page name="basic" _label="Basic information" _description="General Project Information">
+		<property type="string" name="Name" _label="Project Name:" _description="project name" default="gtk-foobar" summary="yes" restriction="filename" mandatory="yes"/>
+		<property type="string" name="Author" _label="Author:" _description="" default="[+UserName+]" mandatory="yes"/>
+		<property type="string" name="Email" _label="Email address:" _description="" default="[+EmailAddress+]" mandatory="no"/>
+		<property type="string" name="Version" _label="Version:" default="0.1" mandatory="yes"/>
+	</page>
+	
+	<page name="options" _label="Project options" _description="Options for project build system">
+		<property type="directory" name="Destination" _label="Destination:" _description="" default='[+AnjutaProjectDirectory+]/[+(string-downcase (get "Name"))+]' mandatory="yes" exist="no" restriction="directory" summary="yes"/>
+		<property type="list" name="License" _label="License" _description="Select code license" default="GPL" editable="no">
+			<item name="GPL" _label="General Public License (GPL)"/>
+			<item name="LGPL" _label="Lesser General Public License (LGPL)"/>
+			<item name="BSD" _label="Berkeley Software Distribution License (BSD)"/>
+			<item name="None" _label="No license"/>
+		</property>
+		<property type="hidden" name="NameUpper" default='[+(string-upcase (get "Name"))+]'/>
+		<property type="hidden" name="NameLower" default='[+(string-downcase (get "Name"))+]'/>
+		<property type="hidden" name="NameCUpper" default='[+(string->c-name! (string-substitute (string-upcase (get "Name")) " " "_"))+]'/>
+		<property type="hidden" name="NameCLower" default='[+(string->c-name! (string-substitute (string-downcase (get "Name")) " " "_"))+]'/>
+		<property type="hidden" name="NameHLower" default='[+(string-substitute (string->c-name! (string-downcase (get "Name"))) " " "-")+]'/>
+		<property type="hidden" name="NameCClass" default='[+(string->camelcase (get "Name"))+]'/>
+		<property type="hidden" name="HavePackage" default="1"/>
+		<property type="hidden" name="PackageModule1" default="gtk+-3.0 >= 2.90.3"/>
+		<property type="boolean" name="HaveLangCPP" _label="Add C++ support:" _description="Adds C++ support to the project so that C++ source files can be built" default="0"/>
+		<property type="boolean" name="HaveI18n" _label="Add internationalization:" _description="Adds support for internationalization so that your project can have translations in different languages" default="1"/>
+		<property type="boolean" name="HaveSharedlib" _label="Add shared library support:" _description="Adds support for building shared libraries in your project" default="1"/>
+		<property type="boolean" name="HaveGtkDoc" _label="Add gtk-doc system:" _description="gtk-doc is used to compile API documentations for GObject based classes" default="0"/>
+		<property type="boolean" name="HavePackageExtra" _label="Configure external packages:" _description="Use pkg-config to add library support from other packages" default="0"/>
+	</page>
+	
+	[+IF (=(get "HavePackageExtra") "1")+]
+	<page name="packages" _label="Configure external packages" _description="Configure external packages">
+		<property type="package" name="PackageModule2" _label="Require Package:" _description="Give a package name that your project require. You may also mention what is the required version of the package. For example, 'libgnomeui-2.0' or 'libgnomeui-2.0 &gt;= 2.2.0'" mandatory="yes"/>
+	</page>
+	[+ENDIF+]
+	
+	<content>
+		<directory source="terminal" destination="[+Destination+]">
+			<file source="AUTHORS"/>
+			<file source="ChangeLog"/>
+			<file source="Makefile.am.tpl" destination="Makefile.am"/>
+			<file source="NEWS"/>
+			<file source="README"/>
+			<file source="autogen.sh" executable="yes"/>
+			<file source="configure.ac.tpl" destination="configure.ac"/>
+			<file destination="[+NameHLower+].anjuta" source="project.anjuta"/>
+			[+IF (=(get "HaveI18n") "1") +]
+			<directory source="po">
+				<file source="ChangeLog"/>
+				<file source="POTFILES.in"/>
+				<file source="LINGUAS" />
+			</directory>
+			[+ENDIF+]
+		</directory>
+		<directory source="gtkapplication" destination="[+Destination+]">
+			<directory source="src">
+				<file source="main.c"/>
+				<file source="application.h" destination="[+NameLower+].h"/>
+				<file source="application.c" destination="[+NameLower+].c"/>
+				<file source="project.ui" destination="[+NameHLower+].ui"/>
+				<file source="Makefile.am.tpl" destination="Makefile.am"/>
+			</directory>
+		</directory>
+		<directory source="licenses" destination="[+Destination+]">
+			<file source="[+License+]" destination="COPYING"/>	
+		</directory>
+		<directory source="minimal" destination="[+Destination+]">
+			<directory source="." destination=".anjuta">
+				<directory source="." destination="session">
+					<file source="anjuta.session"/>
+				</directory>
+			</directory>
+		</directory>
+	</content>
+
+	<action>
+		<open file="[+Destination+]/[+NameHLower+].anjuta"/>
+	</action>
+</project-template>
diff --git a/plugins/project-wizard/templates/gtkapplication/Makefile.am b/plugins/project-wizard/templates/gtkapplication/Makefile.am
new file mode 100644
index 0000000..6edb9f4
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/Makefile.am
@@ -0,0 +1,4 @@
+
+SUBDIRS = src po
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/project-wizard/templates/gtkapplication/po/Makefile.am b/plugins/project-wizard/templates/gtkapplication/po/Makefile.am
new file mode 100644
index 0000000..7432390
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/po/Makefile.am
@@ -0,0 +1,5 @@
+wizard_filesdir = $(anjuta_data_dir)/project/gtkapplication/po
+wizard_files_DATA = POTFILES.in
+EXTRA_DIST = $(wizard_files_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/project-wizard/templates/gtkapplication/po/POTFILES.in b/plugins/project-wizard/templates/gtkapplication/po/POTFILES.in
new file mode 100644
index 0000000..41ad205
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/po/POTFILES.in
@@ -0,0 +1,6 @@
+[+ autogen5 template +]
+# List of source files containing translatable strings.
+
+src/main.c
+src/callbacks.c
+src/callbacks.h
diff --git a/plugins/project-wizard/templates/gtkapplication/src/Makefile.am b/plugins/project-wizard/templates/gtkapplication/src/Makefile.am
new file mode 100644
index 0000000..8bb01e3
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/src/Makefile.am
@@ -0,0 +1,5 @@
+wizard_filesdir = $(anjuta_data_dir)/project/gtkapplication/src
+wizard_files_DATA = main.c application.c application.h Makefile.am.tpl project.ui
+EXTRA_DIST = $(wizard_files_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/project-wizard/templates/gtkapplication/src/Makefile.am.tpl b/plugins/project-wizard/templates/gtkapplication/src/Makefile.am.tpl
new file mode 100644
index 0000000..8aa9d8b
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/src/Makefile.am.tpl
@@ -0,0 +1,36 @@
+[+ autogen5 template +]
+## Process this file with automake to produce Makefile.in
+
+## Created by Anjuta
+
+uidir = $(datadir)/[+NameHLower+]/ui
+ui_DATA = [+NameHLower+].ui
+
+AM_CPPFLAGS = \
+	-DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+	-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
+	-DPACKAGE_DATA_DIR=\""$(datadir)"\" \
+	$([+NameCUpper+]_CFLAGS)
+
+AM_CFLAGS =\
+	 -Wall\
+	 -g
+
+bin_PROGRAMS = [+NameHLower+]
+
+[+NameCLower+]_SOURCES = \
+	main.c \
+	[+NameLower+].h \
+	[+NameLower+].c	
+
+[+NameCLower+]_LDFLAGS = \
+	-Wl,--export-dynamic
+
+[+NameCLower+]_LDADD = $([+NameCUpper+]_LIBS)
+
+EXTRA_DIST = $(ui_DATA)
+
+# Remove ui directory on uninstall
+uninstall-local:
+	-rm -r $(uidir)
+	-rm -r $(datadir)/[+NameHLower+]
diff --git a/plugins/project-wizard/templates/gtkapplication/src/application.c b/plugins/project-wizard/templates/gtkapplication/src/application.c
new file mode 100644
index 0000000..6449126
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/src/application.c
@@ -0,0 +1,106 @@
+[+ autogen5 template +]
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * [+NameLower+].c
+ * Copyright (C) [+Author+] [+(shell "date +%Y")+] <[+Email+]>
+ * 
+[+CASE (get "License") +]
+[+ == "BSD"  +][+(bsd  (get "Name") (get "Author") " * ")+]
+[+ == "LGPL" +][+(lgpl (get "Name") (get "Author") " * ")+]
+[+ == "GPL"  +][+(gpl  (get "Name")                " * ")+]
+[+ESAC+] */
+#include "[+NameLower+].h"
+[+IF (=(get "HaveI18n") "1")+]
+#include <glib/gi18n.h>
+[+ENDIF+]
+
+
+
+G_DEFINE_TYPE ([+NameCClass+], [+NameCLower+], GTK_TYPE_APPLICATION);
+
+/* Create a new window loading a file */
+static void
+[+NameCLower+]_new_window (GApplication *app,
+                           GFile        *file)
+{
+	GtkWidget *window;
+	GtkBuilder *builder;
+	GError* error = NULL;
+
+	/* Load UI from file */
+	builder = gtk_builder_new ();
+	if (!gtk_builder_add_from_file (builder, UI_FILE, &error))
+	{
+		g_warning ("Couldn't load builder file: %s", error->message);
+		g_error_free (error);
+	}
+
+	/* Auto-connect signal handlers */
+	gtk_builder_connect_signals (builder, NULL);
+
+	/* Get the window object from the ui file */
+	window = GTK_WIDGET (gtk_builder_get_object (builder, "window"));
+	g_object_unref (builder);
+
+
+	gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app));
+	if (file != NULL)
+	{
+		/* TODO: Add code here to open the file in the new window */
+	}
+	gtk_widget_show_all (GTK_WIDGET (window));
+}
+
+
+/* GApplication implementation */
+static void
+[+NameCLower+]_activate (GApplication *application)
+{
+  new_window (application, NULL);
+}
+
+static void
+[+NameCLower+]_open (GApplication  *application,
+                     GFile        **files,
+                     gint           n_files,
+                     const gchar   *hint)
+{
+  gint i;
+
+  for (i = 0; i < n_files; i++)
+    new_window (application, files[i]);
+}
+
+static void
+[+NameCLower+]_init ([+NameCClass+] *object)
+{
+
+}
+
+static void
+[+NameCLower+]_finalize (GObject *object)
+{
+
+	G_OBJECT_CLASS (application_parent_class)->finalize (object);
+}
+
+static void
+[+NameCLower+]_class_init ([+NameCClass+]Class *klass)
+{
+	GObjectClass* object_class = G_OBJECT_CLASS (klass);
+	GApplicationClass* parent_class = G_APPLICATION_CLASS (klass);
+
+	G_APPLICATION_CLASS (klass)->activate = [+NameCLower+]_activate;
+	G_APPLICATION_CLASS (klass)->open = [+NameCLower+]_open;
+}
+
+[+NameCClass+] *
+[+NameCLower+]_new (void)
+{
+	g_type_init ();
+
+	return g_object_new (bloat_pad_get_type (),
+	                     "application-id", "org.gnome.[+NameCLower+]",
+	                     "flags", G_APPLICATION_HANDLES_OPEN,
+	                     NULL);
+}
diff --git a/plugins/project-wizard/templates/gtkapplication/src/application.h b/plugins/project-wizard/templates/gtkapplication/src/application.h
new file mode 100644
index 0000000..9811c81
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/src/application.h
@@ -0,0 +1,45 @@
+[+ autogen5 template +]
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * [+NameLower+].h
+ * Copyright (C) [+Author+] [+(shell "date +%Y")+] <[+Email+]>
+ * 
+[+CASE (get "License") +]
+[+ == "BSD"  +][+(bsd  (get "Name") (get "Author") " * ")+]
+[+ == "LGPL" +][+(lgpl (get "Name") (get "Author") " * ")+]
+[+ == "GPL"  +][+(gpl  (get "Name")                " * ")+]
+[+ESAC+] */
+
+#ifndef _[+NameCUppper+]_
+#define _[+NameCUppper+]_
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define [+NameCUpper+]_TYPE_APPLICATION             ([+NameCLower+]_get_type ())
+#define [+NameCUpper+]_APPLICATION(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), [+NameCUpper+]_TYPE_APPLICATION, [+NameCClass+]))
+#define [+NameCUpper+]_APPLICATION_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), [+NameCUpper+]_TYPE_APPLICATION, [+NameCClass+]Class))
+#define [+NameCUpper+]_IS_APPLICATION(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), [+NameCUpper+]_TYPE_APPLICATION))
+#define [+NameCUpper+]_IS_APPLICATION_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), [+NameCUpper+]_TYPE_APPLICATION))
+#define [+NameCUpper+]_APPLICATION_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), [+NameCUpper+]_TYPE_APPLICATION, [+NameCClass+]Class))
+
+typedef struct _[+NameCClass+]Class [+NameCClass+]Class;
+typedef struct _[+NameCClass+] [+NameCClass+];
+
+struct _[+NameCClass+]Class
+{
+	GtkApplicationClass parent_class;
+};
+
+struct _[+NameCClass+]
+{
+	GtkApplication parent_instance;
+};
+
+GType [+NameCLower+]_get_type (void) G_GNUC_CONST;
+[+NameCClass+] *[+NameCLower+]_new (void);
+
+G_END_DECLS
+
+#endif /* _APPLICATION_H_ */
diff --git a/plugins/project-wizard/templates/gtkapplication/src/main.c b/plugins/project-wizard/templates/gtkapplication/src/main.c
new file mode 100644
index 0000000..6b1283f
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/src/main.c
@@ -0,0 +1,44 @@
+[+ autogen5 template +]
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * main.c
+ * Copyright (C) [+Author+] [+(shell "date +%Y")+] <[+Email+]>
+ * 
+[+CASE (get "License") +]
+[+ == "BSD"  +][+(bsd  (get "Name") (get "Author") " * ")+]
+[+ == "LGPL" +][+(lgpl (get "Name") (get "Author") " * ")+]
+[+ == "GPL"  +][+(gpl  (get "Name")                " * ")+]
+[+ESAC+] */
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include "[+NameLower+].h"
+
+[+IF (=(get "HaveI18n") "1")+]
+#include <glib/gi18n.h>
+[+ENDIF+]
+
+/* For testing propose use the local (not installed) ui file */
+/* #define UI_FILE PACKAGE_DATA_DIR"/[+NameHLower+]/ui/[+NameHLower+].ui" */
+#define UI_FILE "src/[+NameHLower+].ui"
+
+int
+main (int argc, char *argv[])
+{
+	[+NameCClass+] *app;
+	int status;
+
+[+IF (=(get "HaveI18n") "1")+]
+#ifdef ENABLE_NLS
+	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+	textdomain (GETTEXT_PACKAGE);
+#endif
+[+ENDIF+]
+	
+  app = [+NameCLower+]_pad_new ();
+  status = g_application_run (G_APPLICATION (app), argc, argv);
+  g_object_unref (app);
+
+  return status;
+}
diff --git a/plugins/project-wizard/templates/gtkapplication/src/project.ui b/plugins/project-wizard/templates/gtkapplication/src/project.ui
new file mode 100644
index 0000000..a21329c
--- /dev/null
+++ b/plugins/project-wizard/templates/gtkapplication/src/project.ui
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy project-wide -->
+  <object class="GtkWindow" id="window">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">window</property>
+    <property name="default_width">500</property>
+    <property name="default_height">400</property>
+    <signal name="destroy" handler="destroy"/>
+    <child>
+      <placeholder/>
+    </child>
+  </object>
+</interface>



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