[gnome-devel-docs/wip/dxhackfest2013] platform-demos: add scrolledwindowexample.js
- From: Meg Ford (Margaret) <megford src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs/wip/dxhackfest2013] platform-demos: add scrolledwindowexample.js
- Date: Fri, 22 Feb 2013 03:39:27 +0000 (UTC)
commit 7a1ee8eb8ef8515a3b4f4a0c9c8402a7bcfe926d
Author: Meg Ford <megford gnome org>
Date: Thu Feb 21 21:23:52 2013 -0600
platform-demos: add scrolledwindowexample.js
platform-demos/C/scrolledwindowexample.js | 62 +++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/scrolledwindowexample.js b/platform-demos/C/scrolledwindowexample.js
new file mode 100644
index 0000000..ca553bb
--- /dev/null
+++ b/platform-demos/C/scrolledwindowexample.js
@@ -0,0 +1,62 @@
+#!/usr/bin/gjs
+
+const GObject = imports.gi.GObject;
+const Gtk = imports.gi.Gtk;
+const Lang = imports.lang;
+
+const ScrolledWindowExample = new Lang.Class ({
+ Name: 'ScrolledWindow Example',
+
+ // Create the application itself
+ _init: function () {
+ this.application = new Gtk.Application({ application_id: 'org.example.jscrolledwindow' });
+
+ // 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: "Scrolled Window Example",
+ default_width: 200,
+ default_height: 200,
+ border_width: 10 });
+ // the scrolledwindow
+ this.scrolledWindow = new Gtk.ScrolledWindow();
+ this.scrolledWindow.set_border_width(10);
+ // there is always the scrollbar (otherwise: AUTOMATIC - only if needed - or NEVER)
+ this.scrolledWindow.set_policy(Gtk.PolicyType.ALWAYS, Gtk.PolicyType.ALWAYS);
+ // an image - slightly larger than the window
+ this.image = new Gtk.Image();
+ this.image.set_from_file("gnome-image.png");
+
+ // add the image to the scrolledwindow
+ this.scrolledWindow.add_with_viewport(this.image);
+
+ // add the scrolledwindow to the window
+ this.window.add(this.scrolledWindow);
+ this.window.show_all();
+ }
+});
+
+// Run the application
+let app = new ScrolledWindowExample();
+app.application.run (ARGV);
+
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]