[gegl-gtk] Examples: Add C example with scrolledwindow



commit 9564c3b97b54ec46dcde4cbeb0ed2111f74d3f2e
Author: Jon Nordby <jononor gmail com>
Date:   Wed Oct 5 21:19:34 2011 +0200

    Examples: Add C example with scrolledwindow

 examples/c/.gitignore        |    1 +
 examples/c/gegl-gtk-scroll.c |   80 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)
---
diff --git a/examples/c/.gitignore b/examples/c/.gitignore
new file mode 100644
index 0000000..54e0920
--- /dev/null
+++ b/examples/c/.gitignore
@@ -0,0 +1 @@
+gegl-gtk-scroll
diff --git a/examples/c/gegl-gtk-scroll.c b/examples/c/gegl-gtk-scroll.c
new file mode 100644
index 0000000..64f1e6a
--- /dev/null
+++ b/examples/c/gegl-gtk-scroll.c
@@ -0,0 +1,80 @@
+/* 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 <stdlib.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;
+  GtkWidget *scrolled = 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 scrolled example");
+  
+  
+  scrolled = gtk_scrolled_window_new(NULL, NULL);
+
+  view = GTK_WIDGET(gegl_gtk_view_new_for_node(node));
+
+  // FIXME: should be possible for the widget to do this automatically, and take changes into account
+  gtk_widget_set_size_request(view, 500, 500);
+  
+  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolled), view);
+  
+  gtk_container_add (GTK_CONTAINER (window), scrolled);
+
+  g_signal_connect (window, "destroy", 
+                    G_CALLBACK (gtk_main_quit), NULL);
+  gtk_widget_show_all (window);
+
+  /* Run */
+  gtk_main ();
+
+  /* Cleanup */
+  g_object_unref (graph);
+  gegl_exit ();
+  return 0;
+}



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