Unbreak Window#resize.
[ruby-ecore.git] / src / ecore_x / rb_window.c
index 5c688f767c079fa63f669a9fe8cab5c67f5a1340..b0f0837db8cb686360d90444fb9936dba262e8f6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: rb_window.c 95 2004-08-23 11:05:15Z tilman $
+ * $Id: rb_window.c 103 2004-08-29 08:57:12Z 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,13 @@ 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];
@@ -115,6 +123,47 @@ static VALUE c_equal_value (VALUE self, VALUE other)
        return w1->real == w2->real ? Qtrue : Qfalse;
 }
 
+static VALUE c_configure (int argc, VALUE *argv, VALUE self)
+{
+       VALUE mask, geom[4], border, sibling, stackm;
+       RbWindow *sibwin = NULL;
+       int i;
+
+       GET_OBJ (self, RbWindow, win);
+
+       rb_scan_args (argc, argv, "17", &mask,
+                     &geom[0], &geom[1], &geom[2], &geom[3],
+                     &border, &sibling, &stackm);
+
+       Check_Type (mask, T_FIXNUM);
+
+       for (i = 0; i < 4; i++)
+               if (!NIL_P (geom[i]))
+                       Check_Type (geom[i], T_FIXNUM);
+
+       if (!NIL_P (border))
+               Check_Type (border, T_FIXNUM);
+
+       if (!NIL_P (sibling)) {
+               CHECK_CLASS (sibling, cWindow);
+               Data_Get_Struct (sibling, RbWindow, sibwin);
+       }
+
+       if (!NIL_P (stackm))
+               Check_Type (stackm, T_FIXNUM);
+
+       ecore_x_window_configure (win->real, FIX2INT (mask),
+                                 NIL_P (geom[0]) ? 0 : FIX2INT (geom[0]),
+                                 NIL_P (geom[1]) ? 0 : FIX2INT (geom[1]),
+                                 NIL_P (geom[2]) ? 0 : FIX2INT (geom[2]),
+                                 NIL_P (geom[3]) ? 0 : FIX2INT (geom[3]),
+                                 NIL_P (border) ? 0 : FIX2INT (border),
+                                 sibwin ? sibwin->real : 0,
+                                 NIL_P (stackm) ? 0 : FIX2INT (stackm));
+
+       return Qnil;
+}
+
 static VALUE c_show (VALUE self)
 {
        GET_OBJ (self, RbWindow, win);
@@ -220,7 +269,7 @@ static VALUE c_resize (VALUE self, VALUE w, VALUE h)
        Check_Type (w, T_FIXNUM);
        Check_Type (h, T_FIXNUM);
 
-       ecore_x_window_move (win->real, FIX2INT (w), FIX2INT (h));
+       ecore_x_window_resize (win->real, FIX2INT (w), FIX2INT (h));
 
        return Qnil;
 }
@@ -255,6 +304,17 @@ static VALUE c_border_width_get (VALUE self)
        return INT2FIX (ecore_x_window_border_width_get (win->real));
 }
 
+static VALUE c_border_width_set (VALUE self, VALUE val)
+{
+       GET_OBJ (self, RbWindow, win);
+
+       Check_Type (val, T_FIXNUM);
+
+       ecore_x_window_border_width_set (win->real, FIX2INT (val));
+
+       return Qnil;
+}
+
 static VALUE c_depth_get (VALUE self)
 {
        GET_OBJ (self, RbWindow, win);
@@ -272,9 +332,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)
@@ -357,6 +421,19 @@ static VALUE c_sticky_set (VALUE self, VALUE val)
        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);
@@ -407,8 +484,10 @@ 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, "configure", c_configure, -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);
@@ -424,6 +503,7 @@ void Init_Window (void)
        rb_define_method (cWindow, "size", c_size_get, 0);
        rb_define_method (cWindow, "geometry", c_geometry_get, 0);
        rb_define_method (cWindow, "border_width", c_border_width_get, 0);
+       rb_define_method (cWindow, "border_width=", c_border_width_set, 1);
        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);
@@ -435,9 +515,12 @@ void Init_Window (void)
        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);
 }