[gst-debugger] gst-debugger: implement "add hooks" button



commit aa85e44e38375447fd02f09e1b9e9246f47170bb
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Tue Sep 1 13:54:14 2015 +0200

    gst-debugger: implement "add hooks" button

 src/gst-debugger/modules/bus_messages_module.cpp   |    1 +
 src/gst-debugger/modules/control_module.h          |   16 +++++++++++++++-
 src/gst-debugger/modules/main_module.cpp           |   10 +++++-----
 .../modules/pad_path_control_module.cpp            |   11 ++++++++++-
 src/gst-debugger/modules/pad_path_control_module.h |    4 +++-
 .../modules/pad_path_types_control_module.h        |    6 ++++--
 src/gst-debugger/modules/types_control_module.cpp  |   20 ++++++++++++++++++--
 src/gst-debugger/modules/types_control_module.h    |    4 +++-
 8 files changed, 59 insertions(+), 13 deletions(-)
---
diff --git a/src/gst-debugger/modules/bus_messages_module.cpp 
b/src/gst-debugger/modules/bus_messages_module.cpp
index 4563c66..54ac941 100644
--- a/src/gst-debugger/modules/bus_messages_module.cpp
+++ b/src/gst-debugger/modules/bus_messages_module.cpp
@@ -16,6 +16,7 @@ static void free_bus_messages(GstreamerQEBM *qebm) { delete qebm; }
 
 BusMessagesModule::BusMessagesModule()
 {
+       model = Gtk::ListStore::create(columns);
        create_dispatcher("new-message", sigc::mem_fun(*this, &BusMessagesModule::bus_message_received_), 
(GDestroyNotify)free_bus_messages);
 }
 
diff --git a/src/gst-debugger/modules/control_module.h b/src/gst-debugger/modules/control_module.h
index db3a7e9..e247631 100644
--- a/src/gst-debugger/modules/control_module.h
+++ b/src/gst-debugger/modules/control_module.h
@@ -9,6 +9,7 @@
 #define SRC_GST_DEBUGGER_MODULES_CONTROL_MODULE_H_
 
 #include "controller/iview.h"
+#include "controller/controller.h"
 
 #include "common_model_columns.h"
 
@@ -24,6 +25,8 @@ public:
 
 class HooksControlModule : public ControlModule
 {
+       PadWatch_WatchType watch_type;
+
 protected:
        Gtk::Box *main_box = nullptr;
        Gtk::Button *add_hook_button;
@@ -31,6 +34,13 @@ protected:
        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);
@@ -48,8 +58,12 @@ protected:
                add_hook_button->set_sensitive(add_hook_unlocked());
        }
 
+       virtual int get_type() const { return -1; }
+       virtual std::string get_pad_path() const { return std::string(); }
+
 public:
