#include <list>
#include <vector>
-#include <gtk/gtkwidget.h>
-#include <gtk/gtkwindow.h>
-#include <gtk/gtkfilechooser.h>
-#include <gtk/gtkfilechooserdialog.h>
-#include <gtk/gtkstock.h>
+#include <gtk/gtk.h>
+#include <uilib/uilib.h>
#include "string/string.h"
#include "stream/stringstream.h"
filetype_copy_t( const filetype_pair_t& other )
: m_moduleName( other.m_moduleName ), m_name( other.m_type.name ), m_pattern( other.m_type.pattern ){
}
- CopiedString m_moduleName;
- CopiedString m_name;
- CopiedString m_pattern;
+ std::string m_moduleName;
+ std::string m_name;
+ std::string m_pattern;
};
typedef std::list<filetype_copy_t> Types;
{
const FileTypeList& m_types;
public:
-std::vector<CopiedString> m_filters;
-std::vector<CopiedString> m_masks;
+std::vector<std::string> m_filters;
+std::vector<std::string> m_masks;
GTKMasks( const FileTypeList& types ) : m_types( types ){
m_masks.reserve( m_types.size() );
}
filetype_pair_t GetTypeForGTKMask( const char *mask ) const {
- std::vector<CopiedString>::const_iterator j = m_masks.begin();
+ std::vector<std::string>::const_iterator j = m_masks.begin();
for ( FileTypeList::const_iterator i = m_types.begin(); i != m_types.end(); ++i, ++j )
{
if ( string_equal( ( *j ).c_str(), mask ) ) {
if ( path != 0 && !string_empty( path ) ) {
ASSERT_MESSAGE( path_is_absolute( path ), "file_dialog_show: path not absolute: " << makeQuoted( path ) );
- Array<char> new_path( strlen( path ) + 1 );
+ std::string new_path(path);
+ std::replace(new_path.begin(), new_path.end(), '/', G_DIR_SEPARATOR);
+ if ( !new_path.empty() && new_path.back() == G_DIR_SEPARATOR )
+ new_path.pop_back();
- // copy path, replacing dir separators as appropriate
- Array<char>::iterator w = new_path.begin();
- for ( const char* r = path; *r != '\0'; ++r )
- {
- *w++ = ( *r == '/' ) ? G_DIR_SEPARATOR : *r;
- }
- // remove separator from end of path if required
- if ( *( w - 1 ) == G_DIR_SEPARATOR ) {
- --w;
- }
- // terminate string
- *w = '\0';
-
- gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( dialog ), new_path.data() );
+ gtk_file_chooser_set_current_folder( GTK_FILE_CHOOSER( dialog ), new_path.c_str() );
}
// we should add all important paths as shortcut folder...
return g_file_dialog_file;
}
-char* dir_dialog( GtkWidget* parent, const char* title, const char* path ){
+char* dir_dialog( ui::Widget parent, const char* title, const char* path ){
GtkWidget* dialog = gtk_file_chooser_dialog_new( title,
GTK_WINDOW( parent ),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
return filename;
}
-const char* file_dialog( GtkWidget* parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
+const char* file_dialog( ui::Widget parent, bool open, const char* title, const char* path, const char* pattern, bool want_load, bool want_import, bool want_save ){
for (;; )
{
const char* file = file_dialog_show( parent, open, title, path, pattern, want_load, want_import, want_save );
if ( open
- || file == 0
+ || file == nullptr
|| !file_exists( file )
- || gtk_MessageBox( parent, "The file specified already exists.\nDo you want to replace it?", title, eMB_NOYES, eMB_ICONQUESTION ) == eIDYES ) {
+ || parent.alert("The file specified already exists.\nDo you want to replace it?", title, ui::alert_type::NOYES, ui::alert_icon::QUESTION ) == ui::alert_response::YES ) {
return file;
}
}