File: FileOpenDialog.h

package info (click to toggle)
granule 1.4.0-7-9
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 5,236 kB
  • ctags: 2,144
  • sloc: cpp: 16,030; makefile: 353
file content (149 lines) | stat: -rw-r--r-- 3,255 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
// -*- c++ -*-
//------------------------------------------------------------------------------
//                               FileOpenDialog.h
//------------------------------------------------------------------------------
// $Id: FileOpenDialog.h,v 1.1 2007/12/02 00:31:24 vlg Exp $
//------------------------------------------------------------------------------
//  Copyright (c) 2006 by Vladislav Grinchenko
//
//  This program is free software; you can redistribute it and/or
//  modify it under the terms of the GNU General Public License
//  as published by the Free Software Foundation; either version
//  2 of the License, or (at your option) any later version.
//------------------------------------------------------------------------------
#ifndef FILE_OPEN_DIALOG_H
#define FILE_OPEN_DIALOG_H

#include <vector>
#include <gtkmm/filechooserdialog.h>
#include <gtkmm/fileselection.h>

#include "Granule-main.h"
#include "Granule.h"

class FileOpenDialog
{
public:
	FileOpenDialog (const Glib::ustring& title_,
					Gtk::Widget*         parent_,
					const Glib::ustring& filter_name_    = "",
					const Glib::ustring& filter_pattern_ = "");

	~FileOpenDialog ();

	/** Sets the current name in the file selector, 
	 * as if entered by the user.
	 */
	void set_current_name (const Glib::ustring& name_);

	/// Return true if path can be set
	bool set_current_folder (const Glib::ustring& path_);

	/** Sets filename as the current filename for the file chooser, 
	 *  by changing to the file's parent folder and actually selecting 
	 *  the file in list.
	 */
	bool set_filename (const Glib::ustring& fname_);

	/// Get the name selected
	Glib::ustring get_filename () const;

	/** For multi-entries
	 */
	void set_select_multiple (bool v_ = true);
	std::vector<Glib::ustring> get_filenames () const;

	int  run  ();
	void show ();
	void hide ();

private:

#ifdef OBSOLETE
	Gtk::FileSelection*     m_dialog;
#else
	Gtk::FileChooserDialog* m_dialog;
#endif
	bool m_multi_choice;		// If true, allows to select multiple items
};

//------------------------------------------------------------------------------
// Inline functions
//------------------------------------------------------------------------------
inline
FileOpenDialog::
~FileOpenDialog ()
{
	if (m_dialog) {
		delete m_dialog;
		m_dialog = NULL;
	}
}

inline bool 
FileOpenDialog::
set_current_folder (const Glib::ustring& path_)
{
	return m_dialog->set_current_folder (path_);

}

inline bool
FileOpenDialog::
set_filename (const Glib::ustring& fname_)
{
	return m_dialog->set_filename (fname_);
}

inline Glib::ustring 
FileOpenDialog::
get_filename () const
{
	return m_dialog->get_filename ();
}

inline void
FileOpenDialog::
set_current_name (const Glib::ustring& name_)
{
#ifdef OBSOLETE
	m_dialog->set_filename (name_);
#else
	m_dialog->set_current_name (name_);
#endif
}

inline void 
FileOpenDialog::
set_select_multiple (bool v_) 
{ 
#ifdef OBSOLETE
	m_dialog->set_select_multiple (v_);
#else
	m_dialog->set_select_multiple (v_);
#endif
}

inline int
FileOpenDialog::
run ()
{
	return (m_dialog->run ());
}
	
inline void
FileOpenDialog::
hide ()
{
	m_dialog->hide ();
}

inline void
FileOpenDialog::
show ()
{
	m_dialog->show ();
}


#endif /* FILE_OPEN_DIALOG_H */