[Vala] Writing to existing file

2009-05-31 Thread Joss 4

Hi , Guys

I am trying to write to an existing file but I found only a write to a 
new file in http://code.valaide.org


code like this :
var file = File.new_for_path (samplefile.txt);
   {
   var file_stream = file.create (FileCreateFlags.NONE, null);

   if (file.query_exists (null)) {
   stdout.printf (File successfully created.\n);
   }

   var data_stream = new DataOutputStream (file_stream);
   data_stream.put_string (Hello, world, null);
   }
What I want is to change this line
var file_stream = file.create (FileCreateFlags.NONE, null); to something 
like


var file_stream = file.open ();
var data_stream = new DataOutputStream (file_stream);

How can I accomplish this ?


___
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


[Vala] [PATCH] Enhance X11 bindings and fix some cnames

2009-05-31 Thread Michael B. Trausch

(Resending a modified patch, per juergbi.)

This patch fixes cnames for the X11 bindings and provides bindings for
new methods which came from my original bindings that I wrote for
AllTray earlier this year.

Signed-off-by: Michael B. Trausch m...@trausch.us
---
 vapi/x11.vapi |  236
- 1 files
changed, 233 insertions(+), 3 deletions(-)

--- Mike

-- 
Fix the cause, not the symptom.
--- Steve Maguire
From 422f788fa199e8b86dd437a016381a7d3aa2b2b9 Mon Sep 17 00:00:00 2001
From: Michael B. Trausch m...@trausch.us
Date: Sun, 31 May 2009 14:38:50 -0400
Subject: [PATCH] Enhance X11 bindings and fix some cnames

This patch fixes cnames for the X11 bindings and provides bindings for
new methods which came from my original bindings that I wrote for
AllTray earlier this year.

Signed-off-by: Michael B. Trausch m...@trausch.us
---
 vapi/x11.vapi |  236 -
 1 files changed, 233 insertions(+), 3 deletions(-)

