[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 20/43: grc: Reworked save confirmation dial
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 20/43: grc: Reworked save confirmation dialog to allow cancel option |
Date: |
Thu, 2 Apr 2015 19:15:51 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 4c12e49b899dfa2067d84b2466502e45c34787de
Author: Ethan Trewhitt <address@hidden>
Date: Tue Feb 17 16:11:45 2015 -0500
grc: Reworked save confirmation dialog to allow cancel option
---
grc/gui/Dialogs.py | 6 ++++--
grc/gui/MainWindow.py | 26 ++++++++++++++++++--------
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py
index eb0a6c1..cf0ca02 100644
--- a/grc/gui/Dialogs.py
+++ b/grc/gui/Dialogs.py
@@ -116,7 +116,7 @@ class TextDisplay(gtk.TextView):
menu.show_all()
return False
-def MessageDialogHelper(type, buttons, title=None, markup=None):
+def MessageDialogHelper(type, buttons, title=None, markup=None,
extra_buttons=None):
"""
Create a modal message dialog and run it.
@@ -126,8 +126,9 @@ def MessageDialogHelper(type, buttons, title=None,
markup=None):
gtk.BUTTONS_NONE, gtk.BUTTONS_OK, gtk.BUTTONS_CLOSE,
gtk.BUTTONS_CANCEL, gtk.BUTTONS_YES_NO, gtk.BUTTONS_OK_CANCEL
Args:
- tittle: the title of the window (string)
+ title: the title of the window (string)
markup: the message text with pango markup
+ extra_buttons: a tuple containing pairs of values; each value is the
button's text and the button's return value
Returns:
the gtk response from run()
@@ -135,6 +136,7 @@ def MessageDialogHelper(type, buttons, title=None,
markup=None):
message_dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, type, buttons)
if title: message_dialog.set_title(title)
if markup: message_dialog.set_markup(markup)
+ if extra_buttons: message_dialog.add_buttons(*extra_buttons)
response = message_dialog.run()
message_dialog.destroy()
return response
diff --git a/grc/gui/MainWindow.py b/grc/gui/MainWindow.py
index d1cf866..f26f30e 100644
--- a/grc/gui/MainWindow.py
+++ b/grc/gui/MainWindow.py
@@ -236,10 +236,15 @@ class MainWindow(gtk.Window):
if self.page_to_be_closed.get_proc() or not
self.page_to_be_closed.get_saved():
self._set_page(self.page_to_be_closed)
#unsaved? ask the user
- if not self.page_to_be_closed.get_saved() and self._save_changes():
- Actions.FLOW_GRAPH_SAVE() #try to save
- if not self.page_to_be_closed.get_saved(): #still unsaved?
- self.page_to_be_closed = None #set the page to be closed back
to None
+ if not self.page_to_be_closed.get_saved():
+ response = self._save_changes() # return value is either OK,
CLOSE, or CANCEL
+ if response == gtk.RESPONSE_OK:
+ Actions.FLOW_GRAPH_SAVE() #try to save
+ if not self.page_to_be_closed.get_saved(): #still unsaved?
+ self.page_to_be_closed = None #set the page to be closed
back to None
+ return
+ elif response == gtk.RESPONSE_CANCEL:
+ self.page_to_be_closed = None
return
#stop the flow graph if executing
if self.page_to_be_closed.get_proc(): Actions.FLOW_GRAPH_KILL()
@@ -337,12 +342,17 @@ class MainWindow(gtk.Window):
Save changes to flow graph?
Returns:
- true if yes
+ the response_id (see buttons variable below)
"""
+ buttons = (
+ 'Close without saving', gtk.RESPONSE_CLOSE,
+ gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+ gtk.STOCK_SAVE, gtk.RESPONSE_OK
+ )
return MessageDialogHelper(
- gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, 'Unsaved Changes!',
- 'Would you like to save changes before closing?'
- ) == gtk.RESPONSE_YES
+ gtk.MESSAGE_QUESTION, gtk.BUTTONS_NONE, 'Unsaved Changes!',
+ 'Would you like to save changes before closing?', buttons
+ )
def _get_files(self):
"""
- [Commit-gnuradio] [gnuradio] 10/43: fec: cleaning up LDPC warnings, (continued)
- [Commit-gnuradio] [gnuradio] 10/43: fec: cleaning up LDPC warnings, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 18/43: fec: ldpc works, add iterations meta tag, etc, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 34/43: Merge remote-tracking branch 'saikwolf/logging_flat_flowgraph', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 03/43: gnuradio-runtime:: removed the individual port setting on hier_block2, current operation assuming the buffers are being set for latency and therefore all blocks are being set to a small amount, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 11/43: fec: LDPC cleaning up comments, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 30/43: grc: clean-up 'gnuradio-companion', add mode 'run from source', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 12/43: fec: re-shuffling LDPC make helper, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 31/43: grc: PropsDialog: apply button and hotkey (Ctrl+Enter), git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 40/43: fec: Move the definition of yp_kernel from the class into a temp variable in the main code. This variable is used just to find the actual Volk kernel, and its current use is not c++11 complaint. Moving it makes the code c++11 complaint on both GCC / libstdc++ and Clang / libc++., git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 35/43: Merge remote-tracking branch 'osh/ldpc_add', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 20/43: grc: Reworked save confirmation dialog to allow cancel option,
git <=
- [Commit-gnuradio] [gnuradio] 42/43: Merge remote-tracking branch 'michaelld/misc_fixes', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 29/43: grc: move context def into Bars.py and add submenu, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 14/43: gnuradio-runtime: modified buffer length types to size_t, moved buffer length vectors into detail, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 22/43: grc: close unsaved pages first (for cancel save option), git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 13/43: fec: ldpc GRC compat cleanup, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 36/43: Merge remote-tracking branch 'fengzhe/chunks_to_symbols_update', git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 25/43: grc: set permissions for generated files, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 08/43: fec: adding ldpc encoder and decoder, initial compile working, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 23/43: grc: make use of GRC_HIER_PATH at runtime, git, 2015/04/02
- [Commit-gnuradio] [gnuradio] 33/43: Merge remote-tracking branch 'saikwolf/hier_buff_tweak', git, 2015/04/02