[gnome-devel-docs] Application examples of building and installing in C, Vala, Python.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] Application examples of building and installing in C, Vala, Python.
- Date: Wed, 15 Aug 2012 22:10:47 +0000 (UTC)
commit e199e3617ae97bb46ecf0bbb9a2bf51cf7d747e6
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Wed Aug 15 18:08:49 2012 -0400
Application examples of building and installing in C, Vala, Python.
platform-demos/C/samples/hello-in-C/Makefile.am | 10 +++++
platform-demos/C/samples/hello-in-C/autogen.sh | 18 ++++++++++
platform-demos/C/samples/hello-in-C/configure.ac | 9 +++++
platform-demos/C/samples/hello-in-C/hello-world.c | 34 ++++++++++++++++++
.../C/samples/hello-in-C/hello-world.desktop.in | 11 ++++++
.../C/samples/hello-in-python/Makefile.am | 11 ++++++
platform-demos/C/samples/hello-in-python/README | 36 ++++++++++++++++++++
.../C/samples/hello-in-python/autogen.sh | 18 ++++++++++
.../C/samples/hello-in-python/configure.ac | 5 +++
.../samples/hello-in-python/hello-world.desktop.in | 11 ++++++
.../C/samples/hello-in-python/hello-world.py | 30 ++++++++++++++++
platform-demos/C/samples/hello-in-vala/Makefile.am | 11 ++++++
platform-demos/C/samples/hello-in-vala/autogen.sh | 18 ++++++++++
.../C/samples/hello-in-vala/configure.ac | 9 +++++
.../C/samples/hello-in-vala/hello-world.desktop.in | 11 ++++++
.../C/samples/hello-in-vala/hello-world.vala | 14 ++++++++
16 files changed, 256 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/samples/hello-in-C/Makefile.am b/platform-demos/C/samples/hello-in-C/Makefile.am
new file mode 100644
index 0000000..0f97551
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-C/Makefile.am
@@ -0,0 +1,10 @@
+# The actual runnable program is set to the SCRIPTS primitive.
+# # Prefix bin_ tells where to copy this
+bin_PROGRAMS = hello-world
+hello_world_CFLAGS = $(gtk_CFLAGS)
+hello_world_LDADD = $(gtk_LIBS)
+hello_world_SOURCES = hello-world.c
+
+desktopdir = $(datadir)/applications
+desktop_DATA = \
+ hello-world.desktop
diff --git a/platform-demos/C/samples/hello-in-C/README b/platform-demos/C/samples/hello-in-C/README
new file mode 100644
index 0000000..e69de29
diff --git a/platform-demos/C/samples/hello-in-C/autogen.sh b/platform-demos/C/samples/hello-in-C/autogen.sh
new file mode 100755
index 0000000..cb2570e
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-C/autogen.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+test -n "$srcdir" || srcdir=`dirname "$0"`
+test -n "$srcdir" || srcdir=.
+
+olddir=`pwd`
+cd "$srcdir"
+
+# This will run autoconf, automake, etc. for us
+autoreconf --force --install
+
+cd "$olddir"
+
+if test -z "$NOCONFIGURE"; then
+ "$srcdir"/configure "$@"
+fi
diff --git a/platform-demos/C/samples/hello-in-C/configure.ac b/platform-demos/C/samples/hello-in-C/configure.ac
new file mode 100644
index 0000000..b8fa181
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-C/configure.ac
@@ -0,0 +1,9 @@
+# This file is processed by autoconf to create a configure script
+AC_INIT([Hello World], 1.0)
+AM_INIT_AUTOMAKE([1.10 no-define foreign dist-xz no-dist-gzip])
+AC_PROG_CC
+AM_PROG_VALAC([0.16])
+PKG_CHECK_MODULES(gtk, gtk+-3.0)
+AC_CONFIG_FILES([Makefile hello-world.desktop])
+
+AC_OUTPUT
diff --git a/platform-demos/C/samples/hello-in-C/hello-world.c b/platform-demos/C/samples/hello-in-C/hello-world.c
new file mode 100644
index 0000000..98fffd1
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-C/hello-world.c
@@ -0,0 +1,34 @@
+#include <gtk/gtk.h>
+
+static void
+activate (GtkApplication* app,
+ gpointer user_data)
+{
+ GtkWidget *window;
+ GtkWidget *label;
+
+ window = gtk_application_window_new (app);
+ label = gtk_label_new ("Hello GNOME!");
+ gtk_container_add (GTK_CONTAINER (window), label);
+ gtk_window_set_title (GTK_WINDOW (window), "Welcome to GNOME");
+ gtk_window_set_default_size (GTK_WINDOW (window), 200, 100);
+ gtk_widget_show_all (window);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ GtkApplication *app;
+ int status;
+
+ app = gtk_application_new (NULL, G_APPLICATION_FLAGS_NONE);
+ g_signal_connect (app, "activate", G_CALLBACK (activate), NULL);
+ status = g_application_run (G_APPLICATION (app), argc, argv);
+ g_object_unref (app);
+
+ return status;
+}
+
+
+
diff --git a/platform-demos/C/samples/hello-in-C/hello-world.desktop.in b/platform-demos/C/samples/hello-in-C/hello-world.desktop.in
new file mode 100644
index 0000000..06fbd41
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-C/hello-world.desktop.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Name=Hello World
+Comment=Say Hello
+Exec= prefix@/bin/hello-world
+Icon=application-default-icon
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=GNOME;GTK;Utility;
diff --git a/platform-demos/C/samples/hello-in-python/Makefile.am b/platform-demos/C/samples/hello-in-python/Makefile.am
new file mode 100644
index 0000000..fa4110a
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-python/Makefile.am
@@ -0,0 +1,11 @@
+# The actual runnable program is set to the SCRIPTS primitive.
+# # Prefix bin_ tells where to copy this
+bin_SCRIPTS = hello-world.py
+# # List of files to be distributed
+EXTRA_DIST= \
+ $(bin_SCRIPTS)
+#
+# # The desktop files
+desktopdir = $(datadir)/applications
+desktop_DATA = \
+ hello-world.desktop
diff --git a/platform-demos/C/samples/hello-in-python/README b/platform-demos/C/samples/hello-in-python/README
new file mode 100644
index 0000000..dba645f
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-python/README
@@ -0,0 +1,36 @@
+To build and install this program:
+
+./autogen.sh --prefix=/home/your_username/.local
+make install
+
+-------------
+Running the first line above creates the following files:
+
+aclocal.m4
+autom4te.cache
+config.log
+config.status
+configure
+hello-world.desktop
+install-sh
+missing
+Makefile.in
+Makefile
+
+Running "make install", installs the application in /home/your_username/.local/bin
+and installs the hello-world.desktop file in /home/your_username/.local/share/applications
+
+You can now run the application by typing "Hello World" in the Overview.
+
+----------------
+To uninstall, type:
+
+make uninstall
+
+----------------
+To create a tarball type:
+
+make distcheck
+
+This will create hello-world-1.0.tar.xz
+
diff --git a/platform-demos/C/samples/hello-in-python/autogen.sh b/platform-demos/C/samples/hello-in-python/autogen.sh
new file mode 100755
index 0000000..cb2570e
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-python/autogen.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+test -n "$srcdir" || srcdir=`dirname "$0"`
+test -n "$srcdir" || srcdir=.
+
+olddir=`pwd`
+cd "$srcdir"
+
+# This will run autoconf, automake, etc. for us
+autoreconf --force --install
+
+cd "$olddir"
+
+if test -z "$NOCONFIGURE"; then
+ "$srcdir"/configure "$@"
+fi
diff --git a/platform-demos/C/samples/hello-in-python/configure.ac b/platform-demos/C/samples/hello-in-python/configure.ac
new file mode 100644
index 0000000..bdd443b
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-python/configure.ac
@@ -0,0 +1,5 @@
+# This file is processed by autoconf to create a configure script
+AC_INIT([Hello World], 1.0)
+AM_INIT_AUTOMAKE([1.10 no-define foreign dist-xz no-dist-gzip])
+AC_CONFIG_FILES([Makefile hello-world.desktop])
+AC_OUTPUT
diff --git a/platform-demos/C/samples/hello-in-python/hello-world.desktop.in b/platform-demos/C/samples/hello-in-python/hello-world.desktop.in
new file mode 100644
index 0000000..06fbd41
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-python/hello-world.desktop.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Name=Hello World
+Comment=Say Hello
+Exec= prefix@/bin/hello-world
+Icon=application-default-icon
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=GNOME;GTK;Utility;
diff --git a/platform-demos/C/samples/hello-in-python/hello-world.py b/platform-demos/C/samples/hello-in-python/hello-world.py
new file mode 100644
index 0000000..ebca626
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-python/hello-world.py
@@ -0,0 +1,30 @@
+from gi.repository import Gtk
+import sys
+
+class MyWindow(Gtk.ApplicationWindow):
+ # constructor for a Gtk.ApplicationWindow
+ def __init__(self, app):
+ Gtk.Window.__init__(self, title="Welcome to GNOME", application=app)
+ self.set_default_size(200, 100)
+
+ # create a label
+ label = Gtk.Label()
+ # set the text of the label
+ label.set_text("Hello GNOME!")
+ # add the label to the window
+ self.add(label)
+
+class MyApplication(Gtk.Application):
+ def __init__(self):
+ Gtk.Application.__init__(self)
+
+ def do_activate(self):
+ win = MyWindow(self)
+ win.show_all()
+
+ def do_startup(self):
+ Gtk.Application.do_startup(self)
+
+app = MyApplication()
+exit_status = app.run(sys.argv)
+sys.exit(exit_status)
diff --git a/platform-demos/C/samples/hello-in-vala/Makefile.am b/platform-demos/C/samples/hello-in-vala/Makefile.am
new file mode 100644
index 0000000..5d6150a
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-vala/Makefile.am
@@ -0,0 +1,11 @@
+# The actual runnable program is set to the SCRIPTS primitive.
+# # Prefix bin_ tells where to copy this
+bin_PROGRAMS = hello-world
+hello_world_CFLAGS = $(gtk_CFLAGS)
+hello_world_LDADD = $(gtk_LIBS)
+hello_world_VALAFLAGS = --pkg gtk+-3.0
+hello_world_SOURCES = hello-world.vala
+
+desktopdir = $(datadir)/applications
+desktop_DATA = \
+ hello-world.desktop
diff --git a/platform-demos/C/samples/hello-in-vala/README b/platform-demos/C/samples/hello-in-vala/README
new file mode 100644
index 0000000..e69de29
diff --git a/platform-demos/C/samples/hello-in-vala/autogen.sh b/platform-demos/C/samples/hello-in-vala/autogen.sh
new file mode 100755
index 0000000..cb2570e
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-vala/autogen.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+set -e
+
+test -n "$srcdir" || srcdir=`dirname "$0"`
+test -n "$srcdir" || srcdir=.
+
+olddir=`pwd`
+cd "$srcdir"
+
+# This will run autoconf, automake, etc. for us
+autoreconf --force --install
+
+cd "$olddir"
+
+if test -z "$NOCONFIGURE"; then
+ "$srcdir"/configure "$@"
+fi
diff --git a/platform-demos/C/samples/hello-in-vala/configure.ac b/platform-demos/C/samples/hello-in-vala/configure.ac
new file mode 100644
index 0000000..b8fa181
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-vala/configure.ac
@@ -0,0 +1,9 @@
+# This file is processed by autoconf to create a configure script
+AC_INIT([Hello World], 1.0)
+AM_INIT_AUTOMAKE([1.10 no-define foreign dist-xz no-dist-gzip])
+AC_PROG_CC
+AM_PROG_VALAC([0.16])
+PKG_CHECK_MODULES(gtk, gtk+-3.0)
+AC_CONFIG_FILES([Makefile hello-world.desktop])
+
+AC_OUTPUT
diff --git a/platform-demos/C/samples/hello-in-vala/hello-world.desktop.in b/platform-demos/C/samples/hello-in-vala/hello-world.desktop.in
new file mode 100644
index 0000000..06fbd41
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-vala/hello-world.desktop.in
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Version=1.0
+Encoding=UTF-8
+Name=Hello World
+Comment=Say Hello
+Exec= prefix@/bin/hello-world
+Icon=application-default-icon
+Terminal=false
+Type=Application
+StartupNotify=true
+Categories=GNOME;GTK;Utility;
diff --git a/platform-demos/C/samples/hello-in-vala/hello-world.vala b/platform-demos/C/samples/hello-in-vala/hello-world.vala
new file mode 100644
index 0000000..5a880fc
--- /dev/null
+++ b/platform-demos/C/samples/hello-in-vala/hello-world.vala
@@ -0,0 +1,14 @@
+public class MyApplication : Gtk.Application {
+ protected override void activate () {
+ var window = new Gtk.ApplicationWindow (this);
+ var label = new Gtk.Label ("Hello GNOME!");
+ window.add (label);
+ window.set_title ("Welcome to GNOME");
+ window.set_default_size (200, 100);
+ window.show_all ();
+ }
+}
+
+public int main (string[] args) {
+ return new MyApplication ().run (args);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]