some tweaking and cleanup...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2015-12-12 04:11:38 +03:00
parent 7c7777d745
commit 903105efb7
2 changed files with 79 additions and 42 deletions

View File

@ -241,17 +241,11 @@ function Toggler(elem, state_accessor, states, callback_a, callback_b){
return action
}
// XXX these are broken...
//func.states = states
// XXX these are broken -- this is wrong...
// ...do not see how to fix this now in a good way...
if(typeof(states_getter) == typeof(function(){})){
Object.defineProperty(func, 'states', {
get: function(){
return typeof(states_getter) == typeof(function(){}) ?
states_getter.apply(this)
: state_set
},
set: function(value){
state_set = states_getter = value
},
get: function(){ return states_getter.apply(this) },
})
Object.defineProperty(func, 'doc', {
get: function(){
@ -284,6 +278,25 @@ function Toggler(elem, state_accessor, states, callback_a, callback_b){
},
})
} else {
func.states = state_set
if(state_set.length == 2 && state_set[0] == 'none'){
func.doc = 'With no arguments this will toggle between "on" and '
+'"off".\n'
+'If either "on" or "off" are given then this will switch '
+'to that mode.\n'
+'If "?" is given, this will return either "on" or "off" '
+'depending on the current state.'
} else {
func.doc = 'With no arguments this will toggle between '
+ state_set +' in cycle.\n'
+'if any of the state names or its number is given then that '
+'state is switched on.'
+'If "?" is given, this will return the current state.'
}
}
func.__proto__ = Toggler.prototype
func.constructor = Toggler

View File

@ -1678,7 +1678,6 @@ module.Journal = ImageGridFeatures.Feature({
//---------------------------------------------------------------------
// XXX add .resetDefaults(..)...
var ConfigLocalStorageActions = actions.Actions({
config: {
'config-local-storage-key': 'config',
@ -1688,6 +1687,11 @@ var ConfigLocalStorageActions = actions.Actions({
'auto-save-config-local-storage-interval': 5*60,
},
// XXX should we store this in something like .default_config and
// clone it???
// ...do not think so, as the __base_config xhould always be set
// to the values set in code... (check this!)
__base_config: null,
__config_loaded: null,
__auto_save_config_timer: null,
@ -1711,13 +1715,23 @@ var ConfigLocalStorageActions = actions.Actions({
key = key || this.config['config-local-storage-key']
if(key && localStorage[key]){
var base = this.config
// get the original (default) config and keep it for
// reference...
// NOTE: this is here so as to avoid creating 'endless'
// config inheritance chains...
base = this.__base_config = this.__base_config || this.config
var loaded = JSON.parse(localStorage[key])
loaded.__proto__ = base
this.config = loaded
}
}],
// XXX need to load the reset config, and not just set it...
resetConfig: ['File/Reset configuration to default state',
function(){
this.config = this.__base_config || this.config
}],
// XXX make this a real toggler...
toggleAutoStoreConfig: ['File/Store configuration',
@ -3696,6 +3710,16 @@ module.AppControl = ImageGridFeatures.Feature({
win.show()
}],
['focusImage',
function(){
var gui = requirejs('nw.gui')
var win = gui.Window.get()
if(this.images){
var img = this.images[this.current]
win.title = 'ImageGrid.Viewer: '+ (img.name || img.path)
}
}],
],
})