Add option to control the number of file history that is shown

(default 5, range 1 to 10 files)


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4185 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Michael R Sweet 2005-03-24 17:45:50 +00:00
parent ae55d848e9
commit 60b5a637f3
4 changed files with 77 additions and 30 deletions

View File

@ -206,11 +206,18 @@ static void cb_Close1(Fl_Button*, void*) {
settings_window->hide();
}
Fl_Spinner *recent_spinner=(Fl_Spinner *)0;
static void cb_recent_spinner(Fl_Spinner*, void*) {
fluid_prefs.set("recent_files", recent_spinner->value());
load_history();
}
Fl_Double_Window* make_settings_window() {
Fl_Double_Window* w;
{ Fl_Double_Window* o = settings_window = new Fl_Double_Window(300, 190, "GUI Settings");
{ Fl_Double_Window* o = settings_window = new Fl_Double_Window(340, 225, "GUI Settings");
w = o;
{ Fl_Choice* o = scheme_choice = new Fl_Choice(75, 10, 115, 25, "Scheme:");
{ Fl_Choice* o = scheme_choice = new Fl_Choice(116, 10, 115, 25, "Scheme:");
o->down_box(FL_BORDER_BOX);
o->labelfont(1);
o->callback((Fl_Callback*)scheme_cb);
@ -220,10 +227,10 @@ Fl_Double_Window* make_settings_window() {
scheme_choice->value(s);
scheme_cb(0, 0);
}
{ Fl_Group* o = new Fl_Group(75, 45, 215, 100, "Options:\n\n\n\n\n");
{ Fl_Group* o = new Fl_Group(116, 45, 215, 100, "Options:\n\n\n\n\n");
o->labelfont(1);
o->align(FL_ALIGN_LEFT);
{ Fl_Check_Button* o = tooltips_button = new Fl_Check_Button(75, 45, 113, 25, "Show Tooltips");
{ Fl_Check_Button* o = tooltips_button = new Fl_Check_Button(116, 45, 113, 25, "Show Tooltips");
o->down_box(FL_DOWN_BOX);
o->callback((Fl_Callback*)cb_tooltips_button);
int b;
@ -231,21 +238,21 @@ Fl_Double_Window* make_settings_window() {
tooltips_button->value(b);
Fl_Tooltip::enable(b);
}
{ Fl_Check_Button* o = completion_button = new Fl_Check_Button(75, 70, 186, 25, "Show Completion Dialogs");
{ Fl_Check_Button* o = completion_button = new Fl_Check_Button(116, 70, 186, 25, "Show Completion Dialogs");
o->down_box(FL_DOWN_BOX);
o->callback((Fl_Callback*)cb_completion_button);
int b;
fluid_prefs.get("show_completion_dialogs", b, 1);
completion_button->value(b);
}
{ Fl_Check_Button* o = openlast_button = new Fl_Check_Button(75, 95, 215, 25, "Open Previous File on Startup");
{ Fl_Check_Button* o = openlast_button = new Fl_Check_Button(116, 95, 215, 25, "Open Previous File on Startup");
o->down_box(FL_DOWN_BOX);
o->callback((Fl_Callback*)cb_openlast_button);
int b;
fluid_prefs.get("open_previous_file", b, 0);
openlast_button->value(b);
}
{ Fl_Check_Button* o = prevpos_button = new Fl_Check_Button(75, 120, 210, 25, "Remember Window Positions");
{ Fl_Check_Button* o = prevpos_button = new Fl_Check_Button(116, 120, 210, 25, "Remember Window Positions");
o->down_box(FL_DOWN_BOX);
o->callback((Fl_Callback*)cb_prevpos_button);
int b;
@ -254,10 +261,19 @@ Fl_Double_Window* make_settings_window() {
}
o->end();
}
{ Fl_Button* o = new Fl_Button(226, 155, 64, 25, "Close");
{ Fl_Button* o = new Fl_Button(266, 190, 64, 25, "Close");
o->tooltip("Close this dialog.");
o->callback((Fl_Callback*)cb_Close1);
}
{ Fl_Spinner* o = recent_spinner = new Fl_Spinner(116, 155, 40, 25, "# Recent Files:");
o->labelfont(1);
o->callback((Fl_Callback*)cb_recent_spinner);
o->when(FL_WHEN_CHANGED);
int c;
fluid_prefs.get("recent_files", c, 5);
recent_spinner->maximum(10);
recent_spinner->value(c);
}
o->end();
}
return w;

View File

@ -37,6 +37,9 @@ decl {\#include <FL/Fl_Text_Buffer.H>} {public
decl {\#include <FL/Fl_Text_Display.H>} {public
}
decl {extern void load_history();} {selected public
}
Function {make_project_window()} {open
} {
Fl_Window project_window {
@ -135,19 +138,19 @@ decl {extern Fl_Preferences fluid_prefs;} {public
decl {Fl_Text_Buffer *shell_run_buffer;} {public
}
decl {void scheme_cb(Fl_Choice *, void *);} {selected public
decl {void scheme_cb(Fl_Choice *, void *);} {public
}
Function {make_settings_window()} {open
} {
Fl_Window settings_window {
label {GUI Settings} open
xywh {326 155 300 190} type Double visible
xywh {326 145 340 225} type Double visible
} {
Fl_Choice scheme_choice {
label {Scheme:}
callback scheme_cb
xywh {75 10 115 25} down_box BORDER_BOX labelfont 1
xywh {116 10 115 25} down_box BORDER_BOX labelfont 1
code0 {int s;}
code1 {fluid_prefs.get("scheme", s, 0);}
code2 {scheme_choice->value(s);}
@ -172,14 +175,14 @@ Function {make_settings_window()} {open
}
xywh {75 45 215 100} labelfont 1 align 4
} open
xywh {116 45 215 100} labelfont 1 align 4
} {
Fl_Check_Button tooltips_button {
label {Show Tooltips}
callback {Fl_Tooltip::enable(tooltips_button->value());
fluid_prefs.set("show_tooltips", tooltips_button->value());}
xywh {75 45 113 25} down_box DOWN_BOX
xywh {116 45 113 25} down_box DOWN_BOX
code0 {int b;}
code1 {fluid_prefs.get("show_tooltips", b, 1);}
code2 {tooltips_button->value(b);}
@ -188,7 +191,7 @@ fluid_prefs.set("show_tooltips", tooltips_button->value());}
Fl_Check_Button completion_button {
label {Show Completion Dialogs}
callback {fluid_prefs.set("show_completion_dialogs", completion_button->value());}
xywh {75 70 186 25} down_box DOWN_BOX
xywh {116 70 186 25} down_box DOWN_BOX
code0 {int b;}
code1 {fluid_prefs.get("show_completion_dialogs", b, 1);}
code2 {completion_button->value(b);}
@ -196,7 +199,7 @@ fluid_prefs.set("show_tooltips", tooltips_button->value());}
Fl_Check_Button openlast_button {
label {Open Previous File on Startup}
callback {fluid_prefs.set("open_previous_file", openlast_button->value());}
xywh {75 95 215 25} down_box DOWN_BOX
xywh {116 95 215 25} down_box DOWN_BOX
code0 {int b;}
code1 {fluid_prefs.get("open_previous_file", b, 0);}
code2 {openlast_button->value(b);}
@ -204,7 +207,7 @@ fluid_prefs.set("show_tooltips", tooltips_button->value());}
Fl_Check_Button prevpos_button {
label {Remember Window Positions}
callback {fluid_prefs.set("prev_window_pos", prevpos_button->value());}
xywh {75 120 210 25} down_box DOWN_BOX
xywh {116 120 210 25} down_box DOWN_BOX
code0 {int b;}
code1 {fluid_prefs.get("prev_window_pos", b, 1);}
code2 {prevpos_button->value(b);}
@ -213,7 +216,17 @@ fluid_prefs.set("show_tooltips", tooltips_button->value());}
Fl_Button {} {
label Close
callback {settings_window->hide();}
tooltip {Close this dialog.} xywh {226 155 64 25}
tooltip {Close this dialog.} xywh {266 190 64 25}
}
Fl_Spinner recent_spinner {
label {\# Recent Files:}
callback {fluid_prefs.set("recent_files", recent_spinner->value());
load_history();}
xywh {116 155 40 25} labelfont 1 when 1
code0 {int c;}
code1 {fluid_prefs.get("recent_files", c, 5);}
code2 {recent_spinner->maximum(10);}
code3 {recent_spinner->value(c);}
}
}
}

View File

@ -32,6 +32,7 @@
#include <FL/Fl.H>
#include <FL/Fl_Text_Buffer.H>
#include <FL/Fl_Text_Display.H>
extern void load_history();
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Preferences.H>
#include <FL/Fl_Tooltip.H>
@ -70,6 +71,8 @@ extern Fl_Check_Button *tooltips_button;
extern Fl_Check_Button *completion_button;
extern Fl_Check_Button *openlast_button;
extern Fl_Check_Button *prevpos_button;
#include <FL/Fl_Spinner.H>
extern Fl_Spinner *recent_spinner;
Fl_Double_Window* make_settings_window();
extern Fl_Menu_Item menu_scheme_choice[];
extern Fl_Double_Window *shell_window;

View File

@ -1470,8 +1470,13 @@ void make_main_window() {
// Load file history from preferences...
void load_history() {
int i; // Looping var
int max_files;
for (i = 0; i < 10; i ++) {
fluid_prefs.get("recent_files", max_files, 5);
if (max_files > 10) max_files = 10;
for (i = 0; i < max_files; i ++) {
fluid_prefs.get( Fl_Preferences::Name("file%d", i), absolute_history[i], "", sizeof(absolute_history[i]));
if (absolute_history[i][0]) {
// Make a relative version of the filename for the menu...
@ -1479,10 +1484,12 @@ void load_history() {
absolute_history[i]);
Main_Menu[i + HISTORY_ITEM].flags = 0;
} else {
if (i) Main_Menu[i + HISTORY_ITEM - 1].flags |= FL_MENU_DIVIDER;
Main_Menu[i + HISTORY_ITEM].hide();
}
} else break;
}
for (; i < 10; i ++) {
if (i) Main_Menu[i + HISTORY_ITEM - 1].flags |= FL_MENU_DIVIDER;
Main_Menu[i + HISTORY_ITEM].hide();
}
}
@ -1490,10 +1497,15 @@ void load_history() {
void update_history(const char *flname) {
int i; // Looping var
char absolute[1024];
int max_files;
fluid_prefs.get("recent_files", max_files, 5);
if (max_files > 10) max_files = 10;
fl_filename_absolute(absolute, sizeof(absolute), flname);
for (i = 0; i < 10; i ++)
for (i = 0; i < max_files; i ++)
#if defined(WIN32) || defined(__APPLE__)
if (!strcasecmp(absolute, absolute_history[i])) break;
#else
@ -1502,7 +1514,7 @@ void update_history(const char *flname) {
if (i == 0) return;
if (i >= 10) i = 9;
if (i >= max_files) i = max_files - 1;
// Move the other flnames down in the list...
memmove(absolute_history + 1, absolute_history,
@ -1517,13 +1529,16 @@ void update_history(const char *flname) {
absolute_history[0]);
// Update the menu items as needed...
for (i = 0; i < 10; i ++) {
for (i = 0; i < max_files; i ++) {
fluid_prefs.set( Fl_Preferences::Name("file%d", i), absolute_history[i]);
if (absolute_history[i][0]) Main_Menu[i + HISTORY_ITEM].flags = 0;
else {
if (i) Main_Menu[i + HISTORY_ITEM - 1].flags |= FL_MENU_DIVIDER;
Main_Menu[i + HISTORY_ITEM].hide();
}
else break;
}
for (; i < 10; i ++) {
fluid_prefs.set( Fl_Preferences::Name("file%d", i), "");
if (i) Main_Menu[i + HISTORY_ITEM - 1].flags |= FL_MENU_DIVIDER;
Main_Menu[i + HISTORY_ITEM].hide();
}
}