File: gui_watch.cc

package info (click to toggle)
gpsim 0.32.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,640 kB
  • sloc: cpp: 121,258; asm: 54,223; ansic: 13,576; python: 9,708; sh: 4,695; makefile: 1,566; lex: 1,139; yacc: 854; pascal: 511; perl: 93; awk: 44; xml: 41
file content (695 lines) | stat: -rw-r--r-- 18,194 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
/*
   Copyright (C) 1998,1999,2000,2001
   T. Scott Dattalo and Ralf Forsberg

This file is part of gpsim.

gpsim is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

gpsim is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with gpsim; see the file COPYING.  If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.  */

#include "../config.h"
#ifdef HAVE_GUI

#include <gtk/gtk.h>
#include <gdk/gdk.h>
#include <gdk/gdkkeysyms.h>
#include <glib.h>
#include <glib-object.h>

#include <cstdio>

#include <memory>
#include <string>

#include "../src/breakpoints.h"
#include "../src/interface.h"
#include "../src/processor.h"
#include "../src/registers.h"
#include "../src/symbol.h"
#include "../src/ui.h"
#include "../src/value.h"
#include "gui.h"
#include "gui_processor.h"
#include "gui_register.h"
#include "gui_regwin.h"
#include "gui_watch.h"

class gpsimObject;

enum {
  NAMECOL,
  ADDRESSCOL,
  DECIMALCOL,
  HEXCOL,
  ASCIICOL,
  BITCOL,
  ENTRYCOL,
  N_COLUMNS
};

static const gchar *watch_titles[]={"name","address","dec","hex","ascii","bits"};

#define COLUMNS sizeof(watch_titles)/sizeof(char*)

class ColumnData {
public:
  ColumnData(GtkTreeViewColumn *_tc, bool visible);
  void SetVisibility(bool bVisibility);
  bool GetVisibility() { return isVisible;}

private:
  GtkTreeViewColumn *tc;
  bool isVisible;
};

typedef enum {
    MENU_REMOVE,
    MENU_SET_VALUE,
    MENU_BREAK_CLEAR,
    MENU_BREAK_READ,
    MENU_BREAK_WRITE,
    MENU_BREAK_READ_VALUE,
    MENU_BREAK_WRITE_VALUE,
    MENU_COLUMNS,
} menu_id;


typedef struct _menu_item {
    const char *name;
    menu_id id;
} menu_item;

static const menu_item menu_items[] = {
    {"Remove watch", MENU_REMOVE},
    {"Set value...", MENU_SET_VALUE},
    {"Clear breakpoints", MENU_BREAK_CLEAR},
    {"Set break on read", MENU_BREAK_READ},
    {"Set break on write", MENU_BREAK_WRITE},
    {"Set break on read value...", MENU_BREAK_READ_VALUE},
    {"Set break on write value...", MENU_BREAK_WRITE_VALUE},
    {"Columns...", MENU_COLUMNS},
};

//========================================================================

class WatchWindowXREF : public CrossReferenceToGUI
{
public:
  virtual ~WatchWindowXREF();
  void Update(int new_value) override;
};

WatchWindowXREF::~WatchWindowXREF()
{
  gtk_tree_row_reference_free(static_cast<GtkTreeRowReference *>((void *)data));
}

void WatchWindowXREF::Update(int)
{
  Watch_Window *ww  = static_cast<Watch_Window *>(parent_window);
  if (ww) {
    GtkTreePath *path
      = gtk_tree_row_reference_get_path(static_cast<GtkTreeRowReference *>((void *)data));
    GtkTreeIter iter;
    if (gtk_tree_model_get_iter(GTK_TREE_MODEL(ww->watch_list), &iter, path))
      ww->UpdateWatch(&iter);
  }
}

//========================================================================
WatchEntry::WatchEntry(REGISTER_TYPE _type, Register *_pRegister)
  : cpu(nullptr), type(_type), pRegister(_pRegister)
{
}

WatchEntry::~WatchEntry()
{
  Clear_xref();
}

//========================================================================
ColumnData::ColumnData(GtkTreeViewColumn *_tc, bool visible)
  : tc(_tc), isVisible(visible)
{
  int show = isVisible;
  gtk_tree_view_column_set_visible(tc, show);
}

void ColumnData::SetVisibility(bool bVisibility)
{
  isVisible = bVisibility;
  int show = isVisible;
  gtk_tree_view_column_set_visible(tc, show);
}

//========================================================================

void Watch_Window::ClearWatch(GtkTreeIter *iter)
{
  WatchEntry *entry;

  gtk_tree_model_get(GTK_TREE_MODEL(watch_list), iter, ENTRYCOL, &entry, -1);
  delete entry;
  gtk_list_store_remove(watch_list, iter);
}

void Watch_Window::UpdateMenus()
{
  GtkTreeSelection *sel =
    gtk_tree_view_get_selection(GTK_TREE_VIEW(watch_tree));
  GtkTreeIter iter;
  gboolean selected = gtk_tree_selection_get_selected(sel, nullptr, &iter);
  WatchEntry *entry;
  if (selected) {
    gtk_tree_model_get(GTK_TREE_MODEL(watch_list), &iter, ENTRYCOL, &entry, -1);
  }

  for (size_t i = 0; i < G_N_ELEMENTS(menu_items); ++i) {
    GtkWidget *item = popup_items[i];
    if (menu_items[i].id != MENU_COLUMNS) {
      if (menu_items[i].id !=MENU_COLUMNS &&
          (!selected ||
          (entry->type == REGISTER_EEPROM && menu_items[i].id == MENU_BREAK_CLEAR) ||
          (entry->type == REGISTER_EEPROM && menu_items[i].id == MENU_BREAK_READ) ||
          (entry->type == REGISTER_EEPROM && menu_items[i].id == MENU_BREAK_WRITE) ||
          (entry->type == REGISTER_EEPROM && menu_items[i].id == MENU_BREAK_READ_VALUE) ||
          (entry->type == REGISTER_EEPROM && menu_items[i].id == MENU_BREAK_WRITE_VALUE)
          ))
        gtk_widget_set_sensitive(item, FALSE);
      else
        gtk_widget_set_sensitive(item, TRUE);
    }
  }
}

int Watch_Window::set_config()
{
  int iRet = GUI_Object::set_config();
  WriteSymbolList();
  return iRet;
}

gboolean Watch_Window::do_symbol_write(GtkTreeModel *, GtkTreePath *,
  GtkTreeIter *iter, gpointer data)
{
  Watch_Window *ww = static_cast<Watch_Window *>(data);
  WatchEntry *entry;
  gtk_tree_model_get(GTK_TREE_MODEL(ww->watch_list), iter, ENTRYCOL, &entry, -1);

  if (entry && entry->pRegister) {
    char cwv[100];
    g_snprintf(cwv, sizeof(cwv), "WV%d", ww->count);
    config_set_string(ww->name(), cwv, entry->pRegister->name().c_str());
  }

  ww->count += 1;

  return FALSE;
}

void Watch_Window::WriteSymbolList()
{
  // delete previous list
  DeleteSymbolList();
  // write the current list
  count = 0;
  if (watch_list)
      gtk_tree_model_foreach(GTK_TREE_MODEL(watch_list), do_symbol_write, this);
}

void Watch_Window::DeleteSymbolList()
{
  char cwv[100];
  for (int i = 0; i < 1000; ++i) {
    g_snprintf(cwv, sizeof(cwv), "WV%d", i);
    if (config_remove(name(), cwv) == 0) {
      break;
    }
  }
}

void Watch_Window::ReadSymbolList()
{
  // now read symbols watched from a prior simulation session
  char cwv[100];
  char *vname;
  for (int i = 0; i < 1000; ++i) {
    g_snprintf(cwv, sizeof(cwv), "WV%d", i);
    vname = 0;
    if (config_get_string(name(), cwv, &vname) ) {
      Value *val = globalSymbolTable().findValue(vname);
      if (val)
        Add(val);
    }
    else
      break;
  }
}

