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: 455371708425
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: ceeefa05afd8
Choose a head ref
  • 2 commits
  • 4 files changed
  • 1 contributor

Commits on Jul 29, 2020

  1. Copy the full SHA
    099ffaa View commit details
  2. Copy the full SHA
    ceeefa0 View commit details
9 changes: 0 additions & 9 deletions src/glscopeclient/OscilloscopeWindow.cpp
Original file line number Diff line number Diff line change
@@ -486,11 +486,6 @@ void OscilloscopeWindow::OnFileOpen()
{
//TODO: prompt to save changes to the current session

//Remove the CSS provider so the dialog isn't themed
//TODO: how can we un-theme just this one dialog?
get_style_context()->remove_provider_for_screen(
Gdk::Screen::get_default(), m_css);

Gtk::FileChooserDialog dlg(*this, "Open", Gtk::FILE_CHOOSER_ACTION_SAVE);

dlg.add_choice("layout", "Load UI Configuration");
@@ -509,10 +504,6 @@ void OscilloscopeWindow::OnFileOpen()
dlg.add_button("Cancel", Gtk::RESPONSE_CANCEL);
auto response = dlg.run();

//Re-add the CSS provider
get_style_context()->add_provider_for_screen(
Gdk::Screen::get_default(), m_css, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

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

111 changes: 101 additions & 10 deletions src/glscopeclient/ProtocolDecoderDialog.cpp
Original file line number Diff line number Diff line change
@@ -38,6 +38,66 @@

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ParameterRowBase

ParameterRowBase::ParameterRowBase(ProtocolDecoderDialog* parent)
: m_parent(parent)
{
}

ParameterRowBase::~ParameterRowBase()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ParameterRowString

ParameterRowString::ParameterRowString(ProtocolDecoderDialog* parent)
: ParameterRowBase(parent)
{
m_entry.set_size_request(250, 1);
}

ParameterRowString::~ParameterRowString()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ParameterRowFilename

ParameterRowFilename::ParameterRowFilename(ProtocolDecoderDialog* parent)
: ParameterRowString(parent)
{
m_button.set_label("...");
m_button.signal_clicked().connect(sigc::mem_fun(*this, &ParameterRowFilename::OnBrowser));
}

ParameterRowFilename::~ParameterRowFilename()
{
}

void ParameterRowFilename::OnBrowser()
{
Gtk::FileChooserDialog dlg(*m_parent, "Open", Gtk::FILE_CHOOSER_ACTION_OPEN);
dlg.set_filename(m_entry.get_text());

//TODO: get filter from parameter somehow

auto filter = Gtk::FileFilter::create();
filter->add_pattern("*.s2p");
filter->set_name("Touchstone S-parameter files (*.s2p)");
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_entry.set_text(dlg.get_filename());
}

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

@@ -110,6 +170,10 @@ ProtocolDecoderDialog::ProtocolDecoderDialog(
auto decodes = ProtocolDecoder::EnumDecodes();
for(auto d : decodes)
{
//Don't allow circular dependencies
if(d == decoder)
continue;

if(decoder->ValidateChannel(i, d))
{
row->m_chans.append(d->m_displayname);
@@ -123,16 +187,40 @@ ProtocolDecoderDialog::ProtocolDecoderDialog(
//Add parameters
for(auto it = decoder->GetParamBegin(); it != decoder->GetParamEnd(); it ++)
{
auto row = new ParameterRow;
m_grid.attach_next_to(row->m_label, *last_label, Gtk::POS_BOTTOM, 1, 1);
m_grid.attach_next_to(row->m_entry, row->m_label, Gtk::POS_RIGHT, 1, 1);
last_label = &row->m_label;
m_prows.push_back(row);
switch(it->second.GetType())
{
case ProtocolDecoderParameter::TYPE_FILENAME:
{
auto row = new ParameterRowFilename(this);
m_grid.attach_next_to(row->m_label, *last_label, Gtk::POS_BOTTOM, 1, 1);
m_grid.attach_next_to(row->m_entry, row->m_label, Gtk::POS_RIGHT, 1, 1);
m_grid.attach_next_to(row->m_button, row->m_entry, Gtk::POS_RIGHT, 1, 1);
last_label = &row->m_label;
m_prows.push_back(row);

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

//Set initial value
row->m_entry.set_text(it->second.ToString());
break;
}
break;

default:
{
auto row = new ParameterRowString(this);
m_grid.attach_next_to(row->m_label, *last_label, Gtk::POS_BOTTOM, 1, 1);
m_grid.attach_next_to(row->m_entry, row->m_label, Gtk::POS_RIGHT, 1, 1);
last_label = &row->m_label;
m_prows.push_back(row);

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

//Set initial value
row->m_entry.set_text(it->second.ToString());
//Set initial value
row->m_entry.set_text(it->second.ToString());
break;
}
}
}
show_all();
}
@@ -163,8 +251,11 @@ void ProtocolDecoderDialog::ConfigureDecoder()

for(size_t i=0; i<m_prows.size(); i++)
{
m_decoder->GetParameter(m_prows[i]->m_label.get_label()).ParseString(
m_prows[i]->m_entry.get_text());
auto row = m_prows[i];
auto srow = dynamic_cast<ParameterRowString*>(row);
if(srow)
m_decoder->GetParameter(srow->m_label.get_label()).ParseString(srow->m_entry.get_text());
//TODO: other types
}

m_decoder->m_displaycolor = m_channelColorButton.get_color().to_string();
31 changes: 28 additions & 3 deletions src/glscopeclient/ProtocolDecoderDialog.h
Original file line number Diff line number Diff line change
@@ -49,13 +49,38 @@ class ChannelSelectorRow
std::map<std::string, OscilloscopeChannel*> m_chanptrs;
};

class ParameterRow
class ProtocolDecoderDialog;

class ParameterRowBase
{
public:
Gtk::Label m_label;
ParameterRowBase(ProtocolDecoderDialog* parent);
virtual ~ParameterRowBase();

ProtocolDecoderDialog* m_parent;
Gtk::Label m_label;
};

class ParameterRowString : public ParameterRowBase
{
public:
ParameterRowString(ProtocolDecoderDialog* parent);
virtual ~ParameterRowString();

Gtk::Entry m_entry;
};

class ParameterRowFilename : public ParameterRowString
{
public:
ParameterRowFilename(ProtocolDecoderDialog* parent);
virtual ~ParameterRowFilename();

void OnBrowser();

Gtk::Button m_button;
};

/**
@brief Main application window class for an oscilloscope
*/
@@ -77,7 +102,7 @@ class ProtocolDecoderDialog : public Gtk::Dialog
Gtk::ColorButton m_channelColorButton;

std::vector<ChannelSelectorRow*> m_rows;
std::vector<ParameterRow*> m_prows;
std::vector<ParameterRowBase*> m_prows;
};

#endif
19 changes: 19 additions & 0 deletions src/glscopeclient/styles/glscopeclient.css
Original file line number Diff line number Diff line change
@@ -254,3 +254,22 @@ box.sidebar label.highlight
color: @glscopeclient_text_color;
font-weight: bold;
}

/***********************************************************************************************************************
File chooser dialog
**********************************************************************************************************************/

dialog filechooser placessidebar.sidebar.frame viewport.frame list,
dialog filechooser placessidebar.sidebar.frame viewport.frame list row.activatable.sidebar-row
{
background-image: none;
background-color: @glscopeclient_bg_color;
font-family: sans-serif;
}

dialog filechooser,
dialog filechooser treeview,
dialog filechooser treeview header
{
font-family: sans-serif;
}