diff --git a/vapi/x11.vapi b/vapi/x11.vapi
index b7944f3..7f73d9c 100644
--- a/vapi/x11.vapi
+++ b/vapi/x11.vapi
@@ -22,87 +22,202 @@
 
 [CCode (cprefix = , lower_case_cprefix = , cheader_filename = X11/Xlib.h,X11/Xatom.h,X11/Xutil.h)]
 namespace X {
+	// Note: must be called before opening a display or calling any other Xlib function,
+	// see http://tronche.com/gui/x/xlib/display/XInitThreads.html
+	[CCode (cname = XInitThreads)]
+	public Status init_threads ();
+
 	[Compact]
 	[CCode (cname = Display, ref_function = , unref_function = )]
 	public class Display {
+		[CCode (cname = XOpenDisplay)]
+		public Display (string? name = null);
+
+		[CCode (cname = XAllPlanes)]
+		public static ulong get_all_planes ();
+
 		[CCode (cname = XAddToSaveSet)]
 		public int add_to_save_set (Window w);
+
 		[CCode (cname = XAllowEvents)]
 		public int allow_events (int event_mode, int time);
+
+		[CCode (cname = XBitmapBitOrder)]
+		public int bitmap_bit_order ();
+
+		[CCode (cname = XBitmapUnit)]
+		public int bitmap_scanline_unit ();
+
+		[CCode (cname = XBitmapPad)]
+		public int bitmap_scanline_padding ();
+
 		[CCode (cname = XChangeProperty)]
 		public int change_property (Window w, Atom property, Atom type, int format, int mode, [CCode (array_length = false)] uchar[] data, int nelements);
+
 		[CCode (cname = XChangeWindowAttributes)]
 		public int change_window_attributes (Window w, ulong valuemask, SetWindowAttributes attributes);
+
 		[CCode (cname = XConfigureWindow)]
 		public int configure_window (Window w, uint value_mask, WindowChanges values);
+
 		[CCode (cname = ConnectionNumber)]
 		public int connection_number ();
+
 		[CCode (cname = DefaultRootWindow)]
 		public Window default_root_window ();
+
+		[CCode (cname = XDefaultScreenOfDisplay)]
+		public unowned Screen default_screen ();
+
+		[CCode (cname = XScreenOfDisplay)]
+		public unowned Screen screen_by_id (int screen_number);
+
 		[CCode (cname = DisplayString)]
 		public string display_string ();
+
+		[CCode (cname = XQLength)]
+		public int event_queue_length ();
+
 		[CCode (cname = XFlush)]
 		public int flush ();
+
 		[CCode (cname = XGetKeyboardMapping, array_length = false)]
 		public weak uint[] get_keyboard_mapping (uint first_keycode, int keycode_count, ref int keysyms_per_keycode_return);
+
 		[CCode (cname = XGetModifierMapping)]
 		public ModifierKeymap get_modifier_mapping ();
+
 		[CCode (cname = XGetSelectionOwner)]
 		public Window get_selection_owner (Atom selection);
+
 		[CCode (cname = XGetWindowAttributes)]
 		public void get_window_attributes (Window w, out WindowAttributes window_attributes_return);
+
 		[CCode (cname = XGetWindowProperty)]
 		public int get_window_property (Window w, Atom property, long long_offset, long long_length, bool delete, Atom req_type, out Atom actual_type_return, out int actual_format_return, out ulong nitems_return, out ulong bytes_after_return, out void* prop_return);
+
 		[CCode (cname = XGrabButton)]
 		public int grab_button (uint button, uint modifiers, Window grab_window, bool owner_events, uint event_mask, int pointer_mode, int keyboard_mode, Window confine_to, uint cursor);
+
 		[CCode (cname = XGrabPointer)]
 		public int grab_pointer (Window grab_window, bool owner_events, uint event_mask, int pointer_mode, int keyboard_mode, Window confine_to, uint cursor, int time);
+
 		[CCode (cname = XGrabServer)]
 		public int grab_server ();
+
+		[CCode (cname = XImageByteOrder)]
+		public int image_byte_order ();
+
 		[CCode (cname = XInternAtom)]
 		public Atom intern_atom (string atom_name, bool only_if_exists);
+
 		[CCode (cname = XInternAtoms)]
 		public void intern_atoms (string[] names, bool only_if_exists, [CCode (array_length = false)] Atom[] atoms_return);
+
+		[CCode (cname = XInternalConnectionNumbers)]
+		public Status internal_connection_numbers (ref int[] fd_return);
+
 		[CCode (cname = XDisplayKeycodes)]
 		public int keycodes (ref int 

Re: [Vala] [PATCH] Enhance X11 bindings and fix some cnames

2009-05-31 Thread Jürg Billeter
On Sun, 2009-05-31 at 14:48 -0400, Michael B. Trausch wrote:
 (Resending a modified patch, per juergbi.)
 
 This patch fixes cnames for the X11 bindings and provides bindings for
 new methods which came from my original bindings that I wrote for
 AllTray earlier this year.

Thanks, pushed.

Jürg

___
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list


Re: [Vala] [PATCH] Tiny patch regarding gdk-x11 vapi.

2009-05-31 Thread Jürg Billeter
On Sat, 2009-05-30 at 18:30 -0300, Alexandre Moreira wrote:
 I am dealing with the new x11 binding and a few things (trying to port
 a System Tray manager to Vala) and I found that there is (what I
 believe to be) a tiny mistake in gdk-x11 vapi files.
 
 Gdk.x11_screen_get_xscreen is returning a Gdk.Screen, where it should
 return a X.Screen, so I'm sending you the simplest patch possible:
 changing Gdk to X

Thanks for the patch. gdk-x11-2.0.vapi is - like most .vapi files -
generated from files in vapi/packages/ as indicated on the first line of
the .vapi file. This means that we should update the input files and
regenerate the .vapi, instead of directly modifying the .vapi file.

I've pushed updated bindings to git master, let me know if there are
more issues.

Jürg

___
Vala-list mailing list
Vala-list@gnome.org
http://mail.gnome.org/mailman/listinfo/vala-list