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

Destruction

GtkEv overrides only the destroy method from GtkObject, to clean up the event description buffer. The widget's windows will be destroyed in GtkWidget's shutdown method, which unrealizes the widget. GtkWidget's finalize method cleans up some GtkWidget resources and then chains to the GtkObject method which frees the instance struct. (Refer to the section called Object Finalization in the chapter called The GTK+ Object and Type System for more details on these methods.)

Because GtkEv has no object arguments, it does not need to implement get_arg or set_arg methods.

Here is its destroy method implementation:


static void   
gtk_ev_destroy       (GtkObject   *object)
{
  GtkEv* ev;
  GList* tmp;

  g_return_if_fail(object != NULL);
  g_return_if_fail(GTK_IS_EV(object));

  ev = GTK_EV(object);

  tmp = ev->buffer;
  while (tmp != NULL)
    {
      g_strfreev((gchar**)tmp->data);
      
      tmp = g_list_next(tmp);
    }

  g_list_free(ev->buffer);

  ev->buffer = NULL;
  ev->buffer_end = NULL;
  ev->buffer_size = 0;

  /* Chain up */
  if (GTK_OBJECT_CLASS(parent_class)->destroy)
    (* GTK_OBJECT_CLASS(parent_class)->destroy) (object);
}
    

The only detail worthy of note is that freed pointers are set to NULL, because a destroyed object should remain "sane," unlike a finalized object. The GtkEv code depends on the fact that destroyed widgets are always unrealized; otherwise, text could be re-added to the buffer after destruction but before finalization, and a finalize method would be required.

Gtk+/Gnome Application Development
Prev Home Next

 
 
  Published under free license. Design by Interspire