[gst-debugger/refactor-v1.0] gst-debugger: allow to clear main model



commit a5027c30ffc19e7cbf9a5296132c9495af109642
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Sun Oct 4 01:41:49 2015 +0200

    gst-debugger: allow to clear main model

 src/gst-debugger/modules/base_main_module.cpp |    9 +++++++++
 src/gst-debugger/modules/base_main_module.h   |    2 ++
 src/gst-debugger/modules/buffer_module.cpp    |    2 +-
 src/gst-debugger/modules/main_module.cpp      |    8 ++++++--
 src/gst-debugger/modules/main_module.h        |    1 +
 src/gst-debugger/ui/gst-debugger.glade        |   13 +++++++++++++
 6 files changed, 32 insertions(+), 3 deletions(-)
---
diff --git a/src/gst-debugger/modules/base_main_module.cpp b/src/gst-debugger/modules/base_main_module.cpp
index 537db30..8578418 100644
--- a/src/gst-debugger/modules/base_main_module.cpp
+++ b/src/gst-debugger/modules/base_main_module.cpp
@@ -104,3 +104,12 @@ void BaseMainModule::set_controller(const std::shared_ptr<Controller> &controlle
                gui_emit("new-data");
        });
 }
+
+void BaseMainModule::clear_model()
+{
+       for (auto it : model->children())
+       {
+               gpointer data = (*it)[columns.data];
+               delete reinterpret_cast<::google::protobuf::Message*>(data);
+       }
+}
diff --git a/src/gst-debugger/modules/base_main_module.h b/src/gst-debugger/modules/base_main_module.h
index 97de4ca..55819ba 100644
--- a/src/gst-debugger/modules/base_main_module.h
+++ b/src/gst-debugger/modules/base_main_module.h
@@ -67,6 +67,8 @@ public:
        Glib::RefPtr<Gtk::ListStore> get_model() const { return model; }
 
        void set_controller(const std::shared_ptr<Controller> &controller) override;
+
+       void clear_model();
 };
 
 #endif /* SRC_GST_DEBUGGER_MODULES_BASE_MAIN_MODULE_H_ */
diff --git a/src/gst-debugger/modules/buffer_module.cpp b/src/gst-debugger/modules/buffer_module.cpp
index d9b2622..50f1127 100644
--- a/src/gst-debugger/modules/buffer_module.cpp
+++ b/src/gst-debugger/modules/buffer_module.cpp
@@ -68,7 +68,7 @@ BufferControlModule::BufferControlModule()
        main_box->pack_start(*pad_path_label, false, true);
        main_box->reorder_child(*pad_path_label, 0);
 
-       data_check_button = Gtk::manage(new Gtk::CheckButton());
+       data_check_button = Gtk::manage(new Gtk::CheckButton("Send data"));
        main_box->pack_start(*data_check_button, false, true);
        main_box->reorder_child(*data_check_button, 1);
 
diff --git a/src/gst-debugger/modules/main_module.cpp b/src/gst-debugger/modules/main_module.cpp
index c39c082..8d59005 100644
--- a/src/gst-debugger/modules/main_module.cpp
+++ b/src/gst-debugger/modules/main_module.cpp
@@ -28,6 +28,12 @@ MainModule::MainModule(const Glib::RefPtr<Gtk::Builder> &builder)
 
        builder->get_widget("controllerFrame", controller_frame);
 
+       builder->get_widget("clearMainListButton", clear_main_list_button);
+       clear_main_list_button->signal_clicked().connect([this] {
+               current_module->clear_model();
+               current_module->get_model()->clear();
+       });
+
        load_submodules(builder);
 }
 
@@ -66,8 +72,6 @@ void MainModule::set_controller(const std::shared_ptr<Controller> &controller)
 {
        IBaseView::set_controller(controller);
 
-       //controller->on_selected_object_changed.connect([this]{gui_emit("selected-object");});
-
        for (auto m : submodules)
        {
                m.second.display_module->set_controller(controller);
diff --git a/src/gst-debugger/modules/main_module.h b/src/gst-debugger/modules/main_module.h
index eb70c79..04717df 100644
--- a/src/gst-debugger/modules/main_module.h
+++ b/src/gst-debugger/modules/main_module.h
@@ -27,6 +27,7 @@ class MainModule : public IBaseView
        Gtk::TreeView *list_tree_view;
        Gtk::TreeView *details_tree_view;
        Gtk::Frame *controller_frame;
+       Gtk::Button *clear_main_list_button;
 
        TypesModelColumns types_columns;
 
diff --git a/src/gst-debugger/ui/gst-debugger.glade b/src/gst-debugger/ui/gst-debugger.glade
index aad0bd8..b1bde38 100644
--- a/src/gst-debugger/ui/gst-debugger.glade
+++ b/src/gst-debugger/ui/gst-debugger.glade
@@ -284,6 +284,19 @@
                       <packing>
                         <property name="expand">True</property>
                         <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkButton" id="clearMainListButton">
+                        <property name="label" translatable="yes">Clear</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
                         <property name="position">1</property>
                       </packing>
                     </child>


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