Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: f257ffbe6b21
Choose a base ref
...
head repository: ngscopeclient/scopehal-apps
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2c4b5d1d5580
Choose a head ref
  • 1 commit
  • 3 files changed
  • 1 contributor

Commits on Jul 29, 2020

  1. Copy the full SHA
    2c4b5d1 View commit details
Showing with 100 additions and 4 deletions.
  1. +1 −1 lib
  2. +83 −3 src/glscopeclient/ProtocolDecoderDialog.cpp
  3. +16 −0 src/glscopeclient/ProtocolDecoderDialog.h
2 changes: 1 addition & 1 deletion lib
Submodule lib updated from e8c8c0 to ac9922
86 changes: 83 additions & 3 deletions src/glscopeclient/ProtocolDecoderDialog.cpp
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ ParameterRowBase::~ParameterRowBase()
ParameterRowString::ParameterRowString(ProtocolDecoderDialog* parent)
: ParameterRowBase(parent)
{
m_entry.set_size_request(250, 1);
m_entry.set_size_request(500, 1);
}

ParameterRowString::~ParameterRowString()
@@ -97,6 +97,52 @@ void ParameterRowFilename::OnBrowser()
m_entry.set_text(dlg.get_filename());
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ParameterRowFilenames

ParameterRowFilenames::ParameterRowFilenames(ProtocolDecoderDialog* parent, ProtocolDecoderParameter& param)
: ParameterRowBase(parent)
, m_list(1)
, m_param(param)
{
m_list.set_size_request(500, 200);
m_list.set_column_title(0, "Filename");

m_buttonAdd.set_label("+");
m_buttonRemove.set_label("-");

m_buttonAdd.signal_clicked().connect(sigc::mem_fun(*this, &ParameterRowFilenames::OnAdd));
m_buttonRemove.signal_clicked().connect(sigc::mem_fun(*this, &ParameterRowFilenames::OnRemove));
}

ParameterRowFilenames::~ParameterRowFilenames()
{
}

void ParameterRowFilenames::OnAdd()
{
Gtk::FileChooserDialog dlg(*m_parent, "Open", Gtk::FILE_CHOOSER_ACTION_OPEN);

auto filter = Gtk::FileFilter::create();
filter->add_pattern(m_param.m_fileFilterMask);
filter->set_name(m_param.m_fileFilterName);
dlg.add_filter(filter);
dlg.add_button("Open", Gtk::RESPONSE_OK);
dlg.add_button("Cancel", Gtk::RESPONSE_CANCEL);
auto response = dlg.run();

if(response != Gtk::RESPONSE_OK)
return;

m_list.append(dlg.get_filename());
}

void ParameterRowFilenames::OnRemove()
{
auto store = Glib::RefPtr<Gtk::ListStore>::cast_dynamic(m_list.get_model());
store->erase(m_list.get_selection()->get_selected());
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

@@ -205,6 +251,27 @@ ProtocolDecoderDialog::ProtocolDecoderDialog(
}
break;

case ProtocolDecoderParameter::TYPE_FILENAMES:
{
auto row = new ParameterRowFilenames(this, it->second);
m_grid.attach_next_to(row->m_label, *last_label, Gtk::POS_BOTTOM, 1, 2);
m_grid.attach_next_to(row->m_list, row->m_label, Gtk::POS_RIGHT, 1, 2);
m_grid.attach_next_to(row->m_buttonAdd, row->m_list, Gtk::POS_RIGHT, 1, 1);
m_grid.attach_next_to(row->m_buttonRemove, row->m_buttonAdd, Gtk::POS_BOTTOM, 1, 1);
last_label = &row->m_label;
m_prows.push_back(row);

row->m_label.set_label(it->first);

//Set initial value
auto files = it->second.GetFileNames();
for(auto f : files)
row->m_list.append(f);

break;
}
break;

default:
{
auto row = new ParameterRowString(this);
@@ -248,13 +315,26 @@ void ProtocolDecoderDialog::ConfigureDecoder()
m_decoder->SetInput(i, m_rows[i]->m_chanptrs[chname]);
}

//Extract file names
for(size_t i=0; i<m_prows.size(); i++)
{
auto row = m_prows[i];
auto srow = dynamic_cast<ParameterRowString*>(row);
auto frow = dynamic_cast<ParameterRowFilenames*>(row);
auto name = row->m_label.get_label();

//Strings are easy
if(srow)
m_decoder->GetParameter(srow->m_label.get_label()).ParseString(srow->m_entry.get_text());
//TODO: other types
m_decoder->GetParameter(name).ParseString(srow->m_entry.get_text());

//List of file names
else if(frow)
{
vector<string> paths;
for(size_t j=0; j<frow->m_list.size(); j++)
paths.push_back(frow->m_list.get_text(j));
m_decoder->GetParameter(name).SetFileNames(paths);
}
}

m_decoder->m_displaycolor = m_channelColorButton.get_color().to_string();
16 changes: 16 additions & 0 deletions src/glscopeclient/ProtocolDecoderDialog.h
Original file line number Diff line number Diff line change
@@ -82,6 +82,22 @@ class ParameterRowFilename : public ParameterRowString
ProtocolDecoderParameter& m_param;
};

class ParameterRowFilenames : public ParameterRowBase
{
public:
ParameterRowFilenames(ProtocolDecoderDialog* parent, ProtocolDecoderParameter& param);
virtual ~ParameterRowFilenames();

Gtk::ListViewText m_list;
Gtk::Button m_buttonAdd;
Gtk::Button m_buttonRemove;

void OnAdd();
void OnRemove();

ProtocolDecoderParameter& m_param;
};

/**
@brief Main application window class for an oscilloscope
*/