// called when user has selected a menu item
void Watch_Window::popup_activated(GtkWidget *widget, gpointer data)
{
  Watch_Window *ww = static_cast<Watch_Window *>(data);
  WatchEntry *entry = nullptr;

  int value;

  GtkTreeSelection *sel
    = gtk_tree_view_get_selection(GTK_TREE_VIEW(ww->watch_tree));
  GtkTreeIter iter;
  gboolean selected = gtk_tree_selection_get_selected(sel, nullptr, &iter);

  if (selected) {
    gtk_tree_model_get(GTK_TREE_MODEL(ww->watch_list), &iter, ENTRYCOL, &entry, -1);
  }

  int id = GPOINTER_TO_SIZE(g_object_get_data(G_OBJECT(widget), "id"));

  if (id == MENU_COLUMNS) {
    ww->select_columns();
    return;
  }

  if (!entry || !entry->cpu)
    return;

  switch (id)
    {
    case MENU_REMOVE:
      ww->ClearWatch(&iter);
      break;
    case MENU_SET_VALUE:
      value = gui_get_value("value:");
      if (value < 0)
        break; // Cancel
      entry->put_value(value);
      break;
    case MENU_BREAK_READ:
      get_bp().set_read_break(entry->cpu,entry->address);
      break;
    case MENU_BREAK_WRITE:
      get_bp().set_write_break(entry->cpu,entry->address);
      break;
    case MENU_BREAK_READ_VALUE:
      value = gui_get_value("value to read for breakpoint:");
      if (value < 0)
        break; // Cancel
      get_bp().set_read_value_break(entry->cpu,entry->address,value);
      break;
    case MENU_BREAK_WRITE_VALUE:
      value = gui_get_value("value to write for breakpoint:");
      if (value < 0)
        break; // Cancel
      get_bp().set_write_value_break(entry->cpu,entry->address,value);
      break;
    case MENU_BREAK_CLEAR:
      get_bp().clear_all_register(entry->cpu,entry->address);
      break;
    default:
      break;
    }
}

//------------------------------------------------------------
// call back function to toggle column visibility in the configuration popup
void Watch_Window::set_column(GtkCheckButton *button, Watch_Window *ww)
{
  int id = GPOINTER_TO_SIZE(g_object_get_data(G_OBJECT(button), "id"));
  gboolean vis = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button));

  ww->coldata[id].SetVisibility(vis != 0);

  config_set_variable(ww->name(), watch_titles[id], vis);
}

void Watch_Window::select_columns()
{
  GtkWidget *dialog;

  dialog = gtk_dialog_new_with_buttons("", GTK_WINDOW(window),
    GTK_DIALOG_MODAL,
    "_Close", GTK_RESPONSE_CLOSE,
    nullptr);

  GtkWidget *area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));

  gtk_container_set_border_width(GTK_CONTAINER(dialog), 30);

  for (size_t i = 0; i < COLUMNS; ++i) {
    GtkWidget *button = gtk_check_button_new_with_label(watch_titles[i]);
    g_object_set_data(G_OBJECT(button), "id", GSIZE_TO_POINTER(i));
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button),
      coldata[i].GetVisibility());
    gtk_box_pack_start(GTK_BOX(area), button, FALSE, FALSE, 0);
    g_signal_connect(button, "clicked", G_CALLBACK(set_column), this);
  }

  gtk_widget_show_all(dialog);
  gtk_dialog_run(GTK_DIALOG(dialog));
  gtk_widget_destroy(dialog);
}

// helper function, called from do_popup
void Watch_Window::build_menu()
{
  GtkWidget *menu = gtk_menu_new();
  popup_menu = menu;

  popup_items.reserve(G_N_ELEMENTS(menu_items));
  for (size_t i = 0; i < G_N_ELEMENTS(menu_items); ++i) {
    GtkWidget *item = gtk_menu_item_new_with_label(menu_items[i].name);
    popup_items.push_back(item);
    g_object_set_data(G_OBJECT(item), "id", GSIZE_TO_POINTER(i));

    g_signal_connect(item, "activate", G_CALLBACK(popup_activated), this);
    gtk_widget_show(item);
    gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
  }

  UpdateMenus();
}

// button press handler
gboolean Watch_Window::do_popup(GtkWidget *, GdkEventButton *event,
  Watch_Window *ww)
{
  GtkWidget *popup = ww->popup_menu;

  if ((event->type == GDK_BUTTON_PRESS) &&  (event->button == 3)) {
    gtk_menu_popup(GTK_MENU(popup), nullptr, nullptr, nullptr, nullptr, 3, event->time);
    return TRUE;
  }

  return FALSE;
}

static gint
key_press(GtkWidget *,
          GdkEventKey *key,
          gpointer data)
{
  Watch_Window *ww = static_cast<Watch_Window *>(data);

  if (!ww || !ww->gp || !ww->gp->cpu) return FALSE;

  switch (key->keyval) {

  case GDK_KEY_Delete:
    GtkTreeSelection *sel
      = gtk_tree_view_get_selection(GTK_TREE_VIEW(ww->watch_tree));
    GtkTreeIter iter;
    if (gtk_tree_selection_get_selected(sel, nullptr, &iter))
      ww->ClearWatch(&iter);
    break;
  }
  return TRUE;
}

