X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=src%2Fecore_x%2Frb_window.c;h=0463e2142e23dbab01c1234a0e0a1c85baae0ed6;hb=ed7756f1892ec068be14445c39a86f14f7e76a46;hp=58c3d6b2625501a5d62a495861a69b0c53e2e2c2;hpb=aaf65fd2a802aa98b8fb2001bf711fac0f5c74e3;p=ruby-ecore.git diff --git a/src/ecore_x/rb_window.c b/src/ecore_x/rb_window.c index 58c3d6b..0463e21 100644 --- a/src/ecore_x/rb_window.c +++ b/src/ecore_x/rb_window.c @@ -1,5 +1,5 @@ /* - * $Id: rb_window.c 81 2004-08-21 09:43:23Z tilman $ + * $Id: rb_window.c 98 2004-08-26 13:12:55Z tilman $ * * Copyright (C) 2004 ruby-ecore team (see AUTHORS) * @@ -27,6 +27,7 @@ #include "../ecore/rb_ecore.h" #include "rb_ecore_x.h" #include "rb_window.h" +#include "rb_cursor.h" VALUE cWindow; @@ -92,6 +93,26 @@ static VALUE c_new (int argc, VALUE *argv, VALUE klass) return self; } +static VALUE c_init (int argc, VALUE *argv, VALUE self) +{ + rb_iv_set (self, "@cursor", Qnil); + + return self; +} + +static VALUE c_inspect (VALUE self) +{ + char buf[128]; + + GET_OBJ (self, RbWindow, win); + + snprintf (buf, sizeof (buf), + "#<%s:%p id=%u>", rb_obj_classname (self), + (void *) self, win->real); + + return rb_str_new2 (buf); +} + static VALUE c_equal_value (VALUE self, VALUE other) { GET_OBJ (self, RbWindow, w1); @@ -131,10 +152,16 @@ static VALUE c_delete (VALUE self) { GET_OBJ (self, RbWindow, win); - if (win->real) { - ecore_x_window_del (win->real); - win->real = 0; - } + ecore_x_window_del (win->real); + + return Qnil; +} + +static VALUE c_send_delete_request (VALUE self) +{ + GET_OBJ (self, RbWindow, win); + + ecore_x_window_delete_request_send (win->real); return Qnil; } @@ -173,6 +200,15 @@ static VALUE c_reparent (VALUE self, VALUE other, VALUE x, VALUE y) return Qnil; } +static VALUE c_focus (VALUE self) +{ + GET_OBJ (self, RbWindow, win); + + ecore_x_window_focus (win->real); + + return Qnil; +} + static VALUE c_move (VALUE self, VALUE x, VALUE y) { GET_OBJ (self, RbWindow, win); @@ -220,11 +256,11 @@ static VALUE c_geometry_get (VALUE self) INT2FIX (w), INT2FIX (h)); } -static VALUE c_border_size_get (VALUE self) +static VALUE c_border_width_get (VALUE self) { GET_OBJ (self, RbWindow, win); - return INT2FIX (ecore_x_window_border_size_get (win->real)); + return INT2FIX (ecore_x_window_border_width_get (win->real)); } static VALUE c_depth_get (VALUE self) @@ -244,9 +280,13 @@ static VALUE c_parent_get (VALUE self) static VALUE c_title_get (VALUE self) { + char *s; + GET_OBJ (self, RbWindow, win); - return rb_str_new2 (ecore_x_window_prop_title_get (win->real)); + s = ecore_x_window_prop_title_get (win->real); + + return s ? rb_str_new2 (s) : Qnil; } static VALUE c_title_set (VALUE self, VALUE val) @@ -295,24 +335,121 @@ static VALUE c_set_protocol (VALUE self, VALUE proto, VALUE on) return Qnil; } +static VALUE c_get_protocol (VALUE self, VALUE proto) +{ + int s; + + GET_OBJ (self, RbWindow, win); + + s = ecore_x_window_prop_protocol_isset (win->real, FIX2INT (proto)); + + return s ? Qtrue : Qfalse; +} + +static VALUE c_sticky_get (VALUE self) +{ + int s; + + GET_OBJ (self, RbWindow, win); + + s = ecore_x_window_prop_state_isset (win->real, + ECORE_X_WINDOW_STATE_STICKY); + + return s ? Qtrue : Qfalse; +} + +static VALUE c_sticky_set (VALUE self, VALUE val) +{ + GET_OBJ (self, RbWindow, win); + + CHECK_BOOL (val); + + ecore_x_window_prop_sticky_set (win->real, val == Qtrue); + + return Qnil; +} + +static VALUE c_cursor_set (VALUE self, VALUE val) +{ + GET_OBJ (self, RbWindow, win); + + CHECK_CLASS (val, cCursor); + GET_OBJ (val, RbCursor, c); + + ecore_x_window_cursor_set (win->real, c->real); + rb_iv_set (self, "@cursor", val); + + return Qnil; +} + +static VALUE c_manage (VALUE self) +{ + GET_OBJ (self, RbWindow, win); + + ecore_x_window_manage (win->real); + + return Qnil; +} + +static VALUE c_manage_container (VALUE self) +{ + GET_OBJ (self, RbWindow, win); + + ecore_x_window_container_manage (win->real); + + return Qnil; +} + +static VALUE c_manage_client (VALUE self) +{ + GET_OBJ (self, RbWindow, win); + + ecore_x_window_client_manage (win->real); + + return Qnil; +} + +static VALUE c_sniff (VALUE self) +{ + GET_OBJ (self, RbWindow, win); + + ecore_x_window_sniff (win->real); + + return Qnil; +} + +static VALUE c_sniff_client (VALUE self) +{ + GET_OBJ (self, RbWindow, win); + + ecore_x_window_client_sniff (win->real); + + return Qnil; +} + void Init_Window (void) { cWindow = rb_define_class_under (mX, "Window", rb_cObject); rb_define_singleton_method (cWindow, "new", c_new, -1); + rb_define_method (cWindow, "initialize", c_init, -1); + rb_define_method (cWindow, "inspect", c_inspect, 0); rb_define_method (cWindow, "==", c_equal_value, 1); rb_define_method (cWindow, "show", c_show, 0); rb_define_method (cWindow, "hide", c_hide, 0); rb_define_method (cWindow, "visible?", c_visible_get, 0); rb_define_method (cWindow, "delete", c_delete, 0); + rb_define_method (cWindow, "send_delete_request", + c_send_delete_request, 0); rb_define_method (cWindow, "raise", c_raise, 0); rb_define_method (cWindow, "lower", c_lower, 0); rb_define_method (cWindow, "reparent", c_reparent, 3); + rb_define_method (cWindow, "focus", c_focus, 0); rb_define_method (cWindow, "move", c_move, 2); rb_define_method (cWindow, "resize", c_resize, 2); rb_define_method (cWindow, "size", c_size_get, 0); rb_define_method (cWindow, "geometry", c_geometry_get, 0); - rb_define_method (cWindow, "border_size", c_border_size_get, 0); + rb_define_method (cWindow, "border_width", c_border_width_get, 0); rb_define_method (cWindow, "depth", c_depth_get, 0); rb_define_method (cWindow, "parent", c_parent_get, 0); rb_define_method (cWindow, "title", c_title_get, 0); @@ -321,4 +458,15 @@ void Init_Window (void) rb_define_method (cWindow, "unset_event_mask", c_unset_event_mask, 1); rb_define_method (cWindow, "set_protocol", c_set_protocol, 2); + rb_define_method (cWindow, "get_protocol", c_get_protocol, 1); + rb_define_method (cWindow, "sticky?", c_sticky_get, 0); + rb_define_method (cWindow, "sticky=", c_sticky_set, 1); + rb_define_method (cWindow, "cursor=", c_cursor_set, 1); + rb_define_method (cWindow, "manage", c_manage, 0); + rb_define_method (cWindow, "manage_container", c_manage_container, 0); + rb_define_method (cWindow, "manage_client", c_manage_client, 0); + rb_define_method (cWindow, "sniff", c_sniff, 0); + rb_define_method (cWindow, "sniff_client", c_sniff_client, 0); + + rb_define_attr (cWindow, "cursor", 1, 0); }