Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

mlview-name-value-pair.c

Go to the documentation of this file.
00001 /*
00002 *This file is part of GNU MlView
00003 *
00004 *GNU MlView is free software; you can redistribute it and/or modify it under the terms of 
00005 *the GNU General Public License as published by the Free Software Foundation; either version 2, 
00006 *or (at your option) any later version.
00007 *
00008 *GNU MlView is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 
00009 *without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00010 *See the GNU General Public License for more details.
00011 *
00012 *You should have received a copy of the GNU General Public License along with MlView; 
00013 *see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00014 *
00015 *
00016 *Copyright 2001 dodji seketeli
00017 */
00018 
00024 #include "mlview-name-value-pair.h"
00025 static void mlview_name_value_pair_init_class(MlViewNameValuePairClass *a_klass) ;
00026 static void mlview_name_value_pair_init(MlViewNameValuePair *a_object) ;
00027 static void mlview_name_value_pair_destroy(GtkObject *a_object) ;
00028 static GtkObject *parent_class=NULL ;
00029 
00030 /*
00031  *common functions to comply with the GtkObject typing system.
00032  */
00033 
00039 guint
00040 mlview_name_value_pair_get_type(void)
00041 {
00042         static guint mlview_name_value_pair_type=0 ;
00043         if(!mlview_name_value_pair_type){
00044                 static const GtkTypeInfo t_info=
00045                 {
00046                         "MlViewNameValuePair",
00047                         sizeof(MlViewNameValuePair),
00048                         sizeof(MlViewNameValuePairClass),
00049                         (GtkClassInitFunc)mlview_name_value_pair_init_class,
00050                         (GtkObjectInitFunc)mlview_name_value_pair_init,
00051                         NULL,NULL,NULL      
00052                 };
00053                 mlview_name_value_pair_type=gtk_type_unique(GTK_TYPE_OBJECT,&t_info) ;
00054         }
00055         return mlview_name_value_pair_type ;
00056 }
00057 
00064 static void
00065 mlview_name_value_pair_init_class(MlViewNameValuePairClass *a_klass)
00066 {
00067         GtkObjectClass *object_class ;  
00068         g_return_if_fail(a_klass!=NULL) ;
00069   
00070         object_class = GTK_OBJECT_CLASS(a_klass) ;
00071         object_class->destroy=mlview_name_value_pair_destroy ;
00072         parent_class= gtk_type_new(GTK_TYPE_OBJECT) ;
00073         /*We don't define any new signal now*/  
00074 }
00075 
00080 static void mlview_name_value_pair_init(MlViewNameValuePair *a_object)
00081 {
00082         g_return_if_fail(a_object!=NULL) ;
00083         a_object->name=a_object->value=NULL ;  
00084 }
00085 
00091 GtkObject *
00092 mlview_name_value_pair_new(gchar *a_name,gchar *a_value)
00093 {
00094         MlViewNameValuePair *nvpair ;
00095         g_return_val_if_fail(a_name!=NULL,NULL) ;
00096         g_return_val_if_fail(a_value!=NULL,NULL) ;
00097   
00098         nvpair = gtk_type_new(GTK_TYPE_MLVIEW_NAME_VALUE_PAIR) ;
00099         nvpair->name = g_strdup(a_name) ;
00100         nvpair->value = g_strdup(a_value) ;
00101 
00102         return GTK_OBJECT(nvpair) ;
00103 }
00104 
00109 static void
00110 mlview_name_value_pair_destroy(GtkObject *a_object)
00111 {
00112         MlViewNameValuePair *nvpair ;
00113         g_return_if_fail(a_object!=NULL) ;
00114   
00115         nvpair = MLVIEW_NAME_VALUE_PAIR(a_object) ;
00116         if(nvpair->name){
00117                 g_free(nvpair->name) ;
00118                 nvpair->name=NULL ;    
00119         }
00120         if(nvpair->value){
00121                 g_free(nvpair->value) ;
00122                 nvpair->value = NULL ;
00123         }
00124         if(GTK_OBJECT_CLASS(parent_class)->destroy){
00125                 (*GTK_OBJECT_CLASS(parent_class)->destroy)(a_object) ;
00126         }
00127 }
00128 
00133 void
00134 mlview_name_value_pair_set_name(MlViewNameValuePair *a_nvpair, gchar *a_name)
00135 {
00136         g_return_if_fail(a_nvpair) ;
00137         g_return_if_fail(a_name) ;
00138         if(a_nvpair->name)
00139                 g_free(a_nvpair->name) ;
00140         a_nvpair->name = g_strdup(a_name);
00141 }
00142 
00147 void
00148 mlview_name_value_pair_set_value(MlViewNameValuePair *a_nvpair, gchar *a_value)
00149 {
00150         g_return_if_fail(a_nvpair) ;
00151         g_return_if_fail(a_value) ;
00152   
00153         if(a_nvpair->value)
00154                 g_free(a_nvpair->value) ;
00155         a_nvpair->value=g_strdup(a_value) ;
00156 }

Generated on Sat Jul 6 09:57:33 2002 for Gnome-MlView by doxygen1.2.16