1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_IBUS_IBUS_PROPERTY_H_
6 #define CHROMEOS_DBUS_IBUS_IBUS_PROPERTY_H_
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_vector.h"
11 #include "chromeos/chromeos_export.h"
21 typedef ScopedVector
<IBusProperty
> IBusPropertyList
;
23 // Pops a IBusProperty from |reader|.
24 // Returns false if an error occurs.
25 bool CHROMEOS_EXPORT
PopIBusProperty(dbus::MessageReader
* reader
,
26 IBusProperty
* property
);
27 // Pops a IBusPropertyList from |reader|.
28 // Returns false if an error occurs.
29 bool CHROMEOS_EXPORT
PopIBusPropertyList(dbus::MessageReader
* reader
,
30 IBusPropertyList
* property_list
);
32 // Appends a IBusProperty to |writer|.
33 void CHROMEOS_EXPORT
AppendIBusProperty(const IBusProperty
& property
,
34 dbus::MessageWriter
* writer
);
35 // Appends a IBusPropertyList to |writer|.
36 void CHROMEOS_EXPORT
AppendIBusPropertyList(
37 const IBusPropertyList
& property_list
,
38 dbus::MessageWriter
* writer
);
40 // The IBusPropList is one of IBusObjects and it contains array of IBusProperty.
41 // The IBusProperty contains IBusTexts but only plain string is used in Chrome.
42 // We treat IBusPropList as scoped_vector of IBusProperty.
44 // DATA STRUCTURE OVERVIEW:
46 // string "IBusProperty"
48 // string "CompositionMode" // Key
50 // variant struct { // Label
55 // string "IBusAttrList"
60 // string "/usr/share/ibus-mozc/hiragana.png" // icon
61 // variant struct { // Tooltip
66 // string "IBusAttrList"
71 // boolean true // sensitive
72 // boolean true // visible
74 // variant struct { // sub properties
75 // string "IBusPropList"
78 // ... More IBusPropertys
82 class CHROMEOS_EXPORT IBusProperty
{
84 enum IBusPropertyType
{
85 IBUS_PROPERTY_TYPE_NORMAL
= 0,
86 IBUS_PROPERTY_TYPE_TOGGLE
,
87 IBUS_PROPERTY_TYPE_RADIO
,
88 IBUS_PROPERTY_TYPE_MENU
,
89 IBUS_PROPERTY_TYPE_SEPARATOR
,
92 virtual ~IBusProperty();
94 // The identity for the IBusProperty.
95 std::string
key() const { return key_
; }
96 void set_key(const std::string
& key
) { key_
= key
; }
98 // The type of property:
99 IBusPropertyType
type() const { return type_
; }
100 void set_type(IBusPropertyType type
) { type_
= type
; }
102 // The string to be shown in UI.
103 std::string
label() const { return label_
; }
104 void set_label(const std::string
& label
) { label_
= label
; }
106 // The string to be shown in UI as tooltip.
107 std::string
tooltip() const { return tooltip_
; }
108 void set_tooltip(const std::string
& tooltip
) { tooltip_
= tooltip
; }
110 // True if the property is visible.
111 bool visible() const { return visible_
; }
112 void set_visible(bool visible
) { visible_
= visible
; }
114 // True if the property is checked.
115 bool checked() const { return checked_
; }
116 void set_checked(bool checked
) { checked_
= checked
; }
118 const IBusPropertyList
& sub_properties() const { return sub_properties_
; }
119 IBusPropertyList
* mutable_sub_properties() { return &sub_properties_
; }
123 IBusPropertyType type_
;
125 std::string tooltip_
;
128 IBusPropertyList sub_properties_
;
130 DISALLOW_COPY_AND_ASSIGN(IBusProperty
);
133 } // namespace chromeos
135 #endif // CHROMEOS_DBUS_IBUS_IBUS_PROPERTY_H_