// generated by Fast Light User Interface Designer (fluid) version 1.0110 #include "wallpaper.h" // (c) Robert Shingledecker 2008- 2010 // tradotto da Francesco Nuzzi (unsenepopiu@tin.it) #include #include #include #include #include #include using namespace std; static string target; static double r,g,b; void imageBrowserCallback(Fl_Widget*, void*) { installBtn->activate(); } void btnCallback(Fl_Widget*, void* userdata) { string backgroundType; string command; if (userdata == "install") { string selectedImage = imageBrowser->text(imageBrowser->value()); if ( btnFull->value() == 1 ) backgroundType = "full"; else if ( btnFill->value() == 1 ) backgroundType = "fill"; else if ( btnTile->value() == 1 ) backgroundType = "tile"; else backgroundType = "center"; command = "setbackground " + backgroundType + " /opt/backgrounds/" + selectedImage; system(command.c_str()); exit(0); } if (userdata == "color") { if (!fl_color_chooser("New Color",r,g,b)) return; uchar ru,gu,bu; ru = 255*r+.5; gu = 255*g+.5; bu = 255*b+.5; char buffer[10]; int n = sprintf(buffer,"%02X%02X%02X\n",ru,gu,bu); string selectedColor = buffer; backgroundType = "solid"; command = "setbackground " + backgroundType + " \'#" + selectedColor.substr(0,6) + "\'"; system(command.c_str()); exit(0); } if (userdata == "help") fl_message("Installa immagini dalla cartella /opt/backgrounds."); } Fl_File_Browser *imageBrowser=(Fl_File_Browser *)0; Fl_Round_Button *btnFull=(Fl_Round_Button *)0; Fl_Round_Button *btnTile=(Fl_Round_Button *)0; Fl_Round_Button *btnCenter=(Fl_Round_Button *)0; Fl_Round_Button *btnFill=(Fl_Round_Button *)0; Fl_Button *installBtn=(Fl_Button *)0; int main(int argc, char **argv) { Fl_Double_Window* w; { Fl_Double_Window* o = new Fl_Double_Window(295, 245); w = o; { imageBrowser = new Fl_File_Browser(0, 25, 295, 190); imageBrowser->type(2); imageBrowser->callback((Fl_Callback*)imageBrowserCallback); imageBrowser->filter("*.{png,gif,jpg,jpeg}"); imageBrowser->load("/opt/backgrounds"); } // Fl_File_Browser* imageBrowser { btnFull = new Fl_Round_Button(3, 5, 50, 15, "&Pieno"); btnFull->down_box(FL_ROUND_DOWN_BOX); btnFull->value(1); btnFull->selection_color((Fl_Color)2); btnFull->type(FL_RADIO_BUTTON); } // Fl_Round_Button* btnFull { btnTile = new Fl_Round_Button(66, 5, 50, 15, "Pia&strella"); btnTile->down_box(FL_ROUND_DOWN_BOX); btnTile->selection_color((Fl_Color)2); btnTile->type(FL_RADIO_BUTTON); } // Fl_Round_Button* btnTile { btnCenter = new Fl_Round_Button(144, 5, 64, 15, "&Originale"); btnCenter->down_box(FL_ROUND_DOWN_BOX); btnCenter->selection_color((Fl_Color)2); btnCenter->type(FL_RADIO_BUTTON); } // Fl_Round_Button* btnCenter { btnFill = new Fl_Round_Button(223, 5, 50, 15, "A&llarga"); btnFill->down_box(FL_ROUND_DOWN_BOX); btnFill->selection_color((Fl_Color)2); btnFill->type(FL_RADIO_BUTTON); } // Fl_Round_Button* btnFill { installBtn = new Fl_Button(25, 220, 64, 20, "&Installa"); installBtn->callback((Fl_Callback*)btnCallback, (void*)("install")); installBtn->deactivate(); } // Fl_Button* installBtn { Fl_Button* o = new Fl_Button(110, 220, 64, 20, "&Colore"); o->callback((Fl_Callback*)btnCallback, (void*)("color")); } // Fl_Button* o { Fl_Button* o = new Fl_Button(200, 220, 64, 20, "&Aiuto"); o->callback((Fl_Callback*)btnCallback, (void*)("help")); } // Fl_Button* o o->end(); } // Fl_Double_Window* o int results = system("getRGB"); if (results == 0 ) { ifstream rgb_file("/tmp/current_rgb"); istringstream stm; string rgb_info; getline(rgb_file, rgb_info); stm.str(rgb_info); stm >> r >> g >> b; } else { r = 0.067; g = 0.161; b = 0.286; } cout << r << endl; cout << g << endl; cout << b << endl; w->show(argc, argv); return Fl::run(); }