[gnome-devel-docs] tutorials C: image example-a widget displaying an image
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] tutorials C: image example-a widget displaying an image
- Date: Fri, 25 May 2012 00:42:05 +0000 (UTC)
commit 76db486b12344bc240283b13ed14fc244b81a2f9
Author: Monica Kochofar <monicakochofar gmail com>
Date: Thu May 24 14:32:08 2012 -0400
tutorials C: image example-a widget displaying an image
platform-demos/C/image.c.page | 39 ++++++++++++++++++++++++++++++++++++++
platform-demos/C/samples/image.c | 38 +++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/image.c.page b/platform-demos/C/image.c.page
new file mode 100644
index 0000000..574fdd1
--- /dev/null
+++ b/platform-demos/C/image.c.page
@@ -0,0 +1,39 @@
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="image.c">
+ <info>
+ <link type="guide" xref="beginner.c#display-widgets"/>
+ <revision version="0.1" date="2012-05-23" status="draft"/>
+
+ <credit type="author copyright">
+ <name>Monica Kochofar</name>
+ <email>monicakochofar gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A widget displaying an image.</desc>
+ </info>
+
+ <title>Image</title>
+<table>
+ <tr>
+ <td>
+ <media type="image" mime="image/png" src="media/image.png"/>
+ <p>This GtkApplication displays an image file from the current directory.</p>
+ </td>
+ </tr>
+</table>
+
+ <code mime="text/x-csrc" style="numbered">
+<xi:include href="samples/image.c" parse="text"><xi:fallback/></xi:include></code>
+<p>
+ In this sample we used the following:
+</p>
+<list>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.4/GtkApplication.html">GtkApplication</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/stable/GtkWindow.html">GtkWindow</link></p></item>
+ <item><p><link href="http://developer.gnome.org/gtk3/stable/GtkImage.html">GtkImage</link></p></item>
+</list>
+</page>
+
diff --git a/platform-demos/C/samples/image.c b/platform-demos/C/samples/image.c
new file mode 100644
index 0000000..e7e9e7b
--- /dev/null
+++ b/platform-demos/C/samples/image.c
@@ -0,0 +1,38 @@
+#include <gtk/gtk.h>
+
+
+static void
+activate (GtkApplication *app,
+ gpointer user_data)
+{
+ GtkWidget *window;
+ GtkWidget *image;
+
+ window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+
+ gtk_window_set_application (GTK_WINDOW (window), GTK_APPLICATION (app));
+ gtk_window_set_title (GTK_WINDOW (window), "Welcome to GNOME");
+ gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);//may have to change size
+
+ image = gtk_image_new_from_file("gnome-image.png");
+
+ gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(image));
+
+ gtk_widget_show_all (GTK_WIDGET (window));
+}
+
+
+int
+main (int argc, char **argv)
+{
+ GtkApplication *app;
+ int status;
+
+ app = gtk_application_new ("org.gtk.example",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;
+}
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]