summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vmchooser/SWindow.cxx22
-rw-r--r--vmchooser/inc/SWindow.h24
-rw-r--r--vmchooser/main.cxx20
3 files changed, 48 insertions, 18 deletions
diff --git a/vmchooser/SWindow.cxx b/vmchooser/SWindow.cxx
index fedd762..fe7855c 100644
--- a/vmchooser/SWindow.cxx
+++ b/vmchooser/SWindow.cxx
@@ -35,7 +35,11 @@ SWindow::SWindow(int w, int h, char* p)
: fltk::Window(w,h,p),
go(w/3 + 10, h-40, (2*w)/3 - 20 , 30, "START"),
exit_btn(10, h-40, w/3 -10, 30, "EXIT"),
- sel(10,10, w-20, h-50)
+ sel(10,10, w-20, h-50),
+ ent(NULL),
+ entgroup(NULL),
+ lin_entgroup(NULL),
+ lin_ent(NULL)
{
// sel.indented(1);
begin();
@@ -199,7 +203,7 @@ void SWindow::free_entries()
* WARNING: this->ent and/or this->lin_ent
* has to assigned before WARNING
******************************************************/
-void SWindow::unfold_entries(bool lin_entries, bool vm_entries) {
+void SWindow::unfold_entries(bool lin_entries, bool vm_entries, char* defsession) {
int ind = 0;
if(lin_entries) {
sel.goto_index(ind);
@@ -226,6 +230,10 @@ void SWindow::unfold_entries(bool lin_entries, bool vm_entries) {
//sel.indented(false);
char* prename = readSession();
+ DataEntry* dp = NULL;
+ if(defsession) {
+ prename = defsession;
+ }
if ( prename == '\0' ) {
return;
} else {
@@ -233,7 +241,12 @@ void SWindow::unfold_entries(bool lin_entries, bool vm_entries) {
Item* it = (Item*) sel.next();
while( it ) {
- if(! strcmp(prename,it->label()) ) {
+ dp = (DataEntry*) it->user_data();
+ if(!dp) {
+ it = (Item*) sel.next();
+ continue;
+ }
+ if( dp->short_description.find(prename) != string::npos ) {
sel.select_only_this(0);
curr = it;
return;
@@ -294,7 +307,8 @@ const char** SWindow::get_symbol(DataEntry* dat) {
}
return linux_32_xpm;
}
- return xp_32_xpm;
+
+ return linux_32_xpm;
}
diff --git a/vmchooser/inc/SWindow.h b/vmchooser/inc/SWindow.h
index ad8b63e..845e72d 100644
--- a/vmchooser/inc/SWindow.h
+++ b/vmchooser/inc/SWindow.h
@@ -25,7 +25,7 @@ class SWindow : public fltk::Window {
private:
// ReturnButton to start the session
fltk::ReturnButton go;
-
+
// Button to exit
fltk::Button exit_btn;
@@ -43,13 +43,13 @@ private:
// Arrays with data from .xml and .desktop files
DataEntry** ent;
DataEntry** lin_ent;
-
-
+
+
int width;
int height;
-
-
-
+
+
+
/**
* ctor with some reasonable default values
@@ -62,8 +62,8 @@ public:
static SWindow instance(w,h);
return &instance;
}
-
-
+
+
int pathsize;
char* pname; /* Holds the current absolute path */
@@ -75,7 +75,7 @@ public:
static void cb_select(fltk::Widget*, void* w) {
((SWindow*)w)->cb_select();
};
-
+
static void cb_exit(fltk::Widget*, void* w) {
exit(0);
}
@@ -85,12 +85,12 @@ public:
void set_entries(DataEntry** ent);
void set_lin_entries(DataEntry** ent);
-
+
const char** get_symbol(DataEntry* dat);
void free_entries();
- void unfold_entries(bool,bool);
-
+ void unfold_entries(bool,bool,char* defsession=0);
+
void sort_entries();
};
diff --git a/vmchooser/main.cxx b/vmchooser/main.cxx
index 8e8b2ea..579e938 100644
--- a/vmchooser/main.cxx
+++ b/vmchooser/main.cxx
@@ -33,6 +33,7 @@ int main(int argc, char** argv) {
AnyOption* opt = new AnyOption();
char* xmlpath = NULL;
char* lsesspath = NULL;
+ char* dsession = NULL;
int width=0, height=0;
//opt->setVerbose();
@@ -40,6 +41,7 @@ int main(int argc, char** argv) {
opt->addUsage("");
opt->addUsage("SessionChooser Usage: vmchooser [OPTS|image.xml]");
+ opt->addUsage("\t{-d |--default=} name of session to select (part of)");
opt->addUsage("\t{-p |--path=} path to vmware (.xml) files");
opt->addUsage("\t{-l |--lpath=} path to linux session (.desktop) files");
opt->addUsage("\t{-s |--size=} [widthxheight]");
@@ -50,6 +52,7 @@ int main(int argc, char** argv) {
opt->setFlag("help",'h');
opt->setFlag("version",'v');
+ opt->setOption("default", 'd');
opt->setOption("path", 'p');
opt->setOption("lpath", 'l');
opt->setOption("size",'s');
@@ -87,6 +90,14 @@ int main(int argc, char** argv) {
}
+ if(opt->getValue('d')!=NULL) {
+ dsession = opt->getValue('d');
+ }
+
+ if(opt->getValue("default")!= NULL) {
+ dsession = opt->getValue("default");
+ }
+
if(opt->getValue('p')!=NULL) {
xmlpath = opt->getValue('p');
}
@@ -103,7 +114,7 @@ int main(int argc, char** argv) {
/* VERSION */
if(opt->getFlag('v') || opt->getFlag("version")) {
// just print out version information - helps testing
- cout << "virtual machine chooser 0.0.10"<< endl;
+ cout << "virtual machine chooser 0.0.11"<< endl;
delete opt;
return 0;
@@ -182,7 +193,12 @@ int main(int argc, char** argv) {
vm_entries = true;
}
- win.unfold_entries(lin_entries, vm_entries);
+ if(dsession) {
+ win.unfold_entries(lin_entries, vm_entries, dsession);
+ }
+ else {
+ win.unfold_entries(lin_entries, vm_entries);
+ }
win.show(); // argc,argv
win.border(false);
free(xmlpath);