|
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="dialog.vala" xml:lang="el">
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<title type="text">Διάλογος (Vala)</title>
|
|
Packit |
1470ea |
<link type="guide" xref="beginner.vala#windows"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2012-04-07" status="stub"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Tiffany Antopolski</name>
|
|
Packit |
1470ea |
<email its:translate="no">tiffany.antopolski@gmail.com</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>Ελληνική μεταφραστική ομάδα GNOME</mal:name>
|
|
Packit |
1470ea |
<mal:email>team@gnome.gr</mal:email>
|
|
Packit |
1470ea |
<mal:years>2012-2015</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
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>dmtrs32@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2012, 2013</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
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>marablack3@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2014</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
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>tomtryf@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2014, 2015</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Διάλογος</title>
|
|
Packit |
1470ea |
<media type="image" mime="image/png" src="media/dialog.png"/>
|
|
Packit |
1470ea |
Ένας διάλογος με το σήμα απάντησης συνδεμένο σε μια συνάρτηση επανάκλησης.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* A window in the application. */
|
|
Packit |
1470ea |
public class MyWindow : Gtk.ApplicationWindow {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Constructor */
|
|
Packit |
1470ea |
internal MyWindow (MyApplication app) {
|
|
Packit |
1470ea |
Object (application: app, title: "GNOME Button");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
this.window_position = Gtk.WindowPosition.CENTER;
|
|
Packit |
1470ea |
this.set_default_size (250,50);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var button = new Gtk.Button.with_label ("Click Me");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Connect the button's "clicked" signal to
|
|
Packit |
1470ea |
* the signal handler (aka. this.callback function).
|
|
Packit |
1470ea |
*/
|
|
Packit |
1470ea |
button.clicked.connect (this.on_button_click);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Add the button to this window and show it. */
|
|
Packit |
1470ea |
this.add (button);
|
|
Packit |
1470ea |
button.show ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* The signal handler for the buttons 'clicked' signal. */
|
|
Packit |
1470ea |
void on_button_click (Gtk.Button button) {
|
|
Packit |
1470ea |
var dialog = new Gtk.Dialog.with_buttons ("A Gtk+ Dialog", this,
|
|
Packit |
1470ea |
Gtk.DialogFlags.MODAL,
|
|
Packit |
1470ea |
Gtk.Stock.OK,
|
|
Packit |
1470ea |
Gtk.ResponseType.OK, null);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
var content_area = dialog.get_content_area ();
|
|
Packit |
1470ea |
var label = new Gtk.Label ("This demonstrates a dialog with a label");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
content_area.add (label);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Connect the 'response' signal of the dialog
|
|
Packit |
1470ea |
* the signal handler. It is emitted when the dialog's
|
|
Packit |
1470ea |
* OK button is clicked.
|
|
Packit |
1470ea |
*/
|
|
Packit |
1470ea |
dialog.response.connect (on_response);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Show the dialog and all the widgets. */
|
|
Packit |
1470ea |
dialog.show_all ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Signal handler for the 'response' signal of the dialog. */
|
|
Packit |
1470ea |
void on_response (Gtk.Dialog dialog, int response_id) {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* To see the int value of the ResponseType. This is only
|
|
Packit |
1470ea |
* for demonstration purposes.*/
|
|
Packit |
1470ea |
print ("response is %d\n", response_id);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* This causes the dialog to be destroyed. */
|
|
Packit |
1470ea |
dialog.destroy ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* This is the application. */
|
|
Packit |
1470ea |
public class MyApplication : Gtk.Application {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* The constructor of the application. */
|
|
Packit |
1470ea |
internal MyApplication () {
|
|
Packit |
1470ea |
Object (application_id: "org.example.MyApplication");
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Override the 'activate' signal of GLib.Application. */
|
|
Packit |
1470ea |
protected override void activate () {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* Create a window for the this application and show it. */
|
|
Packit |
1470ea |
new MyWindow (this).show ();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
/* The main function creates and runs the application. */
|
|
Packit |
1470ea |
public int main (string[] args) {
|
|
Packit |
1470ea |
return new MyApplication ().run (args);
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Σε αυτό το παράδειγμα χρησιμοποιήσαμε τα παρακάτω:
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Dialog.html">Gtk.Dialog</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Dialog.Dialog.with_buttons.html">Gtk.Dialog.with_buttons</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Label.html">Gtk.Label</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.valadoc.org/gtk+-3.0/Gtk.Dialog.get_content_area.html">get_content_area</link> </item>
|
|
Packit |
1470ea |
<item><link xref="response-type"/> </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</page>
|