/usr/share/help/el/gnome-devel-demos/filechooserdialog.vala.page is in gnome-devel-docs 3.28.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 | <?xml version="1.0" encoding="utf-8"?>
<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="filechooserdialog.vala" xml:lang="el">
<info>
<title type="text">FileChooserDialog (Vala)</title>
<link type="guide" xref="beginner.vala#file-selectors"/>
<link type="seealso" xref="textview.vala"/>
<link type="seealso" xref="menubar.vala"/>
<link type="seealso" xref="scrolledwindow.vala"/>
<revision version="0.1" date="2012-07-01" status="draft"/>
<credit type="author copyright">
<name>Tiffany Antopolski</name>
<email its:translate="no">tiffany.antopolski@gmail.com</email>
<years>2012</years>
</credit>
<desc>Ένας διάλογος κατάλληλος για τις εντολές "Open" και "Save".</desc>
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
<mal:name>Ελληνική μεταφραστική ομάδα GNOME</mal:name>
<mal:email>team@gnome.gr</mal:email>
<mal:years>2012-2015</mal:years>
</mal:credit>
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
<mal:name>Δημήτρης Σπίγγος</mal:name>
<mal:email>dmtrs32@gmail.com</mal:email>
<mal:years>2012, 2013</mal:years>
</mal:credit>
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
<mal:name>Μαρία Θουκιδίδου</mal:name>
<mal:email>marablack3@gmail.com</mal:email>
<mal:years>2014</mal:years>
</mal:credit>
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
<mal:name>Θάνος Τρυφωνίδης</mal:name>
<mal:email>tomtryf@gmail.com</mal:email>
<mal:years>2014, 2015</mal:years>
</mal:credit>
</info>
<title>FileChooserDialog</title>
<links type="sections"/>
<section id="overview"><title>Επισκόπηση του παραδείγματος</title>
<p>Αυτό το παράδειγμα δείχνει πώς μπορεί να χρησιμοποιηθεί ο FileChooserDialog. Είναι ενσωματωμένος σε μια πολλή απλή εφαρμογή επεξεργαστή κειμένου. Όλες οι <link xref="menubar.vala#win-app">ενέργειες</link>, συμπεριλαμβάνοντας τις εντολές "open", "save" και "save-as" μπορούν να βρεθούν στο <link xref="gmenu.vala">app-menu</link>. Εδώ, το μενού εφαρμογών δημιουργήθηκε χρησιμοποιώντας ένα αρχείο UI XML, που έπειτα εισήχθη στην εφαρμογή χρησιμοποιώντας Gtk.Builder.</p>
</section>
<section id="xml"><title>Το αρχείο UI XML που δημιουργεί το μενού εφαρμογών</title>
<code mime="application/xml" style="numbered"><?xml version="1.0"?>
<interface>
<menu id="appmenu">
<section>
<item>
<attribute name="label">New</attribute>
<attribute name="action">win.new</attribute>
</item>
<item>
<attribute name="label">Open</attribute>
<attribute name="action">win.open</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Save</attribute>
<attribute name="action">win.save</attribute>
</item>
<item>
<attribute name="label">Save As...</attribute>
<attribute name="action">win.save-as</attribute>
</item>
</section>
<section>
<item>
<attribute name="label">Quit</attribute>
<attribute name="action">app.quit</attribute>
</item>
</section>
</menu>
</interface>
</code>
</section>
<section id="vala-code"><title>Κώδικας Vala</title>
<code mime="text/x-csharp" style="numbered">class MyWindow: Gtk.ApplicationWindow {
/* MyWindow instance variables. */
GLib.File? file;
Gtk.TextBuffer buffer;
Gtk.TextView textview;
Gtk.ScrolledWindow scrolled_window;
/* Create ActionEntries. */
const ActionEntry[] actions = {
{ "new", new_cb },
{ "open", open_cb },
{ "save", save_cb },
{ "save-as", save_as_cb }
};
/* Constructor creates MyWindow, and add the scrolled_window. */
internal MyWindow (MyApplication app) {
Object (application: app, title: "FileChooserDialog Example");
this.set_default_size (400, 400);
/* Add the ActionEntries to MyWindow. */
this.add_action_entries (actions, this);
buffer = new Gtk.TextBuffer (null); //stores text to be displayed
textview = new Gtk.TextView.with_buffer (buffer); //displays TextBuffer
textview.set_wrap_mode (Gtk.WrapMode.WORD); //sets line wrapping
scrolled_window = new Gtk.ScrolledWindow (null, null);
scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC,
Gtk.PolicyType.AUTOMATIC);
scrolled_window.add (textview);
scrolled_window.set_border_width (5);
this.add (scrolled_window);
this.show_all ();
}
void new_cb (SimpleAction action, Variant? parameter) {
file = null;
buffer.set_text ("");
print ("New file created\n");
}
/* Create FileChooserDialog in OPEN mode. */
void open_cb (SimpleAction action, Variant? parameter) {
var open_dialog = new Gtk.FileChooserDialog ("Pick a file",
this as Gtk.Window,
Gtk.FileChooserAction.OPEN,
Gtk.Stock.CANCEL,
Gtk.ResponseType.CANCEL,
Gtk.Stock.OPEN,
Gtk.ResponseType.ACCEPT);
open_dialog.local_only = false; //allow for uri
open_dialog.set_modal (true);
open_dialog.response.connect (open_response_cb);
open_dialog.show ();
}
/* Either open the file and load the file contents or cancel. */
void open_response_cb (Gtk.Dialog dialog, int response_id) {
var open_dialog = dialog as Gtk.FileChooserDialog;
switch (response_id) {
case Gtk.ResponseType.ACCEPT: //open the file
file = open_dialog.get_file();
uint8[] file_contents;
try {
file.load_contents (null, out file_contents, null);
}
catch (GLib.Error err) { //handle the exception
error ("%s\n", err.message);
}
/* Set the buffer text to be the contents of the file. */
buffer.set_text ((string) file_contents,
file_contents.length);
print ("opened: %s\n", (open_dialog.get_filename ()));
break;
case Gtk.ResponseType.CANCEL:
print ("cancelled: FileChooserAction.OPEN\n");
break;
}
dialog.destroy ();
}
/* Create FileChooserDialog in SAVE mode. */
void save_as_cb (SimpleAction action, Variant? parameter) {
var save_dialog = new Gtk.FileChooserDialog ("Pick a file",
this as Gtk.Window,
Gtk.FileChooserAction.SAVE,
Gtk.Stock.CANCEL,
Gtk.ResponseType.CANCEL,
Gtk.Stock.SAVE,
Gtk.ResponseType.ACCEPT);
save_dialog.set_do_overwrite_confirmation (true);
save_dialog.set_modal (true);
if (file != null) {
try {
(save_dialog as Gtk.FileChooser).set_file (file);
}
catch (GLib.Error error) {
print ("%s\n", error.message);
}
}
save_dialog.response.connect (save_as_response_cb);
save_dialog.show ();
}
void save_as_response_cb (Gtk.Dialog dialog, int response_id) {
var save_dialog = dialog as Gtk.FileChooserDialog;
switch (response_id) {
case Gtk.ResponseType.ACCEPT:
file = save_dialog.get_file();
this.save_to_file ();
break;
default:
break;
}
dialog.destroy ();
}
/* Save the existing contents to the file.
* If file does not exist, call save_as_cb.
*/
void save_cb (SimpleAction action, Variant? parameter) {
if (file != null) {
this.save_to_file ();
}
else {
save_as_cb (action, parameter);
}
}
void save_to_file (){
Gtk.TextIter start;
Gtk.TextIter end;
buffer.get_bounds (out start, out end);
string current_contents = buffer.get_text (start, end, false);
try {
file.replace_contents (current_contents.data, null, false,
GLib.FileCreateFlags.NONE, null, null);
print ("saved: %s\n", file.get_path ());
}
catch (GLib.Error err) {
error ("%s\n", err.message);
}
}
}
/* This is the application */
class MyApplication: Gtk.Application {
protected override void activate () {
new MyWindow (this).show_all;
}
const ActionEntry[] actions = {
{ "quit", quit_cb }
};
void quit_cb (SimpleAction action, Variant? parameter) {
this.quit ();
}
protected override void startup () {
base.startup ();
/* Setup actions */
this.add_action_entries (actions, this);
/* Setup menus */
var builder = new Gtk.Builder ();
try {
builder.add_from_file ("filechooserdialog.ui");
} catch (GLib.Error err) {
error ("Unable to load file: %s\n", err.message);
}
this.app_menu = builder.get_object ("appmenu") as MenuModel;
}
}
/* main creates and runs the application. */
public int main (string[] args) {
return new MyApplication ().run (args);
}
</code>
</section>
<section id="api"><title>Σχετική τεκμηρίωση API</title>
<p>Σε αυτό το παράδειγμα χρησιμοποιήσαμε τα παρακάτω:</p>
<list>
<item><p><link href="http://valadoc.org/gtk+-3.0/Gtk.FileChooser.html">FileChooser</link></p></item>
<item><p><link href="http://valadoc.org/gtk+-3.0/Gtk.FileChooserDialog.html">FileChooserDialog</link></p></item>
<item><p><link href="http://valadoc.org/gtk+-3.0/Gtk.Builder.html">Gtk.Builder</link></p></item>
<item><p><link href="http://valadoc.org/gio-2.0/GLib.ActionEntry.html">GLib.ActionEntry</link></p></item>
</list>
</section>
</page>
|