Browse Source

made it work

master
tedjk 11 years ago
parent
commit
ca126a4d6c
  1. 4
      juci/CMakeLists.txt
  2. 11
      juci/api.cc
  3. 4
      juci/api.h
  4. 3
      juci/api_ext.cc
  5. 6
      juci/plugins.py

4
juci/CMakeLists.txt

@ -131,8 +131,8 @@ link_directories(
${LIBCLANG_LIBRARY_DIRS} ${LIBCLANG_LIBRARY_DIRS}
) )
#module: #module:
set_target_properties(${module} PROPERTIES PREFIX "" set_target_properties(${module} PROPERTIES PREFIX "")
LIBRARY_OUTPUT_DIRECTORY "/usr/lib/python2.7/dist-packages/") # LIBRARY_OUTPUT_DIRECTORY "/usr/lib/python2.7/dist-packages/")
target_link_libraries(${module} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES}) target_link_libraries(${module} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES})
#executable: #executable:
target_link_libraries(${project_name} ${LIVCLANG_LIBRARIES} ${LCL_LIBRARIES} ${GTKMM_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES}) target_link_libraries(${project_name} ${LIVCLANG_LIBRARIES} ${LCL_LIBRARIES} ${GTKMM_LIBRARIES} ${Boost_LIBRARIES} ${PYTHON_LIBRARIES})

11
juci/api.cc

@ -107,7 +107,7 @@ void libjuci::ReplaceWord(const std::string word) {
} }
void libjuci::ReplaceLine(const std::string line) { void libjuci::ReplaceLine(const std::string line) {
std::cout << "unimplemented function: 'libjuci::ReplaceLine()' called" std::cout << "unimplemented: " << __func__ << " called"
<< std::endl; << std::endl;
} }
std::string libjuci::GetWord() { std::string libjuci::GetWord() {
@ -201,16 +201,7 @@ void libjuci::IterToWordEnd(Gtk::TextIter &iter) {
} }
Glib::RefPtr<Gtk::TextBuffer> libjuci::BufferFromNotebook() { Glib::RefPtr<Gtk::TextBuffer> libjuci::BufferFromNotebook() {
// finding focused view
// int i = 0;
// while (!PluginApi::notebook_->source_vec_.at(i)->view().has_focus()) {
// i++;
// while(!PluginApi::notebook_->CurrentTextView().has_focus()) {
// i++;
// }
return Glib::RefPtr<Gtk::TextBuffer>(PluginApi::notebook_ return Glib::RefPtr<Gtk::TextBuffer>(PluginApi::notebook_
// ->source_vec_.at(i)
// ->view().get_buffer());
->CurrentTextView().get_buffer()); ->CurrentTextView().get_buffer());
} }

4
juci/api.h

@ -25,7 +25,6 @@ public:
const std::string menu_func_name, const std::string menu_func_name,
const std::string plugin_path, const std::string plugin_path,
const std::string menu_keybinding); const std::string menu_keybinding);
// text-buffer functions
static void ReplaceWord(const std::string word); static void ReplaceWord(const std::string word);
static void ReplaceLine(const std::string line); static void ReplaceLine(const std::string line);
protected: protected:
@ -64,11 +63,10 @@ namespace libjuci {
namespace bp = boost::python; namespace bp = boost::python;
bp::api::object OpenPythonScript(const std::string path, bp::api::object OpenPythonScript(const std::string path,
bp::api::object python_name_space); bp::api::object python_name_space);
void LoadPlugin(const std::string& plugin_name); void LoadPlugin(const std::string& plugin_name);
void LoadPluginFunction(const std::string &function_name, void LoadPluginFunction(const std::string &function_name,
const std::string &plugin_path); const std::string &plugin_path);
void InitPlugin(const std::string& plugin_path); void InitPlugin(const std::string& plugin_path);
} // libjuci } // namespace libjuci
#endif // JUCI_API_H_ #endif // JUCI_API_H_

3
juci/api_ext.cc

@ -12,7 +12,4 @@ BOOST_PYTHON_MODULE(juci_to_python_api) {
def("replaceLine", &libjuci::ReplaceLine); def("replaceLine", &libjuci::ReplaceLine);
def("replaceWord", &libjuci::ReplaceWord); def("replaceWord", &libjuci::ReplaceWord);
def("getWord", &libjuci::GetWord); def("getWord", &libjuci::GetWord);
//something more
} // module::juci_to_python_api } // module::juci_to_python_api

6
juci/plugins.py

@ -1,9 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
#plugin handler #plugin handler
import juci_to_python_api as juci, os, glob import sys, os, glob
cwd = os.getcwd()
sys.path.append(cwd)
import juci_to_python_api as juci
def loadplugins(): def loadplugins():
cwd = os.getcwd()
plugin_files = glob.glob(cwd+"/plugins/*.py") plugin_files = glob.glob(cwd+"/plugins/*.py")
for current_file in plugin_files: for current_file in plugin_files:
juci.initPlugin(current_file) juci.initPlugin(current_file)

Loading…
Cancel
Save