|
Packit |
1470ea |
|
|
Packit |
1470ea |
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="progressbar.js" xml:lang="ko">
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<title type="text">ProgressBar (JavaScript)</title>
|
|
Packit |
1470ea |
<link type="guide" xref="beginner.js#display-widgets"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2012-06-01" status="draft"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Taryn Fox</name>
|
|
Packit |
1470ea |
<email its:translate="no">jewelfox@fursona.net</email>
|
|
Packit |
1470ea |
<years>2012</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc>진행 상황을 움직임으로 나타내는 표시줄입니다</desc>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>조성호</mal:name>
|
|
Packit |
1470ea |
<mal:email>shcho@gnome.org</mal:email>
|
|
Packit |
1470ea |
<mal:years>2017</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>ProgressBar</title>
|
|
Packit |
1470ea |
<media type="video" mime="application/ogv" src="media/progressbar.ogv">
|
|
Packit |
1470ea |
<tt:tt xmlns:tt="http://www.w3.org/ns/ttml">
|
|
Packit |
1470ea |
<tt:body>
|
|
Packit |
1470ea |
<tt:div begin="0s" end="6s">
|
|
Packit |
1470ea |
<tt:p>아무 키나 눌러서 ProgressBar 동작을 멈추거나 시작합니다.</tt:p>
|
|
Packit |
1470ea |
</tt:div>
|
|
Packit |
1470ea |
</tt:body>
|
|
Packit |
1470ea |
</tt:tt>
|
|
Packit |
1470ea |
</media>
|
|
Packit |
1470ea |
이 ProgressBar는 어떤 키든 눌렀을 때 동작을 멈추거나 시작합니다.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
#!/usr/bin/gjs
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
imports.gi.versions.Gtk = '3.0';
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
const Gio = imports.gi.Gio;
|
|
Packit |
1470ea |
const GLib = imports.gi.GLib;
|
|
Packit |
1470ea |
const Gtk = imports.gi.Gtk;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
class ProgressBarExample {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the application itself
|
|
Packit |
1470ea |
constructor() {
|
|
Packit |
1470ea |
this.application = new Gtk.Application({
|
|
Packit |
1470ea |
application_id: 'org.example.jsprogressbar',
|
|
Packit |
1470ea |
flags: Gio.ApplicationFlags.FLAGS_NONE
|
|
Packit |
1470ea |
});
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Connect 'activate' and 'startup' signals to the callback functions
|
|
Packit |
1470ea |
this.application.connect('activate', this._onActivate.bind(this));
|
|
Packit |
1470ea |
this.application.connect('startup', this._onStartup.bind(this));
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Callback function for 'activate' signal presents windows when active
|
|
Packit |
1470ea |
_onActivate() {
|
|
Packit |
1470ea |
this._window.present();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Callback function for 'startup' signal builds the UI
|
|
Packit |
1470ea |
_onStartup() {
|
|
Packit |
1470ea |
this._buildUI();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Build the application's UI
|
|
Packit |
1470ea |
_buildUI() {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the application window
|
|
Packit |
1470ea |
this._window = new Gtk.ApplicationWindow({ application: this.application,
|
|
Packit |
1470ea |
window_position: Gtk.WindowPosition.CENTER,
|
|
Packit |
1470ea |
default_height: 20,
|
|
Packit |
1470ea |
default_width: 220,
|
|
Packit |
1470ea |
title: "ProgressBar Example"});
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the progress bar
|
|
Packit |
1470ea |
this.progressBar = new Gtk.ProgressBar ();
|
|
Packit |
1470ea |
this._window.add(this.progressBar);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Start the function that pulses the bar every 100 milliseconds
|
|
Packit |
1470ea |
this.sourceID = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 100,
|
|
Packit |
1470ea |
this._barPulse.bind(this));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Connect a keypress event to the function that toggles the bar to start or stop pulsing
|
|
Packit |
1470ea |
this._window.connect("key-press-event", this._onKeyPress.bind(this));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Show the window and all child widgets
|
|
Packit |
1470ea |
this._window.show_all();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Pulse the progressbar (unless it has been disabled by a keypress)
|
|
Packit |
1470ea |
_barPulse() {
|
|
Packit |
1470ea |
this.progressBar.pulse();
|
|
Packit |
1470ea |
return true;
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Start or stop the progressbar when a key is pressed
|
|
Packit |
1470ea |
_onKeyPress() {
|
|
Packit |
1470ea |
if (this.sourceID == 0)
|
|
Packit |
1470ea |
this.sourceID = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 100,
|
|
Packit |
1470ea |
this._barPulse.bind(this));
|
|
Packit |
1470ea |
else {
|
|
Packit |
1470ea |
GLib.source_remove(this.sourceID);
|
|
Packit |
1470ea |
this.sourceID = 0;
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
};
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Run the application
|
|
Packit |
1470ea |
let app = new ProgressBarExample ();
|
|
Packit |
1470ea |
app.application.run (ARGV);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
이 예제는 다음 참고자료가 필요합니다:
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/GLib.html">GLib</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Application.html">Gtk.Application</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://developer.gnome.org/gtk3/stable/GtkApplicationWindow.html">Gtk.ApplicationWindow</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.ProgressBar.html">Gtk.ProgressBar</link> </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</page>
|