]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/wx-console/main.cpp
Mark translatable strings in all source files.
[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-2005 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 #include <wx/wxprec.h>
33 #include <wx/config.h>
34
35 #include "wxbmainframe.h"
36
37 #include "csprint.h"
38
39 void InitWinAPIWrapper();
40
41 /* Dummy functions */
42 int generate_daemon_event(JCR *jcr, const char *event) { return 1; }
43 int generate_job_event(JCR *jcr, const char *event) { return 1; }
44
45
46 // ----------------------------------------------------------------------------
47 // resources
48 // ----------------------------------------------------------------------------
49
50 class MyApp : public wxApp
51 {
52 public:
53    virtual bool OnInit();
54 };
55
56 // ============================================================================
57 // implementation
58 // ============================================================================
59
60 IMPLEMENT_APP(MyApp)
61
62 // ----------------------------------------------------------------------------
63 // the application class
64 // ----------------------------------------------------------------------------
65
66 // 'Main program' equivalent: the program execution "starts" here
67 bool MyApp::OnInit()
68 {
69    setlocale(LC_ALL, "");
70    bindtextdomain("bacula", LOCALEDIR);
71    textdomain("bacula");
72
73    long posx, posy, sizex, sizey;
74    int displayx, displayy;
75    InitWinAPIWrapper();
76    wxConfig::Get()->Read(wxT("/Position/X"), &posx, 50);
77    wxConfig::Get()->Read(wxT("/Position/Y"), &posy, 50);
78    wxConfig::Get()->Read(wxT("/Size/Width"), &sizex, 780);
79    wxConfig::Get()->Read(wxT("/Size/Height"), &sizey, 500);
80    
81    wxDisplaySize(&displayx, &displayy);
82    
83    /* Check if we are on the screen... */
84    if ((posx+sizex > displayx) || (posy+sizey > displayy)) {
85       /* Try to move the top-left corner first */
86       posx = 50;
87       posy = 50;
88       if ((posx+sizex > displayx) || (posy+sizey > displayy)) {
89          posx = 25;
90          posy = 25;
91          sizex = displayx - 50;
92          sizey = displayy - 50;
93       }
94    }
95
96    wxbMainFrame *frame = wxbMainFrame::CreateInstance(wxT(_("Bacula wx-console")),
97                          wxPoint(posx, posy), wxSize(sizex, sizey));
98
99    frame->Show(TRUE);
100
101    frame->Print(wxString::Format(wxT(_("Welcome to bacula wx-console %s (%s)!\n")), wxT(VERSION), wxT(BDATE)), CS_DEBUG);
102
103    frame->StartConsoleThread(wxT(""));
104    
105    return TRUE;
106 }
107
108 #ifndef HAVE_WIN32
109 void InitWinAPIWrapper() { };
110 #endif