39
39
#include " window.hpp"
40
40
#include " breakpoint.hpp"
41
41
#include " breakpoint_dialog.hpp"
42
+ #include " follow_dialog.hpp"
42
43
#include " canvas.hpp"
43
44
44
45
using asio::ip::tcp;
@@ -58,6 +59,7 @@ const char *const open_file_id = "open-file";
58
59
*/
59
60
UIWindow::UIWindow (const int num_processes)
60
61
: m_num_processes(num_processes),
62
+ m_follow_rank(0 ),
61
63
m_sent_run(false )
62
64
{
63
65
// allocate memory
@@ -307,6 +309,10 @@ bool UIWindow::init(Glib::RefPtr<Gtk::Application> app)
307
309
sigc::mem_fun (*this , &UIWindow::on_key_press), false );
308
310
m_root_window->signal_delete_event ().connect (
309
311
sigc::mem_fun (*this , &UIWindow::on_delete));
312
+ get_widget<Gtk::Button >(" follow-process-button" )
313
+ ->signal_clicked ()
314
+ .connect (
315
+ sigc::mem_fun (*this , &UIWindow::on_follow_button_clicked));
310
316
get_widget<Gtk::Button >(" step-over-button" )
311
317
->signal_clicked ()
312
318
.connect (sigc::bind (
@@ -422,6 +428,22 @@ bool UIWindow::on_delete(GdkEventAny *)
422
428
return false ;
423
429
}
424
430
431
+ /* *
432
+ * This function opens a dialog to select the process to follow.
433
+ */
434
+ void UIWindow::on_follow_button_clicked ()
435
+ {
436
+ std::unique_ptr<FollowDialog> dialog = std::make_unique<FollowDialog>(
437
+ m_num_processes, m_max_buttons_per_row);
438
+ if (Gtk::RESPONSE_OK != dialog->run ())
439
+ {
440
+ return ;
441
+ }
442
+ m_follow_rank = dialog->follow_rank ();
443
+ get_widget<Gtk::Button >(" follow-process-button" )
444
+ ->set_label (" Following Process " + std::to_string (m_follow_rank));
445
+ }
446
+
425
447
/* *
426
448
* This function scrolls a scrolled window to the bottom. After scrolling the
427
449
* event listener is deleted, so that the user can freely scroll in the ouput.
@@ -1097,12 +1119,15 @@ void UIWindow::append_overview_row(const string &basename,
1097
1119
*
1098
1120
* @param[in] fullpath The fullpath of the source file to append.
1099
1121
*/
1100
- void UIWindow::append_source_file (const string &fullpath)
1122
+ void UIWindow::append_source_file (const string &fullpath, const int rank )
1101
1123
{
1102
1124
// check that file is not opened already
1103
1125
if (m_opened_files.find (fullpath) != m_opened_files.end ())
1104
1126
{
1105
- m_files_notebook->set_current_page (m_path_2_pagenum[fullpath]);
1127
+ if (rank == m_follow_rank)
1128
+ {
1129
+ m_files_notebook->set_current_page (m_path_2_pagenum[fullpath]);
1130
+ }
1106
1131
return ;
1107
1132
}
1108
1133
m_opened_files.insert (fullpath);
@@ -1156,7 +1181,10 @@ void UIWindow::append_source_file(const string &fullpath)
1156
1181
}
1157
1182
scrolled_window->show_all ();
1158
1183
int page_num = m_files_notebook->append_page (*scrolled_window, *label);
1159
- m_files_notebook->set_current_page (page_num);
1184
+ if (rank == m_follow_rank)
1185
+ {
1186
+ m_files_notebook->set_current_page (page_num);
1187
+ }
1160
1188
m_path_2_pagenum[fullpath] = page_num;
1161
1189
m_pagenum_2_path[page_num] = fullpath;
1162
1190
m_path_2_view[fullpath] = source_view;
@@ -1228,7 +1256,7 @@ void UIWindow::open_file()
1228
1256
if (Gtk::RESPONSE_OK == dialog->run ())
1229
1257
{
1230
1258
string fullpath = dialog->get_filename ();
1231
- append_source_file (fullpath);
1259
+ append_source_file (fullpath, m_follow_rank );
1232
1260
}
1233
1261
dialog.reset ();
1234
1262
}
@@ -1402,8 +1430,11 @@ void UIWindow::do_scroll(const int rank) const
1402
1430
*/
1403
1431
void UIWindow::scroll_to_line (const int rank) const
1404
1432
{
1405
- Glib::signal_idle ().connect_once (
1406
- sigc::bind (sigc::mem_fun (this , &UIWindow::do_scroll), rank));
1433
+ if (rank == m_follow_rank)
1434
+ {
1435
+ Glib::signal_idle ().connect_once (
1436
+ sigc::bind (sigc::mem_fun (this , &UIWindow::do_scroll), rank));
1437
+ }
1407
1438
}
1408
1439
1409
1440
/* *
@@ -1523,7 +1554,7 @@ void UIWindow::print_data_gdb(const char *const data, const int rank)
1523
1554
// this index is one-based!
1524
1555
const int line = stop_record->frame ->line ;
1525
1556
set_position (rank, fullpath, line);
1526
- append_source_file (fullpath);
1557
+ append_source_file (fullpath, rank );
1527
1558
scroll_to_line (rank);
1528
1559
}
1529
1560
mi_free_stop (stop_record);
0 commit comments