From: bdilly Date: Mon, 20 Aug 2007 04:09:10 +0000 (+0000) Subject: merge of dialog and impl classes of ocaldialogs X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2d4aeccc796c90f2301f78b14242ba2e77cef859;p=inkscape.git merge of dialog and impl classes of ocaldialogs --- diff --git a/src/file.cpp b/src/file.cpp index e8e9af9d3..0e8a084e3 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -1206,7 +1206,7 @@ sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow) // Show the Export To OCAL dialog if (!exportDialogInstance) - exportDialogInstance = Inkscape::UI::Dialog::FileExportToOCALDialog::create( + exportDialogInstance = new Inkscape::UI::Dialog::FileExportToOCALDialog( parentWindow, Inkscape::UI::Dialog::EXPORT_TYPES, (char const *) _("Select file to export to") @@ -1253,7 +1253,7 @@ sp_file_export_to_ocal_dialog(Gtk::Window &parentWindow) if(!gotSuccess) { if (!exportPasswordDialogInstance) - exportPasswordDialogInstance = Inkscape::UI::Dialog::FileExportToOCALPasswordDialog::create( + exportPasswordDialogInstance = new Inkscape::UI::Dialog::FileExportToOCALPasswordDialog( parentWindow, (char const *) _("Open Clip Art Login")); success = exportPasswordDialogInstance->show(); @@ -1320,8 +1320,8 @@ sp_file_import_from_ocal(Gtk::Window &parentWindow) static Inkscape::UI::Dialog::FileImportFromOCALDialog *importDialogInstance = NULL; if (!importDialogInstance) { - importDialogInstance = - Inkscape::UI::Dialog::FileImportFromOCALDialog::create( + importDialogInstance = new + Inkscape::UI::Dialog::FileImportFromOCALDialog( parentWindow, import_path, Inkscape::UI::Dialog::IMPORT_TYPES, diff --git a/src/ui/dialog/ocaldialogs.cpp b/src/ui/dialog/ocaldialogs.cpp index ae2dbd315..7f1d72c70 100644 --- a/src/ui/dialog/ocaldialogs.cpp +++ b/src/ui/dialog/ocaldialogs.cpp @@ -31,63 +31,10 @@ namespace Dialog //# F I L E E X P O R T T O O C A L //######################################################################## - -/** - * Public factory method. Used in file.cpp - */ - - FileExportToOCALDialog *FileExportToOCALDialog::create(Gtk::Window& parentWindow, - FileDialogType fileTypes, - const Glib::ustring &title) -{ - FileExportToOCALDialog *dialog = new FileExportToOCALDialogImpl(parentWindow, fileTypes, title); - return dialog; -} - -//######################################################################## -//# F I L E E X P O R T T O O C A L P A S S W O R D -//######################################################################## - - -/** - * Public factory method. Used in file.cpp - */ - -FileExportToOCALPasswordDialog *FileExportToOCALPasswordDialog::create(Gtk::Window& parentWindow, - const Glib::ustring &title) -{ - FileExportToOCALPasswordDialog *dialog = new FileExportToOCALPasswordDialogImpl(parentWindow, title); - return dialog; -} - - -//######################################################################### -//### F I L E I M P O R T F R O M O C A L -//######################################################################### - -/** - * Public factory. Called by file.cpp. - */ -FileImportFromOCALDialog *FileImportFromOCALDialog::create(Gtk::Window &parentWindow, - const Glib::ustring &path, - FileDialogType fileTypes, - const Glib::ustring &title) -{ - FileImportFromOCALDialog *dialog = new FileImportFromOCALDialogImplGtk(parentWindow, path, fileTypes, title); - return dialog; -} - - -//######################################################################## -//# F I L E E X P O R T T O O C A L -//######################################################################## - - - /** * Callback for fileNameEntry widget */ -void FileExportToOCALDialogImpl::fileNameEntryChangedCallback() +void FileExportToOCALDialog::fileNameEntryChangedCallback() { if (!fileNameEntry) return; @@ -100,16 +47,13 @@ void FileExportToOCALDialogImpl::fileNameEntryChangedCallback() response(Gtk::RESPONSE_OK); } - - - /** * Constructor */ -FileExportToOCALDialogImpl::FileExportToOCALDialogImpl(Gtk::Window &parentWindow, +FileExportToOCALDialog::FileExportToOCALDialog(Gtk::Window &parentWindow, FileDialogType fileTypes, const Glib::ustring &title) : - FileDialogOCALBase(title) + FileDialogOCALBase(title, parentWindow) { /* * Start Taking the vertical Box and putting a Label @@ -120,11 +64,10 @@ FileExportToOCALDialogImpl::FileExportToOCALDialogImpl(Gtk::Window &parentWindow extension = NULL; /* No filename to start out with */ myFilename = ""; - /* Set our dialog type (save, export, etc...)*/ dialogType = fileTypes; Gtk::VBox *vbox = get_vbox(); - + Gtk::Label *fileLabel = new Gtk::Label(_("File")); fileNameEntry = new Gtk::Entry(); @@ -144,7 +87,7 @@ FileExportToOCALDialogImpl::FileExportToOCALDialogImpl(Gtk::Window &parentWindow //Catch when user hits [return] on the text field fileNameEntry = entries[0]; fileNameEntry->signal_activate().connect( - sigc::mem_fun(*this, &FileExportToOCALDialogImpl::fileNameEntryChangedCallback) ); + sigc::mem_fun(*this, &FileExportToOCALDialog::fileNameEntryChangedCallback) ); } add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); @@ -153,12 +96,10 @@ FileExportToOCALDialogImpl::FileExportToOCALDialogImpl(Gtk::Window &parentWindow show_all_children(); } - - /** * Destructor */ -FileExportToOCALDialogImpl::~FileExportToOCALDialogImpl() +FileExportToOCALDialog::~FileExportToOCALDialog() { } @@ -166,7 +107,7 @@ FileExportToOCALDialogImpl::~FileExportToOCALDialogImpl() * Show this dialog modally. Return true if user hits [OK] */ bool -FileExportToOCALDialogImpl::show() +FileExportToOCALDialog::show() { set_modal (TRUE); //Window sp_transientize((GtkWidget *)gobj()); //Make transient @@ -187,7 +128,7 @@ FileExportToOCALDialogImpl::show() * Get the file name chosen by the user. Valid after an [OK] */ Glib::ustring -FileExportToOCALDialogImpl::getFilename() +FileExportToOCALDialog::getFilename() { myFilename = fileNameEntry->get_text(); if (!Glib::get_charset()) //If we are not utf8 @@ -198,7 +139,7 @@ FileExportToOCALDialogImpl::getFilename() void -FileExportToOCALDialogImpl::change_title(const Glib::ustring& title) +FileExportToOCALDialog::change_title(const Glib::ustring& title) { this->set_title(title); } @@ -212,8 +153,8 @@ FileExportToOCALDialogImpl::change_title(const Glib::ustring& title) /** * Constructor */ -FileExportToOCALPasswordDialogImpl::FileExportToOCALPasswordDialogImpl(Gtk::Window &parentWindow, - const Glib::ustring &title) : FileDialogOCALBase(title) +FileExportToOCALPasswordDialog::FileExportToOCALPasswordDialog(Gtk::Window &parentWindow, + const Glib::ustring &title) : FileDialogOCALBase(title, parentWindow) { /* * Start Taking the vertical Box and putting 2 Labels @@ -257,7 +198,7 @@ FileExportToOCALPasswordDialogImpl::FileExportToOCALPasswordDialogImpl(Gtk::Wind /** * Destructor */ -FileExportToOCALPasswordDialogImpl::~FileExportToOCALPasswordDialogImpl() +FileExportToOCALPasswordDialog::~FileExportToOCALPasswordDialog() { } @@ -265,7 +206,7 @@ FileExportToOCALPasswordDialogImpl::~FileExportToOCALPasswordDialogImpl() * Show this dialog modally. Return true if user hits [OK] */ bool -FileExportToOCALPasswordDialogImpl::show() +FileExportToOCALPasswordDialog::show() { set_modal (TRUE); //Window sp_transientize((GtkWidget *)gobj()); //Make transient @@ -286,7 +227,7 @@ FileExportToOCALPasswordDialogImpl::show() * Get the username. Valid after an [OK] */ Glib::ustring -FileExportToOCALPasswordDialogImpl::getUsername() +FileExportToOCALPasswordDialog::getUsername() { myUsername = usernameEntry->get_text(); return myUsername; @@ -296,14 +237,14 @@ FileExportToOCALPasswordDialogImpl::getUsername() * Get the password. Valid after an [OK] */ Glib::ustring -FileExportToOCALPasswordDialogImpl::getPassword() +FileExportToOCALPasswordDialog::getPassword() { myPassword = passwordEntry->get_text(); return myPassword; } void -FileExportToOCALPasswordDialogImpl::change_title(const Glib::ustring& title) +FileExportToOCALPasswordDialog::change_title(const Glib::ustring& title) { this->set_title(title); } @@ -420,7 +361,7 @@ Glib::ustring FileListViewText::getFilename() /** * Callback for user input into searchTagEntry */ -void FileImportFromOCALDialogImplGtk::searchTagEntryChangedCallback() +void FileImportFromOCALDialog::searchTagEntryChangedCallback() { if (!searchTagEntry) return; @@ -539,7 +480,7 @@ void FileImportFromOCALDialogImplGtk::searchTagEntryChangedCallback() * Prints the names of the all the xml elements * that are siblings or children of a given xml node */ -void FileImportFromOCALDialogImplGtk::print_xml_element_names(xmlNode * a_node) +void FileImportFromOCALDialog::print_xml_element_names(xmlNode * a_node) { xmlNode *cur_node = NULL; guint row_num = 0; @@ -581,11 +522,11 @@ void FileImportFromOCALDialogImplGtk::print_xml_element_names(xmlNode * a_node) /** * Constructor. Not called directly. Use the factory. */ -FileImportFromOCALDialogImplGtk::FileImportFromOCALDialogImplGtk(Gtk::Window& parentWindow, +FileImportFromOCALDialog::FileImportFromOCALDialog(Gtk::Window& parentWindow, const Glib::ustring &dir, FileDialogType fileTypes, const Glib::ustring &title) : - FileDialogOCALBase(title) + FileDialogOCALBase(title, parentWindow) { // Initalize to Autodetect extension = NULL; @@ -644,11 +585,11 @@ FileImportFromOCALDialogImplGtk::FileImportFromOCALDialogImplGtk(Gtk::Window& pa //Catch when user hits [return] on the text field searchTagEntry = entries[0]; searchTagEntry->signal_activate().connect( - sigc::mem_fun(*this, &FileImportFromOCALDialogImplGtk::searchTagEntryChangedCallback)); + sigc::mem_fun(*this, &FileImportFromOCALDialog::searchTagEntryChangedCallback)); } searchButton->signal_clicked().connect( - sigc::mem_fun(*this, &FileImportFromOCALDialogImplGtk::searchTagEntryChangedCallback)); + sigc::mem_fun(*this, &FileImportFromOCALDialog::searchTagEntryChangedCallback)); show_all_children(); notFoundLabel->hide(); @@ -657,7 +598,7 @@ FileImportFromOCALDialogImplGtk::FileImportFromOCALDialogImplGtk(Gtk::Window& pa /** * Destructor */ -FileImportFromOCALDialogImplGtk::~FileImportFromOCALDialogImplGtk() +FileImportFromOCALDialog::~FileImportFromOCALDialog() { } @@ -666,7 +607,7 @@ FileImportFromOCALDialogImplGtk::~FileImportFromOCALDialogImplGtk() * Show this dialog modally. Return true if user hits [OK] */ bool -FileImportFromOCALDialogImplGtk::show() +FileImportFromOCALDialog::show() { set_modal (TRUE); //Window sp_transientize((GtkWidget *)gobj()); //Make transient @@ -688,7 +629,7 @@ FileImportFromOCALDialogImplGtk::show() * Get the file extension type that was selected by the user. Valid after an [OK] */ Inkscape::Extension::Extension * -FileImportFromOCALDialogImplGtk::getSelectionType() +FileImportFromOCALDialog::getSelectionType() { return extension; } @@ -698,7 +639,7 @@ FileImportFromOCALDialogImplGtk::getSelectionType() * Get the file name chosen by the user. Valid after an [OK] */ Glib::ustring -FileImportFromOCALDialogImplGtk::getFilename (void) +FileImportFromOCALDialog::getFilename (void) { return filesList->getFilename(); } diff --git a/src/ui/dialog/ocaldialogs.h b/src/ui/dialog/ocaldialogs.h index c7c8009de..0953e76bc 100644 --- a/src/ui/dialog/ocaldialogs.h +++ b/src/ui/dialog/ocaldialogs.h @@ -64,160 +64,6 @@ namespace UI namespace Dialog { - -/** - * This class provides an implementation-independent API for - * file "ExportToOCAL" dialogs. - */ -class FileExportToOCALDialog -{ -public: - - /** - * Constructor. Do not call directly . Use the factory. - * @param fileTypes one of FileDialogTypes - * @param title the title of the dialog - * @param key a list of file types from which the user can select - */ - FileExportToOCALDialog () - {}; - - /** - * Factory. - * @param fileTypes one of FileDialogTypes - * @param title the title of the dialog - * @param key a list of file types from which the user can select - */ - static FileExportToOCALDialog *create(Gtk::Window& parentWindow, - FileDialogType fileTypes, - const Glib::ustring &title); - - - /** - * Destructor. - * Perform any necessary cleanups. - */ - virtual ~FileExportToOCALDialog() {}; - - - /** - * Show an SaveAs file selector. - * @return the selected path if user selected one, else NULL - */ - virtual bool show() =0; - - virtual Glib::ustring getFilename () =0; - - /** - * Change the window title. - */ - virtual void change_title(const Glib::ustring& title) =0; - - -}; //FileExportToOCAL - -/** - * This class provides an implementation-independent API for - * file "ExportToOCALPassword" dialogs. - */ -class FileExportToOCALPasswordDialog -{ -public: - - /** - * Constructor. Do not call directly . Use the factory. - * @param title the title of the dialog - */ - FileExportToOCALPasswordDialog () - {}; - - /** - * Factory. - * @param title the title of the dialog - */ - static FileExportToOCALPasswordDialog *create(Gtk::Window& parentWindow, - const Glib::ustring &title); - - - /** - * Destructor. - * Perform any necessary cleanups. - */ - virtual ~FileExportToOCALPasswordDialog() {}; - - - /** - * Show 2 entry to input username and password. - */ - virtual bool show() =0; - - virtual Glib::ustring getUsername () =0; - virtual Glib::ustring getPassword () =0; - - /** - * Change the window title. - */ - virtual void change_title(const Glib::ustring& title) =0; - - -}; //FileExportToOCALPassword - - - -/** - * This class provides an implementation-independent API for - * file "ImportFromOCAL" dialogs. - */ -class FileImportFromOCALDialog -{ -public: - - - /** - * Constructor .. do not call directly - * @param path the directory where to start searching - * @param fileTypes one of FileDialogTypes - * @param title the title of the dialog - */ - FileImportFromOCALDialog() - {}; - - /** - * Factory. - * @param path the directory where to start searching - * @param fileTypes one of FileDialogTypes - * @param title the title of the dialog - */ - static FileImportFromOCALDialog *create(Gtk::Window& parentWindow, - const Glib::ustring &path, - FileDialogType fileTypes, - const Glib::ustring &title); - - - /** - * Destructor. - * Perform any necessary cleanups. - */ - virtual ~FileImportFromOCALDialog() {}; - - /** - * Show an OpenFile file selector. - * @return the selected path if user selected one, else NULL - */ - virtual bool show() =0; - - /** - * Return the 'key' (filetype) of the selection, if any - * @return a pointer to a string if successful (which must - * be later freed with g_free(), else NULL. - */ - virtual Inkscape::Extension::Extension * getSelectionType() = 0; - - virtual Glib::ustring getFilename () =0; - -}; //FileImportFromOCALDialog - - /*######################################################################### ### F I L E D I A L O G O C A L B A S E C L A S S #########################################################################*/ @@ -230,12 +76,13 @@ class FileDialogOCALBase : public Gtk::Dialog public: /** - * + * Constructor */ - FileDialogOCALBase(const Glib::ustring &title) : Gtk::Dialog(title,true) + FileDialogOCALBase(const Glib::ustring &title, Gtk::Window& parent) : Gtk::Dialog(title, parent, true) {} + /* - * + * Destructor */ virtual ~FileDialogOCALBase() {} @@ -243,7 +90,6 @@ public: protected: void cleanup( bool showConfirmed ); - //Glib::ustring preferenceBase; /** * What type of 'open' are we? (open, import, place, etc) */ @@ -258,28 +104,44 @@ protected: //######################################################################## - /** * Our implementation of the FileExportToOCALDialog interface. */ -class FileExportToOCALDialogImpl : public FileExportToOCALDialog, public FileDialogOCALBase +class FileExportToOCALDialog : public FileDialogOCALBase { public: - FileExportToOCALDialogImpl(Gtk::Window& parentWindow, + /** + * Constructor + * @param fileTypes one of FileDialogTypes + * @param title the title of the dialog + * @param key a list of file types from which the user can select + */ + FileExportToOCALDialog(Gtk::Window& parentWindow, FileDialogType fileTypes, const Glib::ustring &title); - virtual ~FileExportToOCALDialogImpl(); + /** + * Destructor. + * Perform any necessary cleanups. + */ + ~FileExportToOCALDialog(); + /** + * Show an SaveAs file selector. + * @return the selected path if user selected one, else NULL + */ bool show(); Glib::ustring getFilename(); Glib::ustring myFilename; + /** + * Change the window title. + */ void change_title(const Glib::ustring& title); - + private: /** @@ -311,7 +173,8 @@ private: * List of known file extensions. */ std::set knownExtensions; -}; + +}; //FileExportToOCAL //######################################################################## @@ -322,25 +185,40 @@ private: /** * Our implementation of the FileExportToOCALPasswordDialog interface. */ -class FileExportToOCALPasswordDialogImpl : public FileExportToOCALPasswordDialog, public FileDialogOCALBase +class FileExportToOCALPasswordDialog : public FileDialogOCALBase { public: - FileExportToOCALPasswordDialogImpl(Gtk::Window& parentWindow, + /** + * Constructor + * @param title the title of the dialog + */ + FileExportToOCALPasswordDialog(Gtk::Window& parentWindow, const Glib::ustring &title); - virtual ~FileExportToOCALPasswordDialogImpl(); + /** + * Destructor. + * Perform any necessary cleanups. + */ + ~FileExportToOCALPasswordDialog(); + + /** + * Show 2 entry to input username and password. + */ bool show(); Glib::ustring getUsername(); Glib::ustring getPassword(); + /** + * Change the window title. + */ + void change_title(const Glib::ustring& title); + Glib::ustring myUsername; Glib::ustring myPassword; - void change_title(const Glib::ustring& title); - private: /** @@ -354,8 +232,7 @@ private: Gtk::HBox userBox; Gtk::HBox passBox; -}; - +}; //FileExportToOCALPassword @@ -390,19 +267,37 @@ private: /** * Our implementation class for the FileImportFromOCALDialog interface.. */ -class FileImportFromOCALDialogImplGtk : public FileImportFromOCALDialog, public FileDialogOCALBase +class FileImportFromOCALDialog : public FileDialogOCALBase { public: - - FileImportFromOCALDialogImplGtk(Gtk::Window& parentWindow, + /** + * Constructor + * @param path the directory where to start searching + * @param fileTypes one of FileDialogTypes + * @param title the title of the dialog + */ + FileImportFromOCALDialog(Gtk::Window& parentWindow, const Glib::ustring &dir, FileDialogType fileTypes, const Glib::ustring &title); - virtual ~FileImportFromOCALDialogImplGtk(); + /** + * Destructor. + * Perform any necessary cleanups. + */ + ~FileImportFromOCALDialog(); + /** + * Show an OpenFile file selector. + * @return the selected path if user selected one, else NULL + */ bool show(); + /** + * Return the 'key' (filetype) of the selection, if any + * @return a pointer to a string if successful (which must + * be later freed with g_free(), else NULL. + */ Inkscape::Extension::Extension *getSelectionType(); Glib::ustring getFilename(); @@ -444,9 +339,8 @@ private: * The extension to use to write this file */ Inkscape::Extension::Extension *extension; -}; - +}; //FileImportFromOCALDialog } //namespace Dialog