Nux

Merge lp:~thumper/nux/dont-leak-ibus into lp:nux/2.0

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: 585
Merged at revision: 584
Proposed branch: lp:~thumper/nux/dont-leak-ibus
Merge into: lp:nux/2.0
Diff against target: 119 lines (+22/-14)
3 files modified
Nux/TextEntry.cpp (+1/-0)
Nux/TextEntry.h (+0/-3)
tests/xtest-text-entry.cpp (+21/-11)
To merge this branch: bzr merge lp:~thumper/nux/dont-leak-ibus
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Review via email: mp+94332@code.launchpad.net

Description of the change

= Problem description =

Unity failed to compile cleanly as nux was exposing the ibus.h header through the includes.

Also make check failed if I didn't have ibus set up with at least one language.

= The fix =

Only include the IM header in the source file.
Early exit in the tests.

= Test coverage =

Existing xtest-text-entry test for ibus input.

To post a comment you must log in.
Revision history for this message
Brandon Schaefer (brandontschaefer) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Nux/TextEntry.cpp'
2--- Nux/TextEntry.cpp 2012-02-23 05:13:46 +0000
3+++ Nux/TextEntry.cpp 2012-02-23 08:59:49 +0000
4@@ -30,6 +30,7 @@
5
6 #if defined(NUX_OS_LINUX)
7 #include <X11/cursorfont.h>
8+#include "InputMethodIBus.h"
9 #endif
10
11 namespace nux
12
13=== modified file 'Nux/TextEntry.h'
14--- Nux/TextEntry.h 2012-02-23 05:13:46 +0000
15+++ Nux/TextEntry.h 2012-02-23 08:59:49 +0000
16@@ -25,9 +25,6 @@
17 #include "pango/pango.h"
18 #include "pango/pangocairo.h"
19 #include "NuxImage/CairoGraphics.h"
20-#if defined(NUX_OS_LINUX)
21-#include "InputMethodIBus.h"
22-#endif
23
24 namespace nux
25 {
26
27=== modified file 'tests/xtest-text-entry.cpp'
28--- tests/xtest-text-entry.cpp 2012-02-23 05:13:46 +0000
29+++ tests/xtest-text-entry.cpp 2012-02-23 08:59:49 +0000
30@@ -22,6 +22,7 @@
31 #include "Nux/WindowThread.h"
32 #include "Nux/VLayout.h"
33 #include "Nux/TextEntry.h"
34+#include "Nux/InputMethodIBus.h"
35 #include "Nux/ProgramFramework/ProgramTemplate.h"
36 #include "Nux/ProgramFramework/TestView.h"
37 #include <X11/extensions/XTest.h>
38@@ -90,8 +91,10 @@
39 bool SetEngineActive (IBusBus* bus_, std::string engine)
40 {
41 GList* engines = ibus_bus_list_active_engines(bus_);
42+ if (!engines)
43+ return false;
44+
45 GList* start = engines;
46-
47 bool found = false;
48 gboolean global_flag = ibus_bus_get_use_global_engine(bus_);
49
50@@ -101,21 +104,27 @@
51 IBusEngineDesc *engine_desc = IBUS_ENGINE_DESC (engines->data);
52
53 // Found Engine, make it active!
54- if (g_strcmp0(ibus_engine_desc_get_name(engine_desc), engine.c_str()) == 0)
55+ if (engine == ibus_engine_desc_get_name(engine_desc))
56 {
57- found = true;
58+ found = true;
59
60 // Set ibus to use global engines
61 if (!global_flag)
62- ibus_config_set_value (ibus_bus_get_config(bus_), "general", "use_global_engine", g_variant_new_boolean(true));
63+ ibus_config_set_value(ibus_bus_get_config(bus_),
64+ "general",
65+ "use_global_engine",
66+ g_variant_new_boolean(true));
67
68 // Set and activate the engine
69- ibus_bus_set_global_engine(bus_,engine.c_str());
70+ ibus_bus_set_global_engine(bus_, engine.c_str());
71 }
72 } while ((engines = g_list_next(engines)) != NULL);
73
74- // Restores the global setting back to what it was
75- ibus_config_set_value (ibus_bus_get_config(bus_), "general", "use_global_engine", g_variant_new_boolean(global_flag));
76+ // Restores the global setting back to what it was
77+ ibus_config_set_value(ibus_bus_get_config(bus_),
78+ "general",
79+ "use_global_engine",
80+ g_variant_new_boolean(global_flag));
81
82 g_list_free(start);
83 return found;
84@@ -255,7 +264,7 @@
85 bool active = false;
86
87 // Test for ibus-pinyin
88- if (SetEngineActive(bus_,"pinyin"))
89+ if (bus_ && SetEngineActive(bus_,"pinyin"))
90 {
91 // Type random stuff
92 {
93@@ -305,7 +314,7 @@
94 }
95
96 // Test for ibus-hangul
97- if (SetEngineActive(bus_,"hangul"))
98+ if (bus_ && SetEngineActive(bus_,"hangul"))
99 {
100 // Test for the the space in ibus-hangul working correctlly
101 {
102@@ -328,8 +337,8 @@
103 }
104
105 // Checking for ibus-anthy - Japanese
106- if (SetEngineActive(bus_,"anthy"))
107- {
108+ if (bus_ && SetEngineActive(bus_,"anthy"))
109+ {
110 {
111 test.ViewSendString("shisutemu ");
112 nux::SleepForMilliseconds(500);
113@@ -344,6 +353,7 @@
114 nux::SleepForMilliseconds(500);
115
116 test.ViewSendDelete();
117+
118 nux::SleepForMilliseconds(500);
119 }
120

Subscribers

People subscribed via source and target branches

to all changes: