[gst-debugger] gst-debugger: modules - further refactoring
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gst-debugger] gst-debugger: modules - further refactoring
- Date: Tue, 1 Sep 2015 20:42:20 +0000 (UTC)
commit 5a0d08f2ead7ac46424eec0603b9010f53e32060
Author: Marcin Kolny <marcin kolny gmail com>
Date: Tue Sep 1 21:48:25 2015 +0200
gst-debugger: modules - further refactoring
src/gst-debugger/modules/control_module.h | 78 +++++++++++++++----
.../modules/pad_path_control_module.cpp | 77 ++++++++++++++++---
src/gst-debugger/modules/pad_path_control_module.h | 4 +
.../modules/pad_path_types_control_module.h | 13 ++-
src/gst-debugger/modules/types_control_module.cpp | 73 +++++++++++++++----
src/gst-debugger/modules/types_control_module.h | 4 +
6 files changed, 200 insertions(+), 49 deletions(-)
---
diff --git a/src/gst-debugger/modules/control_module.h b/src/gst-debugger/modules/control_module.h
index e247631..465505b 100644
--- a/src/gst-debugger/modules/control_module.h
+++ b/src/gst-debugger/modules/control_module.h
@@ -23,30 +23,41 @@ public:
virtual Gtk::Widget* get_widget() = 0;
};
+class HooksModelColumns : public Gtk::TreeModel::ColumnRecord
+{
+public:
+ HooksModelColumns() {
+ add(pad_path); add(qe_type_name); add(qe_type);
+ }
+
+ Gtk::TreeModelColumn<Glib::ustring> pad_path;
+ Gtk::TreeModelColumn<Glib::ustring> qe_type_name;
+ Gtk::TreeModelColumn<gint> qe_type;
+};
+
+
class HooksControlModule : public ControlModule
{
- PadWatch_WatchType watch_type;
+ Gtk::ScrolledWindow *wnd;
protected:
+ PadWatch_WatchType watch_type;
+
+ Glib::RefPtr<Gtk::ListStore> hooks_model;
+ HooksModelColumns hooks_model_columns;
+
+ Gtk::TreeView *hooks_tree_view;
Gtk::Box *main_box = nullptr;
+ Gtk::Button *remove_hook_button;
Gtk::Button *add_hook_button;
void append_hook_widgets()
{
- add_hook_button = Gtk::manage(new Gtk::Button("Add hook"));
- add_hook_button->signal_clicked().connect([this]{
- if ((int)watch_type == -1) // todo it has to be fixed on design protocol level
- controller->send_message_request_command(get_type(), true);
- else
- controller->send_pad_watch_command(true, watch_type, get_pad_path(),
get_type());
- });
-
main_box->pack_start(*add_hook_button, false, true);
- main_box->pack_start(*Gtk::manage(new Gtk::Label("Existing hooks:")));
- Gtk::ScrolledWindow *wnd = Gtk::manage(new Gtk::ScrolledWindow);
- wnd->add(*Gtk::manage(new Gtk::TreeView()));
+ main_box->pack_start(*Gtk::manage(new Gtk::Label("Existing hooks:")), false, true);
+
main_box->pack_start(*wnd, true, true);
- main_box->pack_start(*Gtk::manage(new Gtk::Button("Remove selected hook")), false, true);
+ main_box->pack_start(*remove_hook_button, false, true);
update_add_hook();
}
@@ -62,18 +73,51 @@ protected:
virtual std::string get_pad_path() const { return std::string(); }
public:
- HooksControlModule(PadWatch_WatchType watch_type)
- : watch_type(watch_type)
+ HooksControlModule(PadWatch_WatchType w_type)
+ : watch_type(w_type)
{
- main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possible memleak
+ add_hook_button = Gtk::manage(new Gtk::Button("Add hook"));
+ add_hook_button->signal_clicked().connect([this]{
+ if ((int)watch_type == -1) // todo it has to be fixed on design protocol level
+ controller->send_message_request_command(get_type(), true);
+ else
+ controller->send_pad_watch_command(true, watch_type, get_pad_path(),
get_type());
+ });
- append_hook_widgets();
+ wnd = Gtk::manage(new Gtk::ScrolledWindow);
+
+ hooks_tree_view = Gtk::manage(new Gtk::TreeView());
+ wnd->add(*hooks_tree_view);
+ hooks_model = Gtk::ListStore::create(hooks_model_columns);
+ hooks_tree_view->set_model(hooks_model);
+
+ remove_hook_button = Gtk::manage(new Gtk::Button("Remove selected hook"));
+ remove_hook_button->signal_clicked().connect([this]{
+ auto selection = hooks_tree_view->get_selection();
+ if (!selection) return;
+ auto iter = selection->get_selected();
+ if (!iter) return;
+ Gtk::TreeModel::Row row = *iter;
+ auto type = row[hooks_model_columns.qe_type];
+ auto pad_path = (Glib::ustring)row[hooks_model_columns.pad_path];
+
+ if ((int)watch_type == -1) // todo
+ controller->send_message_request_command(type, false);
+ else
+ controller->send_pad_watch_command(false, watch_type, pad_path, type);
+ });
}
virtual ~HooksControlModule() {}
Gtk::Widget* get_widget() override
{
+ if (main_box == nullptr)
+ {
+ main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possible
memleak
+
+ append_hook_widgets();
+ }
return main_box;
}
};
diff --git a/src/gst-debugger/modules/pad_path_control_module.cpp
b/src/gst-debugger/modules/pad_path_control_module.cpp
index 6c37f10..fd7f306 100644
--- a/src/gst-debugger/modules/pad_path_control_module.cpp
+++ b/src/gst-debugger/modules/pad_path_control_module.cpp
@@ -10,17 +10,13 @@
#include "controller/controller.h"
#include "controller/element_path_processor.h"
+template<typename T>
+static void free_data(T *data) { delete data; }
+
void PadPathControlModule::append_pad_path_widgets()
{
- Gtk::Box *path_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
- path_box->pack_start(*Gtk::manage(new Gtk::Label("Pad path")));
-
- any_path_check_button = Gtk::manage(new Gtk::CheckButton("any path"));
- any_path_check_button->signal_clicked().connect([this] { update_add_hook(); });
-
- path_box->pack_start(*any_path_check_button);
- main_box->pack_start(*path_box);
- main_box->pack_start(*Gtk::manage(new Gtk::Label("none")));
+ main_box->pack_start(*path_box, false, true);
+ main_box->pack_start(*Gtk::manage(new Gtk::Label("none")), false, true);
}
bool PadPathControlModule::add_hook_unlocked()
@@ -37,16 +33,28 @@ void PadPathControlModule::selected_object_changed_()
PadPathControlModule::PadPathControlModule(PadWatch_WatchType watch_type)
: HooksControlModule(watch_type)
{
- main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possibly memleak
+ path_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
+ path_box->pack_start(*Gtk::manage(new Gtk::Label("Pad path")));
+
+ any_path_check_button = Gtk::manage(new Gtk::CheckButton("any path"));
+ any_path_check_button->signal_clicked().connect([this] { update_add_hook(); });
- append_pad_path_widgets();
- append_hook_widgets();
+ path_box->pack_start(*any_path_check_button);
+ hooks_tree_view->append_column("Pad path", hooks_model_columns.pad_path);
+ create_dispatcher("confirmation", sigc::mem_fun(*this,
&PadPathControlModule::confirmation_received_), (GDestroyNotify)free_data<PadWatch>);
create_dispatcher("selected-object", sigc::mem_fun(*this,
&PadPathControlModule::selected_object_changed_), nullptr);
}
Gtk::Widget* PadPathControlModule::get_widget()
{
+ if (main_box == nullptr)
+ {
+ main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possibly memleak
+
+ append_pad_path_widgets();
+ append_hook_widgets();
+ }
return main_box;
}
@@ -56,6 +64,14 @@ void PadPathControlModule::set_controller(const std::shared_ptr<Controller> &con
controller->on_selected_object_changed.connect([this](){
gui_emit("selected-object");
});
+
+ controller->on_pad_watch_confirmation_received.connect([this](const PadWatch& watch,
PadWatch_WatchType type) {
+ if (type == watch_type)
+ {
+ gui_push("confirmation", new PadWatch(watch));
+ gui_emit("confirmation");
+ }
+ });
}
std::string PadPathControlModule::get_pad_path() const
@@ -64,3 +80,40 @@ std::string PadPathControlModule::get_pad_path() const
return any_path_check_button->get_active() || !selected_pad ? std::string() :
ElementPathProcessor::get_object_path(selected_pad);
}
+
+void PadPathControlModule::confirmation_received_()
+{
+ auto conf = gui_pop<PadWatch*>("confirmation");
+
+ if (conf->watch_type() != watch_type)
+ return;
+
+ if (conf->toggle() == ENABLE)
+ {
+ Gtk::TreeModel::Row row = *(hooks_model->append());
+ row[hooks_model_columns.pad_path] = conf->pad_path();
+
+ if (watch_type != PadWatch_WatchType_BUFFER)
+ {
+ row[hooks_model_columns.qe_type_name] = watch_type == PadWatch_WatchType_EVENT ?
+ Gst::Enums::get_name(static_cast<Gst::EventType>(conf->qe_type())) :
+ Gst::Enums::get_name(static_cast<Gst::QueryType>(conf->qe_type()));
+ }
+ row[hooks_model_columns.qe_type] = conf->qe_type();
+ }
+ else
+ {
+ for (auto iter = hooks_model->children().begin();
+ iter != hooks_model->children().end(); ++iter)
+ {
+ if ((*iter)[hooks_model_columns.pad_path] == conf->pad_path() &&
+ (*iter)[hooks_model_columns.qe_type] == conf->qe_type())
+ {
+ hooks_model->erase(iter);
+ break;
+ }
+ }
+ }
+
+ delete conf;
+}
diff --git a/src/gst-debugger/modules/pad_path_control_module.h
b/src/gst-debugger/modules/pad_path_control_module.h
index 5bc97d1..d2d2952 100644
--- a/src/gst-debugger/modules/pad_path_control_module.h
+++ b/src/gst-debugger/modules/pad_path_control_module.h
@@ -12,6 +12,10 @@
class PadPathControlModule : virtual public HooksControlModule
{
+ Gtk::Box *path_box;
+
+ void confirmation_received_();
+
protected:
Gtk::CheckButton *any_path_check_button;
diff --git a/src/gst-debugger/modules/pad_path_types_control_module.h
b/src/gst-debugger/modules/pad_path_types_control_module.h
index 7a24e30..045f26d 100644
--- a/src/gst-debugger/modules/pad_path_types_control_module.h
+++ b/src/gst-debugger/modules/pad_path_types_control_module.h
@@ -24,17 +24,20 @@ public:
PadPathControlModule(watch_type),
HooksControlModule(watch_type)
{
- main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possibly memleak
-
- append_types_widgets();
- append_pad_path_widgets();
- append_hook_widgets();
}
virtual ~PadPathTypesControlModule () {}
Gtk::Widget* get_widget() override
{
+ if (main_box == nullptr)
+ {
+ main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possibly
memleak
+
+ append_types_widgets();
+ append_pad_path_widgets();
+ append_hook_widgets();
+ }
return main_box;
}
diff --git a/src/gst-debugger/modules/types_control_module.cpp
b/src/gst-debugger/modules/types_control_module.cpp
index fd4d4a6..e50b234 100644
--- a/src/gst-debugger/modules/types_control_module.cpp
+++ b/src/gst-debugger/modules/types_control_module.cpp
@@ -9,21 +9,12 @@
#include "controller/controller.h"
+static void free_message(MessageWatch* m) { delete m; }
+
void TypesControlModule::append_types_widgets()
{
- Gtk::Box *type_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
- any_type_check_button = Gtk::manage(new Gtk::CheckButton("any event"));
- any_type_check_button->signal_clicked().connect([this] { update_add_hook(); });
-
- type_box->pack_start(*any_type_check_button);
- main_box->pack_start(*type_box);
-
- types_combobox = Gtk::manage(new Gtk::ComboBox());
+ main_box->pack_start(*type_box, false, true);
main_box->pack_start(*Gtk::manage(types_combobox), false, true);
- types_model = Gtk::ListStore::create(types_model_columns);
- types_combobox->set_model(types_model);
- types_combobox->pack_start(types_model_columns.type_name);
-
}
bool TypesControlModule::add_hook_unlocked()
@@ -36,16 +27,36 @@ TypesControlModule::TypesControlModule(const std::string &enum_type_name, PadWat
: HooksControlModule(watch_type),
type_name(enum_type_name)
{
+ type_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL));
+ any_type_check_button = Gtk::manage(new Gtk::CheckButton("any event"));
+ any_type_check_button->signal_clicked().connect([this] { update_add_hook(); });
+
+ type_box->pack_start(*any_type_check_button);
+
+ types_combobox = Gtk::manage(new Gtk::ComboBox());
+ types_model = Gtk::ListStore::create(types_model_columns);
+ types_combobox->set_model(types_model);
+ types_combobox->pack_start(types_model_columns.type_name);
+
create_dispatcher("enum", sigc::mem_fun(*this, &TypesControlModule::enum_list_changed_), nullptr); //
todo memleak
- main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possibly memleak
+ hooks_tree_view->append_column("Type", hooks_model_columns.qe_type_name);
- append_types_widgets();
- append_hook_widgets();
+ if ((int)watch_type == -1) // todo
+ {
+ create_dispatcher("message-confirmation", sigc::mem_fun(*this,
&TypesControlModule::message_confirmation_), (GDestroyNotify)free_message);
+ }
}
Gtk::Widget* TypesControlModule::get_widget()
{
+ if (main_box == nullptr)
+ {
+ main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possibly memleak
+
+ append_types_widgets();
+ append_hook_widgets();
+ }
return main_box;
}
@@ -60,6 +71,14 @@ void TypesControlModule::set_controller(const std::shared_ptr<Controller> &contr
gui_push("enum", new bool(add));
gui_emit("enum");
});
+
+ if ((int)watch_type == -1) // todo
+ {
+ controller->on_message_confirmation_received.connect([this](const MessageWatch& watch) {
+ gui_push("message-confirmation", new MessageWatch(watch));
+ gui_emit("message-confirmation");
+ });
+ }
}
void TypesControlModule::enum_list_changed_()
@@ -100,3 +119,27 @@ int TypesControlModule::get_type() const
Gtk::TreeModel::Row row = *iter;
return row ? row[types_model_columns.type_id] : -1;
}
+
+void TypesControlModule::message_confirmation_()
+{
+ auto confirmation = gui_pop<MessageWatch*>("message-confirmation");
+ if (confirmation->toggle() == ENABLE)
+ {
+ Gtk::TreeModel::Row row = *(hooks_model->append());
+ row[hooks_model_columns.qe_type_name] =
Gst::Enums::get_name(static_cast<Gst::MessageType>(confirmation->message_type()));
+ row[hooks_model_columns.qe_type] = confirmation->message_type();
+ }
+ else
+ {
+ for (auto iter = hooks_model->children().begin();
+ iter != hooks_model->children().end(); ++iter)
+ {
+ if ((*iter)[hooks_model_columns.qe_type] == confirmation->message_type())
+ {
+ hooks_model->erase(iter);
+ break;
+ }
+ }
+ }
+ delete confirmation;
+}
diff --git a/src/gst-debugger/modules/types_control_module.h b/src/gst-debugger/modules/types_control_module.h
index 860aba0..19249d7 100644
--- a/src/gst-debugger/modules/types_control_module.h
+++ b/src/gst-debugger/modules/types_control_module.h
@@ -12,6 +12,8 @@
class TypesControlModule : virtual public HooksControlModule
{
+ Gtk::Box *type_box;
+
protected:
TypesModelColumns types_model_columns;
Glib::RefPtr<Gtk::ListStore> types_model;
@@ -28,6 +30,8 @@ protected:
int get_type() const override;
+ void message_confirmation_();
+
public:
TypesControlModule(const std::string &enum_type_name, PadWatch_WatchType watch_type);
virtual ~TypesControlModule() {}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]