Dave Page a écrit :
> On Tue, Jan 6, 2009 at 10:30 PM, Guillaume Lelarge
> <[email protected]> wrote:
>> Dave Page a écrit :
>>> On Mon, Jan 5, 2009 at 11:26 PM, Guillaume Lelarge
>>> <[email protected]> wrote:
>>>
>>> Doesn't seem to make much difference on OS X. I certainly can't
>>> rearrange tabs etc.
>>>
>> Works for me on Linux and Mac OS X. I can close tabs and rearrange them.
>
> Oh, I see - you've got all the cool functionality turned off :-(
>
I suppose the cool functionality is wxAUI_NB_TAB_SPLIT :)
>> The new patch attached fixes the crash issue I had yesterday.
>
> Not entirely - if you close the Log tab, it seems to crash when
> pgAdmin is closed.
>
You're right. The new version fixes this.
>> It also
>> adds a close box on each tab and customizes the wxAuiNotebook style.
>
> Let's get it to work with wxAUI_NB_DEFAULT_STYLE. That allows the
> split functionality which is what I think makes this change worthwhile
> - the ability to view more than one tab at once and arrange them as
> required. A quick test shows it needs a new way to figure out which
> tabs are visible (and therefore need refreshing), and there are some
> sizing issues which appear to all be our old friend the generic
> wxListCtrl.
>
Actually, I find this great. It works nice on Mac OS X, but I disabled
it on v2 because it crashes the linux build. Perhaps I did something
wrong but even the auidemo sample from wxGTK crashes.
(re-enables the "cool functionality", so crashes a lot on my laptop)
> It also looks a bit nicer than having the close box on all tabs I think.
>
You mean, to have a close box only on the active tab? (aka
wxAUI_NB_CLOSE_ON_ACTIVE_TAB)
>> Thinking again about it, a view menu would be the only way to re-add a
>> tab that has been closed previously. (in the current patch, the only way
>> to re-open a tab previously closed is to close and open the server
>> status dialog)
>
> Yeah - plus it's where we put the option to reset the layout to the
> default view.
>
OK.
>> One last question: should we record the new display (ie tabs closed and
>> rearranged) so we can completely restore it next time the user opens the
>> server status dialog?
>
> Yes - but isn't that handled by the AUI code and associated functions
> as per frmMain etc?
>
With the perspective code, yes. I need to better understand it to code
it for the server status window.
--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com
Index: pgadmin/include/frm/frmStatus.h
===================================================================
--- pgadmin/include/frm/frmStatus.h (révision 7539)
+++ pgadmin/include/frm/frmStatus.h (copie de travail)
@@ -19,14 +19,52 @@
#include <wx/spinctrl.h>
#include <wx/notebook.h>
+// wxAUI
+#include <wx/aui/aui.h>
+#include <wx/aui/auibook.h>
+
#include "dlg/dlgClasses.h"
#include "utils/factory.h"
-#define CTL_STATUSLIST 300
+enum
+{
+ CTL_NTBK=250,
+ CTL_RATELABEL,
+ CTL_RATESLIDER,
+ CTL_RATELABEL2,
+ CTL_REFRESHBTN,
+ CTL_CLOSEBTN,
+ CTL_STATUSLIST,
+ CTL_CANCELBTN1,
+ CTL_TERMINATEBTN1,
+ CTL_LOCKLIST,
+ CTL_CANCELBTN2,
+ CTL_TERMINATEBTN2,
+ CTL_XACTLIST,
+ CTL_COMMITBTN,
+ CTL_ROLLBACKBTN,
+ CTL_LOGLIST,
+ CTL_LOGCBO,
+ CTL_ROTATEBTN
+};
+
+#define FRMSTATUS_PERSPECTIVE_VER wxT("$Rev$")
+
+#ifdef __WXMAC__
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=serverstatus;caption=Server Status;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=415;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
+#else
+#ifdef __WXGTK__
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=serverstatus;caption=Server Status;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=525;besth=30;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
+#else
+#define FRMSTATUS_DEFAULT_PERSPECTIVE wxT("layout2|name=serverstatus;caption=Server Status;state=16788208;dir=1;layer=10;row=0;pos=0;prop=100000;bestw=415;besth=23;minw=-1;minh=-1;maxw=-1;maxh=-1;floatx=-1;floaty=-1;floatw=-1;floath=-1|")
+#endif
+#endif
+
+
// Class declarations
-class frmStatus : public pgDialog
+class frmStatus : public pgFrame
{
public:
frmStatus(frmMain *form, const wxString& _title, pgConn *conn);
@@ -34,6 +72,17 @@
void Go();
private:
+ wxSlider *slRate;
+ wxStaticText *stRate;
+ wxAuiNotebook *nbStatus;
+ wxComboBox *cbLogfiles;
+ wxButton *btnRotateLog;
+
+ ctlListView *statusList;
+ ctlListView *lockList;
+ ctlListView *xactList;
+ ctlListView *logList;
+
void OnHelp(wxCommandEvent& ev);
void OnCloseBtn(wxCommandEvent &event);
void OnClose(wxCloseEvent &event);
@@ -60,6 +109,8 @@
void checkConnection();
+ wxAuiManager manager;
+
frmMain *mainForm;
wxButton *btnCancelSt, *btnTerminateSt,*btnCancelLk, *btnTerminateLk, *btnCommit, *btnRollback;
Index: pgadmin/frm/frmStatus.cpp
===================================================================
--- pgadmin/frm/frmStatus.cpp (révision 7539)
+++ pgadmin/frm/frmStatus.cpp (copie de travail)
@@ -17,6 +17,10 @@
#include <wx/image.h>
#include <wx/textbuf.h>
+// wxAUI
+#include <wx/aui/aui.h>
+#include <wx/aui/auibook.h>
+
// App headers
#include "frm/frmStatus.h"
#include "frm/frmHint.h"
@@ -26,38 +30,29 @@
#define TIMER_ID 333
-BEGIN_EVENT_TABLE(frmStatus, pgDialog)
+BEGIN_EVENT_TABLE(frmStatus, pgFrame)
EVT_BUTTON(wxID_REFRESH, frmStatus::OnRefresh)
EVT_BUTTON(wxID_CLOSE, frmStatus::OnCloseBtn)
EVT_BUTTON(wxID_CANCEL, frmStatus::OnCloseBtn)
- EVT_BUTTON(XRCID("btnCancelSt"), frmStatus::OnCancelBtn)
+ EVT_BUTTON(CTL_CANCELBTN1, frmStatus::OnCancelBtn)
EVT_BUTTON(wxID_STOP, frmStatus::OnTerminateBtn)
- EVT_BUTTON(XRCID("btnCommit"), frmStatus::OnCommit)
- EVT_BUTTON(XRCID("btnRollback"), frmStatus::OnRollback)
+ EVT_BUTTON(CTL_COMMITBTN, frmStatus::OnCommit)
+ EVT_BUTTON(CTL_ROLLBACKBTN, frmStatus::OnRollback)
EVT_CLOSE( frmStatus::OnClose)
- EVT_COMMAND_SCROLL(XRCID("slRate"), frmStatus::OnRateChange)
- EVT_NOTEBOOK_PAGE_CHANGING(XRCID("nbStatus"), frmStatus::OnNotebookPageChanged)
+ EVT_COMMAND_SCROLL(CTL_RATESLIDER, frmStatus::OnRateChange)
+ EVT_NOTEBOOK_PAGE_CHANGING(CTL_NOTEBOOK, frmStatus::OnNotebookPageChanged)
EVT_TIMER(TIMER_ID, frmStatus::OnRefreshTimer)
- EVT_LIST_ITEM_SELECTED(XRCID("lstStatus"), frmStatus::OnSelStatusItem)
- EVT_LIST_ITEM_DESELECTED(XRCID("lstStatus"), frmStatus::OnSelStatusItem)
- EVT_LIST_ITEM_SELECTED(XRCID("lstLocks"), frmStatus::OnSelLockItem)
- EVT_LIST_ITEM_DESELECTED(XRCID("lstLocks"), frmStatus::OnSelLockItem)
- EVT_LIST_ITEM_SELECTED(XRCID("lstXacts"), frmStatus::OnSelXactItem)
- EVT_LIST_ITEM_DESELECTED(XRCID("lstXacts"), frmStatus::OnSelXactItem)
- EVT_COMBOBOX(XRCID("cbLogfiles"), frmStatus::OnLoadLogfile)
- EVT_BUTTON(XRCID("btnRotateLog"), frmStatus::OnRotateLogfile)
+ EVT_LIST_ITEM_SELECTED(CTL_STATUSLIST, frmStatus::OnSelStatusItem)
+ EVT_LIST_ITEM_DESELECTED(CTL_STATUSLIST, frmStatus::OnSelStatusItem)
+ EVT_LIST_ITEM_SELECTED(CTL_LOCKLIST, frmStatus::OnSelLockItem)
+ EVT_LIST_ITEM_DESELECTED(CTL_LOCKLIST, frmStatus::OnSelLockItem)
+ EVT_LIST_ITEM_SELECTED(CTL_XACTLIST, frmStatus::OnSelXactItem)
+ EVT_LIST_ITEM_DESELECTED(CTL_XACTLIST, frmStatus::OnSelXactItem)
+ EVT_COMBOBOX(CTL_LOGCBO, frmStatus::OnLoadLogfile)
+ EVT_BUTTON(CTL_ROTATEBTN, frmStatus::OnRotateLogfile)
END_EVENT_TABLE();
-#define statusList CTRL_LISTVIEW("lstStatus")
-#define lockList CTRL_LISTVIEW("lstLocks")
-#define xactList CTRL_LISTVIEW("lstXacts")
-#define logList CTRL_LISTVIEW("lstLog")
-#define slRate CTRL_SLIDER("slRate")
-#define stRate CTRL_STATIC("stRate")
-#define nbStatus CTRL_NOTEBOOK("nbStatus")
-#define cbLogfiles CTRL_COMBOBOX("cbLogfiles")
-#define btnRotateLog CTRL_BUTTON("btnRotateLog")
void frmStatus::OnCloseBtn(wxCommandEvent &event)
@@ -78,30 +73,130 @@
}
-frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn)
+frmStatus::frmStatus(frmMain *form, const wxString& _title, pgConn *conn) : pgFrame(NULL, _title)
{
+ dlgName = wxT("frmStatus");
+
loaded = false;
xactPage=2;
logPage=3;
- wxWindowBase::SetFont(settings->GetSystemFont());
- LoadResource(0, wxT("frmStatus"));
-
- RestorePosition(-1, -1, 400, 240, 200, 150);
- SetTitle(_title);
- appearanceFactory->SetIcons(this);
-
mainForm=form;
timer=0;
connection=conn;
logHasTimestamp = false;
logFormatKnown = false;
- btnCancelSt = CTRL_BUTTON("btnCancelSt");
- btnCancelLk = CTRL_BUTTON("btnCancelLk");
- btnTerminateSt = CTRL_BUTTON("btnTerminateSt");
- btnTerminateLk = CTRL_BUTTON("btnTerminateLk");
- btnCommit = CTRL_BUTTON("btnCommit");
- btnRollback = CTRL_BUTTON("btnRollback");
+
+ statusBar=CreateStatusBar(1);
+ SetStatusBarPane(-1);
+
+ SetTitle(_title);
+ appearanceFactory->SetIcons(this);
+
+ wxWindowBase::SetFont(settings->GetSystemFont());
+
+ // notify wxAUI which frame to use
+ manager.SetManagedWindow(this);
+ manager.SetFlags(wxAUI_MGR_DEFAULT | wxAUI_MGR_TRANSPARENT_DRAG);
+
+ // build UI
+ wxFlexGridSizer *item0 = new wxFlexGridSizer(3, 1, 5, 5);
+ item0->AddGrowableCol(0);
+ item0->AddGrowableRow(0);
+ nbStatus = new wxAuiNotebook(this, CTL_NTBK);
+ item0->Add(nbStatus, 0, wxALL|wxEXPAND|wxGROW|wxALIGN_CENTRE, 2);
+ wxFlexGridSizer *item1 = new wxFlexGridSizer(1, 6, 5, 5);
+ item1->AddGrowableCol(3);
+ wxStaticText *stRateLabel = new wxStaticText(this, CTL_RATELABEL, _("Refresh rate:"));
+ item1->Add(stRateLabel, 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL, 3);
+ slRate = new wxSlider(this, CTL_RATESLIDER, 1, 0, 600, wxDefaultPosition, wxSize(150, -1));
+ item1->Add(slRate, 0, wxLEFT|wxALIGN_CENTRE_VERTICAL, 3);
+ stRate = new wxStaticText(this, CTL_RATELABEL2, _("Stopped"));
+ item1->Add(stRate, 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL, 3);
+ wxStaticText *filler = new wxStaticText(this, wxID_ANY, wxT(""));
+ item1->Add(filler, 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL, 3);
+ wxButton *btnRefresh = new wxButton(this, CTL_REFRESHBTN, _("Refresh"));
+ item1->Add(btnRefresh, 0, wxTOP|wxBOTTOM|wxLEFT|wxRIGHT, 5);
+ wxButton *btnClose = new wxButton(this, CTL_CLOSEBTN, _("Close"));
+ item1->Add(btnClose, 0, wxLEFT|wxRIGHT|wxALIGN_CENTRE_VERTICAL, 3);
+ item0->Add(item1, 0, wxTOP|wxEXPAND|wxGROW, 2);
+
+ // page 0 : stat activity
+ wxPanel *pnlActivity = new wxPanel(nbStatus);
+ wxFlexGridSizer *grdActivity = new wxFlexGridSizer(2, 1, 5, 5);
+ grdActivity->AddGrowableCol(0);
+ grdActivity->AddGrowableRow(0);
+ wxListCtrl *lstStatus = new wxListCtrl(pnlActivity, CTL_STATUSLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
+ grdActivity->Add(lstStatus, 0, wxGROW, 3);
+ wxFlexGridSizer *item3 = new wxFlexGridSizer(1, 2, 5, 5);
+ btnCancelSt = new wxButton(pnlActivity, CTL_CANCELBTN1, _("Cancel"));
+ item3->Add(btnCancelSt, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+ btnTerminateSt = new wxButton(pnlActivity, CTL_TERMINATEBTN1, _("Terminate"));
+ item3->Add(btnTerminateSt, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+ grdActivity->Add(item3, 0, wxGROW, 3);
+ nbStatus->AddPage(pnlActivity, wxT("Status"));
+ pnlActivity->SetSizer(grdActivity);
+ grdActivity->Fit(pnlActivity);
+ // page 1 : lock
+ wxPanel *pnlLock = new wxPanel(nbStatus);
+ wxFlexGridSizer *grdLock = new wxFlexGridSizer(2, 1, 5, 5);
+ grdLock->AddGrowableCol(0);
+ grdLock->AddGrowableRow(0);
+ wxListCtrl *lstLocks = new wxListCtrl(pnlLock, CTL_XACTLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
+ grdLock->Add(lstLocks, 0, wxGROW, 3);
+ wxFlexGridSizer *item5 = new wxFlexGridSizer(1, 2, 5, 5);
+ btnCancelLk = new wxButton(pnlLock, CTL_CANCELBTN2, _("Cancel"));
+ item5->Add(btnCancelLk, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+ btnTerminateLk = new wxButton(pnlLock, CTL_TERMINATEBTN2, _("Terminate"));
+ item5->Add(btnTerminateLk, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+ grdLock->Add(item5, 0, wxGROW, 3);
+ pnlLock->SetSizer(grdLock);
+ grdLock->Fit(pnlLock);
+ nbStatus->AddPage(pnlLock, wxT("Locks"));
+ // page 2 : transaction
+ wxPanel *pnlXacts = new wxPanel(nbStatus);
+ wxFlexGridSizer *grdXacts = new wxFlexGridSizer(2, 1, 5, 5);
+ grdXacts->AddGrowableCol(0);
+ grdXacts->AddGrowableRow(0);
+ wxListCtrl *lstXacts = new wxListCtrl(pnlXacts, CTL_LOCKLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
+ grdXacts->Add(lstXacts, 0, wxGROW, 3);
+ wxFlexGridSizer *item4 = new wxFlexGridSizer(1, 2, 5, 5);
+ btnCommit = new wxButton(pnlXacts, CTL_COMMITBTN, _("Commit"));
+ item4->Add(btnCommit, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+ btnRollback = new wxButton(pnlXacts, CTL_ROLLBACKBTN, _("Rollback"));
+ item4->Add(btnRollback, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+ grdXacts->Add(item4, 0, wxGROW, 3);
+ pnlXacts->SetSizer(grdXacts);
+ grdXacts->Fit(pnlXacts);
+ nbStatus->AddPage(pnlXacts, wxT("Transactions"));
+ // page 3 : logfile
+ wxPanel *pnlLog = new wxPanel(nbStatus);
+ wxFlexGridSizer *grdLog = new wxFlexGridSizer(2, 1, 5, 5);
+ grdLog->AddGrowableCol(0);
+ grdLog->AddGrowableRow(0);
+ wxListCtrl *lstLog = new wxListCtrl(pnlLog, CTL_LOGLIST, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxSUNKEN_BORDER);
+ grdLog->Add(lstLog, 0, wxGROW, 3);
+ wxFlexGridSizer *item6 = new wxFlexGridSizer(1, 2, 5, 5);
+ cbLogfiles = new wxComboBox(pnlLog, CTL_LOGCBO, wxT(""), wxDefaultPosition, wxDefaultSize, 0, NULL,
+ wxCB_READONLY|wxCB_DROPDOWN);
+ item6->Add(cbLogfiles, 0, wxALL|wxALIGN_CENTRE|wxALIGN_CENTRE_VERTICAL, 5);
+ btnRotateLog = new wxButton(pnlLog, CTL_ROTATEBTN, _("Rotate"));
+ item6->Add(btnRotateLog, 0, wxALL, 5);
+ grdLog->Add(item6, 0, wxGROW, 3);
+ pnlLog->SetSizer(grdLog);
+ grdLog->Fit(pnlLog);
+ nbStatus->AddPage(pnlLog, wxT("Logfile"));
+
+ nbStatus->SetSelection(0);
+
+ statusList = (ctlListView*)lstStatus;
+ lockList = (ctlListView*)lstLocks;
+ xactList = (ctlListView*)lstXacts;
+ logList = (ctlListView*)lstLog;
+
+ ChangeButtonId(btnClose, wxID_CLOSE, _("Close"));
+ ChangeButtonId(btnRefresh, wxID_REFRESH, _("Refresh"));
+
ChangeButtonId(btnTerminateSt, wxID_STOP, _("Terminate"));
ChangeButtonId(btnTerminateLk, wxID_STOP, _("Terminate"));
@@ -188,6 +283,7 @@
nbStatus->DeletePage(logPage);
logPage=-5;
}
+
long rate;
settings->Read(wxT("frmStatus/Refreshrate"), &rate, 1);
slRate->SetValue(rate);
@@ -218,15 +314,23 @@
btnCommit->Enable(false);
btnRollback->Enable(false);
}
+
+ this->SetSizer(item0);
+ item0->Fit(this);
+ RestorePosition(100, 100, 600, 500, 450, 300);
+
loaded = true;
}
frmStatus::~frmStatus()
{
- mainForm->RemoveFrame(this);
+ if (mainForm)
+ mainForm->RemoveFrame(this);
+ manager.UnInit();
+
SavePosition();
settings->Write(wxT("frmStatus/Refreshrate"), slRate->GetValue());
@@ -234,8 +338,14 @@
if (connection)
delete connection;
- if (logPage > 0)
- emptyLogfileCombo();
+ for (int index = 0 ; index < nbStatus->GetPageCount() ; index++)
+ {
+ if (nbStatus->GetPageText(index) == wxT("Logfile"))
+ {
+ if (logPage > 0)
+ emptyLogfileCombo();
+ }
+ }
}
@@ -331,14 +441,14 @@
// To avoid hammering the lock manager (and the network for that matter),
// only query for the required tab.
- wxLogNull nolog;
+ //wxLogNull nolog;
if (!connection)
return;
connection->ExecuteVoid(wxT("SET log_statement='none';"));
- if (nbStatus->GetSelection() == 0)
+ if (nbStatus->GetPageText(nbStatus->GetSelection()) == wxT("Status"))
{
// Status
long row=0;
@@ -421,7 +531,7 @@
row++;
}
}
- else if (nbStatus->GetSelection() == 1)
+ else if (nbStatus->GetPageText(nbStatus->GetSelection()) == wxT("Locks"))
{
// Locks
long row=0;
@@ -545,7 +655,7 @@
row++;
}
}
- else if (nbStatus->GetSelection() == xactPage)
+ else if (nbStatus->GetPageText(nbStatus->GetSelection()) == wxT("Transactions"))
{
// Transactions
long row=0;
@@ -607,7 +717,7 @@
row++;
}
}
- else if (nbStatus->GetSelection() == logPage)
+ else if (nbStatus->GetPageText(nbStatus->GetSelection()) == wxT("Logfile"))
{
long newlen=0;
--
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers