Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Gtk+/Gnome Application Development
Prev Home Next

Realizing and Mapping

Canvas items are realized and mapped just as widgets are. These methods play the same role they do for widgets; realizing a canvas item allocates any GDK resources it plans to use, unrealizing it deallocates the same resources. Mapping a canvas item shows its GdkWindow, unmapping it hides the GdkWindow. Very few canvas items have a GdkWindow (GnomeCanvasWidget is the big exception), so most canvas items will not even implement map and unmap methods. GnomeCanvasRect does not. It does have realize and unrealize methods, however.

Here is its realize method:


static void
gnome_canvas_re_realize (GnomeCanvasItem *item)
{
  GnomeCanvasRE *re;

  re = GNOME_CANVAS_RE (item);

  if (re_parent_class->realize)
    (* re_parent_class->realize) (item);

  if (!item->canvas->aa) {
    re->fill_gc = gdk_gc_new (item->canvas->layout.bin_window);
    re->outline_gc = gdk_gc_new (item->canvas->layout.bin_window);
  }
}

      

And unrealize:


static void
gnome_canvas_re_unrealize (GnomeCanvasItem *item)
{
  GnomeCanvasRE *re;

  re = GNOME_CANVAS_RE (item);

  if (!item->canvas->aa) {
    gdk_gc_unref (re->fill_gc);
    gdk_gc_unref (re->outline_gc);
  }

  if (re_parent_class->unrealize)
    (* re_parent_class->unrealize) (item);
}
      

Note that your realize and unrealize methods are unlikely to have anything to do in antialiased mode, since there won't be any GDK resources to worry about.

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire