commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 82/101: grc: gtk3: Converted to Gtk.Applica


From: git
Subject: [Commit-gnuradio] [gnuradio] 82/101: grc: gtk3: Converted to Gtk.Application (ActionHandler) and Gtk.ApplicationWindow (MainWindow)
Date: Thu, 16 Mar 2017 14:58:12 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch python3
in repository gnuradio.

commit 8b2f679202c95896647231820eb07f42a2bc204b
Author: Seth Hitefield <address@hidden>
Date:   Tue Aug 9 18:48:31 2016 -0400

    grc: gtk3: Converted to Gtk.Application (ActionHandler) and 
Gtk.ApplicationWindow (MainWindow)
---
 grc/gui/ActionHandler.py       | 24 +++++++++++++++++-------
 grc/gui/MainWindow.py          |  7 ++++---
 grc/main.py                    | 10 ++++------
 grc/scripts/gnuradio-companion |  2 ++
 4 files changed, 27 insertions(+), 16 deletions(-)

diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index b10737d..ad4dc35 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -23,7 +23,7 @@ from __future__ import absolute_import, print_function
 import os
 import subprocess
 
-from gi.repository import Gtk
+from gi.repository import Gtk, GObject
 
 from . import Dialogs, Preferences, Actions, Executor, FileDialogs, Utils
 from .MainWindow import MainWindow
@@ -33,13 +33,14 @@ from .PropsDialog import PropsDialog
 from ..core import ParseXML, Messages
 
 
-class ActionHandler:
+class ActionHandler(Gtk.Application):
     """
     The action handler will setup all the major window components,
     and handle button presses and flow graph operations from the GUI.
     """
 
     def __init__(self, file_paths, platform):
+        Gtk.Application.__init__(self)
         """
         ActionHandler constructor.
         Create the main window, setup the message handler, import the 
preferences,
@@ -54,16 +55,25 @@ class ActionHandler:
         for action in Actions.get_all_actions(): action.connect('activate', 
self._handle_action)
         #setup the main window
         self.platform = platform
-        self.main_window = MainWindow(platform, self._handle_action)
+
+        #initialize
+        self.init_file_paths = [os.path.abspath(file_path) for file_path in 
file_paths]
+        self.init = False
+
+    def do_startup(self):
+        Gtk.Application.do_startup(self)
+
+    def do_activate(self):
+        Gtk.Application.do_activate(self)
+
+        self.main_window = MainWindow(self, self.platform, self._handle_action)
         self.main_window.connect('delete-event', self._quit)
         self.main_window.connect('key-press-event', self._handle_key_press)
         self.get_focus_flag = self.main_window.get_focus_flag
         #setup the messages
         Messages.register_messenger(self.main_window.add_console_line)
-        Messages.send_init(platform)
-        #initialize
-        self.init_file_paths = [os.path.abspath(file_path) for file_path in 
file_paths]
-        self.init = False
+        Messages.send_init(self.platform)
+
         Actions.APPLICATION_INITIALIZE()
 
     def _handle_key_press(self, widget, event):
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index 3d4bf10..e86273e 100644
--- a/grc/gui/MainWindow.py
+++ b/grc/gui/MainWindow.py
@@ -41,7 +41,7 @@ from ..core import Messages
 ############################################################
 # Main window
 ############################################################
-class MainWindow(Gtk.Window):
+class MainWindow(Gtk.ApplicationWindow):
     """The topmost window with menus, the tool bar, and other major windows."""
 
     # Constants the action handler can use to indicate which panel visibility 
to change.
@@ -49,16 +49,17 @@ class MainWindow(Gtk.Window):
     CONSOLE = 1
     VARIABLES = 2
 
-    def __init__(self, platform, action_handler_callback):
+    def __init__(self, app, platform, action_handler_callback):
         """
         MainWindow constructor
         Setup the menu, toolbar, flow graph editor notebook, block selection 
window...
         """
+        Gtk.ApplicationWindow.__init__(self, title="GNU Radio Companion", 
application=app)
+
         self._platform = platform
         Preferences.load(platform)
 
         # Setup window
-        GObject.GObject.__init__(self)
         vbox = Gtk.VBox()
         self.add(vbox)
 
diff --git a/grc/main.py b/grc/main.py
index 40a61a2..e4d2cef 100755
--- a/grc/main.py
+++ b/grc/main.py
@@ -15,16 +15,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
USA
 
-import argparse
+import argparse, sys
 
 import gi
 gi.require_version('Gtk', '3.0')
 gi.require_version('PangoCairo', '1.0')
-
 from gi.repository import Gtk
 
 from gnuradio import gr
-
 from .gui.Platform import Platform
 from .gui.ActionHandler import ActionHandler
 
@@ -55,6 +53,6 @@ def main():
         prefs=gr.prefs(),
         install_prefix=gr.prefix()
     )
-    ActionHandler(args.flow_graphs, platform)
-    Gtk.main()
-
+    
+    app = ActionHandler(args.flow_graphs, platform)
+    sys.exit(app.run())
diff --git a/grc/scripts/gnuradio-companion b/grc/scripts/gnuradio-companion
index 8f267c8..21d9891 100755
--- a/grc/scripts/gnuradio-companion
+++ b/grc/scripts/gnuradio-companion
@@ -39,6 +39,8 @@ Is the library path environment variable set correctly?
 def die(error, message):
     msg = "{0}\n\n({1})".format(message, error)
     try:
+        import gi
+        gi.require_version('Gtk', '3.0')
         from gi.repository import Gtk
         d = Gtk.MessageDialog(
             message_type=Gtk.MessageType.ERROR,



reply via email to

[Prev in Thread] Current Thread [Next in Thread]