improve examples
This commit is contained in:
parent
8ea05274f0
commit
0f94a9920c
4 changed files with 14 additions and 11 deletions
|
@ -29,7 +29,7 @@ PhotoViewer::PhotoViewer(Gtk::Window *win) : p_win(win)
|
|||
{
|
||||
}
|
||||
|
||||
void PhotoViewer::open_file(const char *filename)
|
||||
void PhotoViewer::open_file(const std::string &filename)
|
||||
{
|
||||
if (p_image)
|
||||
p_image.clear();
|
||||
|
@ -39,7 +39,7 @@ void PhotoViewer::open_file(const char *filename)
|
|||
// Read file
|
||||
std::ifstream ifs(filename, std::ios::in | std::ios::binary);
|
||||
if (!ifs.is_open()) {
|
||||
Gtk::MessageDialog msg(*p_win, "Failed to open file: " + Glib::ustring(filename), false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
||||
Gtk::MessageDialog msg(*p_win, "Failed to open file: " + filename, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
||||
msg.set_title("Open Photo");
|
||||
msg.run();
|
||||
return;
|
||||
|
@ -52,7 +52,7 @@ void PhotoViewer::open_file(const char *filename)
|
|||
if (!loaded) {
|
||||
const RagePhoto::Error error = ragePhoto.error();
|
||||
if (error <= RagePhoto::Error::PhotoReadError) {
|
||||
Gtk::MessageDialog msg(*p_win, "Failed to read photo: " + Glib::ustring(filename), false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
||||
Gtk::MessageDialog msg(*p_win, "Failed to read photo: " + filename, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
||||
msg.set_title("Open Photo");
|
||||
msg.run();
|
||||
return;
|
||||
|
|
|
@ -27,7 +27,7 @@ class PhotoViewer : public Gtk::DrawingArea
|
|||
{
|
||||
public:
|
||||
PhotoViewer(Gtk::Window *win);
|
||||
void open_file(const char *filename);
|
||||
void open_file(const std::string &filename);
|
||||
|
||||
protected:
|
||||
bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr) override;
|
||||
|
|
|
@ -96,14 +96,14 @@ int main(int argc, char *argv[])
|
|||
app->signal_open().connect([&](const Gio::Application::type_vec_files &files, const Glib::ustring &hint) {
|
||||
if (files.size() == 1) {
|
||||
for (const auto &file : files) {
|
||||
photo_viewer.open_file(file->get_path().c_str());
|
||||
photo_viewer.open_file(file->get_path());
|
||||
}
|
||||
app->add_window(win);
|
||||
win.show();
|
||||
win.present();
|
||||
}
|
||||
else {
|
||||
app->add_window(win);
|
||||
win.show();
|
||||
win.present();
|
||||
Gtk::MessageDialog msg(win, "Can't open multiple photos at once!", false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_OK, true);
|
||||
msg.set_title("RagePhoto GTK Photo Viewer");
|
||||
msg.run();
|
||||
|
@ -114,6 +114,7 @@ int main(int argc, char *argv[])
|
|||
vertical_box.show();
|
||||
|
||||
win.add(vertical_box);
|
||||
win.present();
|
||||
|
||||
return app->run(win);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue