[gst-debugger] gst-debugger: add log module



commit 68a55499610086986d145170b00eca566fd38db2
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Mon Aug 31 15:49:35 2015 +0200

    gst-debugger: add log module

 src/gst-debugger/Makefile.am                  |    2 +
 src/gst-debugger/main_window.cpp              |    3 +-
 src/gst-debugger/modules/base_main_module.cpp |    6 ++
 src/gst-debugger/modules/base_main_module.h   |    3 +-
 src/gst-debugger/modules/log_module.cpp       |   65 +++++++++++++++++++++++++
 src/gst-debugger/modules/log_module.h         |   43 ++++++++++++++++
 src/gst-debugger/modules/pad_data_modules.cpp |    8 ---
 src/gst-debugger/modules/pad_data_modules.h   |    1 -
 8 files changed, 120 insertions(+), 11 deletions(-)
---
diff --git a/src/gst-debugger/Makefile.am b/src/gst-debugger/Makefile.am
index e1bc772..1dd5218 100644
--- a/src/gst-debugger/Makefile.am
+++ b/src/gst-debugger/Makefile.am
@@ -44,6 +44,7 @@ gst_debugger_headers =                                        \
        models/gst_pipeline_model.h                     \
        models/remote_data_container.h                  \
        modules/base_main_module.h                      \
+       modules/log_module.h                            \
        modules/gst_log_module.h                        \
        modules/gst_properties_module.h                 \
        modules/main_module.h                           \
@@ -75,6 +76,7 @@ gst_debugger_ GST_API_VERSION@_SOURCES =              \
        models/gst_factory_model.cpp                    \
        models/gst_pipeline_model.cpp                   \
        modules/main_module.cpp                         \
+       modules/log_module.cpp                          \
        modules/base_main_module.cpp                    \
        modules/pad_data_modules.cpp                    \
        modules/gst_log_module.cpp                      \
diff --git a/src/gst-debugger/main_window.cpp b/src/gst-debugger/main_window.cpp
index f5e76ef..118d9fe 100644
--- a/src/gst-debugger/main_window.cpp
+++ b/src/gst-debugger/main_window.cpp
@@ -15,6 +15,7 @@
 #include "controller/controller.h"
 
 #include "modules/pad_data_modules.h"
+#include "modules/log_module.h"
 
 MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& builder)
 : IMainView(cobject),
@@ -75,7 +76,7 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
 
 void MainWindow::load_base_main_modules(const Glib::RefPtr<Gtk::Builder>& builder)
 {
-       //main_modules["logMessages"].module = std::make_shared<GstLogModule>();
+       main_modules["logMessages"].module = std::make_shared<LogModule>();
        main_modules["queries"].module = std::make_shared<QueryModule>();
        //main_modules["busMessages"].module = std::make_shared<GstMessageModule>();
        main_modules["buffers"].module = std::make_shared<BufferModule>();
diff --git a/src/gst-debugger/modules/base_main_module.cpp b/src/gst-debugger/modules/base_main_module.cpp
index 51118e9..d60b93c 100644
--- a/src/gst-debugger/modules/base_main_module.cpp
+++ b/src/gst-debugger/modules/base_main_module.cpp
@@ -33,3 +33,9 @@ void BaseMainModule::configure_details_view(Gtk::TreeView *view)
        view->append_column("Value", detail_columns.value);
 }
 
+void BaseMainModule::append_details_row(const std::string &name, const std::string &value)
+{
+       Gtk::TreeModel::Row row = *(details_model->append());
+       row[detail_columns.name] = name;
+       row[detail_columns.value] = value;
+}
diff --git a/src/gst-debugger/modules/base_main_module.h b/src/gst-debugger/modules/base_main_module.h
index 24f956e..00d466c 100644
--- a/src/gst-debugger/modules/base_main_module.h
+++ b/src/gst-debugger/modules/base_main_module.h
@@ -22,7 +22,8 @@ protected:
 
        Glib::RefPtr<Gtk::ListStore> model;
        Glib::RefPtr<Gtk::ListStore> details_model;
-       Glib::RefPtr<Gtk::ListStore> hooks_model;
+
+       void append_details_row(const std::string &name, const std::string &value);
 
 public:
        BaseMainModule();
diff --git a/src/gst-debugger/modules/log_module.cpp b/src/gst-debugger/modules/log_module.cpp
new file mode 100644
index 0000000..35f289d
--- /dev/null
+++ b/src/gst-debugger/modules/log_module.cpp
@@ -0,0 +1,65 @@
+/*
+ * log_module.cpp
+ *
+ *  Created on: Aug 31, 2015
+ *      Author: loganek
+ */
+
+#include "log_module.h"
+
+#include "controller/controller.h"
+
+static void free_log(GstreamerLog *log) { delete log; }
+
+LogModule::LogModule()
+{
+       create_dispatcher("new-log", sigc::mem_fun(*this, &LogModule::log_received_), 
(GDestroyNotify)free_log);
+}
+
+void LogModule::configure_main_list_view(Gtk::TreeView *view)
+{
+       BaseMainModule::configure_main_list_view(view);
+       view->append_column("Logs", columns.header);
+}
+
+void LogModule::load_details(Gtk::TreeView *view, const Gtk::TreeModel::Path &path)
+{
+       BaseMainModule::load_details(view, path);
+
+       Gtk::TreeModel::iterator iter = model->get_iter(path);
+       if (!iter)
+       {
+               return;
+       }
+
+       Gtk::TreeModel::Row row = *iter;
+       auto log_info = (GstreamerLog*)row[columns.log];
+
+       append_details_row("Level", std::to_string(log_info->level()));
+       append_details_row("Category name", log_info->category_name());
+       append_details_row("File", log_info->file());
+       append_details_row("Function", log_info->function());
+       append_details_row("Line", std::to_string(log_info->line()));
+       append_details_row("Object path", log_info->object_path());
+       append_details_row("Message", log_info->message());
+}
+
+void LogModule::set_controller(const std::shared_ptr<Controller> &controller)
+{
+       BaseMainModule::set_controller(controller);
+
+       controller->on_log_received.connect([this] (const GstreamerLog &log) {
+               gui_push("new-log", new GstreamerLog (log));
+               gui_emit("new-log");
+       });
+}
+
+void LogModule::log_received_()
+{
+       auto log = gui_pop<GstreamerLog*>("new-log");
+       Gtk::TreeModel::Row row = *(model->append());
+       row[columns.header] = log->function();
+       row[columns.log] = log;
+}
+
+
diff --git a/src/gst-debugger/modules/log_module.h b/src/gst-debugger/modules/log_module.h
new file mode 100644
index 0000000..d91c85d
--- /dev/null
+++ b/src/gst-debugger/modules/log_module.h
@@ -0,0 +1,43 @@
+/*
+ * log_module.h
+ *
+ *  Created on: Aug 31, 2015
+ *      Author: loganek
+ */
+
+#ifndef SRC_GST_DEBUGGER_MODULES_LOG_MODULE_H_
+#define SRC_GST_DEBUGGER_MODULES_LOG_MODULE_H_
+
+#include "base_main_module.h"
+
+class GstreamerLog;
+
+class LogModelColumns : public Gtk::TreeModel::ColumnRecord
+{
+public:
+       LogModelColumns() {
+               add(header); add(log);
+       }
+
+       Gtk::TreeModelColumn<Glib::ustring> header;
+       Gtk::TreeModelColumn<GstreamerLog*> log;
+};
+
+class LogModule : public BaseMainModule
+{
+       void log_received_();
+
+       LogModelColumns columns;
+
+public:
+       LogModule();
+       virtual ~LogModule() {}
+
+       void configure_main_list_view(Gtk::TreeView *view) override;
+       void load_details(Gtk::TreeView *view, const Gtk::TreeModel::Path &path) override;
+
+       void set_controller(const std::shared_ptr<Controller> &controller) override;
+};
+
+
+#endif /* SRC_GST_DEBUGGER_MODULES_LOG_MODULE_H_ */
diff --git a/src/gst-debugger/modules/pad_data_modules.cpp b/src/gst-debugger/modules/pad_data_modules.cpp
index 15ff73f..b43cb19 100644
--- a/src/gst-debugger/modules/pad_data_modules.cpp
+++ b/src/gst-debugger/modules/pad_data_modules.cpp
@@ -72,14 +72,6 @@ void PadDataModule<T>::load_details(Gtk::TreeView *view, const Gtk::TreeModel::P
 }
 
 template<typename T>
-void PadDataModule<T>::append_details_row(const std::string &name, const std::string &value)
-{
-       Gtk::TreeModel::Row row = *(details_model->append());
-       row[detail_columns.name] = name;
-       row[detail_columns.value] = value;
-}
-
-template<typename T>
 void PadDataModule<T>::append_details_from_structure(Gst::Structure& structure)
 {
        if (!structure.gobj())
diff --git a/src/gst-debugger/modules/pad_data_modules.h b/src/gst-debugger/modules/pad_data_modules.h
index aee5b9e..dccd260 100644
--- a/src/gst-debugger/modules/pad_data_modules.h
+++ b/src/gst-debugger/modules/pad_data_modules.h
@@ -40,7 +40,6 @@ protected:
        PadWatch_WatchType get_watch_type() const;
 
        void append_details_from_structure(Gst::Structure& structure);
-       void append_details_row(const std::string &name, const std::string &value);
        virtual void display_details(const Glib::RefPtr<Gst::MiniObject> &obj, const Glib::ustring &pad_path) 
= 0;
 
 public:


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