[gegl-gtk] Add a basic example



commit 2ce1975ab4ac735ee30e42be10dbd347dc889ce1
Author: Jon Nordby <jononor gmail com>
Date:   Thu Jun 16 20:24:35 2011 +0200

    Add a basic example
    
    Shows how to use Gegl + GeglGtk in the simplest case.

 README                    |    6 ++-
 examples/.gitignore       |    1 +
 examples/gegl-gtk-basic.c |   70 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 2 deletions(-)
---
diff --git a/README b/README
index d1d4b65..196f200 100644
--- a/README
+++ b/README
@@ -2,7 +2,6 @@ License: Library is LGPLv3+, examples GPLv3+
 
 == TODO ==
 General
-* Add GObject introspection support
 * Write a Gegl based GdkPixbuf loader plugin
 
 GeglView
@@ -17,5 +16,8 @@ gtk-display
 * Use GeglView instead of custom widget
 
 examples
-* Add a super basic example (10 liner)
 * Add a way to manipulate view transformation to paint example
+
+== BUGS ==
+* On first redraw of GeglGtkView, there is sometimes a segfault inside babl:
+babl-fish-reference.c:290 process_same_model()
diff --git a/examples/.gitignore b/examples/.gitignore
index 9d10337..727dec4 100644
--- a/examples/.gitignore
+++ b/examples/.gitignore
@@ -1 +1,2 @@
 gegl-gtk-paint
+gegl-gtk-basic
diff --git a/examples/gegl-gtk-basic.c b/examples/gegl-gtk-basic.c
new file mode 100644
index 0000000..fd95f1b
--- /dev/null
+++ b/examples/gegl-gtk-basic.c
@@ -0,0 +1,70 @@
+/* This file is part of GEGL-GTK
+ *
+ * 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/>.
+ *
+ * Copyright (C) 2011 Jon Nordby <jononor gmail com>
+ */
+
+#include <string.h>
+#include <glib.h>
+#include <gegl.h>
+#include <gtk/gtk.h>
+#include <gegl-gtk.h>
+
+gint
+main (gint    argc,
+      gchar **argv)
+{
+  GtkWidget *window = NULL;
+  GtkWidget *view = NULL;
+  GeglNode *graph = NULL;
+  GeglNode *node = NULL;
+
+  g_thread_init (NULL);
+  gtk_init (&argc, &argv);
+  gegl_init (&argc, &argv);
+
+  if (argc != 2) {
+    g_print ("Usage: %s <FILENAME>\n", argv[0]);
+    exit(1);
+  }
+
+  /* Build graph that loads an image */
+  graph = gegl_node_new ();
+  node = gegl_node_new_child (graph,
+    "operation", "gegl:load", 
+    "path", argv[1], NULL);
+
+  gegl_node_process (node);
+
+  /* Setup */
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title (GTK_WINDOW (window), "GEGL-GTK basic example");
+
+  view = g_object_new (GEGL_GTK_TYPE_VIEW, "node", node, NULL);
+  gtk_container_add (GTK_CONTAINER (window), view);
+
+  g_signal_connect (G_OBJECT (window), "delete-event",
+                    G_CALLBACK (gtk_main_quit), window);
+  gtk_widget_show_all (window);
+
+  /* Run */
+  gtk_main ();
+
+  /* Cleanup */
+  g_object_unref (graph);
+  gtk_widget_destroy (window);
+  gegl_exit ();
+  return 0;
+}



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