Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Revert "improved code quality according to Minoru's advice"
Browse files Browse the repository at this point in the history
This reverts commit d3b455c.
  • Loading branch information
Minoru committed Sep 4, 2017
1 parent 7f06233 commit b3cf168
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 24 deletions.
2 changes: 1 addition & 1 deletion include/pb_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class pb_controller {

double get_total_kbps();

bool play_file(const std::string& str) __attribute__((warn_unused_result));
void play_file(const std::string& str);

inline newsbeuter::configcontainer * get_cfgcont() {
return cfg;
Expand Down
4 changes: 1 addition & 3 deletions include/pb_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ class pb_view {
set_bindings();
}

void show_error (const std::string& msg) {
this->dllist_form.set("msg", msg);
}
private:

friend class newsbeuter::colormanager;
Expand All @@ -43,6 +40,7 @@ class pb_view {
std::string prepare_keymaphint(keymap_hint_entry * hints);
pb_controller * ctrl;
newsbeuter::stfl::form dllist_form;
friend class pb_controller; // to use newsbeuter::stfl::form::set()

newsbeuter::stfl::form help_form;
newsbeuter::keymap * keys;
Expand Down
6 changes: 3 additions & 3 deletions src/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,10 +1319,10 @@ void controller::edit_urls_file() {

/* Most editors check for unsaved changes when attempting to exit and
* prompt to either save or discard them. If save was choosen without
* having write permissions a proper code will fail and stay open
* having write permissions a properly codd will fail and stay open
* (like vim, nano, gedit, geany). However other editors (texmaker
* 5.0.1 and notepadqq 1.0.1) close (obviously without saving) but
* despite return 0. So we should not check this particular exit code.
* 5.0.1 and notepadqq 1.0.1) close but despite return 0.
* So we should not check this particular exit code.
*/
int unused __attribute__((unused));
unused = utils::run_interactively(cmdline, "controller::edit_urls_file");
Expand Down
6 changes: 0 additions & 6 deletions src/itemview_formaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,6 @@ void itemview_formaction::process_operation(operation op, bool automatic, std::v
v->set_status(_("Starting browser..."));
if (!v->open_in_browser(item->link())) {
v->show_error(_("Browser failed to open the link!"));
} else {
v->set_status("");
}
break;
case OP_BOOKMARK:
Expand Down Expand Up @@ -375,8 +373,6 @@ void itemview_formaction::process_operation(operation op, bool automatic, std::v
v->set_status(_("Starting browser..."));
if (!v->open_in_browser(links[idx].first)) {
v->show_error(_("Browser failed to open the link!"));
} else {
v->set_status("");
}
}
}
Expand Down Expand Up @@ -526,8 +522,6 @@ void itemview_formaction::finished_qna(operation op) {
v->set_status(_("Starting browser..."));
if (!v->open_in_browser(links[idx-1].first)) {
v->show_error(_("Browser failed to open the link!"));
} else {
v->set_status("");
}
}
}
Expand Down
12 changes: 4 additions & 8 deletions src/pb_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,24 +361,20 @@ void pb_controller::decrease_parallel_downloads() {
--max_dls;
}

bool pb_controller::play_file(const std::string& file) {
void pb_controller::play_file(const std::string& file) {
std::string cmdline;
std::string player = cfg->get_configvalue("player");
if (player == "") {
v->show_error(_("No player is set!"));
return false;
}
if (player == "")
return;
cmdline.append(player);
cmdline.append(" \"");
cmdline.append(utils::replace_all(file,"\"", "\\\""));
cmdline.append("\"");
stfl::reset();
int player_exit_code = utils::run_interactively(cmdline, "pb_controller::play_file");
if (player_exit_code != 0) {
v->show_error(_("The player failed to play the file!"));
return false;
v->dllist_form.set("msg", _("The player failed!"));
}
return true;
}


Expand Down
5 changes: 2 additions & 3 deletions src/pb_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,8 @@ void pb_view::run(bool auto_download) {
if (idx != -1) {
dlstatus status = ctrl->downloads()[idx].status();
if (status == dlstatus::FINISHED || status == dlstatus::PLAYED || status == dlstatus::READY) {
if (ctrl->play_file(ctrl->downloads()[idx].filename())) {
ctrl->downloads()[idx].set_status(dlstatus::PLAYED);
}
ctrl->play_file(ctrl->downloads()[idx].filename());
ctrl->downloads()[idx].set_status(dlstatus::PLAYED);
} else {
dllist_form.set("msg", _("Error: download needs to be finished before the file can be played."));
}
Expand Down

0 comments on commit b3cf168

Please sign in to comment.