1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
/*
* Copyright 2007 Simone Della Longa <simonedll@yahoo.it>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef MAIN_H_
#define MAIN_H_
#include <iostream> //cout
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <dirent.h>
#include <glib.h>
#include <gconf/gconf-client.h>
#include <gdk/gdkx.h>
#include "wx/wx.h"
#include "wx/utils.h"
#include "wx/xml/xml.h"
#include "wx/event.h"
#include "wx/filesys.h"
#include "wx/encconv.h"
#include "wx/dialog.h"
#include "wx/cmdline.h"
#include "wx/graphics.h"
#include "wx/dynarray.h"
#include "wx/file.h"
#include "wx/filename.h"
#include "wx/aboutdlg.h"
#include "wx/generic/aboutdlgg.h"
#include "wx/propdlg.h"
#include "wx/generic/propdlg.h"
#include "wx/dcbuffer.h"
#include "wx/tooltip.h"
/* For dialogs stuff */
#include "wx/checkbox.h"
#include "wx/imaglist.h"
#include "wx/artprov.h"
#include "wx/spinctrl.h"
#include "wx/toolbook.h"
#include "wx/stattext.h"
#include "wx/filedlg.h"
class simImage;
class simSettings;
class MyApp;
WX_DEFINE_ARRAY (simImage *, ImagesArray);
#define SIMDOCK_VERSION "1.3"
#define SIMDOCK_WEBSITE "http://sourceforge.net/projects/simdock"
//#define SIMDOCK_DEBUG
//#define SIMDOCK_DEBUG_ICON_POSITIONING //this is very verbose
#include "simImage.h"
#include "settingsDialog.h"
#include "myFrame.h"
//#include "getBg.h"
#include "gconf_settings.h"
#include "background.h"
//windows list
#include "tasks.h"
#include "simSettings.h"
#include "xstuff.h"
/* Loading wxStrings from chars */
#ifdef wxUSE_UNICODE
#define _U(x) wxString((x),wxConvUTF8)
#define _UU(x,y) wxString((x),y)
#else
#define _U(x) (x)
#define _UU(x,y) (x)
#endif
#define CONF_DIR ".simdock"
#define CONF_FILE "launchers.xml"
/* XML nodes */
#define XML_SIMDOCK "SimDock"
#define XML_PROGRAM "Program"
#define XML_PATH "path"
#define XML_ICON "icon"
#define XML_DESCR "description"
#define XML_NAME "name"
#define TIMER_TIMEOUT_BLUR 100
#define STRETCHED 1
#define CENTERED 2
#define SCALED 3
#define NONE 4
#define WALLPAPER 5
#define STRETCHED_STR "stretched"
#define CENTERED_STR "centered"
#define SCALED_STR "scaled"
#define NONE_STR "none"
#define WALLPAPER_STR "wallpaper"
#define DATA_DIR "/usr/share/simdock"
//#include <wx/arrimpl.cpp>
//WX_DEFINE_OBJARRAY(simImage)
//WX_DEFINE_OBJARRAY(ImagesList);
//WX_DECLARE_LIST(simImage, ImagesList);
/* wxString to std::string converter. Useful for printing stuff */
std::string wx2std (const wxString & input);
const wxString PROGRAMS_PATH = wxGetHomeDir() + _T ("/") + _T (CONF_DIR) + _T ("/") + _T (CONF_FILE);
std::string getGTKIconPath(std::string name);
/* Creates the given directory only if it does not exist */
bool fixSimDir (wxString * dirPath);
/* Opens the given filename or initialize it with given data */
bool openOrInitialize (wxString * fullPath, std::string *initializeData);
/* Opens the given filename or creates it if does not exist */
bool openOrCreate (wxFile * settingsFile, wxString * fullPath);
/* Saves the given images array to the given filesystem location*/
bool saveLaunchers(ImagesArray* list);
/* Register the sigint callback to call MyApp::GracefullyExit ()*/
void register_sigint (MyApp * application);
/* ------ Various functions for simImage array manipulation -------*/
/* Reposition icons according to their size and order
* Currently repositioning starts from index 0 so all the icons are moved to the right
* TODO: Implement right side and left side repositioning starting from "ind" index?
*/
wxSize PositionIcons (wxSize sz, simSettings settings, ImagesArray* ImagesList);
wxSize FirstPosition (wxSize sz, simSettings settings, ImagesArray* list);
/* ------ Various functions for simImage array manipulation -------*/
class MyApp:public wxApp
{
public:
virtual int OnExit ();
void GracefullyExit ();
virtual bool OnInit ();
virtual void OnInitCmdLine (wxCmdLineParser & parser);
virtual bool OnCmdLineParsed (wxCmdLineParser & parser);
void reposition() { if (frame) frame->appSize = FirstPosition (frame->GetClientSize (),frame->settings,ImagesList); }
void updateSize() { if (frame) frame->updateSize();}
void refresh() { if (frame) frame->Refresh(false);}
bool onTop;
void SetWallpaper (wxBitmap * newBitmap) {if (frame) frame->SetWallpaper(newBitmap); }
wxBitmap * GetWallpaper (){if (frame) return frame->GetWallpaper(); }
private:
/* -----Custom background stuff----- */
wxString customBackground;
int customBackgroundType;
wxColour customBackgroundColour;
/* -----Custom background stuff----- */
MyFrame *frame;
bool showInTray;
ImagesArray* ImagesList;
SettingsDialog* sd;
std::string defaultLaunchers;
};
/* http://www.wxwidgets.org/wiki/index.php/Command-Line_Arguments */
static const wxCmdLineEntryDesc g_cmdLineDesc[] = {
{wxCMD_LINE_SWITCH, wxT ("h"), wxT ("help"),
wxT ("displays help on the command line parameters"),
wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP},
{wxCMD_LINE_OPTION, wxT ("b"), wxT ("background"),
wxT ("use custom wallpaper"),
wxCMD_LINE_VAL_STRING},
{wxCMD_LINE_OPTION, wxT ("t"), wxT ("type"),
_("wallpaper positioning: <" CENTERED_STR "> <" STRETCHED_STR "> <"
NONE_STR ">"), wxCMD_LINE_VAL_STRING},
{wxCMD_LINE_OPTION, wxT ("o"), wxT ("color"),
wxT
("background color. Hex or name values accepted. examples: -o:#FF0000 , -o:red"),
wxCMD_LINE_VAL_STRING},
{wxCMD_LINE_SWITCH, wxT ("r"), wxT ("tray"), wxT ("show in the trayBar"),
wxCMD_LINE_VAL_NONE},
{wxCMD_LINE_SWITCH, wxT ("y"), wxT ("on top"), wxT ("show on-top of other windows"),
wxCMD_LINE_VAL_NONE},
{wxCMD_LINE_NONE}
};
DECLARE_APP (MyApp)
#endif
|