Updates from Fred Bouvier:
You'll find attached the modified fgadmin that takes care of 'Objects' and 'Terrain' if they exist. I also implemented the 'Check all' / 'Check none' feature you suggested several months ago.
This commit is contained in:
parent
ff0d55fd4a
commit
2c0e18bdd0
4 changed files with 293 additions and 173 deletions
utils/fgadmin/src
|
@ -1,4 +1,4 @@
|
||||||
// generated by Fast Light User Interface Designer (fluid) version 1.0104
|
// generated by Fast Light User Interface Designer (fluid) version 1.0106
|
||||||
|
|
||||||
#include "fgadmin.h"
|
#include "fgadmin.h"
|
||||||
#include <FL/fl_ask.H>
|
#include <FL/fl_ask.H>
|
||||||
|
@ -14,7 +14,7 @@ inline void FGAdminUI::cb_quit_b_i(Fl_Button*, void*) {
|
||||||
quit();
|
quit();
|
||||||
}
|
}
|
||||||
void FGAdminUI::cb_quit_b(Fl_Button* o, void* v) {
|
void FGAdminUI::cb_quit_b(Fl_Button* o, void* v) {
|
||||||
((FGAdminUI*)(o->parent()->user_data()))->cb_quit_b_i(o,v);
|
((FGAdminUI*)(o->parent()->parent()->user_data()))->cb_quit_b_i(o,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FGAdminUI::cb_source_b_i(Fl_Button*, void*) {
|
inline void FGAdminUI::cb_source_b_i(Fl_Button*, void*) {
|
||||||
|
@ -22,7 +22,28 @@ inline void FGAdminUI::cb_source_b_i(Fl_Button*, void*) {
|
||||||
refresh_lists();
|
refresh_lists();
|
||||||
}
|
}
|
||||||
void FGAdminUI::cb_source_b(Fl_Button* o, void* v) {
|
void FGAdminUI::cb_source_b(Fl_Button* o, void* v) {
|
||||||
((FGAdminUI*)(o->parent()->user_data()))->cb_source_b_i(o,v);
|
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_source_b_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FGAdminUI::cb_install_b_i(Fl_Button*, void*) {
|
||||||
|
install_selected();
|
||||||
|
}
|
||||||
|
void FGAdminUI::cb_install_b(Fl_Button* o, void* v) {
|
||||||
|
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_install_b_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FGAdminUI::cb_source_sel_all_i(Fl_Button*, void*) {
|
||||||
|
install_box->check_all();
|
||||||
|
}
|
||||||
|
void FGAdminUI::cb_source_sel_all(Fl_Button* o, void* v) {
|
||||||
|
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_source_sel_all_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FGAdminUI::cb_source_desel_all_i(Fl_Button*, void*) {
|
||||||
|
install_box->check_none();
|
||||||
|
}
|
||||||
|
void FGAdminUI::cb_source_desel_all(Fl_Button* o, void* v) {
|
||||||
|
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_source_desel_all_i(o,v);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FGAdminUI::cb_dest_b_i(Fl_Button*, void*) {
|
inline void FGAdminUI::cb_dest_b_i(Fl_Button*, void*) {
|
||||||
|
@ -30,21 +51,28 @@ inline void FGAdminUI::cb_dest_b_i(Fl_Button*, void*) {
|
||||||
refresh_lists();
|
refresh_lists();
|
||||||
}
|
}
|
||||||
void FGAdminUI::cb_dest_b(Fl_Button* o, void* v) {
|
void FGAdminUI::cb_dest_b(Fl_Button* o, void* v) {
|
||||||
((FGAdminUI*)(o->parent()->user_data()))->cb_dest_b_i(o,v);
|
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_dest_b_i(o,v);
|
||||||
}
|
|
||||||
|
|
||||||
inline void FGAdminUI::cb_install_b_i(Fl_Button*, void*) {
|
|
||||||
install_selected();
|
|
||||||
}
|
|
||||||
void FGAdminUI::cb_install_b(Fl_Button* o, void* v) {
|
|
||||||
((FGAdminUI*)(o->parent()->user_data()))->cb_install_b_i(o,v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FGAdminUI::cb_remove_b_i(Fl_Button*, void*) {
|
inline void FGAdminUI::cb_remove_b_i(Fl_Button*, void*) {
|
||||||
remove_selected();
|
remove_selected();
|
||||||
}
|
}
|
||||||
void FGAdminUI::cb_remove_b(Fl_Button* o, void* v) {
|
void FGAdminUI::cb_remove_b(Fl_Button* o, void* v) {
|
||||||
((FGAdminUI*)(o->parent()->user_data()))->cb_remove_b_i(o,v);
|
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_remove_b_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FGAdminUI::cb_dest_sel_all_i(Fl_Button*, void*) {
|
||||||
|
remove_box->check_all();
|
||||||
|
}
|
||||||
|
void FGAdminUI::cb_dest_sel_all(Fl_Button* o, void* v) {
|
||||||
|
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_dest_sel_all_i(o,v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FGAdminUI::cb_dest_desel_all_i(Fl_Button*, void*) {
|
||||||
|
remove_box->check_none();
|
||||||
|
}
|
||||||
|
void FGAdminUI::cb_dest_desel_all(Fl_Button* o, void* v) {
|
||||||
|
((FGAdminUI*)(o->parent()->parent()->parent()->user_data()))->cb_dest_desel_all_i(o,v);
|
||||||
}
|
}
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
using std::cout;
|
using std::cout;
|
||||||
|
@ -55,34 +83,60 @@ FGAdminUI::FGAdminUI() {
|
||||||
{ Fl_Double_Window* o = main_window = new Fl_Double_Window(465, 435, "FlightGear Admin Wizard");
|
{ Fl_Double_Window* o = main_window = new Fl_Double_Window(465, 435, "FlightGear Admin Wizard");
|
||||||
w = o;
|
w = o;
|
||||||
o->callback((Fl_Callback*)cb_main_window, (void*)(this));
|
o->callback((Fl_Callback*)cb_main_window, (void*)(this));
|
||||||
{ Fl_Button* o = quit_b = new Fl_Button(360, 405, 85, 25, "Quit");
|
{ Fl_Group* o = new Fl_Group(5, 405, 455, 25);
|
||||||
|
{ Fl_Button* o = quit_b = new Fl_Button(375, 405, 85, 25, "Quit");
|
||||||
o->callback((Fl_Callback*)cb_quit_b);
|
o->callback((Fl_Callback*)cb_quit_b);
|
||||||
}
|
}
|
||||||
|
{ Fl_Progress* o = progress = new Fl_Progress(5, 405, 365, 25);
|
||||||
|
o->color(FL_BACKGROUND_COLOR);
|
||||||
|
o->selection_color((Fl_Color)175);
|
||||||
|
Fl_Group::current()->resizable(o);
|
||||||
|
}
|
||||||
|
o->end();
|
||||||
|
}
|
||||||
|
{ Fl_Group* o = new Fl_Group(5, 5, 460, 390);
|
||||||
|
{ Fl_Group* o = new Fl_Group(5, 5, 225, 390);
|
||||||
{ Fl_Button* o = source_b = new Fl_Button(5, 5, 225, 25, "Select Scenery Source ...");
|
{ Fl_Button* o = source_b = new Fl_Button(5, 5, 225, 25, "Select Scenery Source ...");
|
||||||
o->callback((Fl_Callback*)cb_source_b);
|
o->callback((Fl_Callback*)cb_source_b);
|
||||||
}
|
}
|
||||||
source_text = new Fl_Input(5, 35, 225, 25);
|
source_text = new Fl_Input(5, 35, 225, 25);
|
||||||
{ Fl_Button* o = dest_b = new Fl_Button(235, 5, 225, 25, "Select Install Destination ...");
|
{ Fl_Check_Browser* o = install_box = new Fl_Check_Browser(5, 95, 225, 240, "Select Files to Install");
|
||||||
o->callback((Fl_Callback*)cb_dest_b);
|
|
||||||
}
|
|
||||||
dest_text = new Fl_Input(235, 35, 225, 25);
|
|
||||||
{ Fl_Group* o = new Fl_Group(5, 65, 455, 270);
|
|
||||||
install_box = new Fl_Check_Browser(5, 65, 225, 270, "Select Files to Install");
|
|
||||||
remove_box = new Fl_Check_Browser(235, 65, 225, 270, "Select Files to Remove");
|
|
||||||
o->end();
|
|
||||||
Fl_Group::current()->resizable(o);
|
Fl_Group::current()->resizable(o);
|
||||||
}
|
}
|
||||||
{ Fl_Button* o = install_b = new Fl_Button(20, 360, 195, 35, "Install Selected Files");
|
{ Fl_Button* o = install_b = new Fl_Button(20, 360, 195, 35, "Install Selected Files");
|
||||||
o->labelfont(1);
|
o->labelfont(1);
|
||||||
o->callback((Fl_Callback*)cb_install_b);
|
o->callback((Fl_Callback*)cb_install_b);
|
||||||
}
|
}
|
||||||
|
{ Fl_Button* o = source_sel_all = new Fl_Button(5, 65, 110, 25, "Select all");
|
||||||
|
o->callback((Fl_Callback*)cb_source_sel_all);
|
||||||
|
}
|
||||||
|
{ Fl_Button* o = source_desel_all = new Fl_Button(120, 65, 110, 25, "Deselect all");
|
||||||
|
o->callback((Fl_Callback*)cb_source_desel_all);
|
||||||
|
}
|
||||||
|
o->end();
|
||||||
|
}
|
||||||
|
{ Fl_Group* o = new Fl_Group(230, 5, 230, 390);
|
||||||
|
{ Fl_Button* o = dest_b = new Fl_Button(235, 5, 225, 25, "Select Install Destination ...");
|
||||||
|
o->callback((Fl_Callback*)cb_dest_b);
|
||||||
|
}
|
||||||
|
dest_text = new Fl_Input(235, 35, 225, 25);
|
||||||
|
{ Fl_Check_Browser* o = remove_box = new Fl_Check_Browser(235, 95, 225, 240, "Select Files to Remove");
|
||||||
|
Fl_Group::current()->resizable(o);
|
||||||
|
}
|
||||||
{ Fl_Button* o = remove_b = new Fl_Button(250, 360, 195, 35, "Remove Selected Files");
|
{ Fl_Button* o = remove_b = new Fl_Button(250, 360, 195, 35, "Remove Selected Files");
|
||||||
o->labelfont(1);
|
o->labelfont(1);
|
||||||
o->callback((Fl_Callback*)cb_remove_b);
|
o->callback((Fl_Callback*)cb_remove_b);
|
||||||
}
|
}
|
||||||
{ Fl_Progress* o = progress = new Fl_Progress(5, 405, 345, 25);
|
{ Fl_Button* o = dest_sel_all = new Fl_Button(235, 65, 110, 25, "Select all");
|
||||||
o->color(FL_BACKGROUND_COLOR);
|
o->callback((Fl_Callback*)cb_dest_sel_all);
|
||||||
o->selection_color((Fl_Color)175);
|
}
|
||||||
|
{ Fl_Button* o = dest_desel_all = new Fl_Button(350, 65, 110, 25, "Deselect all");
|
||||||
|
o->callback((Fl_Callback*)cb_dest_desel_all);
|
||||||
|
}
|
||||||
|
o->end();
|
||||||
|
}
|
||||||
|
o->end();
|
||||||
|
Fl_Group::current()->resizable(o);
|
||||||
}
|
}
|
||||||
o->end();
|
o->end();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# data file for the Fltk User Interface Designer (fluid)
|
# data file for the Fltk User Interface Designer (fluid)
|
||||||
version 1.0104
|
version 1.0106
|
||||||
header_name {.h}
|
header_name {.h}
|
||||||
code_name {.cxx}
|
code_name {.cxx}
|
||||||
decl {\#include <string>} {public
|
decl {\#include <string>} {public
|
||||||
|
@ -24,12 +24,25 @@ class FGAdminUI {open
|
||||||
label {FlightGear Admin Wizard}
|
label {FlightGear Admin Wizard}
|
||||||
callback {fl_alert("Use the Quit button to exit fgadmin");} open
|
callback {fl_alert("Use the Quit button to exit fgadmin");} open
|
||||||
xywh {500 247 465 435} type Double resizable visible
|
xywh {500 247 465 435} type Double resizable visible
|
||||||
|
} {
|
||||||
|
Fl_Group {} {open
|
||||||
|
xywh {5 405 455 25}
|
||||||
} {
|
} {
|
||||||
Fl_Button quit_b {
|
Fl_Button quit_b {
|
||||||
label Quit
|
label Quit
|
||||||
callback {quit();}
|
callback {quit();}
|
||||||
xywh {360 405 85 25}
|
xywh {375 405 85 25}
|
||||||
}
|
}
|
||||||
|
Fl_Progress progress {
|
||||||
|
xywh {5 405 365 25} color 49 selection_color 175 resizable
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Fl_Group {} {open
|
||||||
|
xywh {5 5 460 390} resizable
|
||||||
|
} {
|
||||||
|
Fl_Group {} {open
|
||||||
|
xywh {5 5 225 390}
|
||||||
|
} {
|
||||||
Fl_Button source_b {
|
Fl_Button source_b {
|
||||||
label {Select Scenery Source ...}
|
label {Select Scenery Source ...}
|
||||||
callback {select_install_source();
|
callback {select_install_source();
|
||||||
|
@ -39,6 +52,29 @@ refresh_lists();}
|
||||||
Fl_Input source_text {
|
Fl_Input source_text {
|
||||||
xywh {5 35 225 25}
|
xywh {5 35 225 25}
|
||||||
}
|
}
|
||||||
|
Fl_Check_Browser install_box {
|
||||||
|
label {Select Files to Install}
|
||||||
|
xywh {5 95 225 240} resizable
|
||||||
|
}
|
||||||
|
Fl_Button install_b {
|
||||||
|
label {Install Selected Files}
|
||||||
|
callback {install_selected();}
|
||||||
|
xywh {20 360 195 35} labelfont 1
|
||||||
|
}
|
||||||
|
Fl_Button source_sel_all {
|
||||||
|
label {Select all}
|
||||||
|
callback {install_box->check_all();}
|
||||||
|
xywh {5 65 110 25}
|
||||||
|
}
|
||||||
|
Fl_Button source_desel_all {
|
||||||
|
label {Deselect all}
|
||||||
|
callback {install_box->check_none();}
|
||||||
|
xywh {120 65 110 25}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Fl_Group {} {open
|
||||||
|
xywh {230 5 230 390}
|
||||||
|
} {
|
||||||
Fl_Button dest_b {
|
Fl_Button dest_b {
|
||||||
label {Select Install Destination ...}
|
label {Select Install Destination ...}
|
||||||
callback {select_install_dest();
|
callback {select_install_dest();
|
||||||
|
@ -48,30 +84,26 @@ refresh_lists();}
|
||||||
Fl_Input dest_text {
|
Fl_Input dest_text {
|
||||||
xywh {235 35 225 25}
|
xywh {235 35 225 25}
|
||||||
}
|
}
|
||||||
Fl_Group {} {open
|
|
||||||
xywh {5 65 455 270} resizable
|
|
||||||
} {
|
|
||||||
Fl_Check_Browser install_box {
|
|
||||||
label {Select Files to Install}
|
|
||||||
xywh {5 65 225 270}
|
|
||||||
}
|
|
||||||
Fl_Check_Browser remove_box {
|
Fl_Check_Browser remove_box {
|
||||||
label {Select Files to Remove}
|
label {Select Files to Remove}
|
||||||
xywh {235 65 225 270}
|
xywh {235 95 225 240} resizable
|
||||||
}
|
|
||||||
}
|
|
||||||
Fl_Button install_b {
|
|
||||||
label {Install Selected Files}
|
|
||||||
callback {install_selected();}
|
|
||||||
xywh {20 360 195 35} labelfont 1
|
|
||||||
}
|
}
|
||||||
Fl_Button remove_b {
|
Fl_Button remove_b {
|
||||||
label {Remove Selected Files}
|
label {Remove Selected Files}
|
||||||
callback {remove_selected();}
|
callback {remove_selected();}
|
||||||
xywh {250 360 195 35} labelfont 1
|
xywh {250 360 195 35} labelfont 1
|
||||||
}
|
}
|
||||||
Fl_Progress progress {
|
Fl_Button dest_sel_all {
|
||||||
xywh {5 405 345 25} color 49 selection_color 175
|
label {Select all}
|
||||||
|
callback {remove_box->check_all();}
|
||||||
|
xywh {235 65 110 25}
|
||||||
|
}
|
||||||
|
Fl_Button dest_desel_all {
|
||||||
|
label {Deselect all}
|
||||||
|
callback {remove_box->check_none();} selected
|
||||||
|
xywh {350 65 110 25}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,7 +113,7 @@ refresh_lists();}
|
||||||
}
|
}
|
||||||
decl {void show();} {public
|
decl {void show();} {public
|
||||||
}
|
}
|
||||||
decl {static void step( void * );} {selected public
|
decl {static void step( void * );} {public
|
||||||
}
|
}
|
||||||
decl {static void step( void *, int );} {public
|
decl {static void step( void *, int );} {public
|
||||||
}
|
}
|
||||||
|
@ -93,6 +125,10 @@ refresh_lists();}
|
||||||
decl {void update_remove_box();} {}
|
decl {void update_remove_box();} {}
|
||||||
decl {void install_selected();} {}
|
decl {void install_selected();} {}
|
||||||
decl {void remove_selected();} {}
|
decl {void remove_selected();} {}
|
||||||
|
decl {void select_all_source();} {}
|
||||||
|
decl {void deselect_all_source();} {}
|
||||||
|
decl {void select_all_dest();} {}
|
||||||
|
decl {void deselect_all_dest();} {}
|
||||||
decl {Fl_Preferences *prefs;} {}
|
decl {Fl_Preferences *prefs;} {}
|
||||||
decl {string source;} {}
|
decl {string source;} {}
|
||||||
decl {string dest;} {}
|
decl {string dest;} {}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
// generated by Fast Light User Interface Designer (fluid) version 1.0104
|
// generated by Fast Light User Interface Designer (fluid) version 1.0106
|
||||||
|
|
||||||
#ifndef fgadmin_h
|
#ifndef fgadmin_h
|
||||||
#define fgadmin_h
|
#define fgadmin_h
|
||||||
|
@ -7,11 +7,11 @@
|
||||||
#include <FL/Fl_Preferences.H>
|
#include <FL/Fl_Preferences.H>
|
||||||
using std::string;
|
using std::string;
|
||||||
#include <FL/Fl_Double_Window.H>
|
#include <FL/Fl_Double_Window.H>
|
||||||
#include <FL/Fl_Button.H>
|
|
||||||
#include <FL/Fl_Input.H>
|
|
||||||
#include <FL/Fl_Group.H>
|
#include <FL/Fl_Group.H>
|
||||||
#include <FL/Fl_Check_Browser.H>
|
#include <FL/Fl_Button.H>
|
||||||
#include <FL/Fl_Progress.H>
|
#include <FL/Fl_Progress.H>
|
||||||
|
#include <FL/Fl_Input.H>
|
||||||
|
#include <FL/Fl_Check_Browser.H>
|
||||||
|
|
||||||
class FGAdminUI {
|
class FGAdminUI {
|
||||||
public:
|
public:
|
||||||
|
@ -26,31 +26,51 @@ private:
|
||||||
inline void cb_quit_b_i(Fl_Button*, void*);
|
inline void cb_quit_b_i(Fl_Button*, void*);
|
||||||
static void cb_quit_b(Fl_Button*, void*);
|
static void cb_quit_b(Fl_Button*, void*);
|
||||||
public:
|
public:
|
||||||
|
Fl_Progress *progress;
|
||||||
Fl_Button *source_b;
|
Fl_Button *source_b;
|
||||||
private:
|
private:
|
||||||
inline void cb_source_b_i(Fl_Button*, void*);
|
inline void cb_source_b_i(Fl_Button*, void*);
|
||||||
static void cb_source_b(Fl_Button*, void*);
|
static void cb_source_b(Fl_Button*, void*);
|
||||||
public:
|
public:
|
||||||
Fl_Input *source_text;
|
Fl_Input *source_text;
|
||||||
|
Fl_Check_Browser *install_box;
|
||||||
|
Fl_Button *install_b;
|
||||||
|
private:
|
||||||
|
inline void cb_install_b_i(Fl_Button*, void*);
|
||||||
|
static void cb_install_b(Fl_Button*, void*);
|
||||||
|
public:
|
||||||
|
Fl_Button *source_sel_all;
|
||||||
|
private:
|
||||||
|
inline void cb_source_sel_all_i(Fl_Button*, void*);
|
||||||
|
static void cb_source_sel_all(Fl_Button*, void*);
|
||||||
|
public:
|
||||||
|
Fl_Button *source_desel_all;
|
||||||
|
private:
|
||||||
|
inline void cb_source_desel_all_i(Fl_Button*, void*);
|
||||||
|
static void cb_source_desel_all(Fl_Button*, void*);
|
||||||
|
public:
|
||||||
Fl_Button *dest_b;
|
Fl_Button *dest_b;
|
||||||
private:
|
private:
|
||||||
inline void cb_dest_b_i(Fl_Button*, void*);
|
inline void cb_dest_b_i(Fl_Button*, void*);
|
||||||
static void cb_dest_b(Fl_Button*, void*);
|
static void cb_dest_b(Fl_Button*, void*);
|
||||||
public:
|
public:
|
||||||
Fl_Input *dest_text;
|
Fl_Input *dest_text;
|
||||||
Fl_Check_Browser *install_box;
|
|
||||||
Fl_Check_Browser *remove_box;
|
Fl_Check_Browser *remove_box;
|
||||||
Fl_Button *install_b;
|
|
||||||
private:
|
|
||||||
inline void cb_install_b_i(Fl_Button*, void*);
|
|
||||||
static void cb_install_b(Fl_Button*, void*);
|
|
||||||
public:
|
|
||||||
Fl_Button *remove_b;
|
Fl_Button *remove_b;
|
||||||
private:
|
private:
|
||||||
inline void cb_remove_b_i(Fl_Button*, void*);
|
inline void cb_remove_b_i(Fl_Button*, void*);
|
||||||
static void cb_remove_b(Fl_Button*, void*);
|
static void cb_remove_b(Fl_Button*, void*);
|
||||||
public:
|
public:
|
||||||
Fl_Progress *progress;
|
Fl_Button *dest_sel_all;
|
||||||
|
private:
|
||||||
|
inline void cb_dest_sel_all_i(Fl_Button*, void*);
|
||||||
|
static void cb_dest_sel_all(Fl_Button*, void*);
|
||||||
|
public:
|
||||||
|
Fl_Button *dest_desel_all;
|
||||||
|
private:
|
||||||
|
inline void cb_dest_desel_all_i(Fl_Button*, void*);
|
||||||
|
static void cb_dest_desel_all(Fl_Button*, void*);
|
||||||
|
public:
|
||||||
~FGAdminUI();
|
~FGAdminUI();
|
||||||
void init();
|
void init();
|
||||||
void show();
|
void show();
|
||||||
|
@ -65,6 +85,10 @@ private:
|
||||||
void update_remove_box();
|
void update_remove_box();
|
||||||
void install_selected();
|
void install_selected();
|
||||||
void remove_selected();
|
void remove_selected();
|
||||||
|
void select_all_source();
|
||||||
|
void deselect_all_source();
|
||||||
|
void select_all_dest();
|
||||||
|
void deselect_all_dest();
|
||||||
Fl_Preferences *prefs;
|
Fl_Preferences *prefs;
|
||||||
string source;
|
string source;
|
||||||
string dest;
|
string dest;
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <set>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
using std::cout;
|
using std::cout;
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::vector;
|
using std::set;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
extern string def_install_source;
|
extern string def_install_source;
|
||||||
|
@ -137,9 +137,7 @@ static int stringCompare(const void *string1, const void *string2)
|
||||||
|
|
||||||
|
|
||||||
void FGAdminUI::update_install_box() {
|
void FGAdminUI::update_install_box() {
|
||||||
int i;
|
set<string> file_list;
|
||||||
vector<string> file_list;
|
|
||||||
file_list.clear();
|
|
||||||
|
|
||||||
install_box->clear();
|
install_box->clear();
|
||||||
|
|
||||||
|
@ -183,29 +181,18 @@ void FGAdminUI::update_install_box() {
|
||||||
install.append( base );
|
install.append( base );
|
||||||
if ( ! fl_filename_isdir( install.c_str() ) ) {
|
if ( ! fl_filename_isdir( install.c_str() ) ) {
|
||||||
// cout << install.str() << " install candidate." << endl;
|
// cout << install.str() << " install candidate." << endl;
|
||||||
file_list.push_back( ent->d_name );
|
file_list.insert( ent->d_name );
|
||||||
} else {
|
} else {
|
||||||
// cout << install.str() << " exists." << endl;
|
// cout << install.str() << " exists." << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ulCloseDir( dir );
|
ulCloseDir( dir );
|
||||||
|
for ( set<string>::iterator it = file_list.begin(); it != file_list.end(); ++it ) {
|
||||||
// convert to a qsort()'able array
|
install_box->add( it->c_str() );
|
||||||
string *sort_list = new string[file_list.size()];
|
|
||||||
for ( i = 0; i < file_list.size(); ++i ) {
|
|
||||||
sort_list[i] = fl_filename_name( file_list[i].c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the file list into display order
|
|
||||||
qsort(sort_list, file_list.size(), sizeof(string), stringCompare);
|
|
||||||
|
|
||||||
for ( int i = 0; i < file_list.size(); ++i ) {
|
|
||||||
install_box->add( sort_list[i].c_str() );
|
|
||||||
}
|
|
||||||
|
|
||||||
delete [] sort_list;
|
|
||||||
|
|
||||||
install_box->redraw();
|
install_box->redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,43 +200,40 @@ void FGAdminUI::update_install_box() {
|
||||||
|
|
||||||
// scan the source directory and update the install_box contents
|
// scan the source directory and update the install_box contents
|
||||||
void FGAdminUI::update_remove_box() {
|
void FGAdminUI::update_remove_box() {
|
||||||
int i;
|
|
||||||
vector<string> dir_list;
|
|
||||||
dir_list.clear();
|
|
||||||
|
|
||||||
remove_box->clear();
|
remove_box->clear();
|
||||||
|
|
||||||
if ( dest.length() ) {
|
if ( dest.length() ) {
|
||||||
ulDir *dir = ulOpenDir( dest.c_str() ) ;
|
string path[2];
|
||||||
|
path[0] = dest + "/Terrain";
|
||||||
|
path[1] = dest + "/Objects";
|
||||||
|
if ( !fl_filename_isdir( path[0].c_str() ) ) {
|
||||||
|
path[0] = dest;
|
||||||
|
path[1] = "";
|
||||||
|
} else if ( !fl_filename_isdir( path[1].c_str() ) ) {
|
||||||
|
path[1] = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
set<string> dir_list;
|
||||||
|
for ( int i = 0; i < 2; i++ ) {
|
||||||
|
if ( !path[i].empty() ) {
|
||||||
|
ulDir *dir = ulOpenDir( path[i].c_str() ) ;
|
||||||
ulDirEnt *ent;
|
ulDirEnt *ent;
|
||||||
while ( dir != 0 && ( ent = ulReadDir( dir ) ) ) {
|
while ( dir != 0 && ( ent = ulReadDir( dir ) ) ) {
|
||||||
if ( strlen(ent->d_name) != 7 ) {
|
if ( strlen(ent->d_name) == 7 &&
|
||||||
// simple heuristic to ignore non-scenery directories
|
( ent->d_name[0] == 'e' || ent->d_name[0] == 'w' ) &&
|
||||||
} else if ( ent->d_name[0] != 'e' && ent->d_name[0] != 'w' ) {
|
( ent->d_name[4] == 'n' || ent->d_name[4] == 's' ) ) {
|
||||||
// further sanity checks on name
|
dir_list.insert( ent->d_name );
|
||||||
} else if ( ent->d_name[4] != 'n' && ent->d_name[4] != 's' ) {
|
|
||||||
// further sanity checks on name
|
|
||||||
} else {
|
|
||||||
dir_list.push_back( ent->d_name );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ulCloseDir( dir );
|
ulCloseDir( dir );
|
||||||
|
}
|
||||||
// convert to a qsort()'able array
|
|
||||||
string *sort_list = new string[dir_list.size()];
|
|
||||||
for ( i = 0; i < dir_list.size(); ++i ) {
|
|
||||||
sort_list[i] = fl_filename_name( dir_list[i].c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort the file list into display order
|
for ( set<string>::iterator it = dir_list.begin(); it != dir_list.end(); ++it ) {
|
||||||
qsort(sort_list, dir_list.size(), sizeof(string), stringCompare);
|
remove_box->add( it->c_str() );
|
||||||
|
|
||||||
for ( int i = 0; i < dir_list.size(); ++i ) {
|
|
||||||
remove_box->add( sort_list[i].c_str() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
delete [] sort_list;
|
|
||||||
|
|
||||||
remove_box->redraw();
|
remove_box->redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,10 +277,11 @@ void FGAdminUI::install_selected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static unsigned long count_dir( const char *dir_name ) {
|
static unsigned long count_dir( const char *dir_name, bool top = true ) {
|
||||||
ulDir *dir = ulOpenDir( dir_name ) ;
|
|
||||||
ulDirEnt *ent;
|
|
||||||
unsigned long cnt = 0L;
|
unsigned long cnt = 0L;
|
||||||
|
ulDir *dir = ulOpenDir( dir_name ) ;
|
||||||
|
if ( dir ) {
|
||||||
|
ulDirEnt *ent;
|
||||||
while ( ent = ulReadDir( dir ) ) {
|
while ( ent = ulReadDir( dir ) ) {
|
||||||
if ( strcmp( ent->d_name, "." ) == 0 ) {
|
if ( strcmp( ent->d_name, "." ) == 0 ) {
|
||||||
// ignore "."
|
// ignore "."
|
||||||
|
@ -305,17 +290,28 @@ static unsigned long count_dir( const char *dir_name ) {
|
||||||
} else if ( ent->d_isdir ) {
|
} else if ( ent->d_isdir ) {
|
||||||
SGPath child( dir_name );
|
SGPath child( dir_name );
|
||||||
child.append( ent->d_name );
|
child.append( ent->d_name );
|
||||||
cnt += count_dir( child.c_str() );
|
cnt += count_dir( child.c_str(), false );
|
||||||
} else {
|
} else {
|
||||||
cnt += 1;
|
cnt += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ulCloseDir( dir );
|
ulCloseDir( dir );
|
||||||
|
} else if ( top ) {
|
||||||
|
string base = dir_name;
|
||||||
|
size_t pos = base.rfind('/');
|
||||||
|
string file = base.substr( pos );
|
||||||
|
base.erase( pos );
|
||||||
|
string path = base + "/Terrain" + file;
|
||||||
|
cnt = count_dir( path.c_str(), false );
|
||||||
|
path = base + "/Objects" + file;
|
||||||
|
cnt += count_dir( path.c_str(), false );
|
||||||
|
}
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_dir( const char *dir_name, void (*step)(void*,int), void *data ) {
|
static void remove_dir( const char *dir_name, void (*step)(void*,int), void *data, bool top = true ) {
|
||||||
ulDir *dir = ulOpenDir( dir_name ) ;
|
ulDir *dir = ulOpenDir( dir_name ) ;
|
||||||
|
if ( dir ) {
|
||||||
ulDirEnt *ent;
|
ulDirEnt *ent;
|
||||||
while ( ent = ulReadDir( dir ) ) {
|
while ( ent = ulReadDir( dir ) ) {
|
||||||
if ( strcmp( ent->d_name, "." ) == 0 ) {
|
if ( strcmp( ent->d_name, "." ) == 0 ) {
|
||||||
|
@ -325,7 +321,7 @@ static void remove_dir( const char *dir_name, void (*step)(void*,int), void *dat
|
||||||
} else if ( ent->d_isdir ) {
|
} else if ( ent->d_isdir ) {
|
||||||
SGPath child( dir_name );
|
SGPath child( dir_name );
|
||||||
child.append( ent->d_name );
|
child.append( ent->d_name );
|
||||||
remove_dir( child.c_str(), step, data );
|
remove_dir( child.c_str(), step, data, false );
|
||||||
} else {
|
} else {
|
||||||
SGPath child( dir_name );
|
SGPath child( dir_name );
|
||||||
child.append( ent->d_name );
|
child.append( ent->d_name );
|
||||||
|
@ -335,6 +331,16 @@ static void remove_dir( const char *dir_name, void (*step)(void*,int), void *dat
|
||||||
}
|
}
|
||||||
ulCloseDir( dir );
|
ulCloseDir( dir );
|
||||||
rmdir( dir_name );
|
rmdir( dir_name );
|
||||||
|
} else if ( top ) {
|
||||||
|
string base = dir_name;
|
||||||
|
size_t pos = base.rfind('/');
|
||||||
|
string file = base.substr( pos );
|
||||||
|
base.erase( pos );
|
||||||
|
string path = base + "/Terrain" + file;
|
||||||
|
remove_dir( path.c_str(), step, data, false );
|
||||||
|
path = base + "/Objects" + file;
|
||||||
|
remove_dir( path.c_str(), step, data, false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue