1// -*- c++ -*- 2/* $Id: text.ccg,v 1.1 2003/01/21 13:37:07 murrayc Exp $ */ 3 4/* Copyright 1998-2002 The gtkmm Development Team 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free 18 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 */ 20 21#include <atkmm/object.h> 22#include <glib.h> 23#include <algorithm> /* for std::swap() */ 24 25 26// static 27GType Glib::Value<Atk::TextAttribute>::value_type() 28{ 29 return atk_text_attribute_get_type(); 30} 31 32 33namespace Atk 34{ 35 36/**** Atk::Attribute *******************************************************/ 37 38Attribute::Attribute() 39{ 40 gobject_.name = 0; 41 gobject_.value = 0; 42} 43 44Attribute::Attribute(const Glib::ustring& name, const Glib::ustring& value) 45{ 46 gobject_.name = g_strndup(name .data(), name .bytes()); 47 gobject_.value = g_strndup(value.data(), value.bytes()); 48} 49 50Attribute::Attribute(const AtkAttribute* gobject) 51{ 52 g_return_if_fail(gobject != 0); 53 54 gobject_.name = g_strdup(gobject->name); 55 gobject_.value = g_strdup(gobject->value); 56} 57 58Attribute::~Attribute() 59{ 60 g_free(gobject_.name); 61 g_free(gobject_.value); 62} 63 64Attribute::Attribute(const Attribute& other) 65{ 66 gobject_.name = g_strdup(other.gobject_.name); 67 gobject_.value = g_strdup(other.gobject_.value); 68} 69 70Attribute& Attribute::operator=(const Attribute& other) 71{ 72 Attribute temp (other); 73 swap(temp); 74 return *this; 75} 76 77void Attribute::swap(Attribute& other) 78{ 79 std::swap(gobject_.name, other.gobject_.name); 80 std::swap(gobject_.value, other.gobject_.value); 81} 82 83 84/**** Atk::TextAttribute ***************************************************/ 85 86// static 87TextAttribute TextAttribute::for_name(const Glib::ustring& name) 88{ 89 return TextAttribute(int(atk_text_attribute_for_name(name.c_str()))); 90} 91 92// static 93Glib::ustring TextAttribute::get_name(TextAttribute attribute) 94{ 95 if(const char *const name = atk_text_attribute_get_name(AtkTextAttribute(int(attribute)))) 96 return Glib::ustring(name); 97 else 98 return Glib::ustring(); 99} 100 101// static 102Glib::ustring TextAttribute::get_value(TextAttribute attribute, int index) 103{ 104 if(const char *const value = atk_text_attribute_get_value(AtkTextAttribute(int(attribute)), index)) 105 return Glib::ustring(value); 106 else 107 return Glib::ustring(); 108} 109 110} // namespace Atk 111 112