summaryrefslogtreecommitdiff
path: root/grc/gui
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-02-10 21:52:44 +0100
committerSebastian Koslowski <koslowski@kit.edu>2016-02-17 19:55:17 +0100
commitd905f0d803574acd158183135e113b807bd7c878 (patch)
tree63bf6c0bc3ea46e779f3545b42562545a49df617 /grc/gui
parent01afb64bda2fb4c93b0a4e9d3e37e7239ba47f26 (diff)
grc-refactor: move Messages to core
Diffstat (limited to 'grc/gui')
-rw-r--r--grc/gui/ActionHandler.py23
-rw-r--r--grc/gui/Dialogs.py6
-rw-r--r--grc/gui/FlowGraph.py13
-rw-r--r--grc/gui/MainWindow.py24
-rw-r--r--grc/gui/Messages.py153
5 files changed, 30 insertions, 189 deletions
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index 6a935740eb..ab7839b20e 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -17,28 +17,25 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
+import os
import subprocess
from threading import Thread
-import os
-import pygtk
-
-pygtk.require('2.0')
import gtk
import gobject
-
-from ..core import Constants, ParseXML
-from .. core.Constants import XTERM_EXECUTABLE
-
-from . import Dialogs, Messages, Preferences, Actions
-from .ParserErrorsDialog import ParserErrorsDialog
-from .MainWindow import MainWindow
-from .PropsDialog import PropsDialog
+from . import Dialogs, Preferences, Actions
+from .Constants import DEFAULT_CANVAS_SIZE, IMAGE_FILE_EXTENSION, GR_PREFIX
from .FileDialogs import (OpenFlowGraphFileDialog, SaveFlowGraphFileDialog,
SaveReportsFileDialog, SaveScreenShotDialog,
OpenQSSFileDialog)
-from .Constants import DEFAULT_CANVAS_SIZE, IMAGE_FILE_EXTENSION, GR_PREFIX
+from .MainWindow import MainWindow
+from .ParserErrorsDialog import ParserErrorsDialog
+from .PropsDialog import PropsDialog
+
+from ..core import Constants, ParseXML
+from ..core.Constants import XTERM_EXECUTABLE
+from ..core import Messages
gobject.threads_init()
diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py
index f2941250a8..7d55e1b2e7 100644
--- a/grc/gui/Dialogs.py
+++ b/grc/gui/Dialogs.py
@@ -17,15 +17,13 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-import pygtk
-pygtk.require('2.0')
import gtk
import sys
from distutils.spawn import find_executable
-
-from . import Utils, Actions, Constants, Messages
+from . import Utils, Actions, Constants
+from ..core import Messages
class SimpleTextDisplay(gtk.TextView):
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 28fc48fc13..25fb157b1e 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -17,20 +17,21 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-import random
import functools
+import random
+from distutils.spawn import find_executable
from itertools import chain, count
from operator import methodcaller
-from distutils.spawn import find_executable
import gobject
-from . import Actions, Colors, Constants, Utils, Messages, Bars, Dialogs
-from . Element import Element
-from . Constants import SCROLL_PROXIMITY_SENSITIVITY, SCROLL_DISTANCE
-from . external_editor import ExternalEditor
+from . import Actions, Colors, Constants, Utils, Bars, Dialogs
+from .Constants import SCROLL_PROXIMITY_SENSITIVITY, SCROLL_DISTANCE
+from .Element import Element
+from .external_editor import ExternalEditor
from ..core.FlowGraph import FlowGraph as _Flowgraph
+from ..core import Messages
class FlowGraph(Element, _Flowgraph):
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index a340bcc817..18118dbd79 100644
--- a/grc/gui/MainWindow.py
+++ b/grc/gui/MainWindow.py
@@ -17,21 +17,19 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-from Constants import \
- NEW_FLOGRAPH_TITLE, DEFAULT_REPORTS_WINDOW_WIDTH
-import Actions
-import pygtk
-pygtk.require('2.0')
-import gtk
-import Bars
-from BlockTreeWindow import BlockTreeWindow
-from Dialogs import TextDisplay, MessageDialogHelper
-from NotebookPage import NotebookPage
-import Preferences
-import Messages
-import Utils
import os
+import gtk
+
+from . import Bars, Actions, Preferences, Utils
+from .BlockTreeWindow import BlockTreeWindow
+from .Constants import \
+ NEW_FLOGRAPH_TITLE, DEFAULT_REPORTS_WINDOW_WIDTH
+from .Dialogs import TextDisplay, MessageDialogHelper
+from .NotebookPage import NotebookPage
+
+from ..core import Messages
+
MAIN_WINDOW_TITLE_TMPL = """\
#if not $saved
*#slurp
diff --git a/grc/gui/Messages.py b/grc/gui/Messages.py
deleted file mode 100644
index 551a8ce753..0000000000
--- a/grc/gui/Messages.py
+++ /dev/null
@@ -1,153 +0,0 @@
-"""
-Copyright 2007 Free Software Foundation, Inc.
-This file is part of GNU Radio
-
-GNU Radio Companion 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
-of the License, or (at your option) any later version.
-
-GNU Radio Companion 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 this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
-"""
-
-import traceback
-import sys
-import os
-
-# A list of functions that can receive a message.
-MESSENGERS_LIST = list()
-_indent = ''
-
-
-def register_messenger(messenger):
- """
- Append the given messenger to the list of messengers.
-
- Args:
- messenger: a method that takes a string
- """
- MESSENGERS_LIST.append(messenger)
-
-
-def set_indent(level=0):
- global _indent
- _indent = ' ' * level
-
-
-def send(message):
- """
- Give the message to each of the messengers.
-
- Args:
- message: a message string
- """
- for messenger in MESSENGERS_LIST:
- messenger(_indent + message)
-
-# register stdout by default
-register_messenger(sys.stdout.write)
-
-
-###########################################################################
-# Special functions for specific program functionalities
-###########################################################################
-def send_init(platform):
- p = platform
-
- def get_paths(x):
- return os.path.abspath(os.path.expanduser(x)), x
-
- send('\n'.join([
- "<<< Welcome to %s %s >>>" % (p.get_name(), p.get_version()),
- "",
- "Preferences file: " + p.get_prefs_file(),
- "Block paths:"
- ] + [
- "\t%s" % path + (" (%s)" % opath if opath != path else "")
- for path, opath in map(get_paths, p.get_block_paths())
- ]) + "\n")
-
-
-def send_page_switch(file_path):
- send('\nShowing: "%s"\n' % file_path)
-
-
-def send_xml_errors_if_any(xml_failures):
- if xml_failures:
- send('\nXML parser: Found {0} erroneous XML file{1} while loading the '
- 'block tree (see "Help/Parser errors" for details)\n'.format(
- len(xml_failures), 's' if len(xml_failures) > 1 else ''))
-
-
-def send_start_load(file_path):
- send('\nLoading: "%s"\n' % file_path)
-
-
-def send_error_msg_load(error):
- send('>>> Error: %s\n' % error)
-
-
-def send_error_load(error):
- send_error_msg_load(error)
- traceback.print_exc()
-
-
-def send_end_load():
- send('>>> Done\n')
-
-
-def send_fail_load(error):
- send('Error: %s\n>>> Failure\n' % error)
- traceback.print_exc()
-
-
-def send_start_gen(file_path):
- send('\nGenerating: %r\n' % file_path)
-
-
-def send_auto_gen(file_path):
- send('>>> Generating: %r\n' % file_path)
-
-
-def send_fail_gen(error):
- send('Generate Error: %s\n>>> Failure\n' % error)
- traceback.print_exc()
-
-
-def send_start_exec(file_path):
- send('\nExecuting: %s\n' % file_path)
-
-
-def send_verbose_exec(verbose):
- send(verbose)
-
-
-def send_end_exec(code=0):
- send('\n>>> Done%s\n' % (" (return code %s)" % code if code else ""))
-
-
-def send_fail_save(file_path):
- send('>>> Error: Cannot save: %s\n' % file_path)
-
-
-def send_fail_connection():
- send('>>> Error: Cannot create connection.\n')
-
-
-def send_fail_load_preferences(prefs_file_path):
- send('>>> Error: Cannot load preferences file: "%s"\n' % prefs_file_path)
-
-
-def send_fail_save_preferences(prefs_file_path):
- send('>>> Error: Cannot save preferences file: "%s"\n' % prefs_file_path)
-
-
-def send_warning(warning):
- send('>>> Warning: %s\n' % warning)