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