Changeset 0e81a88 in git


Ignore:
Timestamp:
06/03/15 04:00:44 (5 years ago)
Author:
Olly Betts <olly@…>
Branches:
line_contents, master, stereo, travis-osx
Children:
bbed692
Parents:
d7b53e3
git-author:
Olly Betts <olly@…> (06/03/15 03:56:50)
git-committer:
Olly Betts <olly@…> (06/03/15 04:00:44)
Message:

lib/survex.pot,src/cavernlog.cc,src/cavernlog.h: Add "Save Log"
button to Aven's cavern log window.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rd7b53e3 r0e81a88  
     1Fri Mar 06 03:56:13 GMT 2015  Olly Betts <olly@survex.com>
     2
     3        * lib/survex.pot,src/cavernlog.cc,src/cavernlog.h: Add "Save Log"
     4          button to Aven's cavern log window.
     5
    16Fri Mar 06 03:24:54 GMT 2015  Olly Betts <olly@survex.com>
    27
  • lib/survex.pot

    rd7b53e3 r0e81a88  
    12361236
    12371237#. TRANSLATORS: Label for button in aven’s cavern log window which
     1238#. allows the user to save the log to a file.
     1239#: ../src/cavernlog.cc:450
     1240#: n:446
     1241msgid "Save Log"
     1242msgstr ""
     1243
     1244#. TRANSLATORS: Label for button in aven’s cavern log window which
    12381245#. causes the survey data to be reprocessed.
    12391246#: ../src/cavernlog.cc:453
     
    15571564#: n:445
    15581565msgid "JSON files"
     1566msgstr ""
     1567
     1568#. TRANSLATORS: Log files from running cavern (extension .log)
     1569#: ../src/cavernlog.cc:508
     1570#: n:447
     1571msgid "Log files"
    15591572msgstr ""
    15601573
  • src/cavernlog.cc

    rd7b53e3 r0e81a88  
    4141#include <unistd.h>
    4242
    43 enum { LOG_REPROCESS = 1234 };
     43enum { LOG_REPROCESS = 1234, LOG_SAVE = 1235 };
    4444
    4545BEGIN_EVENT_TABLE(CavernLogWindow, wxHtmlWindow)
    4646    EVT_BUTTON(LOG_REPROCESS, CavernLogWindow::OnReprocess)
     47    EVT_BUTTON(LOG_SAVE, CavernLogWindow::OnSave)
    4748    EVT_BUTTON(wxID_OK, CavernLogWindow::OnOK)
    4849END_EVENT_TABLE()
     
    185186    SetFocus();
    186187    filename = file;
     188
     189    log_txt.resize(0);
    187190
    188191#ifdef __WXMSW__
     
    292295            break;
    293296        }
     297        log_txt.append((const char *)end, r);
    294298        end += r;
    295299
     
    446450abort:
    447451
     452    /* TRANSLATORS: Label for button in aven’s cavern log window which
     453     * allows the user to save the log to a file. */
     454    AppendToPage(wxString::Format(wxT("<avenbutton id=%d name=\"%s\">"),
     455                                  (int)LOG_SAVE,
     456                                  wmsg(/*Save Log*/446).c_str()));
    448457    int retval = pclose(cavern_out);
    449458    if (retval) {
     
    486495
    487496void
     497CavernLogWindow::OnSave(wxCommandEvent &)
     498{
     499    wxString filelog(filename, 0, filename.length() - 3);
     500    filelog += wxT("log");
     501    AvenAllowOnTop ontop(mainfrm);
     502#ifdef __WXMOTIF__
     503    wxString ext(wxT("*.log"));
     504#else
     505    /* TRANSLATORS: Log files from cavern (extension .log) */
     506    wxString ext = wmsg(/*Log files*/447);
     507    ext += wxT("|*.log");
     508#endif
     509    wxFileDialog dlg(this, wmsg(/*Select an output filename*/319),
     510                     wxString(), filelog, ext,
     511                     wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
     512    if (dlg.ShowModal() != wxID_OK) return;
     513    filelog = dlg.GetPath();
     514#ifdef __WXMSW__
     515    FILE * fh_log = _wfopen(filelog.fn_str(), L"w");
     516#else
     517    FILE * fh_log = fopen(filelog.mb_str(), "w");
     518#endif
     519    if (!fh_log) {
     520        wxGetApp().ReportError(wxString::Format(wmsg(/*Error writing to file “%s”*/110), filelog.c_str()));
     521        return;
     522    }
     523    fwrite(log_txt.data(), log_txt.size(), 1, fh_log);
     524    fclose(fh_log);
     525}
     526
     527void
    488528CavernLogWindow::OnOK(wxCommandEvent &)
    489529{
  • src/cavernlog.h

    rd7b53e3 r0e81a88  
    22 * Run cavern inside an Aven window
    33 *
    4  * Copyright (C) 2005,2006,2010 Olly Betts
     4 * Copyright (C) 2005,2006,2010,2015 Olly Betts
    55 *
    66 * This program is free software; you can redistribute it and/or modify
     
    2525#include <wx/html/htmlwin.h>
    2626
     27#include <string>
     28
    2729class MainFrm;
    2830
     
    3537
    3638    wxString survey;
     39
     40    std::string log_txt;
    3741
    3842  public:
     
    5054    void OnReprocess(wxCommandEvent &);
    5155
     56    void OnSave(wxCommandEvent &);
     57
    5258    void OnOK(wxCommandEvent &);
    5359
Note: See TracChangeset for help on using the changeset viewer.