Update ede2-fltk2 branch with stuff from my disk

This commit is contained in:
Vedran Ljubovic 2007-07-18 18:40:34 +00:00
parent a00fb8164f
commit 4335ce706a
9 changed files with 809 additions and 558 deletions

View File

@ -1,71 +0,0 @@
#
# This is a default data for control panel.
#
# You can change them, and howto for this
# you can find in econtrol documentation.
# This is the main key, and must be present if
# you want to control panel read it
[Control Panel]
Position = true
X = 2
Y = 3
Width = 58
Height = 34
# reads econtrol.conf from user home, appending
# values to this one
ReadUserConf = true
# main items
Items = edewmconf,ekeyconf,esvrconf,einstall,evolume, edatetime,etipconf
[edewmconf]
Name = Window manager
Tip = This item will run window manager configuration
Exec = ewmconf
Icon = preferences-system-windows
IconPathAbsolute = false
[ekeyconf]
Name = Keyboard configuration
Tip = This item will run keyboard configuration
Exec = konqueror
#Icon = preferences-desktop-font
Icon = accessories-character-map
IconPathAbsolute = false
[esvrconf]
Name = Screensaver configuration
Tip = This item will configure screensaver
Exec = esvrconf
Icon = preferences-desktop-screensaver
IconPathAbsolute = false
[einstall]
Name = Install new software
Tip = This item will run installer
Exec = einstall
Icon = system-installer
IconPathAbsolute = false
[evolume]
Name = Sound preferences
Tip = This item will set sound preferences
Exec = evolume
Icon = multimedia-volume-control
IconPathAbsolute = false
[edatetime]
Name = Date and time
Tip = This item will configure date and time
Exec = edatetime
Icon = preferences-date-time
IconPathAbsolute = false
[etipconf]
Name = Tips
Tip = This item will configure tips
Exec = etipconf
Icon = preferences-user-information
IconPathAbsolute = false

View File

