]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/main.cpp
Change Groupbox name to Remote Director in Configuration page if Director is not...
[bacula/bacula] / bacula / src / wx-console / main.cpp
1 /*
2  *
3  *    Bacula wx-console application
4  *
5  *    Nicolas Boichat, April 2004
6  *
7  *    Version $Id$
8  */
9 /*
10    Copyright (C) 2004-2006 Kern Sibbald
11
12    This program is free software; you can redistribute it and/or
13    modify it under the terms of the GNU General Public License
14    version 2 as amended with additional clauses defined in the
15    file LICENSE in the main source directory.
16
17    This program is distributed in the hope that it will be useful,
18    but WITHOUT ANY WARRANTY; without even the implied warranty of
19    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
20    the file LICENSE for additional details.
21
22  */
23
24 // ============================================================================
25 // declarations
26 // ============================================================================
27
28 // ----------------------------------------------------------------------------
29 // headers
30 // ----------------------------------------------------------------------------
31
32 /*  Windows debug builds set _DEBUG which is used by wxWidgets to select their
33  *  debug memory allocator.  Unfortunately it conflicts with Bacula's SmartAlloc.
34  * So we turn _DEBUG off since we aren't interested in things it enables.
35  */
36
37 #undef _DEBUG
38
39 #include "bacula.h"
40
41 #undef setlocale
42 #undef textdomain
43 #undef bindtextdomain
44
45 #include <wx/wxprec.h>
46 #include <wx/config.h>
47 #include <wx/intl.h>
48 #include "wxbmainframe.h"
49 #include "csprint.h"
50
51
52 /* Dummy functions */
53 int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
54 int generate_job_event(JCR *jcr, const char *event) { return 1; }
55
56
57 // ----------------------------------------------------------------------------
58 // resources
59 // ----------------------------------------------------------------------------
60
61 class MyApp : public wxApp
62 {
63 public:
64    virtual bool OnInit();
65 };
66
67 // ============================================================================
68 // implementation
69 // ============================================================================
70
71 IMPLEMENT_APP(MyApp)
72
73 // ----------------------------------------------------------------------------
74 // the application class
75 // ----------------------------------------------------------------------------
76
77 // 'Main program' equivalent: the program execution "starts" here
78 bool MyApp::OnInit()
79 {
80    /* wxWidgets internationalisation */
81    wxLocale m_locale;
82    m_locale.Init();
83    m_locale.AddCatalog(wxT("bacula"));
84    wxLocale::AddCatalogLookupPathPrefix(wxT(LOCALEDIR));
85
86    long posx, posy, sizex, sizey;
87    int displayx, displayy;
88    OSDependentInit();
89    wxConfig::Get()->Read(wxT("/Position/X"), &posx, 50);
90    wxConfig::Get()->Read(wxT("/Position/Y"), &posy, 50);
91    wxConfig::Get()->Read(wxT("/Size/Width"), &sizex, 780);
92    wxConfig::Get()->Read(wxT("/Size/Height"), &sizey, 500);
93    
94    wxDisplaySize(&displayx, &displayy);
95    
96    /* Check if we are on the screen... */
97    if ((posx+sizex > displayx) || (posy+sizey > displayy)) {
98       /* Try to move the top-left corner first */
99       posx = 50;
100       posy = 50;
101       if ((posx+sizex > displayx) || (posy+sizey > displayy)) {
102          posx = 25;
103          posy = 25;
104          sizex = displayx - 50;
105          sizey = displayy - 50;
106       }
107    }
108
109    wxbMainFrame *frame = wxbMainFrame::CreateInstance(_("Bacula wx-console"),
110                          wxPoint(posx, posy), wxSize(sizex, sizey));
111
112    frame->Show(TRUE);
113
114    frame->Print(wxString::Format(_("Welcome to bacula wx-console %s (%s)!\n"), wxT(VERSION), wxT(BDATE)), CS_DEBUG);
115
116    frame->StartConsoleThread(wxT(""));
117    
118    return TRUE;
119 }