Browse code

Pipe errors through to DotWindow from DotWidget.

This commit adds an error_dialog funciton to DotWidget which emits an error
signal. DotWindow connects to this error signal and, when emitted, it displays
the error dialog.

Steven Allen authored on 29/04/2016 16:40:41 • Jose Fonseca committed on 29/04/2016 23:01:30
Showing 1 changed files

  • xdot.py index a0be1b1..bcbe4a9 100755
... ...
@@ -1537,7 +1537,8 @@ class DotWidget(Gtk.DrawingArea):
1537 1537
 
1538 1538
     #TODO GTK3: Second argument has to be of type Gdk.EventButton instead of object.
1539 1539
     __gsignals__ = {
1540
-        'clicked' : (GObject.SIGNAL_RUN_LAST, None, (str, object))
1540
+        'clicked' : (GObject.SIGNAL_RUN_LAST, None, (str, object)),
1541
+        'error' : (GObject.SIGNAL_RUN_LAST, None, (str,))
1541 1542
     }
1542 1543
 
1543 1544
     filter = 'dot'
... ...
@@ -1575,6 +1576,9 @@ class DotWidget(Gtk.DrawingArea):
1575 1576
         self.presstime = None
1576 1577
         self.highlight = None
1577 1578
 
1579
+    def error_dialog(self, message):
1580
+        self.emit('error', message)
1581
+
1578 1582
     def set_filter(self, filter):
1579 1583
         self.filter = filter
1580 1584
 
... ...
@@ -1973,6 +1977,7 @@ class DotWindow(Gtk.Window):
1973 1977
         window.add(vbox)
1974 1978
 
1975 1979
         self.dotwidget = widget or DotWidget()
1980
+        self.dotwidget.connect("error", lambda e, m: self.error_dialog(m))
1976 1981
 
1977 1982
         # Create a UIManager instance
1978 1983
         uimanager = self.uimanager = Gtk.UIManager()