void Watch_Window::watch_list_row_selected(GtkTreeSelection *sel, Watch_Window *ww)
{
  WatchEntry *entry;
  GUI_Processor *gp = ww->gp;

  GtkTreeIter iter;

  if (!gtk_tree_selection_get_selected(sel, nullptr, &iter))
    return;

  gtk_tree_model_get(GTK_TREE_MODEL(ww->watch_list), &iter, ENTRYCOL, &entry, -1);

  if (entry->type == REGISTER_RAM)
    gp->regwin_ram->SelectRegister(entry->address);
  else if (entry->type == REGISTER_EEPROM)
    gp->regwin_eeprom->SelectRegister(entry->address);

  ww->UpdateMenus();
}

//========================================================================
// UpdateWatch
// A single watch entry is updated here. Here's what's done:
//
// If the value has not changed since the last update, then the
// foreground and background colors are refreshed and we return.
//
// If the value has changed, then each of the value fields are refreshed.
// Then the foreground and background are refreshed.

void Watch_Window::UpdateWatch(GtkTreeIter *iter)
{
  WatchEntry *entry;
  gtk_tree_model_get(GTK_TREE_MODEL(watch_list), iter, ENTRYCOL, &entry, -1);

  RegisterValue rvNewValue = entry->getRV();

  // If the value has not changed, then simply update the foreground and background
  // colors and return.

  if (entry->get_shadow() == rvNewValue) {
    // Disable colour change for now
    return;
  }

  RegisterValue rvMaskedNewValue;
  unsigned int uBitmask;

  entry->put_shadow(rvNewValue);

  if (entry->pRegister) {
    rvMaskedNewValue = entry->pRegister->getRV_notrace();
    uBitmask = entry->pRegister->mValidBits; //getBitmask();
  }
  else {
    rvMaskedNewValue = entry->getRV();
    uBitmask = entry->cpu->register_mask();
  }

  char str[80] = "?";

  if (!(rvNewValue.init & uBitmask))
    g_snprintf(str, sizeof(str), "%d", rvNewValue.data);

  // Hexadecimal representation:
  char hStr[80];
  rvMaskedNewValue.toString(hStr, 80);

  // ASCII representation
  char aStr[2];
  aStr[0] = ( rvNewValue.data>0x20 && rvNewValue.data<0x7F ) ? rvNewValue.data : 0;
  aStr[1] = 0;

  // Bit representation
  char sBits[25];
  rvNewValue.toBitStr(sBits, 25, entry->cpu->register_mask(), nullptr);

  gtk_list_store_set(watch_list, iter,
    DECIMALCOL, str,
    HEXCOL, hStr,
    ASCIICOL, aStr,
    BITCOL, sBits,
    -1);

  // Set foreground and background colors
  // Diable colour change for now
}

//------------------------------------------------------------------------
// Update
//
//

static gboolean do_an_update(GtkTreeModel *, GtkTreePath *,
  GtkTreeIter *iter, gpointer data)
{
  Watch_Window *ww = static_cast<Watch_Window *>(data);
  ww->UpdateWatch(iter);

  return FALSE;
}

void Watch_Window::Update()
{
  if (watch_list)
      gtk_tree_model_foreach(GTK_TREE_MODEL(watch_list), do_an_update, this);
}

void Watch_Window::Add(REGISTER_TYPE type, GUIRegister *reg, Register * pReg)
{
  if (!gp || !gp->cpu || !reg || !reg->bIsValid())
    return;

  if (!enabled)
    Build();

  pReg = pReg ? pReg : reg->get_register();
  if (!pReg)
    return;

  unsigned int uAddrMask = 0;
  unsigned int uLastAddr = gp->cpu->register_memory_size() - 1;
  while (uLastAddr) {
    uLastAddr >>= 4;
    uAddrMask <<= 4;
    uAddrMask |= 0xf;
  }

  WatchEntry *watch_entry = new WatchEntry(type, pReg);
  watch_entry->address = reg->address;
  watch_entry->cpu = gp->cpu;
  watch_entry->rma = reg->rma;

  GtkTreeIter iter;
  gtk_list_store_append(watch_list, &iter);
  gtk_list_store_set(watch_list, &iter,
    NAMECOL, pReg ? pReg->name().c_str() : "NULLREG",
    ADDRESSCOL, GetUserInterface().FormatProgramAddress(pReg->getAddress(),
      uAddrMask, IUserInterface::eHex),
    ENTRYCOL, gpointer(watch_entry),
    -1);

  UpdateWatch(&iter);

  GtkTreePath *path = gtk_tree_model_get_path(GTK_TREE_MODEL(watch_list), &iter);
  WatchWindowXREF *cross_reference = new WatchWindowXREF();
  cross_reference->parent_window = (gpointer) this;
  cross_reference->data =
    (gpsimObject *) gtk_tree_row_reference_new(GTK_TREE_MODEL(watch_list), path);
  gtk_tree_path_free(path);

  watch_entry->Assign_xref(cross_reference);

  UpdateMenus();
}

