Separate Simple Backend creation from initialization.
[chromium-blink-merge.git] / chromeos / dbus / ibus / ibus_property.h
bloba36dcde9834acabcd2dee2fae891234037ac63d6
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_
8 #include <string>
9 #include "base/basictypes.h"
10 #include "base/memory/scoped_vector.h"
11 #include "chromeos/chromeos_export.h"
13 namespace dbus {
14 class MessageWriter;
15 class MessageReader;
16 } // namespace dbus
18 namespace chromeos {
20 class IBusProperty;
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:
45 // variant struct {
46 // string "IBusProperty"
47 // array []
48 // string "CompositionMode" // Key
49 // uint32 3 // Type
50 // variant struct { // Label
51 // string "IBusText"
52 // array []
53 // string ""
54 // variant struct {
55 // string "IBusAttrList"
56 // array []
57 // array []
58 // }
59 // }
60 // string "/usr/share/ibus-mozc/hiragana.png" // icon
61 // variant struct { // Tooltip
62 // string "IBusText"
63 // array []
64 // string ""
65 // variant struct {
66 // string "IBusAttrList"
67 // array []
68 // array []
69 // }
70 // }
71 // boolean true // sensitive
72 // boolean true // visible
73 // uint32 0 // state
74 // variant struct { // sub properties
75 // string "IBusPropList"
76 // array []
77 // array [
78 // ... More IBusPropertys
79 // ]
80 // }
81 // }
82 class CHROMEOS_EXPORT IBusProperty {
83 public:
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,
91 IBusProperty();
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_; }
121 private:
122 std::string key_;
123 IBusPropertyType type_;
124 std::string label_;
125 std::string tooltip_;
126 bool visible_;
127 bool checked_;
128 IBusPropertyList sub_properties_;
130 DISALLOW_COPY_AND_ASSIGN(IBusProperty);
133 } // namespace chromeos
135 #endif // CHROMEOS_DBUS_IBUS_IBUS_PROPERTY_H_