[gst-debugger] gst-debugger: use combobox for setting debuglevel instead of gtkentry
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gst-debugger] gst-debugger: use combobox for setting debuglevel instead of gtkentry
- Date: Mon, 5 Oct 2015 08:54:03 +0000 (UTC)
commit 4d410e0948a12ed7990939dc74d6cbe73d8feb2f
Author: Marcin Kolny <marcin kolny gmail com>
Date: Mon Oct 5 10:53:36 2015 +0200
gst-debugger: use combobox for setting debuglevel instead of gtkentry
src/gst-debugger/controller/controller.cpp | 1 +
src/gst-debugger/models/gst_enum_model.h | 7 ++++++
src/gst-debugger/modules/log_module.cpp | 33 +++++++++++++++++++++++----
src/gst-debugger/modules/log_module.h | 2 +-
4 files changed, 37 insertions(+), 6 deletions(-)
---
diff --git a/src/gst-debugger/controller/controller.cpp b/src/gst-debugger/controller/controller.cpp
index 95670c1..788dfd9 100644
--- a/src/gst-debugger/controller/controller.cpp
+++ b/src/gst-debugger/controller/controller.cpp
@@ -28,6 +28,7 @@ Controller::Controller(IMainView *view)
send_data_type_request_command("GstMessageType",
GstDebugger::TypeDescriptionRequest_Type_ENUM_FLAGS);
send_data_type_request_command("GstEventType",
GstDebugger::TypeDescriptionRequest_Type_ENUM_FLAGS);
send_data_type_request_command("GstQueryType",
GstDebugger::TypeDescriptionRequest_Type_ENUM_FLAGS);
+ send_data_type_request_command("GstDebugLevel",
GstDebugger::TypeDescriptionRequest_Type_ENUM_FLAGS);
send_request_entire_topology_command();
send_request_debug_categories_command();
}
diff --git a/src/gst-debugger/models/gst_enum_model.h b/src/gst-debugger/models/gst_enum_model.h
index 8b17f19..3f7b686 100644
--- a/src/gst-debugger/models/gst_enum_model.h
+++ b/src/gst-debugger/models/gst_enum_model.h
@@ -10,6 +10,8 @@
#include <glib.h>
+#include <boost/optional/optional.hpp>
+
#include <map>
#include <vector>
#include <string>
@@ -29,6 +31,11 @@ public:
{
values[value] = ValueInfo {name, nick};
}
+ boost::optional<int> get_value_by_name(const std::string &name)
+ {
+ auto it = std::find_if(values.begin(), values.end(), [name](const
decltype(values)::value_type& v) {return v.second.name == name; });
+ return (it != values.end()) ? boost::optional<int>(it->first) : boost::none;
+ }
const std::map<int, ValueInfo>& get_values() const { return values; }
};
diff --git a/src/gst-debugger/modules/log_module.cpp b/src/gst-debugger/modules/log_module.cpp
index 66366d7..d86e91f 100644
--- a/src/gst-debugger/modules/log_module.cpp
+++ b/src/gst-debugger/modules/log_module.cpp
@@ -44,9 +44,9 @@ LogControlModule::LogControlModule()
main_box->pack_start(*debug_categories_combobox, false, true);
main_box->reorder_child(*debug_categories_combobox, 1);
- log_level_entry = Gtk::manage(new Gtk::Entry());
- main_box->pack_start(*log_level_entry, false, true);
- main_box->reorder_child(*log_level_entry, 0);
+ log_levels_combobox = Gtk::manage(new Gtk::ComboBoxText());
+ main_box->pack_start(*log_levels_combobox, false, true);
+ main_box->reorder_child(*log_levels_combobox, 0);
main_box->pack_start(*Gtk::manage(new Gtk::Label("Log threshold:")), false, true);
@@ -80,12 +80,35 @@ void LogControlModule::set_controller(const std::shared_ptr<Controller> &control
if (!this->controller->get_debug_categories().empty())
debug_categories_combobox->set_active(0);
});
+
+ controller->on_enum_list_changed.connect([this](const Glib::ustring& type_name, bool add) {
+ if (type_name != "GstDebugLevel")
+ return;
+ log_levels_combobox->remove_all();
+
+ if (add)
+ {
+ auto type = this->controller->get_enum_type("GstDebugLevel");
+ if (!type) return;
+
+ for (auto value : type.get().get_values())
+ {
+ puts (value.second.name.c_str());
+ log_levels_combobox->append(value.second.name);
+ }
+ if (!type.get().get_values().empty())
+ log_levels_combobox->set_active(0);
+ }
+ });
}
void LogControlModule::add_hook()
{
- controller->send_set_log_hook_command(true, debug_categories_combobox->get_active_text(),
- atoi(log_level_entry->get_text().c_str()));
+ auto type = controller->get_enum_type("GstDebugLevel");
+ if (!type) return;
+ auto value = type->get_value_by_name(log_levels_combobox->get_active_text());
+ if (value)
+ controller->send_set_log_hook_command(true, debug_categories_combobox->get_active_text(),
value.get());
}
void LogControlModule::remove_hook(const Gtk::TreeModel::Row& row)
diff --git a/src/gst-debugger/modules/log_module.h b/src/gst-debugger/modules/log_module.h
index 706e880..4fd343b 100644
--- a/src/gst-debugger/modules/log_module.h
+++ b/src/gst-debugger/modules/log_module.h
@@ -24,7 +24,7 @@ public:
class LogControlModule : public ControlModule
{
Gtk::CheckButton *overwrite_threshold_check_button;
- Gtk::Entry *log_level_entry;
+ Gtk::ComboBoxText *log_levels_combobox;
Gtk::ComboBoxText *debug_categories_combobox;
Gtk::Button *set_threshold_button;
Gtk::Entry *threshold_entry;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]