//---
// Add - given a symbol, verify that it is a RAM or EEPROM register
// symbol. If it is then extract the register and use it's address
// to get the GUI representation of the register.

void Watch_Window::Add( Value *regSym)
{
  if (regSym && gp) {

    Register *reg = dynamic_cast<Register *>(regSym);

    if (reg)
    {
      GUIRegister *greg = gp->m_pGUIRamRegisters->Get(reg->getAddress());
      Add(REGISTER_RAM, greg, reg);
    }
  }
}

//------------------------------------------------------------------------
// NewSymbols
//
void Watch_Window::NewProcessor(GUI_Processor *)
{
  if (!gp || !gp->cpu)
    return;

  ReadSymbolList();
}

//------------------------------------------------------------------------
// Build
//
//

void Watch_Window::Build()
{
  if (bIsBuilt)
    return;

  GtkWidget *vbox;
  GtkWidget *scrolled_window;

  gtk_window_set_title(GTK_WINDOW(window), "Watch Viewer");

  watch_list = gtk_list_store_new(N_COLUMNS,
    G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING,
    G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER);

  watch_tree = gtk_tree_view_new_with_model(GTK_TREE_MODEL(watch_list));

  coldata.reserve(COLUMNS);

  for (size_t i = 0; i < COLUMNS; i++) {
    GtkCellRenderer *renderer = gtk_cell_renderer_text_new();
    GtkTreeViewColumn *column = gtk_tree_view_column_new_with_attributes(
      watch_titles[i], renderer, "text", int(i), nullptr);
    gtk_tree_view_column_set_resizable(column, TRUE);
    gtk_tree_view_append_column(GTK_TREE_VIEW(watch_tree), column);

    int vis;
    if (!config_get_variable(name(), (gchar *)watch_titles[i], &vis))
      config_set_variable(name(), (gchar *)watch_titles[i], 1);

    coldata.push_back(ColumnData(column, vis));
  }

  {
    // Fix a db error in previous versions of gpsim
    int j;
    while (config_get_variable(name(), "hex", &j))
      config_remove(name(), "hex");

    const int hexIndex = 3;
    config_set_variable(name(), watch_titles[hexIndex], coldata[hexIndex].GetVisibility());
  }

  // TODO:No column sorting for now

  GtkTreeSelection *sel =
    gtk_tree_view_get_selection(GTK_TREE_VIEW(watch_tree));
  g_signal_connect(sel, "changed", G_CALLBACK(watch_list_row_selected), this);

  g_signal_connect(watch_tree, "button_press_event", G_CALLBACK(do_popup), this);
  g_signal_connect(watch_tree, "key_press_event", G_CALLBACK(key_press), this);

  scrolled_window = gtk_scrolled_window_new(nullptr, nullptr);

  vbox = gtk_vbox_new(FALSE, 0);

  gtk_container_add(GTK_CONTAINER(scrolled_window), watch_tree);

  gtk_container_add(GTK_CONTAINER(window),vbox);

  gtk_box_pack_start(GTK_BOX(vbox), scrolled_window, TRUE, TRUE, 0);

  build_menu();

  gtk_widget_show_all(window);


  enabled = 1;

  bIsBuilt = true;

  UpdateMenuItem();
}

Watch_Window::Watch_Window(GUI_Processor *_gp)
  : GUI_Object("watch_viewer"), watch_list(nullptr)
{
  menu = "/menu/Windows/Watch";

  gp = _gp;

  if (enabled)
    Build();
}

#endif // HAVE_GUI