20130313
[gdash.git] / src / framework / selectfileactivity.hpp
blob0ed3eee4b627c70ee9cbceadfcef0e401e7af1a0
1 /*
2 * Copyright (c) 2007-2013, Czirkos Zoltan http://code.google.com/p/gdash/
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef _GD_SELECTFILEAPPLET
18 #define _GD_SELECTFILEAPPLET
20 #include <vector>
21 #include <string>
23 #include "framework/app.hpp"
25 template <typename T> class Command1Param;
27 class SelectFileActivity: public Activity {
28 public:
29 SelectFileActivity(App *app, const char *title, const char *start_dir, const char *glob, bool for_save, const char *defaultname, SmartPtr<Command1Param<std::string> > command_when_successful);
30 ~SelectFileActivity();
32 virtual void keypress_event(KeyCode keycode, int gfxlib_keycode);
33 virtual void redraw_event();
34 virtual void pushed_event();
36 void jump_to_directory(char const *jump_to);
37 void file_selected(char const *filename);
38 void file_selected_do_command();
40 private:
41 SmartPtr<Command1Param<std::string> > command_when_successful;
42 std::string title;
43 bool for_save;
44 int yd;
45 unsigned names_per_page;
46 char **globs;
47 char *directory;
48 char *directory_of_process;
49 int sel;
50 enum FileState {
51 GD_NOT_YET,
52 GD_YES,
53 GD_JUMP,
54 GD_ESCAPE,
55 GD_QUIT,
56 GD_NEW,
58 FileState filestate;
59 std::vector<std::string> files;
60 std::string defaultname;
61 std::string start_dir;
63 void read_dir();
64 void process_enter();
67 #endif