mirror of
https://gitlab.freedesktop.org/dabrain34/GstPipelineStudio.git
synced 2024-11-25 02:21:00 +00:00
logger: add a popup menu to clear the logs
Add a way to clear the logs.
This commit is contained in:
parent
aaaa58072c
commit
39554d8d99
3 changed files with 37 additions and 0 deletions
|
@ -272,6 +272,8 @@ impl GPSApp {
|
|||
|
||||
application.add_action(&gio::SimpleAction::new("favorite.remove", None));
|
||||
|
||||
application.add_action(&gio::SimpleAction::new("logger.clear", None));
|
||||
|
||||
application.add_action(&gio::SimpleAction::new("graph.check", None));
|
||||
application.add_action(&gio::SimpleAction::new("graph.pipeline_details", None));
|
||||
|
||||
|
|
|
@ -60,6 +60,14 @@
|
|||
<attribute name="action">app.favorite.remove</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<menu id="logger_menu">
|
||||
<section>
|
||||
<item>
|
||||
<attribute name="label" translatable="yes" comments="logger menu entry clear the logs">_Clear</attribute>
|
||||
<attribute name="action">app.logger.clear</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
<menu id="node_menu">
|
||||
<section>
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
use crate::app::GPSApp;
|
||||
use crate::ui::treeview;
|
||||
use gtk::prelude::*;
|
||||
use gtk::{gio, glib};
|
||||
|
||||
use gtk::{ListStore, TreeView};
|
||||
|
||||
|
@ -30,6 +31,32 @@ pub fn setup_logger_list(app: &GPSApp) {
|
|||
.object("treeview-logger")
|
||||
.expect("Couldn't get treeview-logger");
|
||||
reset_logger_list(&logger_list);
|
||||
|
||||
let gesture = gtk::GestureClick::new();
|
||||
gesture.set_button(0);
|
||||
let app_weak = app.downgrade();
|
||||
gesture.connect_pressed(
|
||||
glib::clone!(@weak logger_list => move |gesture, _n_press, x, y| {
|
||||
let app = upgrade_weak!(app_weak);
|
||||
if gesture.current_button() == gtk::gdk::BUTTON_SECONDARY {
|
||||
let pop_menu = app.app_pop_menu_at_position(&logger_list, x, y);
|
||||
let menu: gio::MenuModel = app
|
||||
.builder
|
||||
.object("logger_menu")
|
||||
.expect("Couldn't get fav_menu model");
|
||||
pop_menu.set_menu_model(Some(&menu));
|
||||
|
||||
app.connect_app_menu_action("logger.clear",
|
||||
move |_,_| {
|
||||
reset_logger_list(&logger_list);
|
||||
}
|
||||
);
|
||||
|
||||
pop_menu.show();
|
||||
}
|
||||
}),
|
||||
);
|
||||
logger_list.add_controller(&gesture);
|
||||
}
|
||||
|
||||
pub fn add_to_logger_list(app: &GPSApp, log_entry: &str) {
|
||||
|
|
Loading…
Reference in a new issue