Mercurial > octave-nkf
changeset 17010:c50ee84842a9
Add preferences and prefdir functions
* scripts/prefs/private/prefsfile.m
(prefsfile): Use prefdir() instread of ~ for folder part of file.
* scripts/prefs/preferences.m: New file.
* scripts/prefs/prefdir.m: New file.
* scripts/prefs/module.mk: Add preferences.m and prefdir.m
* libinterp/corefcn/octave-link.h, libinterp/corefcn/octave-link.cc
(octave_link::show_preferences): New function.
(octave_link)::do_show_preferences: New fuction.
(__octave_link_show_preferences__): New function.
* libgui/src/octave-qt-link.h, libgui/src/octave-qt-link.cc
(octave_qt_link::show_preferences_signal): New signal.
(octave_qt_link::do_show_preferences): New function.
* libgui/src/main-window.cc
(main_window::construct_octave_qt_link): connect octave link to show settings dialog slot.
author | John Donoghue <john.donoghue@ieee.org> |
---|---|
date | Thu, 18 Jul 2013 10:56:44 -0400 |
parents | adf06e03fbdd |
children | 350cad34b0f8 |
files | libgui/src/main-window.cc libgui/src/octave-qt-link.cc libgui/src/octave-qt-link.h libinterp/corefcn/octave-link.cc libinterp/corefcn/octave-link.h scripts/prefs/module.mk scripts/prefs/prefdir.m scripts/prefs/preferences.m scripts/prefs/private/prefsfile.m |
diffstat | 9 files changed, 134 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Thu Jul 18 14:30:31 2013 -0400 +++ b/libgui/src/main-window.cc Thu Jul 18 10:56:44 2013 -0400 @@ -912,6 +912,10 @@ connect (_octave_qt_link, SIGNAL (exit_debugger_signal ()), this, SLOT (handle_exit_debugger ())); + connect (_octave_qt_link, + SIGNAL (show_preferences_signal (void)), + this, SLOT (process_settings_dialog_request ())); + #ifdef HAVE_QSCINTILLA connect (_octave_qt_link, SIGNAL (edit_file_signal (const QString&)),
--- a/libgui/src/octave-qt-link.cc Thu Jul 18 14:30:31 2013 -0400 +++ b/libgui/src/octave-qt-link.cc Thu Jul 18 10:56:44 2013 -0400 @@ -491,3 +491,11 @@ return ok; } + +void +octave_qt_link::do_show_preferences () +{ + emit show_preferences_signal (); +} + +
--- a/libgui/src/octave-qt-link.h Thu Jul 18 14:30:31 2013 -0400 +++ b/libgui/src/octave-qt-link.h Thu Jul 18 10:56:44 2013 -0400 @@ -121,6 +121,7 @@ static bool file_in_path (const std::string& file, const std::string& dir); + void do_show_preferences (void); private: // No copying! @@ -166,6 +167,8 @@ void insert_debugger_pointer_signal (const QString&, int); void delete_debugger_pointer_signal (const QString&, int); + + void show_preferences_signal (void); }; #endif
--- a/libinterp/corefcn/octave-link.cc Thu Jul 18 14:30:31 2013 -0400 +++ b/libinterp/corefcn/octave-link.cc Thu Jul 18 10:56:44 2013 -0400 @@ -402,3 +402,18 @@ return retval; } + +DEFUN (__octave_link_show_preferences__, , , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} __octave_link_show_preferences__ ()\n\ +Undocumented internal function.\n\ +@end deftypefn") +{ + octave_value retval; + + retval = octave_link::show_preferences (); + + return retval; +} + +
--- a/libinterp/corefcn/octave-link.h Thu Jul 18 14:30:31 2013 -0400 +++ b/libinterp/corefcn/octave-link.h Thu Jul 18 10:56:44 2013 -0400 @@ -307,6 +307,18 @@ return instance_ok () ? instance->link_enabled : false; } + static bool + show_preferences () + { + if (enabled ()) + { + instance->do_show_preferences (); + return true; + } + else + return false; + } + private: static octave_link *instance; @@ -425,6 +437,8 @@ virtual void do_set_default_prompts (std::string& ps1, std::string& ps2, std::string& ps4) = 0; + + virtual void do_show_preferences (void) = 0; }; #endif // OCTAVELINK_H
--- a/scripts/prefs/module.mk Thu Jul 18 14:30:31 2013 -0400 +++ b/scripts/prefs/module.mk Thu Jul 18 10:56:44 2013 -0400 @@ -9,6 +9,8 @@ prefs/addpref.m \ prefs/getpref.m \ prefs/ispref.m \ + prefs/prefdir.m \ + prefs/preferences.m \ prefs/rmpref.m \ prefs/setpref.m \ $(prefs_PRIVATE_FCN_FILES)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/prefs/prefdir.m Thu Jul 18 10:56:44 2013 -0400 @@ -0,0 +1,44 @@ +## Copyright (C) 2013 John Donoghue +## +## This file is part of Octave. +## +## Octave 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 3 of the License, or (at +## your option) any later version. +## +## Octave 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 Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} prefdir +## @deftypefnx {Function File} {folder =} prefdir +## Return the folder that contains the preferences for octave. +## +## Examples: +## +## Display the preferences folder +## @example +## prefdir +## @end example +## +## Change to the preferences folder +## @example +## cd(prefdir) +## @end example +## @end deftypefn + +## Author: John Donoghue +## Version: 0.01 + +function folder = prefdir () + + folder = getenv("HOME"); + +endfunction \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/prefs/preferences.m Thu Jul 18 10:56:44 2013 -0400 @@ -0,0 +1,42 @@ +## Copyright (C) 2013 John Donoghue +## +## This file is part of Octave. +## +## Octave 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 3 of the License, or (at +## your option) any later version. +## +## Octave 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 Octave; see the file COPYING. If not, see +## <http://www.gnu.org/licenses/>. + +## -*- texinfo -*- +## @deftypefn {Function File} {} preferences +## Display the preferences settings. If in GUI mode, display using the preferences dialog, otherwise display in EDITOR. +## +## Example: +# +## @example +## preferences +## @end example +## +## @end deftypefn + +## Author: John Donoghue +## Version: 0.01 + +function preferences () + if (! __octave_link_enabled__ ()) + prefs_file = [ getenv("HOME") "/.octave_prefs" ]; + + edit (prefs_file); + else + __octave_link_show_preferences__ (); + endif +endfunction \ No newline at end of file