[gnome-devel-docs/wip/dxhackfest2013: 165/165] platform-demos: Improve paned.js



commit de3274109887155a47bc88efd593dbf7a980c65d
Author: David King <amigadave amigadave com>
Date:   Sun Jun 23 23:44:28 2013 +0100

    platform-demos: Improve paned.js

 platform-demos/C/paned.js         |   62 -------------------------------------
 platform-demos/C/samples/paned.js |   61 ++++++++++++++++++++++++++++++++++++
 2 files changed, 61 insertions(+), 62 deletions(-)
---
diff --git a/platform-demos/C/samples/paned.js b/platform-demos/C/samples/paned.js
new file mode 100644
index 0000000..3119ac9
--- /dev/null
+++ b/platform-demos/C/samples/paned.js
@@ -0,0 +1,61 @@
+#!/usr/bin/gjs
+
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+
+const PanedExample = new Lang.Class ({
+    Name: 'Paned Example',
+
+    // Create the application itself
+    _init: function () {
+        this.application = new Gtk.Application({ application_id: 'org.example.panedexample' });
+
+       // Connect 'activate' and 'startup' signals to the callback functions
+        this.application.connect('activate', Lang.bind(this, this._onActivate));
+        this.application.connect('startup', Lang.bind(this, this._onStartup));
+    },
+
+    // Callback function for 'activate' signal presents windows when active
+    _onActivate: function() {
+        this.window.present();
+    },
+
+    // Callback function for 'startup' signal builds the UI
+    _onStartup: function () {
+        this._buildUI ();
+    },
+
+    // Build the application's UI
+    _buildUI: function() {
+        // Create the application window
+        this.window = new Gtk.ApplicationWindow  ({ application: this.application,
+                                                    window_position: Gtk.WindowPosition.CENTER,
+                                                    title: "Paned Window Example",
+                                                    default_width: 450,
+                                                    default_height: 350,
+                                                    border_width: 10 });
+
+        // a new widget with two adjustable panes,
+        // one on the left and one on the right
+        this.paned = Gtk.Paned.new(Gtk.Orientation.HORIZONTAL);
+
+        // two images
+        this.image1 = new Gtk.Image();
+        this.image1.set_from_file("gnome-image.png");
+        this.image2 = new Gtk.Image();
+        this.image2.set_from_file("tux.png");
+
+        // add the first image to the left pane
+        this.paned.add1(this.image1);
+        // add the second image to the right pane
+        this.paned.add2(this.image2)
+
+        // add the panes to the window
+        this.window.add(this.paned)
+        this.window.show_all();
+    }
+});
+
+// Run the application
+let app = new PanedExample();
+app.application.run (ARGV);


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