-       HooksControlModule()
+       HooksControlModule(PadWatch_WatchType watch_type)
+       : watch_type(watch_type)
        {
                main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possible memleak
 
diff --git a/src/gst-debugger/modules/main_module.cpp b/src/gst-debugger/modules/main_module.cpp
index cb1ae19..b9cef0e 100644
--- a/src/gst-debugger/modules/main_module.cpp
+++ b/src/gst-debugger/modules/main_module.cpp
@@ -44,19 +44,19 @@ MainModule::MainModule(const Glib::RefPtr<Gtk::Builder> &builder)
 void MainModule::load_submodules(const Glib::RefPtr<Gtk::Builder>& builder)
 {
        submodules["logMessages"].display_module = std::make_shared<LogModule>();
-       submodules["logMessages"].control_module = std::make_shared<HooksControlModule>();
+       submodules["logMessages"].control_module = 
std::make_shared<HooksControlModule>(PadWatch_WatchType_EVENT); //todo
 
        submodules["queries"].display_module = std::make_shared<QueryModule>();
-       submodules["queries"].control_module = std::make_shared<PadPathTypesControlModule>("GstQueryType");
+       submodules["queries"].control_module = std::make_shared<PadPathTypesControlModule>("GstQueryType", 
PadWatch_WatchType_QUERY);
 
        submodules["busMessages"].display_module = std::make_shared<BusMessagesModule>();
-       submodules["busMessages"].control_module = std::make_shared<TypesControlModule>("GstMessageType");
+       submodules["busMessages"].control_module = std::make_shared<TypesControlModule>("GstMessageType", 
(PadWatch_WatchType)-1);
 
        submodules["buffers"].display_module = std::make_shared<BufferModule>();
-       submodules["buffers"].control_module = std::make_shared<PadPathControlModule>();
+       submodules["buffers"].control_module = 
std::make_shared<PadPathControlModule>(PadWatch_WatchType_BUFFER);
 
        submodules["events"].display_module = std::make_shared<EventModule>();
-       submodules["events"].control_module = std::make_shared<PadPathTypesControlModule>("GstEventType");
+       submodules["events"].control_module = std::make_shared<PadPathTypesControlModule>("GstEventType", 
PadWatch_WatchType_EVENT);
 
        for (auto m : submodules)
        {
diff --git a/src/gst-debugger/modules/pad_path_control_module.cpp 
b/src/gst-debugger/modules/pad_path_control_module.cpp
index 49fd4f9..6c37f10 100644
--- a/src/gst-debugger/modules/pad_path_control_module.cpp
+++ b/src/gst-debugger/modules/pad_path_control_module.cpp
@@ -8,6 +8,7 @@
 #include "pad_path_control_module.h"
 
 #include "controller/controller.h"
+#include "controller/element_path_processor.h"
 
 void PadPathControlModule::append_pad_path_widgets()
 {
@@ -33,7 +34,8 @@ void PadPathControlModule::selected_object_changed_()
        update_add_hook();
 }
 
-PadPathControlModule::PadPathControlModule()
+PadPathControlModule::PadPathControlModule(PadWatch_WatchType watch_type)
+: HooksControlModule(watch_type)
 {
        main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possibly memleak
 
@@ -55,3 +57,10 @@ void PadPathControlModule::set_controller(const std::shared_ptr<Controller> &con
                gui_emit("selected-object");
        });
 }
+
+std::string PadPathControlModule::get_pad_path() const
+{
+       auto selected_pad = std::dynamic_pointer_cast<PadModel>(controller->get_selected_object());
+
+       return any_path_check_button->get_active() || !selected_pad ? std::string() : 
ElementPathProcessor::get_object_path(selected_pad);
+}
diff --git a/src/gst-debugger/modules/pad_path_control_module.h 
b/src/gst-debugger/modules/pad_path_control_module.h
index a84e6c2..5bc97d1 100644
--- a/src/gst-debugger/modules/pad_path_control_module.h
+++ b/src/gst-debugger/modules/pad_path_control_module.h
@@ -21,8 +21,10 @@ protected:
 
        bool add_hook_unlocked() override;
 
+       std::string get_pad_path() const override;
+
 public:
-       PadPathControlModule();
+       PadPathControlModule(PadWatch_WatchType watch_type);
        virtual ~PadPathControlModule() {}
 
        Gtk::Widget* get_widget() override;
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 b490231..7a24e30 100644
--- a/src/gst-debugger/modules/pad_path_types_control_module.h
+++ b/src/gst-debugger/modules/pad_path_types_control_module.h
@@ -19,8 +19,10 @@ class PadPathTypesControlModule : public PadPathControlModule, public TypesContr
        }
 
 public:
-       PadPathTypesControlModule(const std::string &type_name)
-       : TypesControlModule(type_name)
+       PadPathTypesControlModule(const std::string &type_name, PadWatch_WatchType watch_type)
+       : TypesControlModule(type_name, watch_type),
+         PadPathControlModule(watch_type),
+         HooksControlModule(watch_type)
        {
                main_box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL)); // todo possibly memleak
 
diff --git a/src/gst-debugger/modules/types_control_module.cpp 
b/src/gst-debugger/modules/types_control_module.cpp
index 1ba0ead..fd4d4a6 100644
--- a/src/gst-debugger/modules/types_control_module.cpp
+++ b/src/gst-debugger/modules/types_control_module.cpp
@@ -32,8 +32,9 @@ bool TypesControlModule::add_hook_unlocked()
                        !!types_combobox->get_active();
 }
 
-TypesControlModule::TypesControlModule(const std::string &enum_type_name)
-: type_name(enum_type_name)
+TypesControlModule::TypesControlModule(const std::string &enum_type_name, PadWatch_WatchType watch_type)
+: HooksControlModule(watch_type),
+  type_name(enum_type_name)
 {
        create_dispatcher("enum", sigc::mem_fun(*this, &TypesControlModule::enum_list_changed_), nullptr); // 
todo memleak
 
@@ -84,3 +85,18 @@ void TypesControlModule::enum_list_changed_()
        delete add;
        delete type_name;
 }
+
+int TypesControlModule::get_type() const
+{
+       if (any_type_check_button->get_active())
+       {
+               return -1;
+       }
+
+       Gtk::TreeModel::iterator iter = types_combobox->get_active();
+       if (!iter)
+               return -1;
+
+       Gtk::TreeModel::Row row = *iter;
+       return row ? row[types_model_columns.type_id] : -1;
+}
diff --git a/src/gst-debugger/modules/types_control_module.h b/src/gst-debugger/modules/types_control_module.h
index 0565dae..860aba0 100644
--- a/src/gst-debugger/modules/types_control_module.h
+++ b/src/gst-debugger/modules/types_control_module.h
@@ -26,8 +26,10 @@ protected:
 
        bool add_hook_unlocked() override;
 
+       int get_type() const override;
+
 public:
-       TypesControlModule(const std::string &enum_type_name);
+       TypesControlModule(const std::string &enum_type_name, PadWatch_WatchType watch_type);
        virtual ~TypesControlModule() {}
 
        Gtk::Widget* get_widget() override;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]