summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8e2a7ea)
raw | patch | inline | side by side (parent: 8e2a7ea)
author | joncruz <joncruz@users.sourceforge.net> | |
Mon, 5 Mar 2007 08:41:37 +0000 (08:41 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Mon, 5 Mar 2007 08:41:37 +0000 (08:41 +0000) |
src/ui/dialog/filedialog.cpp | patch | blob | history |
index 454a356c7aa1faaa28827c36d632e70471b7f39c..0cdd49477ef32b9cf9474333e3ac8c541d698080 100644 (file)
/**
*
*/
- FileDialogBase(const Glib::ustring &title) :
- Gtk::FileChooserDialog(title)
- {
- }
+ FileDialogBase(const Glib::ustring &title, FileDialogType type, gchar const* preferenceBase) :
+ Gtk::FileChooserDialog(title),
+ preferenceBase(preferenceBase ? preferenceBase : "unknown"),
+ dialogType(type)
+ {
+ internalSetup();
+ }
/**
*
*/
FileDialogBase(const Glib::ustring &title,
- Gtk::FileChooserAction dialogType) :
- Gtk::FileChooserDialog(title, dialogType)
- {
- }
+ Gtk::FileChooserAction dialogType, FileDialogType type, gchar const* preferenceBase) :
+ Gtk::FileChooserDialog(title, dialogType),
+ preferenceBase(preferenceBase ? preferenceBase : "unknown"),
+ dialogType(type)
+ {
+ internalSetup();
+ }
/**
*
virtual ~FileDialogBase()
{}
+protected:
+ void cleanup( bool showConfirmed );
+
+ Glib::ustring preferenceBase;
+ /**
+ * What type of 'open' are we? (open, import, place, etc)
+ */
+ FileDialogType dialogType;
+
+ /**
+ * Our svg preview widget
+ */
+ SVGPreview svgPreview;
+
+ //# Child widgets
+ Gtk::CheckButton previewCheckbox;
+
+private:
+ void internalSetup();
+
+ /**
+ * Callback for user changing preview checkbox
+ */
+ void _previewEnabledCB();
+
+ /**
+ * Callback for seeing if the preview needs to be drawn
+ */
+ void _updatePreviewCallback();
};
+void FileDialogBase::internalSetup()
+{
+ bool enablePreview = (bool)prefs_get_int_attribute( preferenceBase.c_str(), "enable_preview", 1 );
+ previewCheckbox.set_label( Glib::ustring(_("Enable Preview")) );
+ previewCheckbox.set_active( enablePreview );
+
+ previewCheckbox.signal_toggled().connect(
+ sigc::mem_fun(*this, &FileDialogBase::_previewEnabledCB) );
+
+ //Catch selection-changed events, so we can adjust the text widget
+ signal_update_preview().connect(
+ sigc::mem_fun(*this, &FileDialogBase::_updatePreviewCallback) );
+
+ //###### Add a preview widget
+ set_preview_widget(svgPreview);
+ set_preview_widget_active( enablePreview );
+ set_use_preview_label (false);
+
+}
+
+void FileDialogBase::cleanup( bool showConfirmed )
+{
+ if ( showConfirmed ) {
+ prefs_set_int_attribute( preferenceBase.c_str(), "enable_preview", previewCheckbox.get_active() );
+ }
+}
+
+void FileDialogBase::_previewEnabledCB()
+{
+ bool enabled = previewCheckbox.get_active();
+ set_preview_widget_active(enabled);
+ if ( enabled ) {
+ _updatePreviewCallback();
+ }
+}
+
+
+/**
+ * Callback for checking if the preview needs to be redrawn
+ */
+void FileDialogBase::_updatePreviewCallback()
+{
+ Glib::ustring fileName = get_preview_filename();
+#ifdef WITH_GNOME_VFS
+ if (fileName.length() < 1)
+ fileName = get_preview_uri();
+#endif
+
+ if (fileName.length() < 1)
+ return;
+
+ svgPreview.set(fileName, dialogType);
+// bool retval = svgPreview.set(fileName, dialogType);
+// set_preview_widget_active(retval);
+}
+
/*#########################################################################
### F I L E O P E N
std::vector<Glib::ustring> getFilenames ();
-protected:
-
-
-
private:
-
- /**
- * What type of 'open' are we? (open, import, place, etc)
- */
- FileDialogType dialogType;
-
- /**
- * Our svg preview widget
- */
- SVGPreview svgPreview;
-
- /**
- * Callback for seeing if the preview needs to be drawn
- */
- void updatePreviewCallback();
-
/**
* Create a filter menu for this type of dialog
*/
-/**
- * Callback for checking if the preview needs to be redrawn
- */
-void FileOpenDialogImpl::updatePreviewCallback()
-{
- Glib::ustring fileName = get_preview_filename();
-#ifdef WITH_GNOME_VFS
- if (fileName.length() < 1)
- fileName = get_preview_uri();
-#endif
- if (fileName.length() < 1)
- return;
- svgPreview.set(fileName, dialogType);
-}
-
-
-
-
-
void FileOpenDialogImpl::createFilterMenu()
FileOpenDialogImpl::FileOpenDialogImpl(const Glib::ustring &dir,
FileDialogType fileTypes,
const Glib::ustring &title) :
- FileDialogBase(title)
+ FileDialogBase(title, fileTypes, "dialogs.open")
{
set_current_folder(udir.c_str());
}
+
+ set_extra_widget( previewCheckbox );
+
+
//###### Add the file types menu
createFilterMenu();
- //###### Add a preview widget
- set_preview_widget(svgPreview);
- set_preview_widget_active(true);
- set_use_preview_label (false);
-
- //Catch selection-changed events, so we can adjust the text widget
- signal_update_preview().connect(
- sigc::mem_fun(*this, &FileOpenDialogImpl::updatePreviewCallback) );
add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
set_default(*add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK));
-
}
if (myFilename.length() < 1)
myFilename = get_uri();
#endif
+ cleanup( true );
return TRUE;
}
else
{
+ cleanup( false );
return FALSE;
}
}
private:
- /**
- * What type of 'open' are we? (save, export, etc)
- */
- FileDialogType dialogType;
-
- /**
- * Our svg preview widget
- */
- SVGPreview svgPreview;
-
/**
* Fix to allow the user to type the file name
*/
Gtk::Entry *fileNameEntry;
- /**
- * Callback for seeing if the preview needs to be drawn
- */
- void updatePreviewCallback();
-
-
-
- /**
- * Allow the specification of the output file type
- */
- Gtk::HBox fileTypeBox;
/**
* Allow the specification of the output file type
std::vector<FileType> fileTypes;
//# Child widgets
+ Gtk::HBox childBox;
+ Gtk::VBox checksBox;
+
Gtk::CheckButton fileTypeCheckbox;
/**
-
-
-/**
- * Callback for checking if the preview needs to be redrawn
- */
-void FileSaveDialogImpl::updatePreviewCallback()
-{
- Glib::ustring fileName = get_preview_filename();
-#ifdef WITH_GNOME_VFS
- if (fileName.length() < 1)
- fileName = get_preview_uri();
-#endif
- if (!fileName.c_str())
- return;
- bool retval = svgPreview.set(fileName, dialogType);
- set_preview_widget_active(retval);
-}
-
-
-
/**
* Callback for fileNameEntry widget
*/
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &default_key) :
- FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE)
+ FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.save_as")
{
/* One file at a time */
set_select_multiple(false);
fileTypeCheckbox.set_active( (bool)prefs_get_int_attribute("dialogs.save_as",
"append_extension", 1) );
- fileTypeBox.pack_start(fileTypeCheckbox);
createFileTypeMenu();
fileTypeComboBox.set_size_request(200,40);
fileTypeComboBox.signal_changed().connect(
sigc::mem_fun(*this, &FileSaveDialogImpl::fileTypeChangedCallback) );
- fileTypeBox.pack_start(fileTypeComboBox);
-
- set_extra_widget(fileTypeBox);
- //get_vbox()->pack_start(fileTypeBox, false, false, 0);
- //get_vbox()->reorder_child(fileTypeBox, 2);
- //###### Add a preview widget
- set_preview_widget(svgPreview);
- set_preview_widget_active(true);
- set_use_preview_label (false);
-
- //Catch selection-changed events, so we can adjust the text widget
- signal_update_preview().connect(
- sigc::mem_fun(*this, &FileSaveDialogImpl::updatePreviewCallback) );
+ childBox.pack_start( checksBox );
+ childBox.pack_end( fileTypeComboBox );
+ checksBox.pack_start( fileTypeCheckbox );
+ checksBox.pack_start( previewCheckbox );
+ set_extra_widget( childBox );
//Let's do some customization
fileNameEntry = NULL;
prefs_set_string_attribute("dialogs.save_as", "default",
( extension != NULL ? extension->get_id() : "" ));
+ cleanup( true );
+
return TRUE;
}
else
{
+ cleanup( false );
+
return FALSE;
}
}
private:
- /**
- * What type of 'open' are we? (save, export, etc)
- */
- FileDialogType dialogType;
-
- /**
- * Our svg preview widget
- */
- SVGPreview svgPreview;
-
/**
* Fix to allow the user to type the file name
*/
Gtk::Entry *fileNameEntry;
- /**
- * Callback for seeing if the preview needs to be drawn
- */
- void updatePreviewCallback();
-
//##########################################
//# EXTRA WIDGET -- SOURCE SIDE
//##########################################
-/**
- * Callback for checking if the preview needs to be redrawn
- */
-void FileExportDialogImpl::updatePreviewCallback()
-{
- Glib::ustring fileName = get_preview_filename();
-#ifdef WITH_GNOME_VFS
- if (fileName.length() < 1)
- fileName = get_preview_uri();
-#endif
- if (!fileName.c_str())
- return;
- bool retval = svgPreview.set(fileName, dialogType);
- set_preview_widget_active(retval);
-}
-
-
-
/**
* Callback for fileNameEntry widget
*/
FileDialogType fileTypes,
const Glib::ustring &title,
const Glib::ustring &default_key) :
- FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE),
+ FileDialogBase(title, Gtk::FILE_CHOOSER_ACTION_SAVE, fileTypes, "dialogs.export"),
sourceX0Spinner("X0", _("Left edge of source")),
sourceY0Spinner("Y0", _("Top edge of source")),
sourceX1Spinner("X1", _("Right edge of source")),
- //###### PREVIEW WIDGET
- set_preview_widget(svgPreview);
- set_preview_widget_active(true);
- set_use_preview_label (false);
-
- //Catch selection-changed events, so we can adjust the text widget
- signal_update_preview().connect(
- sigc::mem_fun(*this, &FileExportDialogImpl::updatePreviewCallback) );
-
-
//Let's do some customization
fileNameEntry = NULL;
Gtk::Container *cont = get_toplevel();