Hello First of all, sorry for my poor English.
I want write an application. I try, but I create a monster not a program. So I decide to start once again. When I was writing first version of it, I put every object that I created to tree of widget. Purpose for that was that: if action had place and specific widget (and his children) was target, he was found in widget tree and after reading associate properties with hem I know what I can do with him. And That was Wrong way to do it. I know, I lost much time. And now I want to really understood what magic happens under the hood. I want build my application over diacanvas2 lib. I what every object on canvas has his own properties. Of course there can be one group of boxes, and another group of boxes with for the program will be complete different. I look into demo in diacanvas2 package. There is such function like add_box: add_box (DiaCanvasView *view) { DiaTool *tool = dia_placement_tool_new (DIA_TYPE_CANVAS_BOX, "parent", view->canvas->root, "width", 0.0, "height", 0.0, "bg_color", 0xFF8FFF55, NULL); g_object_set (view, "tool", tool, NULL); /* First let the tool create the new item... Then unset it. */ g_signal_connect (tool, "button_release_event", G_CALLBACK (cb_unset_tool), view); g_object_unref (tool); } Lets focus on the first function: dia_placement_tool_new. As we can see in dia-placement-tool.c this function use GParamSpec *pspec = g_object_class_find_property (class, name); to search given properties and set some value. From these properties: "parent","width", "height", "bg_color" (or fill_color) dia-canvas-box have the last one. I have two ways and one of them is bad. THE BAD WAY: Copy the *-box file, add add property like gchar *name; (that is working of course) The good way: Create child of widget dia-canavas-box. And here is the first place where I really need help. My widget is in attachment. But something was wrong. When I use it to create widget in diacanvas using add_box and DIA_TYPE_CANVAS_BOX_CHILD for first argument I have this warning: DiaCanvas2-WARNING **: dia-placement-tool.c:319: object class `DiaCanvasBoxChild' has no property named `fill_color', and of course he is right he doesn't have this property his parent have. The second place where I need some help is answer for that : - I want to place line, which will have size (width or height) no less or more then canvas. - I want (i like this word :) have lines or even some object which cant be resized or rotated. I think it is only about blocking some signals for that object when i created them. - I want to (again) add every created object to list or some tree when I put then on the canvas. I wrote this letter because I had bed expierence creating application in gtk without asking anybody how some things can be done in the correct way. I had read "Glib object system" by Mathieu Lacage but I don't understand it, i think because I only read this and never try to create my own widgets :) So this is my first try to understood gobject system. I hope anybody help me. Best regards. ps. when i have littke i will try to understand uml for diacanvas :) -- Przemysław Staniszewski
_______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list