Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3)

Delta Between Two Patch Sets: tools/main.vala

Issue 5517048: Merge the devel branch (Closed) Base URL: git@github.com:phuang/ibus.git@devel
Left Patch Set: Fix a hotkey related issue Created 13 years, 2 months ago
Right Patch Set: Rebase on HEAD Created 13 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
LEFTRIGHT
1 /* vim:set et sts=4 sw=4: 1 /* vim:set et sts=4 sw=4:
2 * 2 *
3 * ibus - The Input Bus 3 * ibus - The Input Bus
4 * 4 *
5 * Copyright(c) 2011 Peng Huang <shawn.p.huang@gmail.com> 5 * Copyright(c) 2011 Peng Huang <shawn.p.huang@gmail.com>
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or(at your option) any later version. 10 * version 2 of the License, or(at your option) any later version.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 string engine = null; 87 string engine = null;
88 if (argv.length > 1) 88 if (argv.length > 1)
89 engine = argv[1]; 89 engine = argv[1];
90 90
91 if (engine == null) { 91 if (engine == null) {
92 var desc = bus.get_global_engine(); 92 var desc = bus.get_global_engine();
93 if (desc == null) 93 if (desc == null)
94 return -1; 94 return -1;
95 print("%s\n", desc.get_name()); 95 print("%s\n", desc.get_name());
96 return 0; 96 return 0;
97 } else { 97 }
98 if(!bus.set_global_engine(engine)) 98
99 return -1; 99 if(!bus.set_global_engine(engine))
100 var desc = bus.get_global_engine(); 100 return -1;
101 if (desc == null) 101 var desc = bus.get_global_engine();
102 return -1; 102 if (desc == null)
103 string cmdline = "setxkbmap %s".printf(desc.get_layout()); 103 return -1;
104 try { 104 string cmdline = "setxkbmap %s".printf(desc.get_layout());
105 if (!GLib.Process.spawn_command_line_sync(cmdline)) { 105 try {
106 warning("Switch xkb layout to %s failed.", 106 if (!GLib.Process.spawn_command_line_sync(cmdline)) {
107 desc.get_layout()); 107 warning("Switch xkb layout to %s failed.",
108 } 108 desc.get_layout());
109 } catch (GLib.SpawnError e) {
110 warning("execute setxkblayout failed");
111 } 109 }
112 return 0; 110 } catch (GLib.SpawnError e) {
111 warning("execute setxkblayout failed");
113 } 112 }
114 return 0; 113 return 0;
115 } 114 }
116 115
117 int message_watch(string[] argv) { 116 int message_watch(string[] argv) {
118 return 0; 117 return 0;
119 } 118 }
120 119
121 int restart_daemon(string[] argv) { 120 int restart_daemon(string[] argv) {
122 var bus = get_bus(); 121 var bus = get_bus();
(...skipping 10 matching lines...) Expand all
133 delegate int EntryFunc(string[] argv); 132 delegate int EntryFunc(string[] argv);
134 133
135 struct CommandEntry { 134 struct CommandEntry {
136 string name; 135 string name;
137 EntryFunc entry; 136 EntryFunc entry;
138 } 137 }
139 138
140 public int main(string[] argv) { 139 public int main(string[] argv) {
141 const CommandEntry commands[] = { 140 const CommandEntry commands[] = {
142 { "engine", get_set_engine }, 141 { "engine", get_set_engine },
142 { "exit", exit_daemon },
143 { "list-engine", list_engine }, 143 { "list-engine", list_engine },
144 { "watch", message_watch }, 144 { "watch", message_watch },
145 { "restart", restart_daemon }, 145 { "restart", restart_daemon }
146 { "exit", exit_daemon }
147 }; 146 };
148 147
149 if (argv.length >= 2) { 148 if (argv.length >= 2) {
150 string[] new_argv = argv[1:argv.length]; 149 string[] new_argv = argv[1:argv.length];
151 foreach (var command in commands) { 150 foreach (var command in commands) {
152 if (command.name == argv[1]) 151 if (command.name == argv[1])
153 return command.entry(new_argv); 152 return command.entry(new_argv);
154 } 153 }
155 warning("%s is unknown command!", argv[1]); 154 warning("%s is unknown command!", argv[1]);
156 } 155 }
157 156
158 return -1; 157 return -1;
159 } 158 }
160 159
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b