ocaldialogs.cpp revision 0a902c5f64552725c541ef2904815baaa2983d42
/**
* Implementation of the ocal dialog interfaces defined in ocaldialog.h
*
* Authors:
* Bruno Dilly
* Other dudes from The Inkscape Organization
*
* Copyright (C) 2007 Bruno Dilly <bruno.dilly@gmail.com>
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "ocaldialogs.h"
#include "filedialogimpl-gtkmm.h"
#include "interface.h"
#include "gc-core.h"
#include <dialogs/dialog-events.h>
namespace Inkscape
{
namespace UI
{
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 *dialog = new FileExportToOCALDialogImpl(parentWindow, fileTypes, title, default_key);
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 *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 *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
*/
{
if (!fileNameEntry)
return;
}
/**
* Callback for fileNameEntry widget
*/
{
return;
}
{
{
// FIXME: would be nice to grey them out instead of not listing them
if (omod->deactivated()) continue;
}
//#Let user choose
fileTypeChangedCallback(); //call at least once to set the filter
}
/**
* Constructor
*/
{
/*
* Start Taking the vertical Box and putting a Label
* and a Entry to take the filename
* Later put the extension selection and checkbox (?)
*/
/* Initalize to Autodetect */
/* No filename to start out with */
myFilename = "";
/* Set our dialog type (save, export, etc...)*/
//###### Do we want the .xxx extension automatically added?
"append_extension", 1) );
//Let's do some customization
//g_message("Found %d entry widgets\n", entries.size());
{
//Catch when user hits [return] on the text field
fileNameEntry = entries[0];
}
//Let's do more customization
//g_message("Found %d expander widgets\n", expanders.size());
{
//Always show the file list
expander->set_expanded(true);
}
}
/**
* Destructor
*/
{
}
/**
* Show this dialog modally. Return true if user hits [OK]
*/
bool
{
hide();
if (b == Gtk::RESPONSE_OK)
{
return TRUE;
}
else
{
return FALSE;
}
}
/**
* Get the file extension type that was selected by the user. Valid after an [OK]
*/
{
return extension;
}
{
// If no pointer to extension is passed in, look up based on filename extension.
if ( !key ) {
// Not quite UTF-8 here.
Inkscape::Extension::Output *ext = dynamic_cast<Inkscape::Extension::Output*>(fileTypes[i].extension);
}
}
}
}
// Ensure the proper entry in the combo box is selected.
if ( key ) {
if ( extensionID ) {
if ( ext ) {
if ( i != oldSel ) {
}
break;
}
}
}
}
}
}
/**
* Get the file name chosen by the user. Valid after an [OK]
*/
{
return myFilename;
}
void
{
}
{
// Pick up any changes the user has typed in.
Inkscape::Extension::Output* newOut = extension ? dynamic_cast<Inkscape::Extension::Output*>(extension) : 0;
try {
bool appendExtension = true;
if ( (trail == ".")
} else {
appendExtension = false;
}
}
if (appendExtension) {
}
} catch ( Glib::ConvertError& e ) {
// ignore
}
}
}
//########################################################################
//# F I L E E X P O R T T O O C A L P A S S W O R D
//########################################################################
/**
* Constructor
*/
{
/*
* Start Taking the vertical Box and putting 2 Labels
* and 2 Entries to take the username and password
*/
/* No username and password to start out with */
myUsername = "";
myPassword = "";
//usernameEntry->set_alignment(1);
passwordEntry->set_visibility(false);
//passwordEntry->set_alignment(1);
passwordEntry->set_activates_default(true);
}
/**
* Destructor
*/
{
}
/**
* Show this dialog modally. Return true if user hits [OK]
*/
bool
{
hide();
if (b == Gtk::RESPONSE_OK)
{
return TRUE;
}
else
{
return FALSE;
}
}
/**
* Get the username. Valid after an [OK]
*/
{
return myUsername;
}
/**
* Get the password. Valid after an [OK]
*/
{
return myPassword;
}
void
{
}
//#########################################################################
//### F I L E I M P O R T F R O M O C A L
//#########################################################################
/*
* Callback for row activated
*/
void FileListViewText::on_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column)
{
// create file path
#ifdef WITH_GNOME_VFS
//get file url
//Glib::ustring fileUrl = "dav://"; //dav url
//fileUrl.append(prefs_get_string_attribute("options.ocalurl", "str"));
//fileUrl.append("/dav.php/");
//fileUrl.append(get_text(posArray[0], 3)); //author dir
//fileUrl.append("/");
//fileUrl.append(get_text(posArray[0], 2)); //filename
// verifies if the file wasn't previously downloaded
if(gnome_vfs_open(&to_handle, myFilename.c_str(), GNOME_VFS_OPEN_READ) == GNOME_VFS_ERROR_NOT_FOUND)
{
// open the temp file to receive
if (result == GNOME_VFS_ERROR_NOT_FOUND){
result = gnome_vfs_create (&to_handle, myFilename.c_str(), GNOME_VFS_OPEN_WRITE, FALSE, GNOME_VFS_PERM_USER_ALL);
}
if (result != GNOME_VFS_OK) {
return;
}
if (result != GNOME_VFS_OK) {
g_warning("Could not find the file in Open Clip Art Library.");
return;
}
// copy the file
while (1) {
break;
}
if (result != GNOME_VFS_OK) {
return;
}
if (result != GNOME_VFS_OK) {
return;
}
if (bytes_read != bytes_written){
g_warning("Bytes read not equal to bytes written");
return;
}
}
}
else
{
}
#endif
}
/*
* Returns the selected filename
*/
{
return myFilename;
}
/**
* Callback for user input into searchTagEntry
*/
{
if (!searchTagEntry)
return;
notFoundLabel->hide();
// create the ocal uri to get rss feed
#ifdef WITH_GNOME_VFS
// get the rss feed
// create the temp file name
// open the temp file to receive
if (result == GNOME_VFS_ERROR_NOT_FOUND){
result = gnome_vfs_create (&to_handle, fileName.c_str(), GNOME_VFS_OPEN_WRITE, FALSE, GNOME_VFS_PERM_USER_ALL);
}
if (result != GNOME_VFS_OK) {
return;
}
// open the rss feed
if (result != GNOME_VFS_OK) {
sp_ui_error_dialog(_("Failed to receive the Open Clip Art Library RSS feed. Verify if the server name is correct in Configuration->Misc (e.g.: openclipart.org)"));
return;
}
// copy the file
while (1) {
break;
}
if (result != GNOME_VFS_OK) {
return;
}
if (result != GNOME_VFS_OK) {
return;
}
if (bytes_read != bytes_written){
g_warning("Bytes read not equal to bytes written");
return;
}
}
// create the resulting xml document tree
// this initialize the library and test mistakes between compiled and shared library used
return;
}
// get the root element node
// clear the fileslist
filesList->clear_items();
filesList->set_sensitive(false);
// print all xml the element names
{
notFoundLabel->show();
filesList->set_sensitive(false);
}
else
filesList->set_sensitive(true);
// free the document
// free the global variables that may have been allocated by the parser
return;
#endif
}
/**
* Prints the names of the all the xml elements
* that are siblings or children of a given xml node
*/
{
// get itens information
{
{
}
#ifdef WITH_GNOME_VFS
{
}
{
}
{
}
#endif
}
}
}
/**
* Constructor. Not called directly. Use the factory.
*/
{
// Initalize to Autodetect
// No filename to start out with
filesPreview = new SVGPreview();
filesList->set_sensitive(false);
// add the listview inside a ScrolledWindow
// only show the scrollbars when they are necessary:
//Let's do some customization
{
//Catch when user hits [return] on the text field
searchTagEntry = entries[0];
}
notFoundLabel->hide();
}
/**
* Destructor
*/
{
}
/**
* Show this dialog modally. Return true if user hits [OK]
*/
bool
{
hide();
if (b == Gtk::RESPONSE_OK)
{
return TRUE;
}
else
{
return FALSE;
}
}
/**
* Get the file extension type that was selected by the user. Valid after an [OK]
*/
{
return extension;
}
/**
* Get the file name chosen by the user. Valid after an [OK]
*/
{
return filesList->getFilename();
}
} //namespace Dialog
} //namespace UI
} //namespace Inkscape
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :