Browse Source

A little cleanup, mostly getting rid of warnings (Added -Wall and -Wno-reorder to compilation).

merge-requests/365/head
eidheim 11 years ago
parent
commit
68ac889879
  1. 2
      juci/CMakeLists.txt
  2. 4
      juci/directories.cc
  3. 2
      juci/juci.cc
  4. 13
      juci/notebook.cc
  5. 1
      juci/notebook.h
  6. 4
      juci/source.cc
  7. 2
      juci/terminal.cc
  8. 12
      juci/window.cc

2
juci/CMakeLists.txt

@ -3,7 +3,7 @@ set(project_name juci)
set(module juci_to_python_api)
project (${project_name})
add_definitions(-DBOOST_LOG_DYN_LINK)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -pthread")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -std=c++11 -pthread -Wall -Wno-reorder")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules/")
#You are of course using Homebrew:

4
juci/directories.cc

@ -43,8 +43,6 @@ list_dirs(const boost::filesystem::path& dir_path,
unsigned row_id) {
boost::filesystem::directory_iterator end_itr;
unsigned dir_counter = row_id;
unsigned file_counter = 0;
Gtk::TreeModel::Row child;
Gtk::TreeModel::Row row;
DEBUG("");
@ -82,7 +80,7 @@ list_dirs(const boost::filesystem::path& dir_path,
int Directories::Controller::count(const std::string path) {
int count = 0;
for (int i = 0; i < path.size(); i++)
for (size_t i = 0; i < path.size(); i++)
if (path[i] == '/')
count++;
return count;

2
juci/juci.cc

@ -16,7 +16,7 @@ int Juci::on_command_line(const Glib::RefPtr<Gio::ApplicationCommandLine> &cmd)
char **argv = cmd->get_arguments(argc);
ctx.parse(argc, argv);
if(argc>=2) {
for(size_t c=1;c<argc;c++) {
for(int c=1;c<argc;c++) {
boost::filesystem::path p=boost::filesystem::canonical(argv[c]);
if(boost::filesystem::exists(p)) {
if(boost::filesystem::is_regular_file(p))

13
juci/notebook.cc

@ -186,7 +186,7 @@ void Notebook::Controller::OnOpenFile(std::string path) {
//Add star on tab label when the page is not saved:
text_vec_.back()->buffer()->signal_changed().connect([this]() {
if(text_vec_.at(CurrentPage())->is_saved) {
std::string path=text_vec_.at(CurrentPage())->view->file_path;
std::string path=CurrentTextView().file_path;
size_t pos = path.find_last_of("/\\");
std::string filename=path;
if(pos!=std::string::npos)
@ -328,12 +328,8 @@ Gtk::Notebook& Notebook::Controller::Notebook() {
return view_.notebook();
}
std::string Notebook::Controller::CurrentPagePath(){
return text_vec_.at(CurrentPage())->view->file_path;
}
bool Notebook::Controller:: OnSaveFile() {
std::string path=text_vec_.at(CurrentPage())->view->file_path;
std::string path=CurrentTextView().file_path;
return OnSaveFile(path);
}
bool Notebook::Controller:: OnSaveFile(std::string path) {
@ -343,7 +339,7 @@ bool Notebook::Controller:: OnSaveFile(std::string path) {
file.open (path);
file << CurrentTextView().get_buffer()->get_text();
file.close();
text_vec_.at(CurrentPage())->view->file_path=path;
CurrentTextView().file_path=path;
size_t pos = path.find_last_of("/\\");
std::string filename=path;
if(pos!=std::string::npos)
@ -373,7 +369,6 @@ std::string Notebook::Controller::OnSaveFileAs(){
case(Gtk::RESPONSE_OK): {
DEBUG("get_filename()");
std::string path = dialog.get_filename();
unsigned pos = path.find_last_of("/\\");
return path;
}
case(Gtk::RESPONSE_CANCEL): {
@ -394,7 +389,7 @@ void Notebook::Controller::AskToSaveDialog() {
false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO);
dialog.set_secondary_text(
"Do you want to save: " +
text_vec_.at(CurrentPage())->view->file_path+" ?");
CurrentTextView().file_path+" ?");
DEBUG("AskToSaveDialog: run dialog");
int result = dialog.run();

1
juci/notebook.h

@ -32,7 +32,6 @@ namespace Notebook {
Source::View& CurrentTextView();
int CurrentPage();
Gtk::Notebook& Notebook();
std::string CurrentPagePath();
void OnCloseCurrentPage();
std::string GetCursorWord();
void OnEditCopy();

4
juci/source.cc

@ -268,7 +268,7 @@ get_compilation_commands() {
std::vector<std::string> arguments;
for (auto &i : cmds) {
std::vector<std::string> lol = i.get_command_as_args();
for (int a = 1; a < lol.size()-4; a++) {
for (size_t a = 1; a < lol.size()-4; a++) {
arguments.emplace_back(lol[a]);
}
}
@ -439,7 +439,7 @@ bool Source::ClangView::on_key_press(GdkEventKey* key) {
string line(get_line_before_insert());
std::smatch sm;
if(std::regex_match(line, sm, bracket_regex)) {
size_t line_nr=get_source_buffer()->get_insert()->get_iter().get_line();
int line_nr=get_source_buffer()->get_insert()->get_iter().get_line();
if((line_nr+1)<get_source_buffer()->get_line_count()) {
string next_line=get_line(line_nr+1);
std::smatch sm2;

2
juci/terminal.cc

@ -8,7 +8,7 @@ Terminal::Config::Config() {
}
Terminal::Config::Config(Terminal::Config& original) :
run_command_(original.run_command_){
for (auto it = 0; it<original.compile_commands().size(); ++it) {
for (size_t it = 0; it<original.compile_commands().size(); ++it) {
InsertCompileCommand(original.compile_commands().at(it));
}
}

12
juci/window.cc

@ -66,8 +66,8 @@ Window::Window() :
SaveFile();
if (running.try_lock()) {
std::thread execute([=]() {
std::string path = notebook_.CurrentPagePath();
int pos = path.find_last_of("/\\");
std::string path = notebook_.CurrentTextView().file_path;
size_t pos = path.find_last_of("/\\");
if(pos != std::string::npos) {
path.erase(path.begin()+pos,path.end());
terminal_.SetFolderCommand(path);
@ -92,8 +92,8 @@ Window::Window() :
SaveFile();
if (running.try_lock()) {
std::thread execute([=]() {
std::string path = notebook_.CurrentPagePath();
int pos = path.find_last_of("/\\");
std::string path = notebook_.CurrentTextView().file_path;
size_t pos = path.find_last_of("/\\");
if(pos != std::string::npos){
path.erase(path.begin()+pos,path.end());
terminal_.SetFolderCommand(path);
@ -203,7 +203,7 @@ void Window::OnOpenFile() {
bool Window::SaveFile() {
if(notebook_.OnSaveFile()) {
terminal_.PrintMessage("File saved to: " +
notebook_.CurrentPagePath()+"\n");
notebook_.CurrentTextView().file_path+"\n");
return true;
}
terminal_.PrintMessage("File not saved");
@ -212,7 +212,7 @@ bool Window::SaveFile() {
bool Window::SaveFileAs() {
if(notebook_.OnSaveFile(notebook_.OnSaveFileAs())){
terminal_.PrintMessage("File saved to: " +
notebook_.CurrentPagePath()+"\n");
notebook_.CurrentTextView().file_path+"\n");
return true;
}
terminal_.PrintMessage("File not saved");

Loading…
Cancel
Save