1 /*
2  *  This file is part of RawTherapee.
3  *
4  *  Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
5  *
6  *  RawTherapee is free software: you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation, either version 3 of the License, or
9  *  (at your option) any later version.
10  *
11  *  RawTherapee is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 #include "renamedlg.h"
20 #include "cacheimagedata.h"
21 #include "multilangmgr.h"
22 #include "rtimage.h"
23 
RenameDialog(Gtk::Window * parent)24 RenameDialog::RenameDialog (Gtk::Window* parent)
25     : Gtk::Dialog (M("FILEBROWSER_RENAMEDLGLABEL"), *parent, true), p(parent), imageData(nullptr)
26 {
27 
28     Gtk::Table* names = Gtk::manage (new Gtk::Table (2, 2));
29     Gtk::Label* onlab = Gtk::manage (new Gtk::Label (M("FILEBROWSER_CURRENT_NAME")));
30     Gtk::Label* nnlab = Gtk::manage (new Gtk::Label (M("FILEBROWSER_NEW_NAME")));
31     oldName = Gtk::manage (new Gtk::Label ("alma"));
32     newName = Gtk::manage (new Gtk::Entry ());
33 
34     names->attach (*onlab, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK, 2, 2);
35     names->attach (*oldName, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 2, 2);
36     names->attach (*nnlab, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK, 2, 2);
37     names->attach (*newName, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK, 2, 2);
38 
39     get_content_area()->pack_start (*names, Gtk::PACK_SHRINK, 4);
40 
41 // Issue 316
42 //    Gtk::HBox* tbox = Gtk::manage (new Gtk::HBox());
43 //    useTmpl = Gtk::manage (new Gtk::CheckButton (M("FILEBROWSER_USETEMPLATE")));
44 //    templates = Gtk::manage (new MyComboBox ());
45 //    templateModel = Gtk::ListStore::create (templateColumns);
46 //    templates->set_model (templateModel);
47 //    templates->pack_start (templateColumns.tmplName);
48 
49 //    tbox->pack_start (*useTmpl, Gtk::PACK_SHRINK, 4);
50 //    tbox->pack_start (*templates);
51 
52 //    get_content_area()->pack_start (*tbox, Gtk::PACK_SHRINK, 4);
53 
54     add_button (Gtk::Stock::OK, Gtk::RESPONSE_OK);
55     add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
56 // Issue 316
57 //    all = add_button ("All", RESPONSE_ALL);
58 
59     newName->set_activates_default (true);
60     set_default_response (Gtk::RESPONSE_OK);
61 // Issue 316
62 //    fillTemplateList ();
63 
64 //    templates->set_row_separator_func (sigc::mem_fun(*this, &RenameDialog::rowSeparatorFunc));
65 //    templates->signal_changed().connect(sigc::mem_fun(*this, &RenameDialog::tmplSelectionChanged));
66 //    useTmpl->signal_toggled().connect( sigc::mem_fun(*this, &RenameDialog::useTemplToggled) );
67 
68 //    useTmpl->set_active (options.renameUseTemplates);
69 
70     show_all_children ();
71 }
72 
initName(const Glib::ustring & iname,const CacheImageData * cid)73 void RenameDialog::initName (const Glib::ustring& iname, const CacheImageData* cid)
74 {
75 
76     imageData = cid;
77     oldName->set_text (iname);
78     newName->set_text (iname);
79 // Issue 316
80 //    if (useTmpl->get_active () && isTemplSelected ())
81 //        newName->set_text (applyTemplate (iname, cid, getActiveTemplate()));
82     newName->select_region (0, newName->get_text().size());
83 }
84 
getNewName()85 Glib::ustring RenameDialog::getNewName ()
86 {
87 
88     return newName->get_text ();
89 }
90 
91