[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r5881 - in grc/trunk: notes src src/Graphics
From: |
jblum |
Subject: |
[Commit-gnuradio] r5881 - in grc/trunk: notes src src/Graphics |
Date: |
Sat, 30 Jun 2007 17:48:48 -0600 (MDT) |
Author: jblum
Date: 2007-06-30 17:48:47 -0600 (Sat, 30 Jun 2007)
New Revision: 5881
Modified:
grc/trunk/notes/notes.txt
grc/trunk/notes/programming_style.txt
grc/trunk/src/ActionHandler.py
grc/trunk/src/Actions.py
grc/trunk/src/DataTypes.py
grc/trunk/src/ExecFlowGraph.py
grc/trunk/src/ExecFlowGraphGUI.py
grc/trunk/src/Graphics/Bars.py
grc/trunk/src/Graphics/Dialogs.py
grc/trunk/src/Graphics/FileDialogs.py
grc/trunk/src/Graphics/__init__.py
Log:
GUI fixes: fixed file extension issue with file dialog and renamed data types
dialog
Modified: grc/trunk/notes/notes.txt
===================================================================
--- grc/trunk/notes/notes.txt 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/notes/notes.txt 2007-06-30 23:48:47 UTC (rev 5881)
@@ -7,7 +7,6 @@
-tun/tap block (with input and output)
############ Known Problems: ####################
--file save, ask for overwrite even when appending file extension
-blocks need to fix themselves when they go out of bounds, like in a resize
-socket controllers should be intelligent on shrinkage
Modified: grc/trunk/notes/programming_style.txt
===================================================================
--- grc/trunk/notes/programming_style.txt 2007-06-30 16:25:09 UTC (rev
5880)
+++ grc/trunk/notes/programming_style.txt 2007-06-30 23:48:47 UTC (rev
5881)
@@ -6,7 +6,7 @@
Most editors can display a tab as a user-defined width or number of
spaces.
The expand command can convert a file with tab indentations to a file
with space indentation.
-2) Naming Conventions:
+2) Naming Conventions:
CamelCaseNames for files and classes.
UPPER_CASE_NAMES for constants.
lower_case_names for public methods and all variables.
Modified: grc/trunk/src/ActionHandler.py
===================================================================
--- grc/trunk/src/ActionHandler.py 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/src/ActionHandler.py 2007-06-30 23:48:47 UTC (rev 5881)
@@ -158,7 +158,7 @@
Graphics.enable_usrp_diagnostics() #try to enable
usrp diagnostics
for action in (
APPLICATION_QUIT, FLOW_GRAPH_NEW,
FLOW_GRAPH_OPEN, FLOW_GRAPH_SAVE_AS,
- ABOUT_WINDOW_DISPLAY, COLORS_WINDOW_DISPLAY,
HOTKEYS_WINDOW_DISPLAY, MATH_EXPR_WINDOW_DISPLAY,
+ ABOUT_WINDOW_DISPLAY,
DATA_TYPES_WINDOW_DISPLAY, HOTKEYS_WINDOW_DISPLAY, MATH_EXPR_WINDOW_DISPLAY,
FLOW_GRAPH_WINDOW_RESIZE, PREFS_WINDOW_DISPLAY,
FLOW_GRAPH_SCREEN_CAPTURE,
): get_action_from_name(action).set_sensitive(True)
if self.flow_graph_file_path == '':
@@ -247,8 +247,8 @@
self.flow_graph.update()
elif state == ABOUT_WINDOW_DISPLAY:
Graphics.AboutDialog()
- elif state == COLORS_WINDOW_DISPLAY:
- Graphics.DataTypeColorsDialog()
+ elif state == DATA_TYPES_WINDOW_DISPLAY:
+ Graphics.DataTypesDialog()
elif state == HOTKEYS_WINDOW_DISPLAY:
Graphics.HotKeysDialog()
elif state == MATH_EXPR_WINDOW_DISPLAY:
@@ -337,6 +337,9 @@
except: print "could not kill pid file:
%s"%self.pid_file
MUTEX.unlock()
else: print "!!! State not handled !!!"
+
##############################################################################################
+ # Global Actions for all States
+
##############################################################################################
#set the exec button if the flow graph is valid and is not
already running
MUTEX.lock()
get_action_from_name(FLOW_GRAPH_EXEC).set_sensitive(self.flow_graph.is_valid()
and self.pid_file == None)
@@ -362,7 +365,11 @@
If the save was not greyed-out, the user is presented with a
dialog.
@return true if save is greyed-out, or the user's choice.
"""
- return not
get_action_from_name(FLOW_GRAPH_SAVE).get_sensitive() or
Graphics.LooseChangesMessage().run()
+ return not
get_action_from_name(FLOW_GRAPH_SAVE).get_sensitive() or \
+ Graphics.MessageDialogHelper(
+ gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
'Unsaved Changes!',
+ 'Would you like to discard your unsaved
changes?'
+ ) == gtk.RESPONSE_YES
class ExecFlowGraphThread(Thread):
"""Execute the flow graph as a new process and wait on it to finish."""
Modified: grc/trunk/src/Actions.py
===================================================================
--- grc/trunk/src/Actions.py 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/src/Actions.py 2007-06-30 23:48:47 UTC (rev 5881)
@@ -68,7 +68,7 @@
FLOW_GRAPH_SCREEN_CAPTURE = 'flow graph screen capture'
ABOUT_WINDOW_DISPLAY = 'about window display'
-COLORS_WINDOW_DISPLAY = 'colors window display'
+DATA_TYPES_WINDOW_DISPLAY = 'data types window display'
HOTKEYS_WINDOW_DISPLAY = 'hotkeys window display'
USRP_DIAGNOSTICS_DISPLAY = 'usrp diagnostics display'
PREFS_WINDOW_DISPLAY = 'prefs window display'
@@ -94,7 +94,7 @@
gtk.Action(USRP_DIAGNOSTICS_DISPLAY, '_USRP Diagnostics', 'Analyze the
USRP', 'gtk-dialog-info'),
gtk.Action(PREFS_WINDOW_DISPLAY, '_Preferences', 'Configure
Preferences', 'gtk-preferences'),
gtk.Action(ABOUT_WINDOW_DISPLAY, '_About', 'About this program',
'gtk-about'),
- gtk.Action(COLORS_WINDOW_DISPLAY, '_Colors', 'Data Type Colors',
'gtk-select-color'),
+ gtk.Action(DATA_TYPES_WINDOW_DISPLAY, '_Data Types', 'Data Types',
'gtk-connect'),
gtk.Action(HOTKEYS_WINDOW_DISPLAY, '_HotKeys', 'Hot Keys', 'gtk-info'),
gtk.Action(MATH_EXPR_WINDOW_DISPLAY, '_Math Expressions', 'Mathematical
Expressions', 'gtk-convert'),
gtk.Action(FLOW_GRAPH_EXEC, '_Execute', 'Execute the flow graph',
'gtk-execute'),
Modified: grc/trunk/src/DataTypes.py
===================================================================
--- grc/trunk/src/DataTypes.py 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/src/DataTypes.py 2007-06-30 23:48:47 UTC (rev 5881)
@@ -461,7 +461,7 @@
Bool contructor.
@param true the cname for the true choice
@param false the cname for the false choice
- @param default the default choice
+ @param default the default choice (boolean)
"""
if default: data = 0 #determine the default index
else: data = 1
Modified: grc/trunk/src/ExecFlowGraph.py
===================================================================
--- grc/trunk/src/ExecFlowGraph.py 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/src/ExecFlowGraph.py 2007-06-30 23:48:47 UTC (rev 5881)
@@ -157,4 +157,5 @@
fg.start()
raw_input('Flow Graph Running...\nPress Enter to Exit: ')
fg.stop()
+ exit(0)
\ No newline at end of file
Modified: grc/trunk/src/ExecFlowGraphGUI.py
===================================================================
--- grc/trunk/src/ExecFlowGraphGUI.py 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/src/ExecFlowGraphGUI.py 2007-06-30 23:48:47 UTC (rev 5881)
@@ -164,7 +164,6 @@
"""Exit the application."""
self.stop() #stop the flow graph
self.Destroy() #destroy the wx frame
- sys.exit(0)
def add_window(self, window, type='', title=''):
"""!
@@ -238,6 +237,7 @@
(options, args) = parser.parse_args()
app = FlowGraphApp(args[0])
if options.no_wx: raw_input('Flow Graph Running...\nPress Enter to
Exit: ') #do not start wx
- else: app.MainLoop() #start the wxApp MainLoop
+ else: app.MainLoop() #start the wxApp MainLoop
+ exit(0)
\ No newline at end of file
Modified: grc/trunk/src/Graphics/Bars.py
===================================================================
--- grc/trunk/src/Graphics/Bars.py 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/src/Graphics/Bars.py 2007-06-30 23:48:47 UTC (rev 5881)
@@ -76,8 +76,8 @@
]),
(gtk.Action('Help', '_Help', None, None), [
ABOUT_WINDOW_DISPLAY,
- COLORS_WINDOW_DISPLAY,
HOTKEYS_WINDOW_DISPLAY,
+ DATA_TYPES_WINDOW_DISPLAY,
MATH_EXPR_WINDOW_DISPLAY,
USRP_DIAGNOSTICS_DISPLAY,
]),
Modified: grc/trunk/src/Graphics/Dialogs.py
===================================================================
--- grc/trunk/src/Graphics/Dialogs.py 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/src/Graphics/Dialogs.py 2007-06-30 23:48:47 UTC (rev 5881)
@@ -108,23 +108,21 @@
return self.dimensions
######################################################################################################
-class LooseChangesMessage(gtk.MessageDialog):
- """Message dialog to ask about discarding unsaved changes."""
- def __init__(self):
- """LooseChangesMessage constructor."""
- gtk.MessageDialog.__init__(self, None, gtk.DIALOG_MODAL,
gtk.MESSAGE_WARNING,
- gtk.BUTTONS_OK_CANCEL, "Would you like to discard your
unsaved changes?")
- self.set_title('Unsaved Changes!')
-
- def run(self):
- """!
- Get the user's response.
- @return true if ok was clicked, otherwise false
- """
- response = gtk.MessageDialog.run(self)
- self.destroy()
- if response == gtk.RESPONSE_OK: return True
- return False
+def MessageDialogHelper(type, buttons, title=None, markup=None):
+ """!
+ Create a modal message dialog and run it.
+ @param type the type of message: gtk.MESSAGE_INFO, gtk.MESSAGE_WARNING,
gtk.MESSAGE_QUESTION or gtk.MESSAGE_ERROR
+ @param buttons the predefined set of buttons to use: gtk.BUTTONS_NONE,
gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE, gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO,
gtk.BUTTONS_OK_CANCEL
+ @param tittle the title of the window (string)
+ @param markup the message text with pango markup
+ @return the gtk response from run()
+ """
+ message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type,
buttons)
+ if title != None: message_dialog.set_title(title)
+ if markup != None: message_dialog.set_markup(markup)
+ response = message_dialog.run()
+ message_dialog.destroy()
+ return response
######################################################################################################
class AboutDialog(gtk.AboutDialog):
@@ -153,13 +151,13 @@
self.destroy()
######################################################################################################
-class DataTypeColorsDialog(gtk.Dialog):
+class DataTypesDialog(gtk.Dialog):
"""Display each data type with its associated color."""
def __init__(self):
- """DataTypeColorsDialog constructor."""
+ """DataTypesDialog constructor."""
gtk.Dialog.__init__(self, buttons=('gtk-close',
gtk.RESPONSE_CLOSE))
- self.set_title('Colors')
- self.set_size_request(150, -1)
+ self.set_title('Data Types')
+ self.set_size_request(170, -1)
markup = ''
for color_spec in (
'Regular Types:',
Modified: grc/trunk/src/Graphics/FileDialogs.py
===================================================================
--- grc/trunk/src/Graphics/FileDialogs.py 2007-06-30 16:25:09 UTC (rev
5880)
+++ grc/trunk/src/Graphics/FileDialogs.py 2007-06-30 23:48:47 UTC (rev
5881)
@@ -23,6 +23,7 @@
import pygtk
pygtk.require('2.0')
import gtk
+from Dialogs import MessageDialogHelper
from Constants import
DEFAULT_FILE_PATH,FLOW_GRAPH_FILE_EXTENSION,IMAGE_FILE_EXTENSION,NEW_FLOGRAPH_TITLE
from os import path
@@ -85,19 +86,49 @@
self.set_select_multiple(False)
self.set_local_only(True)
+ def get_rectified_filename(self):
+ """!
+ Run the dialog and get the filename.
+ If this is a save dialog and the file name is missing the
extension, append the file extension.
+ If the file name with the extension already exists, show a
overwrite dialog.
+ @return the complete file path
+ """
+ if gtk.FileChooserDialog.run(self) == gtk.RESPONSE_OK:
+ filename = self.get_filename()
+ #############################################
+ # Handle Save Dialogs
+ #############################################
+ if self.type in (SAVE_FLOW_GRAPH, SAVE_IMAGE):
+ for extension,filter in (
+ (FLOW_GRAPH_FILE_EXTENSION,
self.flow_graph_files_filter),
+ (IMAGE_FILE_EXTENSION,
self.image_files_filter)
+ ): #append the missing file extension if the
filter matches
+ if
filename[len(filename)-len(extension):] != extension and filter ==
self.get_filter(): filename = filename + extension
+ self.set_current_name(path.basename(filename))
#show the filename with extension
+ if path.exists(filename): #ask the user to
confirm overwrite
+ if MessageDialogHelper(
+ gtk.MESSAGE_QUESTION,
gtk.BUTTONS_YES_NO, 'Confirm Overwrite!',
+ 'File "%s" Exists!\nWould you
like to overwrite the existing file?'%filename,
+ ) == gtk.RESPONSE_NO: filename =
self.get_rectified_filename()
+ #############################################
+ # Handle Open Dialogs
+ #############################################
+ elif self.type in (OPEN_FLOW_GRAPH,):
+ if not path.exists(filename): #show a warning
and re-run
+ MessageDialogHelper(
+ gtk.MESSAGE_WARNING,
gtk.BUTTONS_CLOSE, 'Cannot Open!',
+ 'File "%s" Does not
Exist!'%filename,
+ )
+ filename = self.get_rectified_filename()
+ return filename
+ return None #response was cancel
+
def run(self):
"""!
- Call run, wait for user response, and destroy the dialog.
+ Get the filename and destroy the dialog.
@return the filename or None if a close/cancel occured.
"""
- response = gtk.FileChooserDialog.run(self)
- if response == gtk.RESPONSE_OK:
- filename = self.get_filename()
- if
filename[len(filename)-len(FLOW_GRAPH_FILE_EXTENSION):] !=
FLOW_GRAPH_FILE_EXTENSION and\
- self.flow_graph_files_filter ==
self.get_filter(): filename = filename + FLOW_GRAPH_FILE_EXTENSION
- elif filename[len(filename)-len(IMAGE_FILE_EXTENSION):]
!= IMAGE_FILE_EXTENSION and\
- self.image_files_filter == self.get_filter():
filename = filename + IMAGE_FILE_EXTENSION
- else: filename = None
+ filename = self.get_rectified_filename()
self.destroy()
return filename
Modified: grc/trunk/src/Graphics/__init__.py
===================================================================
--- grc/trunk/src/Graphics/__init__.py 2007-06-30 16:25:09 UTC (rev 5880)
+++ grc/trunk/src/Graphics/__init__.py 2007-06-30 23:48:47 UTC (rev 5881)
@@ -23,5 +23,5 @@
# only import the modules that need external access #
from MainWindow import MainWindow
from FileDialogs import
OpenFlowGraphFileDialog,SaveFlowGraphFileDialog,SaveImageFileDialog
-from Dialogs import
PreferencesDialog,FlowGraphWindowSizeDialog,LooseChangesMessage,AboutDialog,DataTypeColorsDialog,HotKeysDialog,MathExprDialog
+from Dialogs import
PreferencesDialog,FlowGraphWindowSizeDialog,MessageDialogHelper,AboutDialog,DataTypesDialog,HotKeysDialog,MathExprDialog
from USRPDiagnostics import USRPDiagnosticsDialog,enable_usrp_diagnostics
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r5881 - in grc/trunk: notes src src/Graphics,
jblum <=