Code

C++ification of SPObject continued along with the onset of XML Privatisation. Users...
[inkscape.git] / src / ui / dialog / ocaldialogs.h
index 4af282ee3ac2b048ad6161e317a932901d36f64e..ce26f2148434b6d2ddcf66f12e63c8c057a7225e 100644 (file)
@@ -1,17 +1,16 @@
-#ifndef __OCAL_DIALOG_H__
-#define __OCAL_DIALOG_H__
-/**
- * Defines the FileExportToOCALDialog, FileImportFromOCALDialog and 
- * FileExportToOCALPasswordDialog and their supporting classes.
- *
- * Authors:
+/** @file
+ * @brief Open Clip Art Library integration dialogs
+ */
+/* Authors:
  *   Bruno Dilly <bruno.dilly@gmail.com>
  *   Inkscape Guys
  *
  * Copyright (C) 2007 Bruno Dilly <bruno.dilly@gmail.com>
- *
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
+#ifndef __OCAL_DIALOG_H__
+#define __OCAL_DIALOG_H__
 
 #include <glibmm.h>
 #include <vector>
@@ -45,7 +44,6 @@
 #endif
 
 //Inkscape includes
-#include "prefs-utils.h"
 #include <extension/input.h>
 #include <extension/output.h>
 #include <extension/db.h>
@@ -64,170 +62,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,
-                                     const Glib::ustring &default_key);
-
-
-    /**
-     * 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;
-
-    /**
-     * 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 void setSelectionType( Inkscape::Extension::Extension * key ) = 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
 #########################################################################*/
@@ -240,12 +74,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()
     {}
@@ -253,7 +88,6 @@ public:
 protected:
     void cleanup( bool showConfirmed );
 
-    //Glib::ustring preferenceBase;
     /**
      * What type of 'open' are we? (open, import, place, etc)
      */
@@ -268,86 +102,89 @@ 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,
-                            const Glib::ustring &default_key);
-    
-    virtual ~FileExportToOCALDialogImpl();
-
+                 const Glib::ustring &title);
+*/
+    /**
+     * Destructor.
+     * Perform any necessary cleanups.
+     */
+/*
+    ~FileExportToOCALDialog();
+*/
+    /**
+     * Show an SaveAs file selector.
+     * @return the selected path if user selected one, else NULL
+     */
+/*
     bool show();
 
-    Inkscape::Extension::Extension *getSelectionType();
-    virtual void setSelectionType( Inkscape::Extension::Extension * key );
-
     Glib::ustring getFilename();
 
     Glib::ustring myFilename;
-
+*/
+    /**
+     * Change the window title.
+     */
+/*
     void change_title(const Glib::ustring& title);
-    void updateNameAndExtension();
-
+    
 private:
-
+*/
     /**
      * Fix to allow the user to type the file name
      */
+/*
     Gtk::Entry *fileNameEntry;
-    
-    
-    /**
-     * Allow the specification of the output file type
-     */
-    Gtk::ComboBoxText fileTypeComboBox;
-
-
+*/
     /**
      *  Data mirror of the combo box
      */
+/*
     std::vector<FileType> fileTypes;
 
     // Child widgets
     Gtk::HBox childBox;
     Gtk::VBox checksBox;
     Gtk::HBox fileBox;
-
-    Gtk::CheckButton fileTypeCheckbox;
-
-    /**
-     * Callback for user choose a fileType
-     */
-    void fileTypeChangedCallback();
-
-    /**
-     *  Create a filter menu for this type of dialog
-     */
-    void createFileTypeMenu();
-
-
+*/
     /**
      * The extension to use to write this file
      */
+/*
     Inkscape::Extension::Extension *extension;
-
+*/
     /**
      * Callback for user input into fileNameEntry
      */
+/*
     void fileNameEntryChangedCallback();
-
+*/
     /**
      * List of known file extensions.
      */
+/*
     std::set<Glib::ustring> knownExtensions;
-};
 
+}; //FileExportToOCAL
+*/
 
 //########################################################################
 //# F I L E    E X P O R T   T O   O C A L   P A S S W O R D
@@ -357,30 +194,52 @@ 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:
-
+*/
     /**
      * Fix to allow the user to type the file name
      */
+/*
     Gtk::Entry *usernameEntry;
     Gtk::Entry *passwordEntry;
     
@@ -389,9 +248,8 @@ private:
     Gtk::HBox userBox;
     Gtk::HBox passBox;
     
-};
-
-
+}; //FileExportToOCALPassword
+*/
 
 
 //#########################################################################
@@ -404,36 +262,58 @@ private:
 class FileListViewText : public Gtk::ListViewText
 {
 public:
-    FileListViewText(guint columns_count, SVGPreview& filesPreview, Gtk::Label& description):ListViewText(columns_count)
+    FileListViewText(guint columns_count, SVGPreview& filesPreview, Gtk::Label& description, Gtk::Button& okButton)
+                :ListViewText(columns_count)
     {
         myPreview = &filesPreview;
         myLabel = &description;
+        myButton = &okButton;
     }
     Glib::ustring getFilename();
 protected:
     void on_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column);
+    void on_cursor_changed();
 private:
     Glib::ustring myFilename;
     SVGPreview *myPreview;
     Gtk::Label *myLabel;
+    Gtk::Button *myButton;
 };
 
 /**
  * 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();
@@ -449,6 +329,7 @@ private:
     Gtk::Label *notFoundLabel;
     Gtk::Label *descriptionLabel;
     Gtk::Button *searchButton;
+    Gtk::Button *okButton;
 
     // Child widgets
     Gtk::HBox tagBox;
@@ -474,9 +355,8 @@ private:
      * The extension to use to write this file
      */
     Inkscape::Extension::Extension *extension;
-};
-
 
+}; //FileImportFromOCALDialog
 
 
 } //namespace Dialog