[gnome-devel-docs] tutorials C: label example



commit d9f791b78df9e58089700a978b6597f8981031be
Author: Monica Kochofar <monicakochofar gmail com>
Date:   Thu May 24 14:20:23 2012 -0400

    tutorials C: label example

 platform-demos/C/label.c.page    |   39 +++++++++++++++++++++++++++++++++++++
 platform-demos/C/samples/label.c |   40 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/label.c.page b/platform-demos/C/label.c.page
new file mode 100644
index 0000000..7358ce0
--- /dev/null
+++ b/platform-demos/C/label.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="label.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 which displays text</desc>
+  </info>
+
+  <title>Label</title>
+<table>
+  <tr>
+    <td>
+      <media type="image" mime="image/png" src="media/label.png"/>
+      <p>A simple label</p>
+    </td>
+  </tr>
+</table>
+
+      <code mime="text/x-csrc" style="numbered">
+<xi:include href="samples/label.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/3.4/GtkLabel.html";>GtkLabel</link></p></item>
+</list>
+</page> 
+
diff --git a/platform-demos/C/samples/label.c b/platform-demos/C/samples/label.c
new file mode 100644
index 0000000..0e78460
--- /dev/null
+++ b/platform-demos/C/samples/label.c
@@ -0,0 +1,40 @@
+
+#include <gtk/gtk.h>
+
+
+static void
+activate (GtkApplication *app,
+          gpointer        user_data)
+{
+  GtkWidget *window;
+  GtkWidget *label;
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  label = gtk_label_new("Hello GNOME!");
+
+  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), 200,100);
+
+  gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_CENTER);
+  gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
+  gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(label));
+
+  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]