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