@ -1,162 +1,371 @@
/*
* $Id$
*
* The EDE control center
* Part of Equinox Desktop Environment (EDE).
* Copyright (c) 2000-2006 EDE Authors.
*
* This program is licenced under terms of the
* GNU General Public Licence version 2 or newer.
* See COPYING for details.
*/
#include <stdlib.h>
#include <fltk/run.h>
#include "econtrol.h" #include "econtrol.h"
#include <edelib/Config.h> #include "../edelib2/Run.h"
#include <edelib/StrUtil.h> #include "../edelib2/about_dialog.h"
#include <edelib/Debug.h> #include "../edelib2/NLS.h"
#include <edelib/Nls.h> #include "../edelib2/Icon.h"
#include <FL/Fl.h> #include "../edeconf.h"
#include <FL/Fl_Shared_Image.h>
#include <FL/fl_draw.h>
using namespace fltk;
using namespace edelib; using namespace edelib;
ControlButton::ControlButton(Fl_Box* t, String tv, int x, int y, int w, int h, const char* l) :
Fl_Button(x, y, w, h, l) {
tip = t; // Widgets
tipval = tv;
box(FL_FLAT_BOX); Window *configPanelWindow=(Window *)0;
align(FL_ALIGN_WRAP); MenuBar *main_menubar=(MenuBar *)0;
color(FL_WHITE); StatusBarGroup *status_bar=(StatusBarGroup *)0;
ScrollGroup *scroll=(ScrollGroup *)0;
Group *main_view=(Group *)0;
InvisibleBox *help_window=(InvisibleBox *)0;
// Callbacks
static void cb_Quit(Item*, void*)
{
exit(0);
} }
ControlButton::~ControlButton() { static void cb_About(Item*, void*)
{
about_dialog("Control panel", "1.99");
} }
int ControlButton::handle(int event) {
switch(event) { static void cb_Icons(Button*, void*)
case FL_ENTER: {
tip->label(tipval.c_str()); help_window->label(_("Change behaviour of your desktop icons."));
return 1; help_window->redraw();
case FL_LEAVE: //if (Fl::event_clicks())
tip->label(""); run_program("eiconsconf &");
return 1;
case FL_PUSH:
return 1;
case FL_RELEASE:
return 1;
default:
return Fl_Button::handle(event);
}
return Fl_Button::handle(event);
} }
void close_cb(Fl_Widget*, void* w) {
ControlWin* cw = (ControlWin*)w; static void cb_Colors(Button*, void*)
cw->do_close(); {
help_window->label(_("Configure global colors and fonts used by EDE applications."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("ecolorconf &");
} }
ControlWin::ControlWin(const char* title, int w, int h) : Fl_Window(w, h, title) { static void cb_Screen(Button*, void*)
{
IconTheme::init("edeneu"); help_window->label(_("Configure the screensaver."));
help_window->redraw();
fl_register_images(); //if (Fl::event_clicks())
load_icons(); run_program("esvrconf &");
init();
} }
ControlWin::~ControlWin() { static void cb_Window(Button*, void*)
IconTheme::shutdown(); {
help_window->label(_("Setup window decorations and other options."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("ewmconf &");
} }
void ControlWin::load_icons(void) { static void cb_Display(Button*, void*)
Config c; {
help_window->label(_("Set various options for the X windowing system."));
if(!c.load("econtrol.conf")) { help_window->redraw();
EWARNING("Can't load config\n"); //if (Fl::event_clicks())
return; run_program("edisplayconf &");
} }
char buff[1024]; static void cb_Install(Button*, void*)
if(!c.get("Control Panel", "Items", buff, sizeof(buff))) { {
EWARNING("Can't find Items key\n"); help_window->label(_("This utility helps you to install new software."));
return; help_window->redraw();
//if (Fl::event_clicks())
run_program("einstaller",false);
} }
vector<String> spl; static void cb_Time(Button*, void*)
stringtok(spl, buff, ","); {
char* sect; help_window->label(_("Show and set computer time and date."));
help_window->redraw();
ControlIcon cicon; //if (Fl::event_clicks())
for(unsigned int i = 0; i < spl.size(); i++) { run_program("etimedate",false);
sect = (char*)spl[i].c_str();
str_trim(sect);
if(c.get(sect, "Name", buff, sizeof(buff)))
cicon.name = buff;
else {
EWARNING("No %s, skipping...\n", spl[i].c_str());
continue;
} }
if(c.get(sect, "Tip", buff, sizeof(buff))) static void cb_Panel(Button*, void*)
cicon.tip = buff; {
if(c.get(sect, "Exec", buff, sizeof(buff))) help_window->label(_("Change panel behaviour and choose applets."));
cicon.exec = buff; help_window->redraw();
if(c.get(sect, "Icon", buff, sizeof(buff))) { //if (Fl::event_clicks())
cicon.icon = buff; run_program("epanelconf",false);
EDEBUG("setting icon (%s): %s\n", spl[i].c_str(), cicon.icon.c_str());
} }
c.get(spl[i].c_str(), "IconPathAbsolute", cicon.abspath, false); static void cb_Keyboard(Button*, void*)
c.get(spl[i].c_str(), "Position", cicon.abspath, -1); {
help_window->label(_("Configure keyboard shortcuts and other options."));
iconlist.push_back(cicon); help_window->redraw();
} //if (Fl::event_clicks())
run_program("ekeyconf",false);
} }
void ControlWin::init(void) { static void cb_Color(Item* i, void*)
begin(); {
titlegrp = new Fl_Group(0, 0, 455, 50); const char* label = i->label();
titlegrp->box(FL_FLAT_BOX); if (strcmp(label,"White")==0) { scroll->color(WHITE); }
titlegrp->color(138); if (strcmp(label,"Gray")==0) { scroll->color(GRAY75); }
titlegrp->begin(); if (strcmp(label,"Black")==0) { scroll->color(BLACK); }
title = new Fl_Box(10, 10, 435, 30, label()); if (strcmp(label,"Red")==0) { scroll->color(RED); }
title->color(138); if (strcmp(label,"Blue")==0) { scroll->color(BLUE); }
title->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE); scroll->redraw();
title->labelcolor(23);
title->labelfont(FL_HELVETICA_BOLD);
title->labelsize(16);
titlegrp->end();
titlegrp->resizable(title);
icons = new ExpandableGroup(10, 60, 435, 225);
icons->box(FL_DOWN_BOX);
icons->color(FL_BACKGROUND2_COLOR);
icons->end();
tipbox = new Fl_Box(10, 295, 240, 25, _("Double click on desired item"));
tipbox->box(FL_FLAT_BOX);
tipbox->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
for(unsigned int i = 0; i < iconlist.size(); i++) {
ControlButton* b = new ControlButton(tipbox, iconlist[i].tip, 0, 0, 80, 100);
//String iconpath = IconTheme::get(iconlist[i].icon.c_str(), ICON_SIZE_MEDIUM);
String iconpath = IconTheme::get(iconlist[i].icon.c_str(), ICON_SIZE_LARGE);
b->label(iconlist[i].name.c_str());
if(!iconpath.empty())
b->image(Fl_Shared_Image::get(iconpath.c_str()));
icons->add(b);
} }
//options = new Fl_Button(260, 295, 90, 25, _("&Options"));
close = new Fl_Button(355, 295, 90, 25, _("&Close"));
close->callback(close_cb, this);
// resizable invisible box // Main program
rbox = new Fl_Box(10, 220, 120, 65);
resizable(rbox); int main (int argc, char **argv) {
end();
//fl_init_locale_support("econtrol", PREFIX"/share/locale");
Window* configPanelWindow = new Window(450, 310, "Control panel");
configPanelWindow->begin();
{main_menubar = new MenuBar(0, 0, 450, 26);
main_menubar->begin();
{ItemGroup* o = new ItemGroup(_("&File"));
o->begin();
{Item* o = new Item(_("&Quit"));
o->shortcut(0x40071);
o->callback((Callback*)cb_Quit);
//o->x_offset(18);
}
o->end();
}
{ItemGroup* o = new ItemGroup(_("&Color"));
o->align(ALIGN_CENTER);
o->begin();
{Item* o = new Item("White");
o->callback((Callback*)cb_Color);
o->type(Item::RADIO);
o->set();
}
{Item* o = new Item("Gray");
o->callback((Callback*)cb_Color);
o->type(Item::RADIO);
}
{Item* o = new Item("Black");
o->callback((Callback*)cb_Color);
o->type(Item::RADIO);
}
{Item* o = new Item("Red");
o->callback((Callback*)cb_Color);
o->type(Item::RADIO);
}
{Item* o = new Item("Blue");
o->callback((Callback*)cb_Color);
o->type(Item::RADIO);
}
o->end();
}
{ItemGroup* o = new ItemGroup(_("&Help"));
o->align(ALIGN_CENTER);
o->begin();
{Item* o = new Item(_("&About"));
o->shortcut(0x40061);
o->callback((Callback*)cb_About);
//o->x_offset(18);
}
o->end();
}
main_menubar->end();
}
{main_view = new Group(0, 26, 450, 280);
main_view->begin();
{InvisibleBox* o = new InvisibleBox(0, 0, 450, 41, _("Control panel"));
o->box(FLAT_BOX);
o->labeltype(SHADOW_LABEL);
o->color((Color)0xd089d00);
o->buttoncolor((Color)0xe6e7e600);
o->labelcolor((Color)0xffffff00);
o->highlight_color((Color)0xe6e7e600);
o->labelsize(20);
o->textsize(29);
o->align(ALIGN_INSIDE);
}
{TiledGroup* o = new TiledGroup(0, 40, 450, 215);
o->box(FLAT_BOX);
o->color((Color)0xd93b4300);
o->begin();
{help_window = new InvisibleBox(0, 0, 110, 195, _("Welcome to the control panel. Here you can setup most things on your computer."));
help_window->set_vertical();
help_window->box(DOWN_BOX);
help_window->color((Color)0xfff9e400);
help_window->labelcolor((Color)32);
help_window->align(ALIGN_WRAP);
//help_window->set_value();
}
{scroll = new ScrollGroup(110, 0, 340, 195);
scroll->box(DOWN_BOX);
scroll->color(WHITE);
scroll->align(ALIGN_CENTER);
scroll->begin();
{Button* o = new Button(0, 15, 60, 75, _("Icons"));
o->set_vertical();
// o->image(SharedImage::get("icons/behaviour.xpm"));
// o->image(EDE_Icon::get("desktop-mdk",EDE_Icon::SMALL));
// o->image(EDE_Icon::get("kappfinder",EDE_Icon::SMALL));
o->image(Icon::get("desktop",Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->buttonbox(NO_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Icons);
o->align(ALIGN_WRAP);
o->tooltip(_("Icons settings"));
}
{Button* o = new Button(75, 15, 60, 75, _("Colors and Fonts"));
o->set_vertical();
// o->image(SharedImage::get("icons/themes.xpm"));
o->image(Icon::get("fonts",Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Colors);
o->align(ALIGN_WRAP);
o->tooltip(_("Colors settings"));
}
{Button* o = new Button(140, 15, 60, 75, _("Screen Saver"));
o->set_vertical();
// o->image(SharedImage::get("icons/screensaver.xpm"));
o->image(Icon::get("terminal",Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Screen);
o->align(ALIGN_WRAP);
o->tooltip(_("Screensaver configuration"));
}
{Button* o = new Button(10, 95, 60, 75, _("Window Manager"));
o->set_vertical();
// o->image(SharedImage::get("icons/windowmanager.xpm"));
// o->image(EDE_Icon::get("kcmkwm",EDE_Icon::SMALL));
// o->image(EDE_Icon::get("kpersonalizer",EDE_Icon::SMALL));
o->image(Icon::get("window_list",Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Window);
o->align(ALIGN_WRAP);
o->tooltip(_("Window manager settings"));
}
{Button* o = new Button(75, 95, 60, 75, _("Display"));
o->set_vertical();
// o->image(SharedImage::get("icons/display.xpm"));
// o->image(EDE_Icon::get("kcmx",EDE_Icon::SMALL));
// o->image(EDE_Icon::get("randr",EDE_Icon::SMALL));
o->image(Icon::get("looknfeel",Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Display);
o->tooltip(_("Display settings"));
}
{Button* o = new Button(140, 95, 60, 75, _("Install New Software"));
o->set_vertical();
// o->image(SharedImage::get("icons/newsoft.xpm"));
// o->image(EDE_Icon::get("ark",EDE_Icon::SMALL));
o->image(Icon::get("package",Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Install);
o->align(ALIGN_WRAP);
o->tooltip(_("Software installation."));
}
{Button* o = new Button(205, 95, 60, 75, _("Time and Date"));
o->set_vertical();
// o->image(SharedImage::get("icons/timedate.xpm"));
o->image(Icon::get("date",Icon::SMALL));
// o->image(EDE_Icon::get("karm",EDE_Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Time);
o->align(ALIGN_WRAP);
o->tooltip(_("Time and date settings."));
}
{Button* o = new Button(205, 15, 60, 75, _("Panel"));
o->set_vertical();
// o->image(SharedImage::get("icons/panel.xpm"));
o->image(Icon::get("kcmkicker",Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Panel);
o->tooltip(_("Panel configuration."));
}
{Button* o = new Button(265, 15, 60, 75, _("Keyboard"));
o->set_vertical();
// o->image(SharedImage::get("icons/keyboard.xpm"));
// o->image(EDE_Icon::get("kxkb",EDE_Icon::SMALL));
o->image(Icon::get("keyboard",Icon::SMALL));
o->box(HIGHLIGHT_DOWN_BOX);
o->buttonbox(NO_BOX);
o->color((Color)7);
o->highlight_color((Color)7);
o->highlight_textcolor((Color)32);
o->labelsize(10);
o->callback((Callback*)cb_Keyboard);
o->tooltip(_("Keyboard settings"));
}
scroll->end();
//o->edge_offset(10);
}
o->end();
o->parent()->resizable(o);
Group::current()->resizable(o);
}
main_view->end();
Group::current()->resizable(main_view);
}
{status_bar = new StatusBarGroup(0, 281, 450, 24, _("Ready"));
status_bar->box(DOWN_BOX);
} }
void ControlWin::do_close(void) { configPanelWindow->end();
hide(); configPanelWindow->size_range(configPanelWindow->w(), configPanelWindow->h());
}
int main() {
ControlWin cw(_("EDE Control Panel")); // configPanelWindow->menu(main_menubar);
cw.show(); // configPanelWindow->view(main_view);
return Fl::run(); // configPanelWindow->status(status_bar);
configPanelWindow->show(argc, argv);
return run();
} }

View File

@ -1,38 +0,0 @@
# data file for the Fltk User Interface Designer (fluid)
version 1.0108
header_name {.h}
code_name {.cxx}
Function {} {open
} {
Fl_Window {} {open
xywh {392 251 455 330} type Double resizable visible
} {
Fl_Group {} {open
xywh {0 0 455 50} box FLAT_BOX color 138
} {
Fl_Box {} {
label {EDE Control Panel}
xywh {10 10 435 30} box FLAT_BOX color 138 labelfont 1 labelsize 16 labelcolor 23 align 20 resizable
}
}
Fl_Button {} {
label {&Close}
xywh {355 295 90 25}
}
Fl_Button {} {
label {&Options}
xywh {260 295 90 25}
}
Fl_Box {} {
label {This is some label }
xywh {10 295 240 25} box FLAT_BOX align 84
}
Fl_Box {} {
xywh {10 60 435 225} box DOWN_BOX color 7
}
Fl_Box {} {selected
xywh {10 220 120 65} resizable
code0 {/* invisible resizable box */}
}
}
}

193
econtrol/econtrol.fld Executable file
View File

@ -0,0 +1,193 @@
# data file for the FLTK User Interface Designer (FLUID)
version 2.0100
images_dir ./
header_name {.h}
code_name {.cpp}
gridx 5
gridy 5
snap 3
decl {// The EDE control center.} {}
decl {// Copyright (c) 2000. - 2005. EDE Authors} {}
decl {// This program is licenced under terms of the} {}
decl {// GNU General Public Licence version 2 or newer.} {}
decl {// See COPYING for details} {}
decl {//} {}
decl {\#include <stdlib.h>} {}
decl {//\#include <efltk/Fl_Locale.h>} {}
decl {//\#include <efltk/Fl_Util.h>} {}
decl {//\#include <edeconf.h>} {}
decl {\#include "EDE_Run.h"} {}
decl {\#include "../common/aboutdialog.h"} {}
Function {} {open
} {
code {fl_init_locale_support("econtrol", PREFIX"/share/locale");} {}
{fltk::Window} configPanelWindow {
label {Control panel} open
xywh {467 224 450 310} resizable
extra_code {\#include <efltk/Fl_Main_Window.h>
o->size_range(o->w(), o->h());} visible
} {
{fltk::MenuBar} main_menubar {
xywh {0 0 450 26}
} {
{fltk::ItemGroup} {} {
label {&File} open
} {
{fltk::Item} {} {
label {&Quit}
callback {exit(0);}
shortcut 0x40071
extra_code {o->x_offset(18);}
}
}
{fltk::ItemGroup} {} {
label {&Help} open
align 0
} {
{fltk::Item} {} {
label {&About}
callback {AboutDialog("Control panel", "1.0");}
shortcut 0x40061
extra_code {o->x_offset(18);}
}
}
}
{fltk::Group} main_view {open
xywh {0 0 450 280} resizable
} {
{fltk::InvisibleBox} {} {
label {Control panel}
xywh {0 24 450 41} align 32 box FLAT_BOX labeltype SHADOW_LABEL color 0xd089d00 buttoncolor 0xe6e7e600 labelcolor 0xffffff00 highlight_color 0xe6e7e600 labelsize 20 textsize 29
}
{fltk::TiledGroup} {} {open
xywh {0 65 450 215} resizable box FLAT_BOX color 0xd93b4300
extra_code {o->parent()->resizable(o);}
} {
{fltk::InvisibleBox} help_window {
label {Welcome to the control panel. Here you can setup most things on your computer.}
xywh {0 0 110 195} align 128 box DOWN_BOX color 0xfff9e400 labelcolor 32
extra_code {o->set_value();}
}
{fltk::Group} {} {open
private xywh {110 0 340 195} align 0 box DOWN_BOX color 7
extra_code {\#include <efltk/Fl_Scroll.h>
o->edge_offset(10);}
class {fltk::ScrollGroup}
} {
{fltk::Button} {} {
label Icons
callback {help_window->label(_("Change behaviour of your desktop icons."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("eiconsconf &");}
tooltip {Icons settings.}
private xywh {10 15 60 75} align 128 box HIGHLIGHT_DOWN_BOX buttonbox NO_BOX
image {icons/behaviour.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
{fltk::Button} {} {
label {Colors and Fonts}
callback {help_window->label(_("Configure global colors and fonts used by EDE applications."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("ecolorconf &");}
tooltip {Colors settings.}
private xywh {75 15 60 75} align 128 box HIGHLIGHT_DOWN_BOX
image {icons/themes.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
{fltk::Button} {} {
label {Screen Saver}
callback {help_window->label(_("Configure the screensaver."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("esvrconf &");}
tooltip {Screensaver configuration.}
private xywh {140 15 60 75} align 128 box HIGHLIGHT_DOWN_BOX
image {icons/screensaver.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
{fltk::Button} {} {
label {Window Manager}
callback {help_window->label(_("Setup window decorations and other options."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("ewmconf &");}
tooltip {Window manager settings.}
private xywh {10 95 60 75} align 128 box HIGHLIGHT_DOWN_BOX
image {icons/windowmanager.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
{fltk::Button} {} {
label Display
callback {help_window->label(_("Set various options for the X windowing system."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("edisplayconf &");}
tooltip {Display settings. }
private xywh {75 95 60 75} box HIGHLIGHT_DOWN_BOX
image {icons/display.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
{fltk::Button} {} {
label {Install New Software}
callback {help_window->label(_("This utility helps you to install new software."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("einstaller",false);} selected
tooltip {Software installation.}
private xywh {140 95 60 75} align 128 box HIGHLIGHT_DOWN_BOX
image {icons/newsoft.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
{fltk::Button} {} {
label {Time and Date}
callback {help_window->label(_("Show and set computer time and date."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("etimedate",false);}
tooltip {Time and date settings.}
private xywh {205 95 60 75} align 128 box HIGHLIGHT_DOWN_BOX
image {icons/timedate.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
{fltk::Button} {} {
label Panel
callback {help_window->label(_("Change panel behaviour and choose applets."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("epanelconf",false);}
tooltip {Panel configuration.}
private xywh {205 15 60 75} box HIGHLIGHT_DOWN_BOX
image {icons/panel.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
{fltk::Button} {} {
label Keyboard
callback {help_window->label(_("Configure keyboard shortcuts and other options."));
help_window->redraw();
//if (Fl::event_clicks())
run_program("ekeyconf",false);}
tooltip {Keyboard settings}
private xywh {265 15 60 75} box HIGHLIGHT_DOWN_BOX buttonbox NO_BOX
image {icons/keyboard.xpm} color 7 highlight_color 7 highlight_textcolor 32 labelsize 10
}
}
}
}
{fltk::InvisibleBox} status_bar {
label Ready
private xywh {0 281 450 24} box DOWN_BOX
class {fltk::StatusBarGroup}
}
}
code {configPanelWindow->menu(main_menubar);
configPanelWindow->view(main_view);
configPanelWindow->status(status_bar);} {}
}
decl {\#include "NLS.h"} {}

View File

@ -1,53 +1,25 @@
#ifndef __ECONTROL_H__ /*
#define __ECONTROL_H__ * $Id$
*
#include <FL/Fl_Window.h> * The EDE control center
#include <FL/Fl_Group.h> * Part of Equinox Desktop Environment (EDE).
#include <FL/Fl_Box.h> * Copyright (c) 2000-2006 EDE Authors.
#include <FL/Fl_Button.h> *
* This program is licenced under terms of the
#include <edelib/IconTheme.h> * GNU General Public Licence version 2 or newer.
#include <edelib/ExpandableGroup.h> * See COPYING for details.
*/
struct ControlIcon {
edelib::String name;
edelib::String tip;
edelib::String exec;
edelib::String icon;
bool abspath;
int pos;
};
class ControlButton : public Fl_Button {
private:
Fl_Box* tip;
edelib::String tipval;
public:
ControlButton(Fl_Box* t, edelib::String tv, int x, int y, int w, int h, const char* l = 0);
~ControlButton();
int handle(int event);
};
class ControlWin : public Fl_Window {
private:
Fl_Group* titlegrp;
Fl_Box* title;
Fl_Button* close;
//Fl_Button* options;
edelib::ExpandableGroup* icons;
Fl_Box* rbox;
Fl_Box* tipbox;
edelib::vector<ControlIcon> iconlist;
void init(void);
void load_icons(void);
public:
ControlWin(const char* title, int w = 455, int h = 330);
~ControlWin();
void do_close(void);
};
#ifndef econtrol_h
#define econtrol_h
#include <fltk/Window.h>
#include <fltk/MenuBar.h>
#include <fltk/ItemGroup.h>
#include <fltk/Item.h>
#include <fltk/Group.h>
#include <fltk/InvisibleBox.h>
#include <fltk/TiledGroup.h>
#include <fltk/ScrollGroup.h>
#include <fltk/Button.h>
#include <fltk/StatusBarGroup.h>
#endif #endif

View File

@ -282,6 +282,7 @@ DirTree::load()
} }
} }
} }
fclose(mtab);
this->end(); this->end();
system->set_flag(fltk::OPENED); system->set_flag(fltk::OPENED);

View File

@ -607,6 +607,9 @@ void do_paste() {
} }
// Draw progress dialog // Draw progress dialog
// NOTE: sometimes when copying/moving just one file, the window
// can get "stuck"
// See: fltk STR 1255, http://www.fltk.org/str.php?L1255
Window* progress_window = new Window(350,150); Window* progress_window = new Window(350,150);
if (operation_is_copy) if (operation_is_copy)
progress_window->label(_("Copying files")); progress_window->label(_("Copying files"));
@ -660,6 +663,8 @@ void do_paste() {
caption->redraw(); caption->redraw();
if (stop_now || !my_copy(files_list[i], dest)) if (stop_now || !my_copy(files_list[i], dest))
break; break;
// Delete file after moving
if (!operation_is_copy) unlink(files_list[i]);
cut_copy_progress->position(cut_copy_progress->position()+1); cut_copy_progress->position(cut_copy_progress->position()+1);
fltk::check(); // check to see if user pressed Stop fltk::check(); // check to see if user pressed Stop
} }

View File

@ -1,14 +0,0 @@
#
# $Id$
#
# Part of Equinox Desktop Environment (EDE).
# Copyright (c) 2000-2007 EDE Authors.
#
# This program is licenced under terms of the
# GNU General Public Licence version 2 or newer.
# See COPYING for details.
SubDir TOP eimage ;
MakeProgram eimage : eimage.cpp ;
ExtractStrings locale : eimage.cpp ;

View File

@ -1,72 +1,76 @@
#include <Fl/Fl.h> #include <fltk/run.h>
#include <Fl/Fl_Window.h> #include <fltk/Window.h>
#include <Fl/Fl_Button.h> #include <fltk/DoubleBufferWindow.h>
#include <Fl/Fl_Shared_Image.h> #include <fltk/Button.h>
#include <Fl/Fl_Scroll.h> #include <fltk/SharedImage.h>
#include <Fl/Fl_Widget.h> #include <fltk/ScrollGroup.h>
#include <Fl/Fl_File_Chooser.h> #include <fltk/Widget.h>
#include <Fl/filename.h> #include <fltk/filename.h>
#include <fltk/events.h>
#include <fltk/PopupMenu.h>
#include <fltk/Item.h>
#include <fltk/Divider.h>
#include <fltk/Divider.h>
#include <fltk/file_chooser.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h>
#define DEBUG 1 using namespace fltk;
// Supported image types // Automatic detection of image type still doesn't work in fltk :(
const char* supported[] = {"bm","bmp","gif","jpg","pbm","pgm","png","ppm","xbm","xpm",0}; static struct {
const char* filename;
SharedImage* (*func)(const char*, const uchar*);
} supported[] = {
{ "*.png", pngImage::get},
{"*.jpg", jpegImage::get},
{"*.gif", gifImage::get},
{"*.bmp", bmpImage::get},
{"*.xpm", xpmFileImage::get},
{0, 0}
};
// Global variables used everywhere
char filename[FL_PATH_MAX], directory[FL_PATH_MAX]; // Making these global vastly simplifies the code
Fl_Window* w; // cause they're used a lot
// The proper thing to do is to make the whole program one big class
char filename[PATH_MAX], directory[PATH_MAX];
Window* w;
class CenteredInScroll;
CenteredInScroll* c;
float zoomfactor; float zoomfactor;
bool autozoom=false; bool autozoom=false;
Fl_Shared_Image *im;
class ScrolledImage; // Variables used in nextpic & prevpic
ScrolledImage* s;
// Directory list cache used in prevnext()
dirent **files; dirent **files;
int nfiles; int nfiles;
// Forward declaration of funcs for use from callbacks // Forward declaration of funcs for use from event handler
void nextpic(); void nextpic();
void prevpic(); void prevpic();
void loadimage(); void loadimage();
void newdir(); void newdir();
// Callbacks for popup menu
// Callbacks for main menu void next_cb(Widget*) { nextpic(); }
void next_cb(Fl_Widget*,void*) { nextpic(); } void prev_cb(Widget*) { prevpic(); }
void prev_cb(Fl_Widget*,void*) { prevpic(); } void open_cb(Widget*) {
void open_cb(Fl_Widget*,void*) { const char* f = file_chooser("Choose image or directory","Image Files (*.{bmp,gif,jpg,png,xpm})",directory);
// construct filename filter
char filter[FL_PATH_MAX];
snprintf(filter, FL_PATH_MAX, "Image files(*.{%s", supported[0]);
for (int i=1; supported[i]; i++)
snprintf(filter, FL_PATH_MAX, "%s,%s", filter, supported[i]);
snprintf(filter, FL_PATH_MAX, "%s})", filter);
const char* f = fl_file_chooser("Choose image or directory",filter,directory);
if (!f) return; if (!f) return;
strncpy(filename,f,PATH_MAX);
strncpy(filename,f,FL_PATH_MAX);
newdir(); newdir();
loadimage(); loadimage();
} }
void manage_cb(Widget* b) {} // call file manager
void manage_cb(Fl_Widget* b,void*) {} // call file manager void fullscr_cb(Widget* b) {
void fullscreen_cb(Fl_Widget* b,void*) {
static bool isfull=false; static bool isfull=false;
static int X,Y,W,H; static int X,Y,W,H;
if (isfull) { if (isfull) {
@ -78,116 +82,136 @@ void fullscreen_cb(Fl_Widget* b,void*) {
isfull=true; isfull=true;
} }
} }
void zoomin_cb(Fl_Widget* b,void*) { void exit_cb(Widget* b) { exit(0); }
void zoomin_cb(Widget* b) {
if (zoomfactor>=1) zoomfactor += 0.2; else zoomfactor += zoomfactor/5; if (zoomfactor>=1) zoomfactor += 0.2; else zoomfactor += zoomfactor/5;
autozoom=false; autozoom=false;
loadimage(); loadimage();
} }
void zoomout_cb(Fl_Widget* b,void*) { void zoomout_cb(Widget* b) {
if (zoomfactor>=1) zoomfactor -= 0.2; else zoomfactor -= zoomfactor/5; if (zoomfactor>=1) zoomfactor -= 0.2; else zoomfactor -= zoomfactor/5;
autozoom=false; autozoom=false;
loadimage(); loadimage();
} }
void zoomrestore_cb(Fl_Widget* b,void*) { zoomfactor = 1; autozoom=false; loadimage(); } void zoomrestore_cb(Widget* b) { zoomfactor = 1; autozoom=false; loadimage(); }
void zoomauto_cb(Fl_Widget *b,void*) { autozoom = !autozoom; loadimage(); } void zoomauto_cb(Widget *b) { autozoom = !autozoom; loadimage(); }
void about_cb(Fl_Widget* b,void*) {} // about window
void exit_cb(Fl_Widget* b,void*) { exit(0); }
// Main popup menu
Fl_Menu_Item mainmenu[] = {
{"&Open", FL_CTRL+'o', open_cb},
{"&Manage", 0, manage_cb, 0, FL_MENU_DIVIDER},
{"&Previous", FL_Page_Up, prev_cb},
{"&Next", FL_Page_Down, next_cb, 0, FL_MENU_DIVIDER},
{"&Zoom in", '+', zoomin_cb},
{"Zoom &out", '-', zoomout_cb},
{"Zoom &auto", FL_CTRL+'a', zoomauto_cb},
{"&Restore", '/', zoomrestore_cb, 0, FL_MENU_DIVIDER},
{"&Fullscreen", FL_F+11, fullscreen_cb, 0, FL_MENU_DIVIDER},
{"A&bout", 0, about_cb},
{"&Exit", FL_Escape, exit_cb},
{0}
};
class ScrolledImage : public Fl_Scroll { class CenteredInScroll : public Button {
private: private:
Fl_Box* b; PopupMenu* popup;
Fl_Menu_Button* mb;
public: public:
ScrolledImage(int x, int y, int w, int h, const char*l = 0) CenteredInScroll(int x, int y, int w, int h, const char*l = 0)
: Fl_Scroll(x,y,w,h,l) { : Button(x,y,w,h,l) {
align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER); popup = new PopupMenu(0, 0, 0, 0);
begin(); if(popup->parent())
popup->parent()->remove(popup);
popup->parent(0);
popup->type(PopupMenu::POPUP3);
popup->begin();
b = new Fl_Box(w/2,h/2,0,0); {Item *i = new Item("&Open...");
i->callback(open_cb);
mb = new Fl_Menu_Button (0,0,0,0,""); i->shortcut(CTRL+'o');
mb->type(Fl_Menu_Button::POPUP3);
mb->menu(0);
end();
redraw();
} }
void image(Fl_Image* a) { b->image(a); } {Item *i = new Item("&Manage...");
void image(Fl_Image& a) { b->image(a); } i->callback(manage_cb);
Fl_Image* image() { return b->image(); }
void label(const char* a) {
if (a) resizebox(0,0); // center label
b->label(a);
} }
// Resize the box containing image new Divider();
void resizebox(int W, int H) {
int X=0,Y=0; {Item *i = new Item("&Next");
int aw = w()-scrollbar.w(); int ah=h()-hscrollbar.h(); i->callback(next_cb);
if(aw>W) X=(aw-W)/2; i->shortcut(DownKey);
if(ah>H) Y=(ah-H)/2;
b->resize(X,Y,W,H);
} }
void resize(int x,int y,int w,int h) { {Item *i = new Item("&Previous");
Fl_Scroll::resize(x,y,w,h); i->callback(prev_cb);
resizebox(b->w(),b->h()); // refresh image position i->shortcut(UpKey);
redraw(); }
new Divider();
{Item *i = new Item("&Zoom in");
i->callback(zoomin_cb);
i->shortcut('+');
}
{Item *i = new Item("Zoom &out");
i->callback(zoomout_cb);
i->shortcut('-');
}
{Item *i = new Item("Zoom &auto");
i->callback(zoomauto_cb);
i->shortcut(CTRL+'a');
}
{Item *i = new Item("&Restore");
i->callback(zoomrestore_cb);
i->shortcut('/');
}
new Divider();
{Item *i = new Item("&Fullscreen");
i->callback(fullscr_cb);
i->shortcut(F11Key);
}
new Divider();
{Item *i = new Item("A&bout");
i->callback(exit_cb);
}
{Item *i = new Item("&Exit");
i->callback(exit_cb);
i->shortcut(EscapeKey);
}
popup->end();
}
virtual void draw() {
int ix, iy;
if (w() < parent()->w()) { ix=((parent()->w() - w())/2); } else { ix=0; }
if (h() < parent()->h()) { iy=((parent()->h() - h())/2); } else { iy=0; }
Image *i = (Image*)image();
i->draw(Rectangle(ix,iy,w(),h()));
} }
virtual int handle(int event) { virtual int handle(int event) {
if (event == FL_PUSH) { if (event == KEY) {
if(Fl::event_button()==3 && mb->menu()!=0) { int key = event_key();
mb->popup(); const char* text = event_text(); // needed to detect some keys
if (key == LeftKey || key == UpKey) prevpic();
else if (key == RightKey || key == DownKey) nextpic();
// Shortcuts from popup menu wont work unless we define them here
// The 'this' is just to pass something to callback, it wont be used
else if (key == CTRL+'o') open_cb(this);
else if (strcmp(text,"+")==0 || key == AddKey) zoomin_cb(this);
else if (strcmp(text,"-")==0 || key == SubtractKey) zoomout_cb(this);
else if (strcmp(text,"/")==0 || key == DivideKey) zoomrestore_cb(this);
else if (key == CTRL+'a') zoomauto_cb(this);
else if (key == F11Key) fullscr_cb(this);
}
else if (event == PUSH) {
if(event_button()==3) {
popup->popup();
return 1; return 1;
} }
} }
// sometimes PgUp and PgDown aren't handled return Button::handle(event);
else if (event == FL_SHORTCUT && mb->menu()!=0) {
int key = Fl::event_key();
if (key==FL_Page_Up || key==FL_Page_Down)
return mb->handle(event);
}
return Fl_Scroll::handle(event);
}
void setmenu(Fl_Menu_Item* menu) {
if (menu!=0) {
mb->menu(menu);
}
} }
}; };
// Directory changed, get new directory from filename // Directory changed, get new directory from filename
void newdir() { void newdir() {
int p=0; int p=0;
@ -203,133 +227,98 @@ void newdir() {
// Load the image given in char[] filename // Load the image given in char[] filename
void loadimage() { void loadimage() {
char tmp[FL_PATH_MAX]; // the string buffer fprintf(stderr, "Loadimage() - file: %s\n",filename);
if (DEBUG) fprintf(stderr, "Loadimage() - file: %s\n",filename);
// Load image // Load image
if (im) { im->release(); im=0; } SharedImage *im;
im = Fl_Shared_Image::get(filename); // image type is autodetected now for (int j=0; supported[j].filename; j++)
if (filename_match(filename,supported[j].filename)) {
if (!im) { im = supported[j].func(filename,0);
if (DEBUG) fprintf(stderr, "Fl_Shared_Image::get() failed!\n"); break;
s->image(0);
snprintf(tmp, FL_PATH_MAX, "Can't load image %s\n",filename);
s->label(strdup(tmp));
s->redraw();
return;
} }
// Measure image int W,H;
int realw=im->w(), realh=im->h(); im->measure(W,H); // Should this wait until image is loaded?
int scaledw,scaledh;
if (autozoom) { if (autozoom) {
// Adjust zoom factor so picture fits inside window // Adjust zoom factor so picture fits on screen
// When user switches to manual zooming, this factor will remain // When switch to manual zooming, this factor will be used
float fw=(float)s->w()/realw; float fh=(float)s->h()/realh; float pw=c->parent()->w()+1, ph=c->parent()->h()+1;
if (fw < fh) zoomfactor=fw; else zoomfactor=fh; // use float to avoid rounding
if (pw/W < ph/H) zoomfactor=pw/W; else zoomfactor=ph/H;
} }
// Resample image to new size c->w((int)W*zoomfactor-1); // cast to int and -1 help avoid
scaledw=realw*zoomfactor; c->h((int)H*zoomfactor-1); // scrollbars when autozoom is on
scaledh=realh*zoomfactor; c->image(im);
if (zoomfactor!=1) { c->parent()->relayout(); // remove scrollbars if necessary
Fl_Image *temp = im->copy(scaledw,scaledh); c->parent()->redraw(); // remove traces of old picture
im = (Fl_Shared_Image*) temp;
}
// Set image c->label(""); // clear any previous labels
s->resizebox(scaledw,scaledh);
s->image(im);
s->label(0); // clear any previous labels char tmp[PATH_MAX]; // set window title
s->redraw();
// set window title
if (zoomfactor==1) if (zoomfactor==1)
snprintf(tmp,FL_PATH_MAX,"%s (%dx%d) - View picture",fl_filename_name(filename),realw,realh); snprintf(tmp,PATH_MAX,"%s (%dx%d) - View picture",filename_name(filename),W,H);
else else
snprintf(tmp,FL_PATH_MAX,"%s (%dx%d) - zoom %1.1fx - View picture",fl_filename_name(filename),realw,realh,zoomfactor); snprintf(tmp,PATH_MAX,"%s (%dx%d) - zoom %1.1fx - View picture",filename_name(filename),W,H,zoomfactor);
w->label(strdup(tmp)); w->label(strdup(tmp));
} }
// Get next/previous picture file in directory // Get next/previous picture file in directory d
// (universal func. to be called from nextpic() and prevpic() ) // (universal func. to be called from nextpic() and prevpic()
void prevnext(int direction) { void prevnext(int direction) {
char tmp[FL_PATH_MAX]; // the string buffer fprintf(stderr, "Nextpic() - file: %s dir: %s direction: %d\n",filename,directory,direction);
if (DEBUG)
fprintf(stderr, "Prevnext() - file: %s dir: %s direction: %d\n",filename,directory,direction);
if (nfiles == 0) { // read directory if (nfiles == 0) { // read directory
nfiles = fl_filename_list(directory,&files); nfiles = filename_list(directory,&files);
} }
// Select next picture after current // Select next picture after current
bool found=false; bool found=false;
if (filename[0]) { const char* justname = filename_name(filename);
const char* justname = fl_filename_name(filename);
// this basically means: if direction is 1 go from first to last, else from last to first // this basically means: if direction is 1 go from first to last, else from last to first
for (int i=(direction?0:nfiles-1); (direction?i<nfiles:i>=0); i+=(direction?1:-1)) { for (int i=(direction?0:nfiles-1); (direction?i<nfiles:i>=0); i+=(direction?1:-1)) {
if (strncmp(justname,files[i]->d_name,FL_PATH_MAX) == 0) { if (strncmp(justname,files[i]->d_name,PATH_MAX) == 0) {
found=true; found=true;
continue; // skip to next file continue;
} }
if (found) { if (found) {
for (int j=0; supported[j]; j++) { for (int j=0; supported[j].filename; j++) {
snprintf(tmp,FL_PATH_MAX,"*.%s",supported[j]); if (filename_match(files[i]->d_name,supported[j].filename)) {
if (fl_filename_match(files[i]->d_name,tmp)) { snprintf(filename,PATH_MAX,"%s/%s",directory,files[i]->d_name);
snprintf(filename,FL_PATH_MAX,"%s/%s",directory,files[i]->d_name);
loadimage(); loadimage();
return; return;
} }
} }
} }
} }
}
if (found) { //this means that the current picture is the last/first in directory // Current picture not found, give first in directory
if (im) { im->release(); im=0; }
s->image(0);
filename[0]=0;
if (direction)
s->label("This was the last picture.\nPress 'Next' again for first one.");
else
s->label("This was the first picture.\nPress 'Previous' again for last one.");
s->redraw();
return;
} else {
// Just give first (or last) picture in directory
for (int i=(direction?0:nfiles-1); (direction?i<nfiles:i>=0); i+=(direction?1:-1)) { for (int i=(direction?0:nfiles-1); (direction?i<nfiles:i>=0); i+=(direction?1:-1)) {
for (int j=0; supported[j]; j++) { for (int j=0; supported[j].filename; j++) {
snprintf(tmp,FL_PATH_MAX,"*.%s",supported[j]); if (filename_match(files[i]->d_name,supported[j].filename)) {
if (fl_filename_match(files[i]->d_name,tmp)) { snprintf(filename,PATH_MAX,"%s/%s",directory,files[i]->d_name);
snprintf(filename,FL_PATH_MAX,"%s/%s",directory,files[i]->d_name);
loadimage(); loadimage();
return; return;
} }
} }
} }
}
// Nothing found... // Nothing found...
if (DEBUG) fprintf(stderr, "Nextpic() - nothing found\n"); fprintf(stderr, "Nextpic() - nothing found\n");
char tmp[PATH_MAX];
if (im) { im->release(); im=0; } snprintf(tmp,PATH_MAX,"No pictures in directory %s",directory);
s->image(0); c->label(strdup(tmp));
filename[0]=0; // Position label on center and redraw everything
snprintf(tmp,FL_PATH_MAX,"No pictures in directory %s",directory); c->w(1); c->h(1);
s->label(strdup(tmp)); c->x(c->parent()->w()/2);
s->redraw(); c->y(c->parent()->h()/2);
c->redraw();
c->parent()->relayout();
c->parent()->redraw();
// Window title // Window title
snprintf(tmp,FL_PATH_MAX,"View picture - nothing found in %s",directory); snprintf(tmp,PATH_MAX,"View picture - nothing found in %s",directory);
w->label(strdup(tmp)); w->label(strdup(tmp));
} }
@ -339,47 +328,59 @@ void prevpic() { prevnext(0); }
int main (int argc, char **argv) { int main (int argc, char **argv) {
filename[0]='\0'; directory[0]='\0'; zoomfactor=1; im=0; filename[0]='\0'; directory[0]='\0'; zoomfactor=1;
fl_register_images();
w = new Window(200, 200, "View picture");
// Main window w->set_vertical();
w->set_double_buffer();
w = new Fl_Window(200, 200, "View picture"); w->begin();
s = new ScrolledImage(0,0,200,200); {ScrollGroup* g = new ScrollGroup(0, 0, 200, 200);
s->color(33); //g->set_vertical();
s->labelcolor(FL_WHITE); // Group::current()->resizable(o);
s->setmenu(mainmenu); g->box(FLAT_BOX);
w->resizable(s); g->color(GRAY05);
// g->color(WHITE);
g->align(ALIGN_RIGHT);
g->resize_align(ALIGN_RIGHT);
g->begin();
{c = new CenteredInScroll(0,0,200,200);
g->align(ALIGN_LEFT|ALIGN_TOP);
c->box(NO_BOX);
c->focusbox(NO_BOX);
g->color(GRAY05);
c->labelcolor(WHITE);
c->labelsize(14);
c->tooltip("Right click for menu");
c->take_focus();
}
g->end();
}
w->end(); w->end();
w->align(FL_ALIGN_INSIDE|FL_ALIGN_CENTER); w->resizable(w);
// Analyze command line // Analyze command line
if (argc==1) { // No params if (argc==1) { // No params
strncpy (directory, getenv("HOME"), FL_PATH_MAX); strncpy (directory, getenv("HOME"), PATH_MAX);
nextpic(); nextpic();
} else if (fl_filename_isdir(argv[1])) { // Param is directory } else if (filename_isdir(argv[1])) { // Param is directory
strncpy (directory, argv[1], FL_PATH_MAX); strncpy (directory, argv[1], PATH_MAX);
nextpic(); nextpic();
argc--; argv++; // ignore this param and forward rest to fltk argc--; argv++; // ignore this param and forward rest to fltk
} else { // Param is file } else { // Param is file
if (argv[1][0] == '~' && argv[1][1] == '/') // expand home dir if (argv[1][0] == '~' && argv[1][1] == '/') // expand home dir
snprintf (filename, FL_PATH_MAX, "%s/%s", getenv("HOME"), argv[1]+2); snprintf (filename, PATH_MAX, "%s/%s", getenv("HOME"), argv[1]+2);
else if (argv[1][0] != '/') // relative filename else if (argv[1][0] != '/') // relative filename
snprintf (filename, FL_PATH_MAX, "%s/%s", getenv("PWD"), argv[1]); snprintf (filename, PATH_MAX, "%s/%s", getenv("PWD"), argv[1]);
else // absolute filename else // absolute filename
strncpy (filename, argv[1], FL_PATH_MAX); strncpy (filename, argv[1], PATH_MAX);
struct stat last_stat; // Does file exist? if (!filename_exist(argv[1])) {
if (stat(argv[0], &last_stat)!=0) { char tmp[PATH_MAX];
char tmp[FL_PATH_MAX]; snprintf(tmp,PATH_MAX,"File not found - %s",filename);
snprintf(tmp,FL_PATH_MAX,"File not found - %s",filename); c->label(tmp);
s->label(tmp);
} else } else
loadimage(); loadimage();
@ -387,14 +388,7 @@ int main (int argc, char **argv) {
argc--; argv++; // ignore this param and forward rest to fltk argc--; argv++; // ignore this param and forward rest to fltk
} }
// Resize window to image size or screen
int W,H;
if (im->w()>Fl::w()) W=Fl::w(); else W=im->w();
if (im->h()>Fl::h()) H=Fl::h(); else H=im->h();
w->resize(0,0,W,H);
// Window manager should make sure that window is fully visible
w->show(argc,argv); w->show(argc,argv);
return Fl::run(); return run();
} }