Permalink
Browse files

Merge branch 'master' of github.com:jjkrol/ZPR

  • Loading branch information...
2 parents ac136cf + 46fbf43 commit d55a2d2c8d16b916c5e1da256bd6b45c3dad8800 @nme01 nme01 committed Jun 3, 2012
View
1 include/core.hpp
@@ -126,7 +126,6 @@ class CoreController {
/**
* @returns all tags
*/
-
Glib::RefPtr<Gtk::ListStore> getTagsList();
void addTagToActivePhoto(std::string tag);
View
2 include/plugins/desaturateEffect.hpp
@@ -6,7 +6,7 @@ class Photo;
class DesaturateEffect : public Effect {
public:
- DesaturateEffect(double amount);
+ DesaturateEffect(double);
virtual ~DesaturateEffect() {};
void execute(Photo* photo);
View
7 include/window.hpp
@@ -39,7 +39,7 @@ class MainWindow : public Gtk::Window {
Gtk::Box left_box, right_box, bottom_box;
Gtk::ScrolledWindow display;
- //menubar creating
+ //menubar
Glib::RefPtr<Gtk::UIManager> ui_manager;
Glib::RefPtr<Gtk::ActionGroup> action_group;
Glib::RefPtr<Gtk::RadioAction> library_view, edit_view;
@@ -52,6 +52,9 @@ class MainWindow : public Gtk::Window {
//toolbar
Gtk::ToolButton save_button, delete_button;
Gtk::ToolButton edit_button, tags_button;
+
+ //prompt
+ Gtk::InfoBar *prompt;
//constructor and desctructor
MainWindow();
@@ -66,6 +69,8 @@ class MainWindow : public Gtk::Window {
void editDatabase();
void editPhotoTags();
void showAbout();
+ bool on_delete_event(GdkEventAny* event);
+ void managePromptResponse(int response);
};
/** @class WindowContent
View
9 src/core.cpp
@@ -484,9 +484,8 @@ vector<string> CoreController::getPluginNames(){
}
void CoreController::applyEffectOfSelectedPlugin(){
- Effect * effect = selectedPlugin->getEffect();
+ Effect * effect = selectedPlugin->getEffect();
(*currentPhoto)->putEffect(effect);
- std::cout<<"Apply effect"<<std::endl;
modifiedPhotos.insert(*currentPhoto);
}
@@ -497,11 +496,11 @@ Gtk::Widget * CoreController::getPluginBox(string name){
}
void CoreController::savePhotos(){
- cout<<"Save photos"<<endl;
set<Photo*>::iterator it;
- for(it = modifiedPhotos.begin(); it != modifiedPhotos.end(); ++it){
+
+ for(it = modifiedPhotos.begin(); it != modifiedPhotos.end(); ++it)
(*it)->save();
- }
+
modifiedPhotos.clear();
}
View
2 src/editView.cpp
@@ -97,7 +97,7 @@ EditView::~EditView() {
///
void EditView::showPluginBox(std::string name) {
- Gtk::Box *pluginBox = dynamic_cast<Gtk::Box *>(core->getPluginBox("Sample plugin"));
+ Gtk::Box *pluginBox = dynamic_cast<Gtk::Box *>(core->getPluginBox(name));
pluginBox->set_margin_left(2);
pluginBox->set_margin_right(2);
pluginBox->set_margin_top(1);
View
1 src/photo.cpp
@@ -109,6 +109,7 @@ bool Photo::hasTag(std::string tag){
}
void Photo::putEffect(Effect * effect){
+ std::cout << "lol" << std::endl;
effect->execute(this);
}
View
6 src/plugins/desaturateEffect.cpp
@@ -1,14 +1,16 @@
#include "../../include/plugins/desaturateEffect.hpp"
#include "../../include/photo.hpp"
#include <gtkmm.h>
+#include <iostream>
DesaturateEffect::DesaturateEffect(double value) {
+ std::cout << "KUURHJFDKSFDKJH DZIALAJ" << std::endl;
amount = (float)value;
}
-void DesaturateEffect::execute(Photo * photo) {
+void DesaturateEffect::execute(Photo* photo) {
Glib::RefPtr<Gdk::Pixbuf> pixbuf = photo->getPixbuf();
- Glib::RefPtr<Gdk::Pixbuf> pixbuf_edited;
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf_edited = pixbuf->copy();
pixbuf->saturate_and_pixelate(pixbuf_edited, 0, false);
photo->setPixbuf(pixbuf_edited);
}
View
9 src/plugins/desaturatePlugin.cpp
@@ -1,5 +1,6 @@
#include "../../include/plugins/desaturatePlugin.hpp"
#include "../../include/plugins/desaturateEffect.hpp"
+#include <iostream>
using namespace std;
@@ -9,16 +10,18 @@ DesaturatePlugin::DesaturatePlugin() {
Gtk::Widget* DesaturatePlugin::getWidget() {
box = new Gtk::Box();
- spin_button = new Gtk::SpinButton(Gtk::Adjustment::create(0.0, 0.0, 1.0, 0.05, 0.1, 0));
+ spin_button = new Gtk::SpinButton(
+ Gtk::Adjustment::create(0.5, 0.0, 1.0, 0.05, 0.1, 0.0), 0.05);
box->pack_start(*spin_button, false, false);
return box;
}
Effect* DesaturatePlugin::getEffect() {
- if(spin_button = NULL)
+ if(spin_button == NULL)
return new DesaturateEffect(0);
- else
+ else {
return new DesaturateEffect(spin_button->get_value());
+ }
}
string DesaturatePlugin::getName() {
View
66 src/window.cpp
@@ -29,13 +29,15 @@ MainWindow::MainWindow() : zoom_slider(Gtk::ORIENTATION_HORIZONTAL),
edit_button.set_tooltip_text("Edit image in external editor");
tags_button.set_tooltip_text("Add/delete image tags");
- //connecting signals to buttons
+ //connecting signals
edit_button.signal_clicked().connect(sigc::mem_fun(core,
&CoreController::editInExternalEditor));
tags_button.signal_clicked().connect(sigc::mem_fun(*this,
&MainWindow::editPhotoTags));
save_button.signal_clicked().connect(sigc::mem_fun(core,
&CoreController::saveCurrentPhoto));
+ //this->signal_delete_event().connect_notify(sigc::mem_fun(*this,
+ //&MainWindow::checkForUnsavedPhotos), true);
//menubar creating
Gtk::RadioAction::Group view_type;
@@ -174,3 +176,65 @@ void MainWindow::editPhotoTags() {
tags_dialog->run();
delete tags_dialog;
}
+
+/// @fn void MainWindow::checkForUnsavedPhotos()
+/// @brief Method responsible for checking for unsaved photos and
+/// displaying the prompt or closing the application.
+bool MainWindow::on_delete_event(GdkEventAny* event) {
+ if(!core->modifiedPhotosExist())
+ return false;
+
+ //prompt is already displayed
+ if(prompt) return true;
+
+ //displaying prompt
+ prompt = new Gtk::InfoBar;
+ Gtk::Box *box = new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL);
+ Gtk::Container *container = dynamic_cast<Gtk::Container*>(prompt->get_content_area());
+ if(container) container->add(*box);
+ box->set_spacing(20);
+
+ //adding image
+ Gtk::Image *icon = new Gtk::Image;
+ if(Gtk::Stock::lookup(Gtk::Stock::DIALOG_WARNING, Gtk::ICON_SIZE_DIALOG, *icon))
+ box->pack_start(*icon, false, false);
+
+ //adding label
+ Gtk::Label *label = new Gtk::Label("It seems like there are some unsaved photos. If you don't save them, changes will be lost.");
+ label->set_line_wrap(true);
+ box->pack_start(*label, false, false);
+
+ //adding button
+ prompt->add_button("Close without saving", 0);
+ prompt->add_button("Save photos", 1);
+ prompt->add_button("Cancel", 2);
+ prompt->signal_response().connect(sigc::mem_fun(*this,
+ &MainWindow::managePromptResponse));
+
+ //displaying
+ right_box.remove(display);
+ right_box.pack_start(*prompt, false, false);
+ right_box.pack_start(display, true, true);
+ show_all_children();
+}
+
+/// @fn void MainWindow::managePromptResponse(int response)
+/// @brief Method responsible for handling the save photos prompt.
+void MainWindow::managePromptResponse(int response) {
+ switch(response) {
+ case 0:
+ //TODO
+ break;
+ case 1:
+ core->savePhotos();
+ right_box.remove(*prompt);
+ delete prompt;
+ prompt = NULL;
+ case 2:
+ right_box.remove(*prompt);
+ delete prompt;
+ prompt = NULL;
+ default:
+ break;
+ }
+}
View
BIN test/test_tree/alpha/2011-04-30 00.09.53-2.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d55a2d2

Please sign in to comment.