2
* Copyright 2007 Simone Della Longa <simonedll@yahoo.it>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include <iostream> //cout
27
#include <gconf/gconf-client.h>
33
#include "wx/xml/xml.h"
35
#include "wx/filesys.h"
36
#include "wx/encconv.h"
37
#include "wx/dialog.h"
38
#include "wx/cmdline.h"
39
#include "wx/graphics.h"
40
#include "wx/dynarray.h"
42
#include "wx/filename.h"
43
#include "wx/aboutdlg.h"
44
#include "wx/generic/aboutdlgg.h"
45
#include "wx/propdlg.h"
46
#include "wx/generic/propdlg.h"
47
#include "wx/dcbuffer.h"
48
#include "wx/tooltip.h"
50
/* For dialogs stuff */
51
#include "wx/checkbox.h"
52
#include "wx/imaglist.h"
53
#include "wx/artprov.h"
54
#include "wx/spinctrl.h"
55
#include "wx/toolbook.h"
56
#include "wx/stattext.h"
57
#include "wx/filedlg.h"
64
WX_DEFINE_ARRAY (simImage *, ImagesArray);
66
#define SIMDOCK_VERSION "1.2.1"
67
#define SIMDOCK_WEBSITE "http://sourceforge.net/projects/simdock"
68
//#define SIMDOCK_DEBUG
69
//#define SIMDOCK_DEBUG_ICON_POSITIONING //this is very verbose
71
#include "settingsDialog.h"
75
#include "gconf_settings.h"
76
#include "background.h"
83
/* Loading wxStrings from chars */
85
#define _U(x) wxString((x),wxConvUTF8)
86
#define _UU(x,y) wxString((x),y)
93
#define CONF_DIR ".SimDock"
94
#define CONF_FILE "launchers.xml"
97
#define XML_SIMDOCK "SimDock"
98
#define XML_PROGRAM "Program"
99
#define XML_PATH "path"
100
#define XML_ICON "icon"
101
#define XML_DESCR "description"
102
#define XML_NAME "name"
104
#define TIMER_TIMEOUT_BLUR 100
112
#define STRETCHED_STR "stretched"
113
#define CENTERED_STR "centered"
114
#define SCALED_STR "scaled"
115
#define NONE_STR "none"
116
#define WALLPAPER_STR "wallpaper"
118
#define DATA_DIR "/usr/share/simdock"
120
//#include <wx/arrimpl.cpp>
121
//WX_DEFINE_OBJARRAY(simImage)
122
//WX_DEFINE_OBJARRAY(ImagesList);
125
//WX_DECLARE_LIST(simImage, ImagesList);
130
/* wxString to std::string converter. Useful for printing stuff */
131
std::string wx2std (const wxString & input);
133
/* Creates the given directory only if it does not exist */
134
bool fixSimDir (wxString * dirPath);
135
/* Opens the given filename or initialize it with given data */
136
bool openOrInitialize (wxString * fullPath, char *initializeData);
137
/* Opens the given filename or creates it if does not exist */
138
bool openOrCreate (wxFile * settingsFile, wxString * fullPath);
139
/* Saves the given images array to the given filesystem location*/
140
bool saveLaunchers(ImagesArray* list, const wxString& location);
142
/* Register the sigint callback to call MyApp::GracefullyExit ()*/
143
void register_sigint (MyApp * application);
145
/* ------ Various functions for simImage array manipulation -------*/
147
/* Reposition icons according to their size and order
148
* Currently repositioning starts from index 0 so all the icons are moved to the right
149
* "ind" is currently ignored.
150
* TODO: Implement right side and left side repositioning starting from "ind" index?
152
wxSize PositionIcons (wxSize sz, int ind, simSettings* settings, ImagesArray* ImagesList);
153
wxSize FirstPosition (wxSize sz, simSettings* settings, ImagesArray* list);
155
/* ------ Various functions for simImage array manipulation -------*/
160
simSettings (int LEFT_BORDER, int RIGHT_BORDER,int BOTTOM_BORDER,int ICONW,int ICONH,
161
int PERCENT,int RANGE,
162
int SPACER,int BG_HEIGHT,wxString bgPath,bool SHOW_REFLEXES,int
163
REFLEX_SCALING,int REFLEX_ALPHA, bool AUTO_POSITION, bool ENABLE_TASKS
166
this->LEFT_BORDER = LEFT_BORDER;
167
this->RIGHT_BORDER = RIGHT_BORDER;
168
this->BOTTOM_BORDER = BOTTOM_BORDER;
171
this->PERCENT = PERCENT;
173
this->SPACER = SPACER;
174
this->BG_HEIGHT = BG_HEIGHT;
175
this->BG_PATH = bgPath;
176
this->SHOW_REFLEXES = SHOW_REFLEXES;
177
this->REFLEX_SCALING = REFLEX_SCALING;
178
this->REFLEX_ALPHA = REFLEX_ALPHA;
179
this->MAXSIZE = ICONW + ICONW * PERCENT / 100;
180
this->AUTO_POSITION = AUTO_POSITION;
181
this->ENABLE_TASKS = ENABLE_TASKS;
203
class MyApp:public wxApp
206
virtual int OnExit ();
207
void GracefullyExit ();
208
virtual bool OnInit ();
209
virtual void OnInitCmdLine (wxCmdLineParser & parser);
210
virtual bool OnCmdLineParsed (wxCmdLineParser & parser);
211
void reposition() { if (frame) frame->appSize = FirstPosition (frame->GetClientSize (),settings,ImagesList); }
212
void updateSize() { if (frame) frame->updateSize();}
213
void refresh() { if (frame) frame->Refresh(false);}
214
/* If launchers list have been modified from the starting */
215
bool launchersModified;
218
void SetWallpaper (wxBitmap * newBitmap) {if (frame) frame->SetWallpaper(newBitmap); }
219
wxBitmap * GetWallpaper (){if (frame) frame->GetWallpaper(); }
222
simSettings* settings;
223
/* -----Custom background stuff----- */
224
wxString customBackground;
225
int customBackgroundType;
226
wxColour customBackgroundColour;
227
/* -----Custom background stuff----- */
230
ImagesArray* ImagesList;
237
/* http://www.wxwidgets.org/wiki/index.php/Command-Line_Arguments */
239
static const wxCmdLineEntryDesc g_cmdLineDesc[] = {
240
{wxCMD_LINE_SWITCH, wxT ("h"), wxT ("help"),
241
wxT ("displays help on the command line parameters"),
242
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP},
243
{wxCMD_LINE_OPTION, wxT ("b"), wxT ("background"),
244
wxT ("use custom wallpaper"),
245
wxCMD_LINE_VAL_STRING},
246
{wxCMD_LINE_OPTION, wxT ("t"), wxT ("type"),
247
_("wallpaper positioning: <" CENTERED_STR "> <" STRETCHED_STR "> <"
248
NONE_STR ">"), wxCMD_LINE_VAL_STRING},
249
{wxCMD_LINE_OPTION, wxT ("o"), wxT ("color"),
251
("background color. Hex or name values accepted. examples: -o:#FF0000 , -o:red"),
252
wxCMD_LINE_VAL_STRING},
253
{wxCMD_LINE_SWITCH, wxT ("r"), wxT ("tray"), wxT ("show in the trayBar"),
254
wxCMD_LINE_VAL_NONE},
255
{wxCMD_LINE_SWITCH, wxT ("y"), wxT ("on top"), wxT ("show on-top of other windows"),
256
wxCMD_LINE_VAL_NONE},